Skip to content

Commit 2445df4

Browse files
committed
build: Fix macOS Apple Silicon build with miniupnpc and libnatpmp
The preferred Homebrew prefix for Apple Silicon is /opt/homebrew. Therefore, if we do not use pkg-config to detect packages, we should set the CPPFLAGS and LDFLAGS variables for them explicitly.
1 parent 1c046bb commit 2445df4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

configure.ac

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,33 @@ case $host in
699699
if $BREW list --versions qt5 >/dev/null; then
700700
export PKG_CONFIG_PATH="$($BREW --prefix qt5 2>/dev/null)/lib/pkgconfig:$PKG_CONFIG_PATH"
701701
fi
702+
703+
case $host in
704+
*aarch64*)
705+
dnl The preferred Homebrew prefix for Apple Silicon is /opt/homebrew.
706+
dnl Therefore, as we do not use pkg-config to detect miniupnpc and libnatpmp
707+
dnl packages, we should set the CPPFLAGS and LDFLAGS variables for them
708+
dnl explicitly.
709+
if test "x$use_upnp" != xno && $BREW list --versions miniupnpc >/dev/null; then
710+
miniupnpc_prefix=$($BREW --prefix miniupnpc 2>/dev/null)
711+
if test "x$suppress_external_warnings" != xno; then
712+
CPPFLAGS="$CPPFLAGS -isystem $miniupnpc_prefix/include"
713+
else
714+
CPPFLAGS="$CPPFLAGS -I$miniupnpc_prefix/include"
715+
fi
716+
LDFLAGS="$LDFLAGS -L$miniupnpc_prefix/lib"
717+
fi
718+
if test "x$use_natpmp" != xno && $BREW list --versions libnatpmp >/dev/null; then
719+
libnatpmp_prefix=$($BREW --prefix libnatpmp 2>/dev/null)
720+
if test "x$suppress_external_warnings" != xno; then
721+
CPPFLAGS="$CPPFLAGS -isystem $libnatpmp_prefix/include"
722+
else
723+
CPPFLAGS="$CPPFLAGS -I$libnatpmp_prefix/include"
724+
fi
725+
LDFLAGS="$LDFLAGS -L$libnatpmp_prefix/lib"
726+
fi
727+
;;
728+
esac
702729
fi
703730
else
704731
case $build_os in

0 commit comments

Comments
 (0)