Hello!
I thought I'd also share my solution:
First, remove the hard-coded CFLAGS and LDFLAGS on autoconf (
configure.ac) and move them to automake (Makefile.am):
diff --git a/configure.ac b/configure.ac
index e82b82c1..f6156a3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,10 +78,7 @@ AC_SUBST(JANUS_VERSION_STRING)
case "$host_os" in
darwin*)
- CFLAGS="$CFLAGS -I/usr/local/opt/openssl/include -I/usr/local/include"
- # add rdynamic to LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-export_dynamic"
- LDFLAGS="$LDFLAGS -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/opt/local/lib -L/usr/local/libsrtp/lib"
AM_CONDITIONAL([DARWIN_OS], true)
;;
freebsd*)
diff --git a/src/Makefile.am b/src/Makefile.am
index c8eeb339..75e7587a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,6 +63,14 @@ duktape_DATA = $(NULL)
s|[@]duktapedir[@]|$(duktapedir)|" \
$< > $@ || rm $@
+##
+# CFLAGS, LDFLAGS
+##
+if DARWIN_OS
+AM_CFLAGS = -I/opt/homebrew/include -I/opt/homebrew/opt/openssl@3/include
+AM_LDFLAGS = -L/opt/homebrew/lib -L/opt/homebrew/opt/openssl@3/lib
+endif
+
##
# Janus
##
@@ -476,9 +484,9 @@ endif
if ENABLE_PLUGIN_VOICEMAIL
plugin_LTLIBRARIES += plugins/libjanus_voicemail.la
plugins_libjanus_voicemail_la_SOURCES = plugins/janus_voicemail.c
-plugins_libjanus_voicemail_la_CFLAGS = $(plugins_cflags)
-plugins_libjanus_voicemail_la_LDFLAGS = $(plugins_ldflags) -logg
-plugins_libjanus_voicemail_la_LIBADD = $(plugins_libadd)
+plugins_libjanus_voicemail_la_CFLAGS = $(plugins_cflags) $(OGG_CFLAGS)
+plugins_libjanus_voicemail_la_LDFLAGS = $(plugins_ldflags) $(OGG_LDFLAGS) $(OGG_LIBS)
+plugins_libjanus_voicemail_la_LIBADD = $(plugins_libadd) $(OGG_LIBADD)
conf_DATA += ../conf/janus.plugin.voicemail.jcfg.sample
EXTRA_DIST += ../conf/janus.plugin.voicemail.jcfg.sample.in
CLEANFILES += ../conf/janus.plugin.voicemail.jcfg.sample ```
Then, when invoking the configure script, provide the homebrew paths:
```
./configure --prefix=$HOME/opt/janus \
PKG_CONFIG_PATH=/opt/homebrew/opt/openssl@3/lib/pkgconfig \
CFLAGS=-I/opt/homebrew/include \
LDFLAGS=-L/opt/homebrew/lib
```
Alternatively, one can build and run Janus through a docker container. For Apple M1 specifically, pick a base docker image that provides ARM images (virtually native performance since there is no translation from ARM to x86) and of course, pick a Linux distro (so there is no need to modify Janus build files).
In my case, I used Debian (ARM) as the base image:
```
FROM debian:11 AS buildbase
SHELL ["/bin/bash", "-c"]
RUN apt update
RUN apt install -y gcc dh-autoreconf pkg-config gengetopt cmake npm \
libglib2.0-dev zlib1g-dev
FROM buildbase AS build
RUN apt install -y lib{jansson,config,nice,ssl,curl4-openssl}-dev \
lib{srtp2,usrsctp,microhttpd,websockets}-dev \
lib{opus,ogg}-dev
RUN mkdir -p /home/workspace
WORKDIR /home/workspace
COPY ./ ./
RUN ./autogen.sh
RUN ./configure --prefix=/opt/janus
RUN make -j$(nproc)
RUN make install
FROM debian:11-slim AS deploy
SHELL ["/bin/bash", "-c"]
RUN apt update
RUN apt install -y lib{jansson4,config9,nice10,ssl1.1,curl4} \
lib{srtp2-1,usrsctp1,microhttpd12,websockets16} \
lib{opus0,ogg0}
COPY --from=build /opt/janus /opt/janus
EXPOSE 7088 8088 8188
ENTRYPOINT /opt/janus/bin/janus
```
Hope this helps!
Best regards,
Erwin