diff options
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/configure.in b/configure.in index bb28708c..1caf7d92 100644 --- a/configure.in +++ b/configure.in @@ -60,6 +60,7 @@ AC_PROG_CXX AC_ISC_POSIX AC_HEADER_STDC AC_C_INLINE +AM_PROG_LIBTOOL AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE) AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) @@ -144,6 +145,36 @@ cc_supports_flag() { return $rc } +ld_supports_flag() { + AC_MSG_CHECKING([whether $LD supports "$@"]) + AC_TRY_LINK([ + int one(void) { return 1; } + int two(void) { return 2; } + ], [ two(); ] , [_ac_ld_flag_supported=yes], [_ac_ld_flag_supported=no]) + + if test "$_ac_ld_flag_supported" = "yes"; then + rm -f conftest.c + touch conftest.c + if $CC -c conftest.c; then + ld_out=`$LD $@ -o conftest conftest.o 2>&1` + ld_ret=$? + if test $ld_ret -ne 0 ; then + _ac_ld_flag_supported=no + elif echo "$ld_out" | egrep 'option ignored|^usage:|unrecognized option|illegal option' >/dev/null ; then + _ac_ld_flag_supported=no + fi + fi + rm -f conftest.c conftest.o conftest + fi + + AC_MSG_RESULT($_ac_ld_flag_supported) + if test "$_ac_ld_flag_supported" = "yes" ; then + return 0 + else + return 1 + fi +} + if test "x$GCC" = "xyes"; then changequote(,)dnl case " $CFLAGS " in @@ -214,7 +245,7 @@ if test "x$GCC" = "xyes"; then *[\ \ ]-fPIC[\ \ ]*) ;; *) if cc_supports_flag -fPIC; then PIC_CFLAGS="-fPIC" - if [ "x$with_gnu_ld" = "xyes" ]; then + if ld_supports_flag -z,relro; then PIC_LDFLAGS="-Wl,-z,relro" fi fi @@ -225,7 +256,7 @@ if test "x$GCC" = "xyes"; then *[\ \ ]-fPIE[\ \ ]*) ;; *) if cc_supports_flag -fPIE; then PIE_CFLAGS="-fPIE" - if [ "x$with_gnu_ld" = "xyes" ]; then + if ld_supports_flag -z,relro; then PIE_LDFLAGS="-pie -Wl,-z,relro" else PIE_LDFLAGS="-pie" @@ -280,28 +311,7 @@ AC_SUBST(PIC_LDFLAGS) AC_SUBST(PIE_CFLAGS) AC_SUBST(PIE_LDFLAGS) -# Check for -Wl,--gc-sections -AC_MSG_CHECKING([for ld that supports "-Wl,--gc-sections"]) -AC_TRY_LINK([ - int one(void) { return 1; } - int two(void) { return 2; } - ], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no]) - -if test "$ac_gcsections" = "yes"; then - rm -f conftest.c - touch conftest.c - if $CC -c conftest.c; then - ld_out=`$LD --gc-sections -o conftest conftest.o 2>&1` - ld_ret=$? - if test $ld_ret -ne 0 ; then - ac_gcsections=no - elif echo "$ld_out" | egrep 'option ignored|^usage:|illegal option' >/dev/null ; then - ac_gcsections=no - fi - fi - rm -f conftest.c conftest.o conftest -fi -if test "$ac_gcsections" = "yes"; then +if ld_supports_flag --gc-sections; then SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS" CFLAGS="-ffunction-sections -fdata-sections $CFLAGS" fi @@ -316,8 +326,6 @@ case $target_os in CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" ;; esac -AM_PROG_LIBTOOL - changequote(,)dnl # compress spaces in flags CFLAGS=`echo "$CFLAGS" | sed -e 's/ +/ /g'` |