From e53a1d410b6e4e691780f74373c38e4230e12605 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 2 Sep 2019 16:01:04 -0700 Subject: Fix OSX build Closes #326 --- ax_check_link_flag.m4 | 53 +++++++++++++++++++++++++++++++++++ configure | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++- configure.ac | 4 ++- 3 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 ax_check_link_flag.m4 diff --git a/ax_check_link_flag.m4 b/ax_check_link_flag.m4 new file mode 100644 index 0000000..03a30ce --- /dev/null +++ b/ax_check_link_flag.m4 @@ -0,0 +1,53 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the linker or gives an error. +# (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the linker's default flags +# when the check is done. The check is thus made with the flags: "LDFLAGS +# EXTRA-FLAGS FLAG". This can for example be used to force the linker to +# issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_LINK_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AC_DEFUN([AX_CHECK_LINK_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl +AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ + ax_check_save_flags=$LDFLAGS + LDFLAGS="$LDFLAGS $4 $1" + AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + LDFLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_LINK_FLAGS diff --git a/configure b/configure index dae4e03..fee4f60 100755 --- a/configure +++ b/configure @@ -2202,6 +2202,46 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the linker or gives an error. +# (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the linker's default flags +# when the check is done. The check is thus made with the flags: "LDFLAGS +# EXTRA-FLAGS FLAG". This can for example be used to force the linker to +# issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_LINK_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + + + #------------------------------------------------------------------------- # Checks for programs #------------------------------------------------------------------------- @@ -4364,7 +4404,41 @@ CFLAGS="-Wall -Wno-unused -g -O2" CXXFLAGS="-Wall -Wno-unused -g -O2 -std=c++11" -LDFLAGS="-Wl,--export-dynamic" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,--export-dynamic" >&5 +$as_echo_n "checking whether the linker accepts -Wl,--export-dynamic... " >&6; } +if ${ax_cv_check_ldflags___Wl___export_dynamic+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,--export-dynamic" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ax_cv_check_ldflags___Wl___export_dynamic=yes +else + ax_cv_check_ldflags___Wl___export_dynamic=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl___export_dynamic" >&5 +$as_echo "$ax_cv_check_ldflags___Wl___export_dynamic" >&6; } +if test "x$ax_cv_check_ldflags___Wl___export_dynamic" = xyes; then : + LDFLAGS="-Wl,--export-dynamic" +else + : +fi #------------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index f7a28db..b4bbd43 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,8 @@ AC_CONFIG_AUX_DIR([scripts]) AC_CANONICAL_BUILD AC_CANONICAL_HOST +m4_include(ax_check_link_flag.m4) + #------------------------------------------------------------------------- # Checks for programs #------------------------------------------------------------------------- @@ -84,7 +86,7 @@ AC_CHECK_TYPE([__int128_t], AC_SUBST([HAVE_INT128],[yes])) AC_SUBST([CFLAGS], ["-Wall -Wno-unused -g -O2"]) AC_SUBST([CXXFLAGS],["-Wall -Wno-unused -g -O2 -std=c++11"]) -AC_SUBST([LDFLAGS], ["-Wl,--export-dynamic"]) +AX_CHECK_LINK_FLAG([-Wl,--export-dynamic], [LDFLAGS="-Wl,--export-dynamic"]) #------------------------------------------------------------------------- # MCPPBS subproject list -- cgit v1.1