Initial release
[adaptation/ap_samsung/gst-plugins-s5pc2xx.git] / 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])
9 dnl AG_GST_SET_ERROR_CXXFLAGS([ADD-WERROR])
10 dnl AG_GST_SET_LEVEL_DEFAULT([IS-CVS-VERSION])
11
12
13 dnl Sets ERROR_CFLAGS to something the compiler will accept.
14 dnl AC_SUBST them so they are available in Makefile
15
16 dnl -Wall is added if it is supported
17 dnl -Werror is added if ADD-WERROR is not "no"
18
19 dnl These flags can be overridden at make time:
20 dnl make ERROR_CFLAGS=
21 AC_DEFUN([AG_GST_SET_ERROR_CFLAGS],
22 [
23   AC_REQUIRE([AC_PROG_CC])
24   AC_REQUIRE([AS_COMPILER_FLAG])
25
26   
27   dnl if we support -Wall, set it unconditionally
28   AS_COMPILER_FLAG(-Wall,
29                    ERROR_CFLAGS="-Wall",
30                    ERROR_CFLAGS="")
31   
32   dnl if asked for, add -Werror if supported
33   if test "x$1" != "xno"
34   then
35     AS_COMPILER_FLAG(-Werror, ERROR_CFLAGS="$ERROR_CFLAGS -Werror")
36
37     dnl if -Werror isn't suported, try -errwarn=%all (Sun Forte case)
38     if test "x$ERROR_CFLAGS" == "x"
39     then
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'
53           do
54             AS_COMPILER_FLAG([-errwarn=%all,$f], [
55               ERROR_CFLAGS="$ERROR_CFLAGS,$f"
56             ])
57           done
58       ])
59     fi
60   fi
61
62   AC_SUBST(ERROR_CFLAGS)
63   AC_MSG_NOTICE([set ERROR_CFLAGS to $ERROR_CFLAGS])
64 ])
65
66 dnl Sets ERROR_CXXFLAGS to something the compiler will accept.
67 dnl AC_SUBST them so they are available in Makefile
68
69 dnl -Wall is added if it is supported
70 dnl -Werror is added if ADD-WERROR is not "no"
71
72 dnl These flags can be overridden at make time:
73 dnl make ERROR_CXXFLAGS=
74 AC_DEFUN([AG_GST_SET_ERROR_CXXFLAGS],
75 [
76   AC_REQUIRE([AC_PROG_CXX])
77   AC_REQUIRE([AS_CXX_COMPILER_FLAG])
78
79   
80   dnl if we support -Wall, set it unconditionally
81   AS_CXX_COMPILER_FLAG(-Wall, [
82       ERROR_CXXFLAGS="-Wall"
83   ], [
84       ERROR_CXXFLAGS=""
85   ])
86   
87   dnl if asked for, add -Werror if supported
88   if test "x$1" != "xno"
89   then
90     AS_CXX_COMPILER_FLAG(-Werror, werror_supported=yes, werror_supported=no)
91
92     if test "x$werror_supported" = "xyes"; then
93         ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror"
94
95         dnl add exceptions
96         for f in '-Wno-non-virtual-dtor'
97         do
98           AS_CXX_COMPILER_FLAG([$f], ERROR_CXXFLAGS="$ERROR_CXXFLAGS $f")
99         done
100     else
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'
118         do
119           AS_CXX_COMPILER_FLAG([-errwarn=%all,$f], [
120             ERROR_CXXFLAGS="$ERROR_CXXFLAGS,$f"
121           ])
122         done
123       fi
124     fi
125   fi
126
127   AC_SUBST(ERROR_CXXFLAGS)
128   AC_MSG_NOTICE([set ERROR_CXXFLAGS to $ERROR_CXXFLAGS])
129 ])
130
131 dnl Sets the default error level for debugging messages
132 AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT],
133 [
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
138   else
139     GST_LEVEL_DEFAULT=GST_LEVEL_NONE
140   fi
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)
145 ])