summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2019-09-27 14:32:25 +0200
committerraveit65 <[email protected]>2019-09-27 14:32:25 +0200
commit51a2f83b28d1e6164e0b7f2fddd5243f3137fd91 (patch)
tree90ec94e2b8de792127e2c61d7d38e107f4c402eb /macros
parentfb2d7dc556afb6aec7ae265edfc015b59b075590 (diff)
downloadmate-common-51a2f83b28d1e6164e0b7f2fddd5243f3137fd91.tar.bz2
mate-common-51a2f83b28d1e6164e0b7f2fddd5243f3137fd91.tar.xz
Revert "update mate-compiler-flags macro"
This reverts commit ad0857b239facbfe89199923c15988aacb00806e. Better not for 1.22
Diffstat (limited to 'macros')
-rw-r--r--macros/mate-compiler-flags.m471
1 files changed, 50 insertions, 21 deletions
diff --git a/macros/mate-compiler-flags.m4 b/macros/mate-compiler-flags.m4
index 6ba33be..4b5ecc0 100644
--- a/macros/mate-compiler-flags.m4
+++ b/macros/mate-compiler-flags.m4
@@ -28,7 +28,13 @@ AC_DEFUN([MATE_COMPILE_WARNINGS],[
[Turn on compiler warnings]),,
[enable_compile_warnings="m4_default([$1],[yes])"])
- AC_LANG_PUSH([C])
+ warnCFLAGS=
+ if test "x$GCC" != xyes; then
+ enable_compile_warnings=no
+ fi
+
+ warning_flags=
+ realsave_CFLAGS="$CFLAGS"
case "$enable_compile_warnings" in
no)
@@ -41,7 +47,24 @@ AC_DEFUN([MATE_COMPILE_WARNINGS],[
warning_flags="-Wall -Wmissing-prototypes"
;;
maximum|error)
- warning_flags="-Wall -Wmissing-prototypes -Wbad-function-cast -Wcast-align -Wextra -Wformat-nonliteral -Wmissing-declarations -Wmissing-field-initializers -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Werror=format-security -Wno-sign-compare"
+ warning_flags="-Wall -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
+ CFLAGS="$warning_flags $CFLAGS"
+ for option in -Wno-sign-compare; do
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $option"
+ AC_MSG_CHECKING([whether gcc understands $option])
+ AC_TRY_COMPILE([], [],
+ has_option=yes,
+ has_option=no,)
+ CFLAGS="$SAVE_CFLAGS"
+ AC_MSG_RESULT($has_option)
+ if test $has_option = yes; then
+ warning_flags="$warning_flags $option"
+ fi
+ unset has_option
+ unset SAVE_CFLAGS
+ done
+ unset option
if test "$enable_compile_warnings" = "error" ; then
warning_flags="$warning_flags -Werror"
fi
@@ -50,26 +73,32 @@ AC_DEFUN([MATE_COMPILE_WARNINGS],[
AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
;;
esac
+ CFLAGS="$realsave_CFLAGS"
+ AC_MSG_CHECKING(what warning flags to pass to the C compiler)
+ AC_MSG_RESULT($warning_flags)
+
+ AC_ARG_ENABLE(iso-c,
+ AS_HELP_STRING([--enable-iso-c],
+ [Try to warn if code is not ISO C ]),,
+ [enable_iso_c=no])
+
+ AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
+ complCFLAGS=
+ if test "x$enable_iso_c" != "xno"; then
+ if test "x$GCC" = "xyes"; then
+ case " $CFLAGS " in
+ *[\ \ ]-ansi[\ \ ]*) ;;
+ *) complCFLAGS="$complCFLAGS -ansi" ;;
+ esac
+ case " $CFLAGS " in
+ *[\ \ ]-pedantic[\ \ ]*) ;;
+ *) complCFLAGS="$complCFLAGS -pedantic" ;;
+ esac
+ fi
+ fi
+ AC_MSG_RESULT($complCFLAGS)
- # Always pass -Werror=unknown-warning-option to get Clang to fail on bad
- # flags, otherwise they are always appended to the warn_cflags variable, and
- # Clang warns on them for every compilation unit.
- # If this is passed to GCC, it will explode, so the flag must be enabled
- # conditionally.
- AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
- compiler_flags_test="-Werror=unknown-warning-option"
- ],[
- compiler_flags_test=""
- ])
-
- for flag in $warning_flags; do
- AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [WARN_CFLAGS])], [], [$compiler_flags_test], [])
- done
-
- AC_MSG_CHECKING(flags to pass to the C compiler $CC)
- AC_MSG_RESULT(${WARN_CFLAGS})
-
- AC_LANG_POP([C])
+ WARN_CFLAGS="$warning_flags $complCFLAGS"
AC_SUBST(WARN_CFLAGS)
])