Improve GCC warning and error triggers and also improve check of GCC version.

Configure snippets shamelessly stolen from http://www.libusb.org/browser/configure.ac
This commit is contained in:
Joachim Nilsson
2010-07-18 02:51:25 +02:00
parent ca56b74763
commit 2d2ec7db98
8 changed files with 125 additions and 15 deletions

View File

@@ -59,5 +59,32 @@ AC_ARG_ENABLE(terminal-bell,
[ --enable-terminal-bell Enable terminal bell on completion.],
AC_DEFINE([CONFIG_ANNOYING_NOISE],, [Define to enable terminal bell on completion.]))
# Restore gnu89 inline semantics on gcc 4.3 and newer
saved_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fgnu89-inline"
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), inline_cflags="-fgnu89-inline", inline_cflags="")
CFLAGS="$saved_cflags"
# check for -fvisibility=hidden compiler support (GCC >= 3.4)
saved_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fvisibility=hidden"
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
[VISIBILITY_CFLAGS="-fvisibility=hidden"
AC_DEFINE([API_EXPORTED], [__attribute__((visibility("default")))], [Default visibility]) ],
[ VISIBILITY_CFLAGS=""
AC_DEFINE([API_EXPORTED], [], [Default visibility]) ],
])
CFLAGS="$saved_cflags"
# check for -Wno-pointer-sign compiler support (GCC >= 4)
saved_cflags="$CFLAGS"
CFLAGS="$CFLAGS -Wno-pointer-sign"
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
CFLAGS="$saved_cflags"
AM_CFLAGS="-std=gnu99 $inline_cflags -W -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow"
AC_SUBST(AM_CFLAGS)
AC_OUTPUT(Makefile src/Makefile include/Makefile man/Makefile examples/Makefile)