Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
+=.dirstamp
[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(the warning flags for this compiler)
11   warnCFLAGS=
12   if test "x$GCC" = "xyes"; then
13     case " $CFLAGS " in
14     *-Wall*) ;;
15     *) warnCFLAGS="-g -Wall -Wunused" ;;
16     esac
17
18     ## -W is not all that useful.  And it cannot be controlled
19     ## with individual -Wno-xxx flags, unlike -Wall
20     if test "x$enable_compile_warnings" = "xyes"; then
21       warnCFLAGS="$warnCFLAGS  -Wmissing-prototypes -Wmissing-declarations \
22  -finline-functions  -Wshadow -Wpointer-arith -Wchar-subscripts \
23  -Wformat=2 -Wno-unused-variable -Wno-unused-function -Wwrite-strings -Werror"
24     fi
25   fi
26
27   AC_MSG_RESULT($warnCFLAGS)
28
29   AC_ARG_ENABLE(iso-c,
30     [  --enable-iso-c          Try to warn if code is not ISO C ],,
31     enable_iso_c=no)
32
33   AC_MSG_CHECKING(the language compliance flags for this compiler)
34   complCFLAGS=
35   if test "x$GCC" = "xyes"; then
36     case " $CFLAGS " in
37     *-ansi*) ;;
38     *) complCFLAGS="$complCFLAGS -ansi" ;;
39     esac
40
41     case " $CFLAGS " in
42     *-pedantic*) ;;
43     *) complCFLAGS="$complCFLAGS -pedantic" ;;
44     esac
45   fi
46   AC_MSG_RESULT($complCFLAGS)
47   
48   
49   AC_MSG_CHECKING(the optimization flags for this compiler)
50   optCFLAGS=
51   if test "x$GCC" = "xyes" ; then
52       optCFLAGS="-ffast-math -funroll-loops -fno-strict-aliasing"
53       case " $CFLAGS " in
54       *-O*) ;;
55       *) optCFLAGS="-03" ;;
56       esac
57   fi
58   AC_MSG_RESULT($complCFLAGS)
59
60   # Take the right flags
61   if test "x$cflags_set" != "xyes" ; then  
62     if test "x$enable_iso_c" != "xno"; then
63       CFLAGS="$CFLAGS $complCFLAGS"
64     fi
65     if test "x$enable_compile_warnings" != "xno" ; then
66       CFLAGS="$CFLAGS $warnCFLAGS"
67     fi  
68     
69     cflags_set=yes
70     AC_SUBST(cflags_set)
71   fi
72 ])