diff --git a/configure.ac b/configure.ac index e24f41f1..f4937170 100644 --- a/configure.ac +++ b/configure.ac @@ -31,6 +31,30 @@ AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR], [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) AC_SUBST([pkgconfigdir]) +dnl === TEST_AND_ADD_CFLAGS(flag) +dnl === Checks whether $CC supports 'flag' and adds it to AM_CFLAGS on success. +AC_DEFUN([TEST_AND_ADD_CFLAGS], + [SAVED_CFLAGS="$CFLAGS" + CFLAGS="-Werror $1" + AC_MSG_CHECKING([whether $CC supports $1]) + dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition. + AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], + [AC_MSG_RESULT([yes])] + [AS_VAR_APPEND([AM_CFLAGS], [" $1"])], + [AC_MSG_RESULT([no])]) + CFLAGS="$SAVED_CFLAGS"]) +TEST_AND_ADD_CFLAGS([-Wall]) +TEST_AND_ADD_CFLAGS([-Wdeclaration-after-statement]) +TEST_AND_ADD_CFLAGS([-Wextra]) +TEST_AND_ADD_CFLAGS([-Wmissing-declarations]) +TEST_AND_ADD_CFLAGS([-Wmissing-prototypes]) +TEST_AND_ADD_CFLAGS([-Wold-style-definition]) +TEST_AND_ADD_CFLAGS([-Wshadow]) +TEST_AND_ADD_CFLAGS([-Wunused-but-set-variable]) +TEST_AND_ADD_CFLAGS([-Wunused]) +TEST_AND_ADD_CFLAGS([-Wvla]) +AC_SUBST([AM_CFLAGS]) + dnl === CLEAR_LIBVARS([var_pfx]) dnl === Clears _{INCLUDES,LIBS}. AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""])