Skip to content

Commit 6718fbe

Browse files
committed
Merge bitcoin/bitcoin#22397: build: Fix macOS Apple Silicon build with miniupnpc and libnatpmp
2445df4 build: Fix macOS Apple Silicon build with miniupnpc and libnatpmp (Hennadii Stepanov) Pull request description: On master (7a49fdc) the `configure` script does not pick up Homebrew's `miniupnpc` and `libnatpmp` packages on macOS Apple Silicon: ``` % ./configure --with-miniupnpc ... checking for miniupnpc/miniupnpc.h... no checking for miniupnpc/upnpcommands.h... no checking for miniupnpc/upnperrors.h... no ... checking whether to build with support for UPnP... configure: error: "UPnP requested but cannot be built. Use --without-miniupnpc." ``` ``` % ./configure --with-natpmp ... checking for natpmp.h... no ... checking whether to build with support for NAT-PMP... configure: error: NAT-PMP requested but cannot be built. Use --without-natpmp ``` The preferred Homebrew [prefix for Apple Silicon](https://docs.brew.sh/Installation) 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. ACKs for top commit: Zero-1729: re-tACK 2445df4 (re-tested on an M1 Machine running macOS 11.4). jarolrod: re-ACK 2445df4 Tree-SHA512: d623d26492f463812bf66ca519847ff4b23d517466b6c51c3caf3642a582d02e5f03ce57915742b29f01bf9bceb731a3978ef9a5fdc82e568bcb62548eda758a
2 parents 92aad53 + 2445df4 commit 6718fbe

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
@@ -705,6 +705,33 @@ case $host in
705705
if $BREW list --versions qt5 >/dev/null; then
706706
export PKG_CONFIG_PATH="$($BREW --prefix qt5 2>/dev/null)/lib/pkgconfig:$PKG_CONFIG_PATH"
707707
fi
708+
709+
case $host in
710+
*aarch64*)
711+
dnl The preferred Homebrew prefix for Apple Silicon is /opt/homebrew.
712+
dnl Therefore, as we do not use pkg-config to detect miniupnpc and libnatpmp
713+
dnl packages, we should set the CPPFLAGS and LDFLAGS variables for them
714+
dnl explicitly.
715+
if test "x$use_upnp" != xno && $BREW list --versions miniupnpc >/dev/null; then
716+
miniupnpc_prefix=$($BREW --prefix miniupnpc 2>/dev/null)
717+
if test "x$suppress_external_warnings" != xno; then
718+
CPPFLAGS="$CPPFLAGS -isystem $miniupnpc_prefix/include"
719+
else
720+
CPPFLAGS="$CPPFLAGS -I$miniupnpc_prefix/include"
721+
fi
722+
LDFLAGS="$LDFLAGS -L$miniupnpc_prefix/lib"
723+
fi
724+
if test "x$use_natpmp" != xno && $BREW list --versions libnatpmp >/dev/null; then
725+
libnatpmp_prefix=$($BREW --prefix libnatpmp 2>/dev/null)
726+
if test "x$suppress_external_warnings" != xno; then
727+
CPPFLAGS="$CPPFLAGS -isystem $libnatpmp_prefix/include"
728+
else
729+
CPPFLAGS="$CPPFLAGS -I$libnatpmp_prefix/include"
730+
fi
731+
LDFLAGS="$LDFLAGS -L$libnatpmp_prefix/lib"
732+
fi
733+
;;
734+
esac
708735
fi
709736
else
710737
case $build_os in

0 commit comments

Comments
 (0)