1dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) 2dnl 3dnl example 4dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) 5dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local 6 7AC_DEFUN([AS_AC_EXPAND], 8[ 9 EXP_VAR=[$1] 10 FROM_VAR=[$2] 11 12 dnl first expand prefix and exec_prefix if necessary 13 prefix_save=$prefix 14 exec_prefix_save=$exec_prefix 15 16 dnl if no prefix given, then use /usr/local, the default prefix 17 if test "x$prefix" = "xNONE"; then 18 prefix=$ac_default_prefix 19 fi 20 dnl if no exec_prefix given, then use prefix 21 if test "x$exec_prefix" = "xNONE"; then 22 exec_prefix=$prefix 23 fi 24 25 full_var="$FROM_VAR" 26 dnl loop until it doesn't change anymore 27 while true; do 28 new_full_var="`eval echo $full_var`" 29 if test "x$new_full_var"="x$full_var"; then break; fi 30 full_var=$new_full_var 31 done 32 33 dnl clean up 34 full_var=$new_full_var 35 AC_SUBST([$1], "$full_var") 36 37 dnl restore prefix and exec_prefix 38 prefix=$prefix_save 39 exec_prefix=$exec_prefix_save 40]) 41 42dnl GNOME_COMPILE_WARNINGS 43dnl Turn on many useful compiler warnings 44dnl For now, only works on GCC 45AC_DEFUN([GNOME_COMPILE_WARNINGS],[ 46 dnl ****************************** 47 dnl More compiler warnings 48 dnl ****************************** 49 50 AC_ARG_ENABLE(compile-warnings, 51 AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@], 52 [Turn on compiler warnings]),, 53 [enable_compile_warnings="m4_default([$1],[yes])"]) 54 55 warnCFLAGS= 56 if test "x$GCC" != xyes; then 57 enable_compile_warnings=no 58 fi 59 60 warning_flags= 61 realsave_CFLAGS="$CFLAGS" 62 63 case "$enable_compile_warnings" in 64 no) 65 warning_flags= 66 ;; 67 minimum) 68 warning_flags="-Wall" 69 ;; 70 yes) 71 warning_flags="-Wall -Wmissing-prototypes" 72 ;; 73 maximum|error) 74 warning_flags="-Wall -Wmissing-prototypes -Wnested-externs -Wpointer-arith" 75 CFLAGS="$warning_flags $CFLAGS" 76 for option in -Wno-sign-compare; do 77 SAVE_CFLAGS="$CFLAGS" 78 CFLAGS="$CFLAGS $option" 79 AC_MSG_CHECKING([whether gcc understands $option]) 80 AC_TRY_COMPILE([], [], 81 has_option=yes, 82 has_option=no,) 83 CFLAGS="$SAVE_CFLAGS" 84 AC_MSG_RESULT($has_option) 85 if test $has_option = yes; then 86 warning_flags="$warning_flags $option" 87 fi 88 unset has_option 89 unset SAVE_CFLAGS 90 done 91 unset option 92 if test "$enable_compile_warnings" = "error" ; then 93 warning_flags="$warning_flags -Werror" 94 fi 95 ;; 96 *) 97 AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings) 98 ;; 99 esac 100 CFLAGS="$realsave_CFLAGS" 101 AC_MSG_CHECKING(what warning flags to pass to the C compiler) 102 AC_MSG_RESULT($warning_flags) 103 104 AC_ARG_ENABLE(iso-c, 105 AC_HELP_STRING([--enable-iso-c], 106 [Try to warn if code is not ISO C ]),, 107 [enable_iso_c=no]) 108 109 AC_MSG_CHECKING(what language compliance flags to pass to the C compiler) 110 complCFLAGS= 111 if test "x$enable_iso_c" != "xno"; then 112 if test "x$GCC" = "xyes"; then 113 case " $CFLAGS " in 114 *[\ \ ]-ansi[\ \ ]*) ;; 115 *) complCFLAGS="$complCFLAGS -ansi" ;; 116 esac 117 case " $CFLAGS " in 118 *[\ \ ]-pedantic[\ \ ]*) ;; 119 *) complCFLAGS="$complCFLAGS -pedantic" ;; 120 esac 121 fi 122 fi 123 AC_MSG_RESULT($complCFLAGS) 124 125 WARN_CFLAGS="$warning_flags $complCFLAGS" 126 AC_SUBST(WARN_CFLAGS) 127]) 128 129dnl For C++, do basically the same thing. 130 131AC_DEFUN([GNOME_CXX_WARNINGS],[ 132 AC_ARG_ENABLE(cxx-warnings, 133 AC_HELP_STRING([--enable-cxx-warnings=@<:@no/minimum/yes@:>@] 134 [Turn on compiler warnings.]),, 135 [enable_cxx_warnings="m4_default([$1],[minimum])"]) 136 137 AC_MSG_CHECKING(what warning flags to pass to the C++ compiler) 138 warnCXXFLAGS= 139 if test "x$GXX" != xyes; then 140 enable_cxx_warnings=no 141 fi 142 if test "x$enable_cxx_warnings" != "xno"; then 143 if test "x$GXX" = "xyes"; then 144 case " $CXXFLAGS " in 145 *[\ \ ]-Wall[\ \ ]*) ;; 146 *) warnCXXFLAGS="-Wall -Wno-unused" ;; 147 esac 148 149 ## -W is not all that useful. And it cannot be controlled 150 ## with individual -Wno-xxx flags, unlike -Wall 151 if test "x$enable_cxx_warnings" = "xyes"; then 152 warnCXXFLAGS="$warnCXXFLAGS -Wshadow -Woverloaded-virtual" 153 fi 154 fi 155 fi 156 AC_MSG_RESULT($warnCXXFLAGS) 157 158 AC_ARG_ENABLE(iso-cxx, 159 AC_HELP_STRING([--enable-iso-cxx], 160 [Try to warn if code is not ISO C++ ]),, 161 [enable_iso_cxx=no]) 162 163 AC_MSG_CHECKING(what language compliance flags to pass to the C++ compiler) 164 complCXXFLAGS= 165 if test "x$enable_iso_cxx" != "xno"; then 166 if test "x$GXX" = "xyes"; then 167 case " $CXXFLAGS " in 168 *[\ \ ]-ansi[\ \ ]*) ;; 169 *) complCXXFLAGS="$complCXXFLAGS -ansi" ;; 170 esac 171 172 case " $CXXFLAGS " in 173 *[\ \ ]-pedantic[\ \ ]*) ;; 174 *) complCXXFLAGS="$complCXXFLAGS -pedantic" ;; 175 esac 176 fi 177 fi 178 AC_MSG_RESULT($complCXXFLAGS) 179 180 WARN_CXXFLAGS="$CXXFLAGS $warnCXXFLAGS $complCXXFLAGS" 181 AC_SUBST(WARN_CXXFLAGS) 182]) 183