diff options
author | Alan Third <alan@idiocy.org> | 2021-09-09 22:33:01 +0100 |
---|---|---|
committer | Alan Third <alan@idiocy.org> | 2021-09-14 10:08:11 +0100 |
commit | 443d37ff213ec31c8450a9cce36a7c44ac63945b (patch) | |
tree | 85c9f9a050c8397f7d45c4f3ff625c4073208f88 /configure.ac | |
parent | 3f835ad5806e246ec671e0b4f5c29fbdd32e2440 (diff) | |
download | emacs-443d37ff213ec31c8450a9cce36a7c44ac63945b.tar.gz |
Fix libgccjit detection on macOS
* configure.ac: Combine the Homebrew and MacPorts detection so they
will not create nonsense flags if both are installed.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/configure.ac b/configure.ac index 418a62fd5ea..1146b581cd7 100644 --- a/configure.ac +++ b/configure.ac @@ -3822,40 +3822,44 @@ if test "${with_native_compilation}" != "no"; then AC_MSG_ERROR(['--with-native-compilation' requires zlib]) fi - # Ensure libgccjit installed by Homebrew can be found. - if test -n "$BREW"; then - if test -n "`$BREW --prefix --installed libgccjit 2>/dev/null`"; then - BREW_LIBGCCJIT_INCLUDE=$(dirname $($BREW ls -v libgccjit | \ - grep libgccjit.h)) - BREW_LIBGCCJIT_LIB=$(dirname $($BREW ls -v libgccjit| \ - grep libgccjit.so\$)) - CFLAGS="$CFLAGS -I${BREW_LIBGCCJIT_INCLUDE}" - LDFLAGS="$LDFLAGS -L${BREW_LIBGCCJIT_LIB}" + SAVE_CFLAGS=$CFLAGS + SAVE_LIBS=$LIBS + + if test "${opsys}" = "darwin"; then + # Ensure libgccjit installed by Homebrew or macports can be found. + if test -n "$BREW"; then + if test -n "`$BREW --prefix --installed libgccjit 2>/dev/null`"; then + MAC_CFLAGS="-I$(dirname $($BREW ls -v libgccjit | \ + grep libgccjit.h))" + MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit| \ + grep libgccjit.so\$))" + fi fi - fi - # Ensure libgccjit installed by MacPorts can be found. - if test -n "$HAVE_MACPORTS"; then - # Determine which gcc version has been installed (gcc11, for - # instance). - PORT_PACKAGE=$(port installed active | grep '^ *gcc@<:@0-9@:>@* ' | \ - awk '{ print $1; }') - MACPORTS_LIBGCCJIT_INCLUDE=$(dirname $(port contents $PORT_PACKAGE | \ - grep libgccjit.h)) - MACPORTS_LIBGCCJIT_LIB=$(dirname $(port contents $PORT_PACKAGE | \ - grep libgccjit.dylib)) - CFLAGS="$CFLAGS -I${MACPORTS_LIBGCCJIT_INCLUDE}" - LDFLAGS="$LDFLAGS -L${MACPORTS_LIBGCCJIT_LIB}" + if test -n "$HAVE_MACPORTS"; then + # Determine which gcc version has been installed (gcc11, for + # instance). + PORT_PACKAGE=$(port installed active | grep '^ *gcc@<:@0-9@:>@* ' | \ + awk '{ print $1; }') + if test -n "$PORT_PACKAGE"; then + MAC_CFLAGS="-I$(dirname $(port contents $PORT_PACKAGE | \ + grep libgccjit.h))" + MAC_LIBS="-L$(dirname $(port contents $PORT_PACKAGE | \ + grep libgccjit.dylib))" + fi + fi + + if test -n "$MAC_CFLAGS" && test -n "$MAC_LIBS"; then + CFLAGS="$CFLAGS ${MAC_CFLAGS}" + LIBS="$LIBS ${MAC_LIBS}" + fi fi # Check if libgccjit is available. AC_CHECK_LIB(gccjit, gcc_jit_context_acquire, [], [libgccjit_not_found]) AC_CHECK_HEADERS(libgccjit.h, [], [libgccjit_dev_not_found]) - emacs_save_LIBS=$LIBS - LIBS="-lgccjit" # Check if libgccjit really works. AC_RUN_IFELSE([libgccjit_smoke_test], [], [libgccjit_broken]) - LIBS=$emacs_save_LIBS HAVE_NATIVE_COMP=yes case "${opsys}" in # mingw32 loads the library dynamically. @@ -3863,17 +3867,17 @@ if test "${with_native_compilation}" != "no"; then # OpenBSD doesn't have libdl, all the functions are in libc netbsd|openbsd) LIBGCCJIT_LIBS="-lgccjit" ;; + darwin) + LIBGCCJIT_CFLAGS="${MAC_CFLAGS}" + LIBGCCJIT_LIBS="${MAC_LIBS} -lgccjit -ldl";; *) LIBGCCJIT_LIBS="-lgccjit -ldl" ;; esac NEED_DYNLIB=yes AC_DEFINE(HAVE_NATIVE_COMP, 1, [Define to 1 if native compiler is available.]) - # Ensure libgccjit installed by MacPorts can be found. - if test -n "$HAVE_MACPORTS"; then - LIBGCCJIT_CFLAGS="$LIBGCCJIT_CFLAGS -I${MACPORTS_LIBGCCJIT_INCLUDE}" - LIBGCCJIT_LIBS="-L${MACPORTS_LIBGCCJIT_LIB} $LIBGCCJIT_LIBS" - fi + CFLAGS=$SAVE_CFLAGS + LIBS=$SAVE_LIBS fi AC_DEFINE_UNQUOTED(NATIVE_ELISP_SUFFIX, ".eln", [System extension for native compiled elisp]) |