summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in196
1 files changed, 139 insertions, 57 deletions
diff --git a/configure.in b/configure.in
index 98c493a03..94bad9ca4 100644
--- a/configure.in
+++ b/configure.in
@@ -248,22 +248,22 @@ AC_ARG_ENABLE(
# LTO
#
AC_ARG_ENABLE(
- [lto],
- AC_HELP_STRING(
- [--enable-lto],
- [
+ [lto],
+ AC_HELP_STRING(
+ [--enable-lto],
+ [
Enables or Disables Linktime Code Optimization (LTO is enabled by default)
- ]
- ),
- [
- enable_lto="$enableval"
- case $enableval in
- "no");;
- "yes");;
- *) AC_MSG_ERROR([[invalid argument --enable-lto=$disableval... stopping]]);;
- esac
- ],
- [enable_lto="yes"]
+ ]
+ ),
+ [
+ enable_lto="$enableval"
+ case $enableval in
+ "no");;
+ "yes");;
+ *) AC_MSG_ERROR([[invalid argument --enable-lto=$disableval... stopping]]);;
+ esac
+ ],
+ [enable_lto="yes"]
)
@@ -433,7 +433,7 @@ AC_PATH_PROG(AR, ar)
AC_LANG([C])
-CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
+CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wextra -Wno-sign-compare"
CPPFLAGS="$CPPFLAGS -I../common"
@@ -517,19 +517,6 @@ AC_RUN_IFELSE(
)
-AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wno-unused-parameter"
-AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE([int foo;])],
- [AC_MSG_RESULT([yes])],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- ]
-)
-
-
#
# LTO Support test
#
@@ -545,8 +532,8 @@ if test "$enable_lto" != "no" ; then
AC_RUN_IFELSE(
[AC_LANG_SOURCE([
int main(int argc, char **argv){
- return 0;
- }
+ return 0;
+ }
])],
[
AC_MSG_RESULT([yes])
@@ -563,49 +550,141 @@ if test "$enable_lto" != "no" ; then
fi
-
-AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wno-pointer-sign"
-AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE([int foo;])],
+AC_DEFUN(AC_CHECK_COMPILER_WFLAG,
[
- AC_MSG_RESULT([yes])
- AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign])
- # This option causes warnings in C++ mode
- # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything
- CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign"
+ AC_MSG_CHECKING([whether $CC supports -W$1])
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror -W$1"
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([int foo;])],
[
AC_MSG_RESULT([yes])
- CFLAGS="$OLD_CFLAGS -Wno-pointer-sign"
+ CFLAGS="$OLD_CFLAGS -W$1"
+ # Optionally, run a test
+ if test "x$2" != "x"; then
+ AC_MSG_CHECKING([whether $CC can actually use -W$1])
+ CFLAGS="$OLD_CFLAGS -Werror -W$1"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([$2])],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$OLD_CFLAGS"
+ ]
+ [
+ AC_MSG_RESULT([yes])
+ CFLAGS="$OLD_CFLAGS -W$1"
+ ],
+ )
+ fi
],
[
AC_MSG_RESULT([no])
CFLAGS="$OLD_CFLAGS"
]
)
- ],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
]
)
-
-AC_MSG_CHECKING([whether $CC supports -Wno-switch])
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wno-switch"
-AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE([int foo;])],
- [AC_MSG_RESULT([yes])],
+AC_DEFUN(AC_CHECK_COMPILER_WNOFLAG,
[
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
+ AC_MSG_CHECKING([whether $CC supports -Wno-$1])
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror -Wno-$1"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int foo;])],
+ [
+ # Recent versions of gcc don't fail if -Wno-foo is not recognized
+ # (unless there are also other warnings), so we also check for -Wfoo
+ # which always fails if not supported
+ CFLAGS="$OLD_CFLAGS -Werror -W$1"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int foo;])],
+ [
+ AC_MSG_RESULT([yes])
+ CFLAGS="$OLD_CFLAGS -Wno-$1"
+ # Optionally, run a test
+ if test "x$2" != "x"; then
+ AC_MSG_CHECKING([whether $CC can actually use -Wno-$1])
+ CFLAGS="$OLD_CFLAGS -Werror -W$1"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([$2])],
+ [
+ AC_MSG_RESULT([not needed but enabled])
+ CFLAGS="$OLD_CFLAGS"
+ ],
+ [
+ CFLAGS="$OLD_CFLAGS -Werror -Wno-$1"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([$2])],
+ [
+ AC_MSG_RESULT([yes])
+ CFLAGS="$OLD_CFLAGS -Wno-$1"
+ ],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$OLD_CFLAGS"
+ ]
+ )
+ ]
+ )
+ fi
+ ],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$OLD_CFLAGS"
+ ]
+ )
+ ],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$OLD_CFLAGS"
+ ]
+ )
]
)
+AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }])
+AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized)
+AC_CHECK_COMPILER_WNOFLAG(clobbered)
+AC_CHECK_COMPILER_WFLAG(empty-body)
+AC_CHECK_COMPILER_WFLAG(newline-eof)
+AC_CHECK_COMPILER_WFLAG(int-conversion)
+AC_CHECK_COMPILER_WFLAG(enum-conversion)
+AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
+AC_CHECK_COMPILER_WFLAG(constant-conversion)
+AC_CHECK_COMPILER_WFLAG(bool-conversion)
+AC_CHECK_COMPILER_WNOFLAG(switch)
+AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
+
+# Certain versions of gcc make -Wshadow completely useless by making it flood
+# you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>
+# Let's check if we can really use it
+SAVED_OLD_CFLAGS="$CFLAGS"
+AC_CHECK_COMPILER_WFLAG(shadow)
+if test "x$CFLAGS" != "x$SAVED_OLD_CFLAGS"; then
+ AC_MSG_CHECKING([whether $CC can efficiently use -Wshadow])
+ NEW_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror -Wshadow"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([
+ int foo(void) {
+ return 0;
+ }
+ int bar(void) {
+ int foo = 0;
+ return foo + 1;
+ }
+ ])],
+ [
+ AC_MSG_RESULT([yes])
+ CFLAGS="$NEW_CFLAGS"
+ ],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$SAVED_OLD_CFLAGS"
+ ]
+ )
+fi
AC_MSG_CHECKING([whether $CC supports -fPIC])
OLD_CFLAGS="$CFLAGS"
@@ -870,7 +949,7 @@ fi
case $enable_debug in
"no")
# default value
- CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses"
+# CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses"
;;
"yes")
CFLAGS="$CFLAGS -g -DDEBUG"
@@ -1123,6 +1202,9 @@ CYGWIN*)
fd_setsize="done"
DLLEXT=".dll"
;;
+Darwin*)
+ DLLEXT=".dylib"
+ ;;
esac
AC_SUBST([DLLEXT])