Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / common / m4 / gst-error.m4
1 dnl handle various error-related things
2
3 dnl Thomas Vander Stichele <thomas@apestaart.org>
4 dnl Tim-Philipp Müller <tim centricular net>
5
6 dnl Last modification: 2008-02-18
7
8 dnl AG_GST_SET_ERROR_CFLAGS([ADD-WERROR], [MORE_FLAGS])
9 dnl AG_GST_SET_ERROR_CXXFLAGS([ADD-WERROR], [MORE_FLAGS])
10 dnl AG_GST_SET_LEVEL_DEFAULT([IS-GIT-VERSION])
11
12
13 dnl Sets WARNING_CFLAGS and ERROR_CFLAGS to something the compiler 
14 dnl will accept and AC_SUBST them so they are available in Makefile
15 dnl
16 dnl WARNING_CFLAGS will contain flags to make the compiler emit more
17 dnl   warnings.
18 dnl ERROR_CFLAGS will contain flags to make those warnings fatal,
19 dnl   unless ADD-WERROR is set to "no"
20 dnl 
21 dnl If MORE_FLAGS is set, tries to add each of the given flags
22 dnl to WARNING_CFLAGS if the compiler supports them. Each flag is 
23 dnl tested separately.
24 dnl
25 dnl These flags can be overridden at make time:
26 dnl make ERROR_CFLAGS=
27 AC_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     else
80       dnl Add -fno-strict-aliasing for GLib versions before 2.19.8
81       dnl as before G_LOCK and friends caused strict aliasing compiler
82       dnl warnings.
83       PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [
84         AS_COMPILER_FLAG(-fno-strict-aliasing,
85             ERROR_CFLAGS="$ERROR_CFLAGS -fno-strict-aliasing")
86         ])
87     fi
88   fi
89
90   if test "x$2" != "x"
91   then
92     UNSUPPORTED=""
93     list="$2"
94     for each in $list
95     do
96       AS_COMPILER_FLAG($each,
97           WARNING_CFLAGS="$WARNING_CFLAGS $each",
98           UNSUPPORTED="$UNSUPPORTED $each")
99     done
100     if test "X$UNSUPPORTED" != X ; then
101       AC_MSG_NOTICE([unsupported compiler flags: $UNSUPPORTED])
102     fi
103   fi
104
105   AC_SUBST(WARNING_CFLAGS)
106   AC_SUBST(ERROR_CFLAGS)
107   AC_MSG_NOTICE([set WARNING_CFLAGS to $WARNING_CFLAGS])
108   AC_MSG_NOTICE([set ERROR_CFLAGS to $ERROR_CFLAGS])
109 ])
110
111 dnl Sets WARNING_CXXFLAGS and ERROR_CXXFLAGS to something the compiler 
112 dnl will accept and AC_SUBST them so they are available in Makefile
113 dnl
114 dnl WARNING_CXXFLAGS will contain flags to make the compiler emit more
115 dnl   warnings.
116 dnl ERROR_CXXFLAGS will contain flags to make those warnings fatal,
117 dnl   unless ADD-WERROR is set to "no"
118 dnl 
119 dnl If MORE_FLAGS is set, tries to add each of the given flags
120 dnl to WARNING_CFLAGS if the compiler supports them. Each flag is 
121 dnl tested separately.
122 dnl
123 dnl These flags can be overridden at make time:
124 dnl make ERROR_CXXFLAGS=
125 AC_DEFUN([AG_GST_SET_ERROR_CXXFLAGS],
126 [
127   AC_REQUIRE([AC_PROG_CXX])
128   AC_REQUIRE([AS_CXX_COMPILER_FLAG])
129
130   ERROR_CXXFLAGS=""
131   WARNING_CXXFLAGS=""
132
133   dnl if we support -Wall, set it unconditionally
134   AS_CXX_COMPILER_FLAG(-Wall, WARNING_CXXFLAGS="$WARNING_CXXFLAGS -Wall")
135
136   dnl if asked for, add -Werror if supported
137   if test "x$1" != "xno"
138   then
139     AS_CXX_COMPILER_FLAG(-Werror, ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror")
140
141     if test "x$ERROR_CXXFLAGS" != "x"
142     then
143         dnl add exceptions
144         AS_CXX_COMPILER_FLAG([-Wno-non-virtual-dtor], ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-non-virtual-dtor")
145
146         dnl Add -fno-strict-aliasing for GLib versions before 2.19.8
147         dnl as before G_LOCK and friends caused strict aliasing compiler
148         dnl warnings.
149         PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [
150           AS_CXX_COMPILER_FLAG([-fno-strict-aliasing],
151             ERROR_CXXFLAGS="$ERROR_CXXFLAGS -fno-strict-aliasing")
152           ])
153     else
154       dnl if -Werror isn't suported, try -errwarn=%all
155       AS_CXX_COMPILER_FLAG([-errwarn=%all], ERROR_CXXFLAGS="$ERROR_CXXFLAGS -errwarn=%all")
156       if test "x$ERROR_CXXFLAGS" != "x"; then
157         dnl try -errwarn=%all,no%E_EMPTY_DECLARATION,
158         dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH,
159         dnl no%E_MACRO_REDEFINED (Sun Forte case)
160         dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon
161         dnl "statement not reached" disabled because there is g_assert_not_reached () in some places
162         dnl "macro redefined" because of gst/gettext.h
163         dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'?
164         dnl FIXME: do any of these work with the c++ compiler? if not, why
165         dnl do we check at all?
166         for f in 'no%E_EMPTY_DECLARATION' \
167                  'no%E_STATEMENT_NOT_REACHED' \
168                  'no%E_ARGUEMENT_MISMATCH' \
169                  'no%E_MACRO_REDEFINED' \
170                  'no%E_LOOP_NOT_ENTERED_AT_TOP'
171         do
172           AS_CXX_COMPILER_FLAG([-errwarn=%all,$f], ERROR_CXXFLAGS="$ERROR_CXXFLAGS,$f")
173         done
174       fi
175     fi
176   fi
177
178   if test "x$2" != "x"
179   then
180     UNSUPPORTED=""
181     list="$2"
182     for each in $list
183     do
184       AS_CXX_COMPILER_FLAG($each,
185           WARNING_CXXFLAGS="$WARNING_CXXFLAGS $each",
186           UNSUPPORTED="$UNSUPPORTED $each")
187     done
188     if test "X$UNSUPPORTED" != X ; then
189       AC_MSG_NOTICE([unsupported compiler flags: $UNSUPPORTED])
190     fi
191   fi
192
193   AC_SUBST(WARNING_CXXFLAGS)
194   AC_SUBST(ERROR_CXXFLAGS)
195   AC_MSG_NOTICE([set WARNING_CXXFLAGS to $WARNING_CXXFLAGS])
196   AC_MSG_NOTICE([set ERROR_CXXFLAGS to $ERROR_CXXFLAGS])
197 ])
198
199 dnl Sets the default error level for debugging messages
200 AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT],
201 [
202   dnl define correct errorlevel for debugging messages. We want to have
203   dnl GST_ERROR messages printed when running cvs builds
204   if test "x[$1]" = "xyes"; then
205     GST_LEVEL_DEFAULT=GST_LEVEL_ERROR
206   else
207     GST_LEVEL_DEFAULT=GST_LEVEL_NONE
208   fi
209   AC_DEFINE_UNQUOTED(GST_LEVEL_DEFAULT, $GST_LEVEL_DEFAULT,
210     [Default errorlevel to use])
211   dnl AC_SUBST so we can use it for win32/common/config.h
212   AC_SUBST(GST_LEVEL_DEFAULT)
213 ])