diff options
-rw-r--r-- | configure.ac | 41 | ||||
-rw-r--r-- | m4/acinclude.m4 | 20 |
2 files changed, 61 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 98e6af1d..b31b58a8 100644 --- a/configure.ac +++ b/configure.ac @@ -128,6 +128,11 @@ AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [enable debugging support]), [debug=$enableval], [debug=no]) +# Help line for compiler warning flags +AC_ARG_ENABLE(warningflags, + AS_HELP_STRING([--enable-warningflags], [enable extra compiler warning flags]), + [warningflags=$enableval], [warningflags=no]) + # Help line for using git version in pacman version string AC_ARG_ENABLE(git-version, AS_HELP_STRING([--enable-git-version], @@ -354,6 +359,40 @@ else WARNING_CFLAGS="-Wall" fi +# Enable or disable compiler warning flags +AC_MSG_CHECKING(for excessive compiler warning flags) +if test "x$warningflags" = "xyes" ; then + AC_MSG_RESULT(yes) + CFLAGS_ADD([-Wcast-align], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wclobbered], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wempty-body], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wfloat-equal], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wformat-nonliteral], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wformat-security], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wignored-qualifiers], [WARNING_CFLAGS]) + CFLAGS_ADD([-Winit-self], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wlogical-op], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wmissing-declarations], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wmissing-parameter-type], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wmissing-prototypes], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wold-style-declaration], [WARNING_CFLAGS]) + CFLAGS_ADD([-Woverride-init], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wpointer-arith], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wredundant-decls], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wshadow], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wsign-compare], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wstrict-aliasing], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wstrict-overflow=5], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wstrict-prototypes], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wtype-limits], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wuninitialized], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wunused-but-set-parameter], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wunused-parameter], [WARNING_CFLAGS]) + CFLAGS_ADD([-Wwrite-strings], [WARNING_CFLAGS]) +else + AC_MSG_RESULT(no) +fi + # Enable or disable use of git version in pacman version string AC_MSG_CHECKING(whether to use git version if available) if test "x$wantgitver" = "xyes" ; then @@ -450,6 +489,8 @@ ${PACKAGE_NAME}: Run make in doc/ dir : ${wantdoc} ${asciidoc} Doxygen support : ${usedoxygen} debug support : ${debug} + extra warning flags : ${warningflags} + use git version : ${wantgitver} " # vim:set ts=2 sw=2 noet: diff --git a/m4/acinclude.m4 b/m4/acinclude.m4 index df4f83a4..8ea45973 100644 --- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -101,6 +101,26 @@ AC_DEFUN([GCC_GNU89_INLINE_CC],[ fi ]) +dnl CFLAGS_ADD(PARAMETER, VARIABLE) +dnl Adds parameter to VARIABLE if the compiler supports it. For example, +dnl CFLAGS_ADD([-Wall],[WARN_FLAGS]). +AC_DEFUN([CFLAGS_ADD], +[AS_VAR_PUSHDEF([my_cflags], [cflags_cv_warn_$1])dnl +AC_CACHE_CHECK([whether compiler handles $1], [my_cflags], [ + save_CFLAGS="$CFLAGS" + CFLAGS="${CFLAGS} $1" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AS_VAR_SET([my_cflags], [yes])], + [AS_VAR_SET([my_cflags], [no])]) + CFLAGS="$save_CFLAGS" +]) +AS_VAR_PUSHDEF([new_cflags], [[$2]])dnl +AS_VAR_IF([my_cflags], [yes], [AS_VAR_APPEND([new_cflags], [" $1"])]) +AS_VAR_POPDEF([new_cflags])dnl +AS_VAR_POPDEF([my_cflags])dnl +m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl +]) + dnl Checks for getmntinfo and determines whether it uses statfs or statvfs AC_DEFUN([FS_STATS_TYPE], [AC_CACHE_CHECK([filesystem statistics type], fs_stats_cv_type, |