The SILC Project

source navigation ]
identifier search ]
freetext search ]
file search ]

silc/silcer/macros/compiler-flags.m4

  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)
  7 
  8   AC_MSG_CHECKING(what warning flags to pass to the C compiler)
  9   warnCFLAGS=
 10   if test "x$GCC" != xyes; then
 11     enable_compile_warnings=no
 12   fi
 13 
 14   if test "x$enable_compile_warnings" != "xno"; then
 15     if test "x$GCC" = "xyes"; then
 16       case " $CFLAGS " in
 17       *[\ \     ]-Wall[\ \      ]*) ;;
 18       *) warnCFLAGS="-Wall -Wunused" ;;
 19       esac
 20 
 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"
 25       fi
 26     fi
 27   fi
 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(what language compliance flags to pass to the C compiler)
 35   complCFLAGS=
 36   if test "x$enable_iso_c" != "xno"; then
 37     if test "x$GCC" = "xyes"; then
 38       case " $CFLAGS " in
 39       *[\ \     ]-ansi[\ \      ]*) ;;
 40       *) complCFLAGS="$complCFLAGS -ansi" ;;
 41       esac
 42 
 43       case " $CFLAGS " in
 44       *[\ \     ]-pedantic[\ \  ]*) ;;
 45       *) complCFLAGS="$complCFLAGS -pedantic" ;;
 46       esac
 47     fi
 48   fi
 49   AC_MSG_RESULT($complCFLAGS)
 50   if test "x$cflags_set" != "xyes"; then
 51     CFLAGS="$CFLAGS $warnCFLAGS $complCFLAGS"
 52     cflags_set=yes
 53     AC_SUBST(cflags_set)
 54   fi
 55 ])
 56 
 57 dnl For C++, do basically the same thing.
 58 
 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)
 62 
 63   AC_MSG_CHECKING(what warning flags to pass to the C++ compiler)
 64   warnCXXFLAGS=
 65   if test "x$GCC" != xyes; then
 66     enable_compile_warnings=no
 67   fi
 68   if test "x$enable_cxx_warnings" != "xno"; then
 69     if test "x$GCC" = "xyes"; then
 70       case " $CXXFLAGS " in
 71       *[\ \     ]-Wall[\ \      ]*) ;;
 72       *) warnCXXFLAGS="-Wall -Wno-unused" ;;
 73       esac
 74 
 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"
 79       fi
 80     fi
 81   fi
 82   AC_MSG_RESULT($warnCXXFLAGS)
 83 
 84    AC_ARG_ENABLE(iso-cxx,
 85      [  --enable-iso-cxx          Try to warn if code is not ISO C++ ],,
 86      enable_iso_cxx=no)
 87 
 88    AC_MSG_CHECKING(what language compliance flags to pass to the C++ compiler)
 89    complCXXFLAGS=
 90    if test "x$enable_iso_cxx" != "xno"; then
 91      if test "x$GCC" = "xyes"; then
 92       case " $CXXFLAGS " in
 93       *[\ \     ]-ansi[\ \      ]*) ;;
 94       *) complCXXFLAGS="$complCXXFLAGS -ansi" ;;
 95       esac
 96 
 97       case " $CXXFLAGS " in
 98       *[\ \     ]-pedantic[\ \  ]*) ;;
 99       *) complCXXFLAGS="$complCXXFLAGS -pedantic" ;;
100       esac
101      fi
102    fi
103   AC_MSG_RESULT($complCXXFLAGS)
104   if test "x$cxxflags_set" != "xyes"; then
105     CXXFLAGS="$CXXFLAGS $warnCXXFLAGS $complCXXFLAGS"
106     cxxflags_set=yes
107     AC_SUBST(cxxflags_set)
108   fi
109 ])

This page was automatically generated by the LXR engine.
Free-text search provided by Glimpse