1dnl handle various error-related things 2 3dnl Thomas Vander Stichele <thomas@apestaart.org> 4dnl Tim-Philipp Müller <tim centricular net> 5 6dnl Last modification: 2008-02-18 7 8dnl AG_GST_SET_ERROR_CFLAGS([ADD-WERROR], [MORE_FLAGS]) 9dnl AG_GST_SET_ERROR_CXXFLAGS([ADD-WERROR], [MORE_FLAGS]) 10dnl AG_GST_SET_LEVEL_DEFAULT([IS-GIT-VERSION]) 11 12 13dnl Sets WARNING_CFLAGS and ERROR_CFLAGS to something the compiler 14dnl will accept and AC_SUBST them so they are available in Makefile 15dnl 16dnl WARNING_CFLAGS will contain flags to make the compiler emit more 17dnl warnings. 18dnl ERROR_CFLAGS will contain flags to make those warnings fatal, 19dnl unless ADD-WERROR is set to "no" 20dnl 21dnl If MORE_FLAGS is set, tries to add each of the given flags 22dnl to WARNING_CFLAGS if the compiler supports them. Each flag is 23dnl tested separately. 24dnl 25dnl These flags can be overridden at make time: 26dnl make ERROR_CFLAGS= 27AC_DEFUN([AG_GST_SET_ERROR_CFLAGS], 28[ 29 AC_REQUIRE([AC_PROG_CC]) 30 AC_REQUIRE([AS_COMPILER_FLAG]) 31 32 WARNING_CFLAGS="" 33 ERROR_CFLAGS="" 34 35 dnl if we support -Wall, set it unconditionally 36 AS_COMPILER_FLAG(-Wall, 37 WARNING_CFLAGS="$WARNING_CFLAGS -Wall") 38 39 dnl Warn if declarations after statements are used (C99 extension) 40 AS_COMPILER_FLAG(-Wdeclaration-after-statement, 41 WARNING_CFLAGS="$WARNING_CFLAGS -Wdeclaration-after-statement") 42 43 dnl Warn if variable length arrays are used (C99 extension) 44 AS_COMPILER_FLAG(-Wvla, 45 WARNING_CFLAGS="$WARNING_CFLAGS -Wvla") 46 47 dnl Warn for invalid pointer arithmetic 48 AS_COMPILER_FLAG(-Wpointer-arith, 49 WARNING_CFLAGS="$WARNING_CFLAGS -Wpointer-arith") 50 51 dnl if asked for, add -Werror if supported 52 if test "x$1" != "xno" 53 then 54 AS_COMPILER_FLAG(-Werror, ERROR_CFLAGS="$ERROR_CFLAGS -Werror") 55 56 dnl if -Werror isn't suported, try -errwarn=%all (Sun Forte case) 57 if test "x$ERROR_CFLAGS" = "x" 58 then 59 AS_COMPILER_FLAG([-errwarn=%all], [ 60 ERROR_CFLAGS="-errwarn=%all" 61 dnl try -errwarn=%all,no%E_EMPTY_DECLARATION, 62 dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH, 63 dnl no%E_MACRO_REDEFINED (Sun Forte case) 64 dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon 65 dnl "statement not reached" disabled because there is g_assert_not_reached () in some places 66 dnl "macro redefined" because of gst/gettext.h 67 dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'? 68 for f in 'no%E_EMPTY_DECLARATION' \ 69 'no%E_STATEMENT_NOT_REACHED' \ 70 'no%E_ARGUEMENT_MISMATCH' \ 71 'no%E_MACRO_REDEFINED' \ 72 'no%E_LOOP_NOT_ENTERED_AT_TOP' 73 do 74 AS_COMPILER_FLAG([-errwarn=%all,$f], [ 75 ERROR_CFLAGS="$ERROR_CFLAGS,$f" 76 ]) 77 done 78 ]) 79 fi 80 fi 81 82 if test "x$2" != "x" 83 then 84 UNSUPPORTED="" 85 list="$2" 86 for each in $list 87 do 88 AS_COMPILER_FLAG($each, 89 WARNING_CFLAGS="$WARNING_CFLAGS $each", 90 UNSUPPORTED="$UNSUPPORTED $each") 91 done 92 if test "X$UNSUPPORTED" != X ; then 93 AC_MSG_NOTICE([unsupported compiler flags: $UNSUPPORTED]) 94 fi 95 fi 96 97 AC_SUBST(WARNING_CFLAGS) 98 AC_SUBST(ERROR_CFLAGS) 99 AC_MSG_NOTICE([set WARNING_CFLAGS to $WARNING_CFLAGS]) 100 AC_MSG_NOTICE([set ERROR_CFLAGS to $ERROR_CFLAGS]) 101]) 102 103dnl Sets WARNING_CXXFLAGS and ERROR_CXXFLAGS to something the compiler 104dnl will accept and AC_SUBST them so they are available in Makefile 105dnl 106dnl WARNING_CXXFLAGS will contain flags to make the compiler emit more 107dnl warnings. 108dnl ERROR_CXXFLAGS will contain flags to make those warnings fatal, 109dnl unless ADD-WERROR is set to "no" 110dnl 111dnl If MORE_FLAGS is set, tries to add each of the given flags 112dnl to WARNING_CFLAGS if the compiler supports them. Each flag is 113dnl tested separately. 114dnl 115dnl These flags can be overridden at make time: 116dnl make ERROR_CXXFLAGS= 117AC_DEFUN([AG_GST_SET_ERROR_CXXFLAGS], 118[ 119 AC_REQUIRE([AC_PROG_CXX]) 120 AC_REQUIRE([AS_CXX_COMPILER_FLAG]) 121 122 ERROR_CXXFLAGS="" 123 WARNING_CXXFLAGS="" 124 125 dnl if we support -Wall, set it unconditionally 126 AS_CXX_COMPILER_FLAG(-Wall, WARNING_CXXFLAGS="$WARNING_CXXFLAGS -Wall") 127 128 dnl if asked for, add -Werror if supported 129 if test "x$1" != "xno" 130 then 131 AS_CXX_COMPILER_FLAG(-Werror, ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror") 132 133 if test "x$ERROR_CXXFLAGS" != "x" 134 then 135 dnl add exceptions 136 AS_CXX_COMPILER_FLAG([-Wno-non-virtual-dtor], ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-non-virtual-dtor") 137 138 dnl Add -fno-strict-aliasing for GLib versions before 2.19.8 139 dnl as before G_LOCK and friends caused strict aliasing compiler 140 dnl warnings. 141 PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [ 142 AS_CXX_COMPILER_FLAG([-fno-strict-aliasing], 143 ERROR_CXXFLAGS="$ERROR_CXXFLAGS -fno-strict-aliasing") 144 ]) 145 else 146 dnl if -Werror isn't suported, try -errwarn=%all 147 AS_CXX_COMPILER_FLAG([-errwarn=%all], ERROR_CXXFLAGS="$ERROR_CXXFLAGS -errwarn=%all") 148 if test "x$ERROR_CXXFLAGS" != "x"; then 149 dnl try -errwarn=%all,no%E_EMPTY_DECLARATION, 150 dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH, 151 dnl no%E_MACRO_REDEFINED (Sun Forte case) 152 dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon 153 dnl "statement not reached" disabled because there is g_assert_not_reached () in some places 154 dnl "macro redefined" because of gst/gettext.h 155 dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'? 156 dnl FIXME: do any of these work with the c++ compiler? if not, why 157 dnl do we check at all? 158 for f in 'no%E_EMPTY_DECLARATION' \ 159 'no%E_STATEMENT_NOT_REACHED' \ 160 'no%E_ARGUEMENT_MISMATCH' \ 161 'no%E_MACRO_REDEFINED' \ 162 'no%E_LOOP_NOT_ENTERED_AT_TOP' 163 do 164 AS_CXX_COMPILER_FLAG([-errwarn=%all,$f], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS,$f"]) 165 done 166 fi 167 fi 168 fi 169 170 if test "x$2" != "x" 171 then 172 UNSUPPORTED="" 173 list="$2" 174 for each in $list 175 do 176 AS_CXX_COMPILER_FLAG($each, 177 WARNING_CXXFLAGS="$WARNING_CXXFLAGS $each", 178 UNSUPPORTED="$UNSUPPORTED $each") 179 done 180 if test "X$UNSUPPORTED" != X ; then 181 AC_MSG_NOTICE([unsupported compiler flags: $UNSUPPORTED]) 182 fi 183 fi 184 185 AC_SUBST(WARNING_CXXFLAGS) 186 AC_SUBST(ERROR_CXXFLAGS) 187 AC_MSG_NOTICE([set WARNING_CXXFLAGS to $WARNING_CXXFLAGS]) 188 AC_MSG_NOTICE([set ERROR_CXXFLAGS to $ERROR_CXXFLAGS]) 189]) 190 191dnl Sets WARNING_OBJCFLAGS and ERROR_OBJCFLAGS to something the compiler 192dnl will accept and AC_SUBST them so they are available in Makefile 193dnl 194dnl WARNING_OBJCFLAGS will contain flags to make the compiler emit more 195dnl warnings. 196dnl ERROR_OBJCFLAGS will contain flags to make those warnings fatal, 197dnl unless ADD-WERROR is set to "no" 198dnl 199dnl If MORE_FLAGS is set, tries to add each of the given flags 200dnl to WARNING_CFLAGS if the compiler supports them. Each flag is 201dnl tested separately. 202dnl 203dnl These flags can be overridden at make time: 204dnl make ERROR_OBJCFLAGS= 205AC_DEFUN([AG_GST_SET_ERROR_OBJCFLAGS], 206[ 207 AC_REQUIRE([AC_PROG_OBJC]) 208 AC_REQUIRE([AS_OBJC_COMPILER_FLAG]) 209 210 ERROR_OBJCFLAGS="" 211 WARNING_OBJCFLAGS="" 212 213 dnl if we support -Wall, set it unconditionally 214 AS_OBJC_COMPILER_FLAG(-Wall, WARNING_OBJCFLAGS="$WARNING_OBJCFLAGS -Wall") 215 216 dnl if asked for, add -Werror if supported 217 if test "x$1" != "xno" 218 then 219 AS_OBJC_COMPILER_FLAG(-Werror, ERROR_OBJCFLAGS="$ERROR_OBJCFLAGS -Werror") 220 221 if test "x$ERROR_OBJCFLAGS" != "x" 222 then 223 dnl Add -fno-strict-aliasing for GLib versions before 2.19.8 224 dnl as before G_LOCK and friends caused strict aliasing compiler 225 dnl warnings. 226 PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [ 227 AS_OBJC_COMPILER_FLAG([-fno-strict-aliasing], 228 ERROR_OBJCFLAGS="$ERROR_OBJCFLAGS -fno-strict-aliasing") 229 ]) 230 else 231 dnl if -Werror isn't suported, try -errwarn=%all 232 AS_OBJC_COMPILER_FLAG([-errwarn=%all], ERROR_OBJCFLAGS="$ERROR_OBJCFLAGS -errwarn=%all") 233 if test "x$ERROR_OBJCFLAGS" != "x"; then 234 dnl try -errwarn=%all,no%E_EMPTY_DECLARATION, 235 dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH, 236 dnl no%E_MACRO_REDEFINED (Sun Forte case) 237 dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon 238 dnl "statement not reached" disabled because there is g_assert_not_reached () in some places 239 dnl "macro redefined" because of gst/gettext.h 240 dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'? 241 dnl FIXME: do any of these work with the c++ compiler? if not, why 242 dnl do we check at all? 243 for f in 'no%E_EMPTY_DECLARATION' \ 244 'no%E_STATEMENT_NOT_REACHED' \ 245 'no%E_ARGUEMENT_MISMATCH' \ 246 'no%E_MACRO_REDEFINED' \ 247 'no%E_LOOP_NOT_ENTERED_AT_TOP' 248 do 249 AS_OBJC_COMPILER_FLAG([-errwarn=%all,$f], [ERROR_OBJCFLAGS="$ERROR_OBJCFLAGS,$f"]) 250 done 251 fi 252 fi 253 fi 254 255 if test "x$2" != "x" 256 then 257 UNSUPPORTED="" 258 list="$2" 259 for each in $list 260 do 261 AS_OBJC_COMPILER_FLAG($each, 262 WARNING_OBJCFLAGS="$WARNING_OBJCFLAGS $each", 263 UNSUPPORTED="$UNSUPPORTED $each") 264 done 265 if test "X$UNSUPPORTED" != X ; then 266 AC_MSG_NOTICE([unsupported compiler flags: $UNSUPPORTED]) 267 fi 268 fi 269 270 AC_SUBST(WARNING_OBJCFLAGS) 271 AC_SUBST(ERROR_OBJCFLAGS) 272 AC_MSG_NOTICE([set WARNING_OBJCFLAGS to $WARNING_OBJCFLAGS]) 273 AC_MSG_NOTICE([set ERROR_OBJCFLAGS to $ERROR_OBJCFLAGS]) 274]) 275 276dnl Sets the default error level for debugging messages 277AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT], 278[ 279 dnl define correct errorlevel for debugging messages. We want to have 280 dnl GST_ERROR messages printed when running cvs builds 281 if test "x[$1]" = "xyes"; then 282 GST_LEVEL_DEFAULT=GST_LEVEL_ERROR 283 else 284 GST_LEVEL_DEFAULT=GST_LEVEL_NONE 285 fi 286 AC_DEFINE_UNQUOTED(GST_LEVEL_DEFAULT, $GST_LEVEL_DEFAULT, 287 [Default errorlevel to use]) 288 dnl AC_SUBST so we can use it for win32/common/config.h 289 AC_SUBST(GST_LEVEL_DEFAULT) 290]) 291