summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-07 01:06:31 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-07 01:06:31 +0300
commite0b4ea2fd47d5281f66b0c92196296e2b133f388 (patch)
treedc9af6bb00c518877a7724bf7ce19d4b42e932ab /configure.ac
parent743f46105e1fc10acf08bd5c79cfbf3ca571282a (diff)
downloadmanaverse-e0b4ea2fd47d5281f66b0c92196296e2b133f388.tar.gz
manaverse-e0b4ea2fd47d5281f66b0c92196296e2b133f388.tar.bz2
manaverse-e0b4ea2fd47d5281f66b0c92196296e2b133f388.tar.xz
manaverse-e0b4ea2fd47d5281f66b0c92196296e2b133f388.zip
Auto detect if librt usable for current compiler.
Diffstat (limited to 'configure.ac')
-rwxr-xr-xconfigure.ac110
1 files 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)