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-CVS-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 if asked for, add -Werror if supported
33 if test "x$1" != "xno"
35 AS_COMPILER_FLAG(-Werror, ERROR_CFLAGS="$ERROR_CFLAGS -Werror")
37 dnl if -Werror isn't suported, try -errwarn=%all (Sun Forte case)
38 if test "x$ERROR_CFLAGS" == "x"
40 AS_COMPILER_FLAG([-errwarn=%all], [
41 ERROR_CFLAGS="-errwarn=%all"
42 dnl try -errwarn=%all,no%E_EMPTY_DECLARATION,
43 dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH,
44 dnl no%E_MACRO_REDEFINED (Sun Forte case)
45 dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon
46 dnl "statement not reached" disabled because there is g_assert_not_reached () in some places
47 dnl "macro redefined" because of gst/gettext.h
48 dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'?
49 for f in 'no%E_EMPTY_DECLARATION' \
50 'no%E_STATEMENT_NOT_REACHED' \
51 'no%E_ARGUEMENT_MISMATCH' \
52 'no%E_MACRO_REDEFINED'
54 AS_COMPILER_FLAG([-errwarn=%all,$f], [
55 ERROR_CFLAGS="$ERROR_CFLAGS,$f"
62 AC_SUBST(ERROR_CFLAGS)
63 AC_MSG_NOTICE([set ERROR_CFLAGS to $ERROR_CFLAGS])
66 dnl Sets ERROR_CXXFLAGS to something the compiler will accept.
67 dnl AC_SUBST them so they are available in Makefile
69 dnl -Wall is added if it is supported
70 dnl -Werror is added if ADD-WERROR is not "no"
72 dnl These flags can be overridden at make time:
73 dnl make ERROR_CXXFLAGS=
74 AC_DEFUN([AG_GST_SET_ERROR_CXXFLAGS],
76 AC_REQUIRE([AC_PROG_CXX])
77 AC_REQUIRE([AS_CXX_COMPILER_FLAG])
80 dnl if we support -Wall, set it unconditionally
81 AS_CXX_COMPILER_FLAG(-Wall, [
82 ERROR_CXXFLAGS="-Wall"
87 dnl if asked for, add -Werror if supported
88 if test "x$1" != "xno"
90 AS_CXX_COMPILER_FLAG(-Werror, werror_supported=yes, werror_supported=no)
92 if test "x$werror_supported" = "xyes"; then
93 ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror"
96 for f in '-Wno-non-virtual-dtor'
98 AS_CXX_COMPILER_FLAG([$f], ERROR_CXXFLAGS="$ERROR_CXXFLAGS $f")
101 dnl if -Werror isn't suported, try -errwarn=%all
102 AS_CXX_COMPILER_FLAG([-errwarn=%all], errwarnall=yes, errwarnall=no)
103 if test "x$errwarnall" = "xyes"; then
104 ERROR_CXXFLAGS="-errwarn=%all"
105 dnl try -errwarn=%all,no%E_EMPTY_DECLARATION,
106 dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH,
107 dnl no%E_MACRO_REDEFINED (Sun Forte case)
108 dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon
109 dnl "statement not reached" disabled because there is g_assert_not_reached () in some places
110 dnl "macro redefined" because of gst/gettext.h
111 dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'?
112 dnl FIXME: do any of these work with the c++ compiler? if not, why
113 dnl do we check at all?
114 for f in 'no%E_EMPTY_DECLARATION' \
115 'no%E_STATEMENT_NOT_REACHED' \
116 'no%E_ARGUEMENT_MISMATCH' \
117 'no%E_MACRO_REDEFINED'
119 AS_CXX_COMPILER_FLAG([-errwarn=%all,$f], [
120 ERROR_CXXFLAGS="$ERROR_CXXFLAGS,$f"
127 AC_SUBST(ERROR_CXXFLAGS)
128 AC_MSG_NOTICE([set ERROR_CXXFLAGS to $ERROR_CXXFLAGS])
131 dnl Sets the default error level for debugging messages
132 AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT],
134 dnl define correct errorlevel for debugging messages. We want to have
135 dnl GST_ERROR messages printed when running cvs builds
136 if test "x[$1]" = "xyes"; then
137 GST_LEVEL_DEFAULT=GST_LEVEL_ERROR
139 GST_LEVEL_DEFAULT=GST_LEVEL_NONE
141 AC_DEFINE_UNQUOTED(GST_LEVEL_DEFAULT, $GST_LEVEL_DEFAULT,
142 [Default errorlevel to use])
143 dnl AC_SUBST so we can use it for win32/common/config.h
144 AC_SUBST(GST_LEVEL_DEFAULT)