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])
87
dnl Sets ERROR_CXXFLAGS to something the compiler will accept.
88
dnl AC_SUBST them so they are available in Makefile
90
dnl -Wall is added if it is supported
91
dnl -Werror is added if ADD-WERROR is not "no"
93
dnl These flags can be overridden at make time:
94
dnl make ERROR_CXXFLAGS=
95
AC_DEFUN([AG_GST_SET_ERROR_CXXFLAGS],
97
AC_REQUIRE([AC_PROG_CXX])
98
AC_REQUIRE([AS_CXX_COMPILER_FLAG])
101
dnl if we support -Wall, set it unconditionally
102
AS_CXX_COMPILER_FLAG(-Wall, [
103
ERROR_CXXFLAGS="-Wall"
108
dnl if asked for, add -Werror if supported
109
if test "x$1" != "xno"
111
AS_CXX_COMPILER_FLAG(-Werror, werror_supported=yes, werror_supported=no)
113
if test "x$werror_supported" = "xyes"; then
114
ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror"
117
AS_CXX_COMPILER_FLAG([-Wno-non-virtual-dtor], ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-non-virtual-dtor")
119
dnl Add -fno-strict-aliasing for GLib versions before 2.19.8
120
dnl as before G_LOCK and friends caused strict aliasing compiler
122
PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [
123
AS_CXX_COMPILER_FLAG([-fno-strict-aliasing],
124
ERROR_CXXFLAGS="$ERROR_CXXFLAGS -fno-strict-aliasing")
127
dnl if -Werror isn't suported, try -errwarn=%all
128
AS_CXX_COMPILER_FLAG([-errwarn=%all], errwarnall=yes, errwarnall=no)
129
if test "x$errwarnall" = "xyes"; then
130
ERROR_CXXFLAGS="-errwarn=%all"
131
dnl try -errwarn=%all,no%E_EMPTY_DECLARATION,
132
dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH,
133
dnl no%E_MACRO_REDEFINED (Sun Forte case)
134
dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon
135
dnl "statement not reached" disabled because there is g_assert_not_reached () in some places
136
dnl "macro redefined" because of gst/gettext.h
137
dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'?
138
dnl FIXME: do any of these work with the c++ compiler? if not, why
139
dnl do we check at all?
140
for f in 'no%E_EMPTY_DECLARATION' \
141
'no%E_STATEMENT_NOT_REACHED' \
142
'no%E_ARGUEMENT_MISMATCH' \
143
'no%E_MACRO_REDEFINED' \
144
'no%E_LOOP_NOT_ENTERED_AT_TOP'
146
AS_CXX_COMPILER_FLAG([-errwarn=%all,$f], [
147
ERROR_CXXFLAGS="$ERROR_CXXFLAGS,$f"
154
AC_SUBST(ERROR_CXXFLAGS)
155
AC_MSG_NOTICE([set ERROR_CXXFLAGS to $ERROR_CXXFLAGS])
158
dnl Sets the default error level for debugging messages
159
AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT],
161
dnl define correct errorlevel for debugging messages. We want to have
162
dnl GST_ERROR messages printed when running cvs builds
163
if test "x[$1]" = "xyes"; then
164
GST_LEVEL_DEFAULT=GST_LEVEL_ERROR
166
GST_LEVEL_DEFAULT=GST_LEVEL_NONE
168
AC_DEFINE_UNQUOTED(GST_LEVEL_DEFAULT, $GST_LEVEL_DEFAULT,
169
[Default errorlevel to use])
170
dnl AC_SUBST so we can use it for win32/common/config.h
171
AC_SUBST(GST_LEVEL_DEFAULT)