Open thenktor opened 4 months ago
This is on purpose as I build all the decoders and support libraries as part of the my macos squeezelite builds. Adding the PATH(s) to these other package managers break my builds.
What about having extra Makefiles like Makefile.m1-pkgsrc
and Makefile.m1-macports
?
I don't know if this is the kind of thing ./configure
would fix, but I was able to get squeezelite compiled on my M2 Mac today. The packages available on the website the OS said were all corrupted.
I don't know what the cleanest way of handling these things are or I'd make a pull request so I'm documenting them here because the binary works fine. I haven't written C code since the 90s.
Apple M2 Mac running Ventura
-I /opt/homebrew/include
to CFLAGS and -L /opt/homebrew/lib
to LDADD so it could find all the includes and lib. Hope that helps!
I don't know if this is the kind of thing
./configure
would fix,
Yes.
but I was able to get squeezelite compiled on my M2 Mac today. The packages available on the website the OS said were all corrupted.
Not sure, what you mean here.
1. Comment out the -rt stuff because it's not Linux 2. Force PORTAUDIO because it was trying to use ALSA
I guess you did not use the existing m1 Makefile. You can specify it like that: make -f Makefile.m1
3. add `-I /opt/homebrew/include` to CFLAGS and `-L /opt/homebrew/lib` to LDADD so it could find all the includes and lib.
Yes, that is basically what you need to do. Tell the build system, where headers and libs are.
Corrupted packages from the Sourceforge site:
I tried using the Makefile.m1
and it looks like it was very hacked for someone's specific machine. I think the Opus stuff might just be a quirk in how Homebrew packages stuff so I wound up taking OPUS and ALAC out since it didn't seem worth fighting with right now to get a clean compile.
This is what I had to change:
diff --git a/Makefile b/Makefile
index 78511dc..07443b1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
#Cross compile support - create a Makefile which defines these three variables and then includes this Makefile...
CFLAGS ?= -Wall -fPIC -O2
-CFLAGS += -fcommon -std=gnu99
+CFLAGS += -fcommon
LDADD ?= -lpthread -lm -lrt
EXECUTABLE ?= squeezelite
@@ -41,7 +41,7 @@ SOURCES_OPUS = opus.c
SOURCES_MAD = mad.c
SOURCES_MPG123 = mpg.c
-LINK_LINUX = -ldl
+LINK_LINUX = -ldl -std=gnu99
LINK_ALSA = -lasound
LINK_PORTAUDIO = -lportaudio
LINK_PULSEAUDIO = -lpulse
diff --git a/Makefile.m1 b/Makefile.m1
index 1157732..032732e 100644
--- a/Makefile.m1
+++ b/Makefile.m1
@@ -1,7 +1,7 @@
# OSX 12.0+ arm64 only
-OPTS = -DUSE_LIBOGG -DPORTAUDIO -DALAC -DOPUS -DRESAMPLE -DLINKALL -DVISEXPORT -DDSD -DUSE_SSL -I./includem1 -I./includem1/opus -I./includem1/alac -arch arm64 -O3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11.0
+OPTS = -DUSE_LIBOGG -DPORTAUDIO -DRESAMPLE -DLINKALL -DVISEXPORT -DDSD -DUSE_SSL -arch arm64 -O3 -mmacosx-version-min=11.0 -I /opt/homebrew/include
-LDFLAGS = -arch arm64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -L./libm1
+LDFLAGS = -arch arm64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=11.0 -L /opt/homebrew/lib
LDADD = -lportaudio -lpthread -ldl -lm -framework CoreVideo -framework VideoDecodeAcceleration -frame
work CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon
diff --git a/opus.c b/opus.c
index baabab0..edbe18b 100644
--- a/opus.c
+++ b/opus.c
@@ -41,7 +41,7 @@
#define ALIGN(n) (n << 16)
#endif
-#include <opusfile.h>
+#include <opus/opusfile.h>
struct opus {
struct OggOpusFile *of
Briefly:
gnu99
stuffsysroot
stuff as it wasn't needed and just broke thingsDALAC
and DOPUS
because they were just causing headaches on my machine. I'm guessing I could fight to get the stuff in the right place to make it work because Homebrew didn't have it or do it. The ALAC stuff is over a decade old at this point.tl;dr I think it would be cool to get the Sourceforge downloads to not be broken. Otherwise, the Makefile.m1
(and Makefile
) needs a little love if people are going to use it without too much trouble. I think the package manager stuff could be handled more cleanly in variables than as hardcoded.
If we can get these sorted out so that most people are happy, I'm happy to submit a PR for the README which is currently not useful to anyone.
Hi,
when builing on macOS libraries that are installed by package managers like pkgsrc or MacPorts are not used.