Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Document last changes
[simgrid.git] / acmacro / gnome-warnings.m4
1
2
3 dnl GNOME_COMPILE_WARNINGS
4 dnl Turn on many useful compiler warnings
5 dnl For now, only works on GCC
6 AC_DEFUN([GNOME_COMPILE_WARNINGS],[
7   AC_ARG_ENABLE(compile-warnings, 
8     [  --enable-compile-warnings=[no/minimum/yes]       Turn on compiler warnings.],,enable_compile_warnings=yes)
9
10   AC_MSG_CHECKING(what warning flags to pass to the C compiler)
11   warnCFLAGS=
12   if test "x$GCC" != xyes; then
13     enable_compile_warnings=no
14   fi
15
16   if test "x$enable_compile_warnings" != "xno"; then
17     if test "x$GCC" = "xyes"; then
18       case " $CFLAGS " in
19       *-Wall*) ;;
20       *) warnCFLAGS="-g -Wall -Wunused" ;;
21       esac
22
23       ## -W is not all that useful.  And it cannot be controlled
24       ## with individual -Wno-xxx flags, unlike -Wall
25       if test "x$enable_compile_warnings" = "xyes"; then
26         warnCFLAGS="$warnCFLAGS  -Wmissing-prototypes -Wmissing-declarations\
27                     -finline-functions  -Wshadow -Wpointer-arith \
28                     -Wwrite-strings -Wno-unused-function -Werror"
29       fi
30     fi
31   fi
32   AC_MSG_RESULT($warnCFLAGS)
33
34   AC_ARG_ENABLE(iso-c,
35     [  --enable-iso-c          Try to warn if code is not ISO C ],,
36     enable_iso_c=no)
37
38   AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
39   complCFLAGS=
40   if test "x$enable_iso_c" != "xno"; then
41     if test "x$GCC" = "xyes"; then
42       case " $CFLAGS " in
43       *-ansi*) ;;
44       *) complCFLAGS="$complCFLAGS -ansi" ;;
45       esac
46
47       case " $CFLAGS " in
48       *-pedantic*) ;;
49       *) complCFLAGS="$complCFLAGS -pedantic" ;;
50       esac
51     fi
52   fi
53   AC_MSG_RESULT($complCFLAGS)
54   if test "x$cflags_set" != "xyes"; then
55     CFLAGS="$CFLAGS $warnCFLAGS $complCFLAGS"
56     cflags_set=yes
57     AC_SUBST(cflags_set)
58   fi
59 ])