From 743f46105e1fc10acf08bd5c79cfbf3ca571282a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 7 Mar 2017 00:56:53 +0300 Subject: Enable -rdynamic flag only if it supported by linker. --- configure.ac | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 4 ++++ 2 files changed, 58 insertions(+) diff --git a/configure.ac b/configure.ac index 4df89a250..406fc3688 100755 --- a/configure.ac +++ b/configure.ac @@ -580,6 +580,60 @@ if test "x$naclbuild_enabled" == "xtrue"; then AC_CHECK_SDL() fi +AC_DEFUN([AC_CHECK_CXX_FLAG], + [ + AC_MSG_CHECKING([whether $CC supports $1]) + OLD_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -Werror $1" + test_flag=no + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([int foo;])], + [ + AC_MSG_RESULT([yes]) + test_flag=yes + ], + [ + AC_MSG_RESULT([no]) + test_flag=no + ] + CXXFLAGS="$OLD_CXXFLAGS" + ) + AM_CONDITIONAL($2, test x$test_flag = xtrue) + ] +) + +AC_DEFUN([AC_CHECK_LD_FLAG], + [ + AC_MSG_CHECKING([whether $LD supports $1]) + OLD_CXXFLAGS="$CXXFLAGS" + OLD_LDFLAGS="$LDFLAGS" + CXXFLAGS="" + LDFLAGS="$LDFLAGS $1" + test_flag=no + AC_LINK_IFELSE( + [AC_LANG_SOURCE([ + int main(int argc, char **argv) + { + return 0; + } + ])], + [ + AC_MSG_RESULT([yes]) + test_flag=yes + ], + [ + AC_MSG_RESULT([no]) + test_flag=no + ] + CXXFLAGS="$OLD_CXXFLAGS" + LDFLAGS="$OLD_LDFLAGS" + ) + AM_CONDITIONAL($2, test x$test_flag = xyes) + ] +) + +AC_CHECK_LD_FLAG(-rdynamic, HAVE_RDYNAMIC) + AC_CONFIG_FILES([ manaplus.spec Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 3a456a35e..89f09413e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,9 +46,11 @@ endif if ENABLE_ASSERTS manaplus_CXXFLAGS += -DENABLE_ASSERTS dyecmd_CXXFLAGS += -DENABLE_ASSERTS +if HAVE_RDYNAMIC manaplus_LDFLAGS = -rdynamic dyecmd_LDFLAGS = -rdynamic endif +endif if ENABLE_PUGIXML manaplus_CXXFLAGS += -DENABLE_PUGIXML @@ -1947,8 +1949,10 @@ manaplustests_CXXFLAGS += -Werror endif if ENABLE_ASSERTS manaplustests_CXXFLAGS += -DENABLE_ASSERTS +if HAVE_RDYNAMIC manaplustests_LDFLAGS = -rdynamic endif +endif if ENABLE_GLIBCDEBUG manaplustests_CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC endif -- cgit v1.2.3-60-g2f50