From e0b4ea2fd47d5281f66b0c92196296e2b133f388 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 7 Mar 2017 01:06:31 +0300 Subject: Auto detect if librt usable for current compiler. --- configure.ac | 110 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/configure.ac b/configure.ac index 406fc3688..e7c32e112 100755 --- a/configure.ac +++ b/configure.ac @@ -3,6 +3,58 @@ AC_INIT([ManaPlus], [1.7.3.4], [akaras@inbox.ru], [manaplus]) AM_INIT_AUTOMAKE([1.9]) AC_LANG_CPLUSPLUS +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) + ] +) + # Enable -Werror AC_ARG_ENABLE(werror, [ --enable-werror Fail build if warning present], @@ -456,8 +508,11 @@ if test "x$with_librt" == "xno"; then else if test "x$applebuild_enabled" == "xfalse"; then if test "x$androidbuild_enabled" == "xfalse"; then - AC_CHECK_LIB(rt, shm_open, , - AC_MSG_ERROR([ *** Unable to find librt library])) + AC_CHECK_LD_FLAG(-lrt, USE_LIBRT) + if test "x$test_flag" == "xyes"; then + AC_CHECK_LIB(rt, shm_open, , + AC_MSG_ERROR([ *** Unable to find librt library])) + fi fi fi without_librt=no @@ -580,57 +635,6 @@ 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) -- cgit v1.2.3-70-g09d2