1
dnl GNOME_COMPILE_WARNINGS
2
dnl Turn on many useful compiler warnings
3
dnl For now, only works on GCC
4
AC_DEFUN([GNOME_COMPILE_WARNINGS],[
5
AC_ARG_ENABLE(compile-warnings,
6
[ --enable-compile-warnings=[no/minimum/yes] Turn on compiler warnings.],,enable_compile_warnings=minimum)
8
AC_MSG_CHECKING(what warning flags to pass to the C compiler)
10
if test "x$GCC" != xyes; then
11
enable_compile_warnings=no
14
if test "x$enable_compile_warnings" != "xno"; then
15
if test "x$GCC" = "xyes"; then
17
*[\ \ ]-Wall[\ \ ]*) ;;
18
*) warnCFLAGS="-Wall -Wunused" ;;
21
## -W is not all that useful. And it cannot be controlled
22
## with individual -Wno-xxx flags, unlike -Wall
23
if test "x$enable_compile_warnings" = "xyes"; then
24
warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations"
28
AC_MSG_RESULT($warnCFLAGS)
31
[ --enable-iso-c Try to warn if code is not ISO C ],,
34
AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
36
if test "x$enable_iso_c" != "xno"; then
37
if test "x$GCC" = "xyes"; then
39
*[\ \ ]-ansi[\ \ ]*) ;;
40
*) complCFLAGS="$complCFLAGS -ansi" ;;
44
*[\ \ ]-pedantic[\ \ ]*) ;;
45
*) complCFLAGS="$complCFLAGS -pedantic" ;;
49
AC_MSG_RESULT($complCFLAGS)
50
if test "x$cflags_set" != "xyes"; then
51
CFLAGS="$CFLAGS $warnCFLAGS $complCFLAGS"
57
dnl For C++, do basically the same thing.
59
AC_DEFUN([GNOME_CXX_WARNINGS],[
60
AC_ARG_ENABLE(cxx-warnings,
61
[ --enable-cxx-warnings=[no/minimum/yes] Turn on compiler warnings.],,enable_cxx_warnings=minimum)
63
AC_MSG_CHECKING(what warning flags to pass to the C++ compiler)
65
if test "x$GCC" != xyes; then
66
enable_compile_warnings=no
68
if test "x$enable_cxx_warnings" != "xno"; then
69
if test "x$GCC" = "xyes"; then
71
*[\ \ ]-Wall[\ \ ]*) ;;
72
*) warnCXXFLAGS="-Wall -Wno-unused" ;;
75
## -W is not all that useful. And it cannot be controlled
76
## with individual -Wno-xxx flags, unlike -Wall
77
if test "x$enable_cxx_warnings" = "xyes"; then
78
warnCXXFLAGS="$warnCXXFLAGS -Wmissing-prototypes -Wmissing-declarations -Wshadow -Woverloaded-virtual"
82
AC_MSG_RESULT($warnCXXFLAGS)
84
AC_ARG_ENABLE(iso-cxx,
85
[ --enable-iso-cxx Try to warn if code is not ISO C++ ],,
88
AC_MSG_CHECKING(what language compliance flags to pass to the C++ compiler)
90
if test "x$enable_iso_cxx" != "xno"; then
91
if test "x$GCC" = "xyes"; then
93
*[\ \ ]-ansi[\ \ ]*) ;;
94
*) complCXXFLAGS="$complCXXFLAGS -ansi" ;;
98
*[\ \ ]-pedantic[\ \ ]*) ;;
99
*) complCXXFLAGS="$complCXXFLAGS -pedantic" ;;
103
AC_MSG_RESULT($complCXXFLAGS)
104
if test "x$cxxflags_set" != "xyes"; then
105
CXXFLAGS="$CXXFLAGS $warnCXXFLAGS $complCXXFLAGS"
107
AC_SUBST(cxxflags_set)