1 Dnl handle various error-related things
3 dnl Thomas Vander Stichele <thomas@apestaart.org>
4 dnl Tim-Philipp Müller <tim centricular net>
6 dnl Last modification: 2008-02-18
8 dnl AG_GST_SET_ERROR_CFLAGS([ADD-WERROR])
9 dnl AG_GST_SET_ERROR_CXXFLAGS([ADD-WERROR])
10 dnl AG_GST_SET_LEVEL_DEFAULT([IS-GIT-VERSION])
13 dnl Sets ERROR_CFLAGS to something the compiler will accept.
14 dnl AC_SUBST them so they are available in Makefile
16 dnl -Wall is added if it is supported
17 dnl -Werror is added if ADD-WERROR is not "no"
19 dnl These flags can be overridden at make time:
20 dnl make ERROR_CFLAGS=
21 AC_DEFUN([AG_GST_SET_ERROR_CFLAGS],
23 AC_REQUIRE([AC_PROG_CC])
24 AC_REQUIRE([AS_COMPILER_FLAG])
27 dnl if we support -Wall, set it unconditionally
28 AS_COMPILER_FLAG(-Wall,
32 dnl Warn if declarations after statements are used (C99 extension)
33 AS_COMPILER_FLAG(-Wdeclaration-after-statement,
34 ERROR_CFLAGS="$ERROR_CFLAGS -Wdeclaration-after-statement")
36 dnl Warn if variable length arrays are used (C99 extension)
37 AS_COMPILER_FLAG(-Wvla,
38 ERROR_CFLAGS="$ERROR_CFLAGS -Wvla")
40 dnl Warn for invalid pointer arithmetic
41 AS_COMPILER_FLAG(-Wpointer-arith,
42 ERROR_CFLAGS="$ERROR_CFLAGS -Wpointer-arith")
44 dnl if asked for, add -Werror if supported
45 if test "x$1" != "xno"
47 AS_COMPILER_FLAG(-Werror, ERROR_CFLAGS="$ERROR_CFLAGS -Werror")
49 dnl if -Werror isn't suported, try -errwarn=%all (Sun Forte case)
50 if test "x$ERROR_CFLAGS" == "x"
52 AS_COMPILER_FLAG([-errwarn=%all], [
53 ERROR_CFLAGS="-errwarn=%all"
54 dnl try -errwarn=%all,no%E_EMPTY_DECLARATION,
55 dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH,
56 dnl no%E_MACRO_REDEFINED (Sun Forte case)
57 dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon
58 dnl "statement not reached" disabled because there is g_assert_not_reached () in some places
59 dnl "macro redefined" because of gst/gettext.h
60 dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'?
61 for f in 'no%E_EMPTY_DECLARATION' \
62 'no%E_STATEMENT_NOT_REACHED' \
63 'no%E_ARGUEMENT_MISMATCH' \
64 'no%E_MACRO_REDEFINED' \
65 'no%E_LOOP_NOT_ENTERED_AT_TOP'
67 AS_COMPILER_FLAG([-errwarn=%all,$f], [
68 ERROR_CFLAGS="$ERROR_CFLAGS,$f"
73 dnl Add -fno-strict-aliasing for GLib versions before 2.19.8
74 dnl as before G_LOCK and friends caused strict aliasing compiler
76 PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [
77 AS_COMPILER_FLAG(-fno-strict-aliasing,
78 ERROR_CFLAGS="$ERROR_CFLAGS -fno-strict-aliasing")
83 AC_SUBST(ERROR_CFLAGS)
84 AC_MSG_NOTICE([set ERROR_CFLAGS to $ERROR_CFLAGS])