tizen beta release
[profile/ivi/gst-openmax0.10.git] / 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-GIT-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 Warn if declarations after statements are used (C99 extension)
33   AS_COMPILER_FLAG(-Wdeclaration-after-statement,
34         ERROR_CFLAGS="$ERROR_CFLAGS -Wdeclaration-after-statement")
35
36   dnl Warn if variable length arrays are used (C99 extension)
37   AS_COMPILER_FLAG(-Wvla,
38         ERROR_CFLAGS="$ERROR_CFLAGS -Wvla")
39
40   dnl Warn for invalid pointer arithmetic
41   AS_COMPILER_FLAG(-Wpointer-arith,
42         ERROR_CFLAGS="$ERROR_CFLAGS -Wpointer-arith")
43
44   dnl if asked for, add -Werror if supported
45   if test "x$1" != "xno"
46   then
47     AS_COMPILER_FLAG(-Werror, ERROR_CFLAGS="$ERROR_CFLAGS -Werror")
48
49     dnl if -Werror isn't suported, try -errwarn=%all (Sun Forte case)
50     if test "x$ERROR_CFLAGS" == "x"
51     then
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'
66           do
67             AS_COMPILER_FLAG([-errwarn=%all,$f], [
68               ERROR_CFLAGS="$ERROR_CFLAGS,$f"
69             ])
70           done
71       ])
72     else
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
75       dnl warnings.
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")
79         ])
80     fi
81   fi
82
83   AC_SUBST(ERROR_CFLAGS)
84   AC_MSG_NOTICE([set ERROR_CFLAGS to $ERROR_CFLAGS])
85 ])