Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of this awful blue line around the picture
[simgrid.git] / acmacro / compiler-flags.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 -Wcomment \
23  -Wformat=2 -Wno-unused-variable -Wno-unused-function -Wno-unused-label -Wwrite-strings \
24  -Werror -O0"
25     fi
26   fi
27
28   AC_MSG_RESULT($warnCFLAGS)
29
30   AC_ARG_ENABLE(iso-c,
31     [  --enable-iso-c          Try to warn if code is not ISO C ],,
32     enable_iso_c=no)
33
34   AC_MSG_CHECKING(the language compliance flags for this compiler)
35   complCFLAGS=
36   if test "x$GCC" = "xyes"; then
37     case " $CFLAGS " in
38     *-ansi*) ;;
39     *) complCFLAGS="$complCFLAGS -ansi" ;;
40     esac
41
42     case " $CFLAGS " in
43     *-pedantic*) ;;
44     *) complCFLAGS="$complCFLAGS -pedantic" ;;
45     esac
46   fi
47   AC_MSG_RESULT($complCFLAGS)
48   
49   
50   AC_MSG_CHECKING(the optimization flags for this compiler)
51   optCFLAGS=
52   if test "x$GCC" = "xyes" ; then
53       optCFLAGS="-ffast-math -funroll-loops -fno-strict-aliasing"
54       case " $CFLAGS " in
55       *-O*) ;;
56       *) optCFLAGS="$optCFLAGS -O3" ;;
57       esac
58   fi
59   AC_MSG_RESULT($optCFLAGS)
60
61   # Take the right flags
62   if test "x$cflags_set" != "xyes" ; then  
63     if test "x$enable_iso_c" != "xno"; then
64       CFLAGS="$CFLAGS $complCFLAGS $optCFLAGS"
65     fi
66     if test "x$enable_compile_warnings" != "xno" ; then
67       CFLAGS="$CFLAGS $warnCFLAGS $optCFLAGS"
68     fi  
69     
70     cflags_set=yes
71     AC_SUBST(cflags_set)
72   fi
73 ])