Initial import
[platform/upstream/gst-rtsp-server.git] / common / m4 / gst-error.m4
1 dnl handle various error-related things
2
3 dnl Thomas Vander Stichele <thomas@apestaart.org>
4
5 dnl Last modification: 2005-10-16
6
7 dnl AG_GST_SET_ERROR_CFLAGS([ADD-WERROR])
8 dnl AG_GST_SET_LEVEL_DEFAULT([IS-CVS-VERSION])
9
10
11 dnl Sets ERROR_CFLAGS to something the compiler will accept.
12 dnl AC_SUBST them so they are available in Makefile
13
14 dnl -Wall is added if it is supported
15 dnl -Werror is added if ADD-WERROR is not "no"
16
17 dnl These flags can be overridden at make time:
18 dnl make ERROR_CFLAGS=
19 AC_DEFUN([AG_GST_SET_ERROR_CFLAGS],
20 [
21   AC_REQUIRE([AC_PROG_CC])
22   AC_REQUIRE([AS_COMPILER_FLAG])
23
24   
25   dnl if we support -Wall, set it unconditionally
26   AS_COMPILER_FLAG(-Wall,
27                    ERROR_CFLAGS="-Wall",
28                    ERROR_CFLAGS="")
29   
30   dnl if asked for, add -Werror if supported
31   if test "x$1" != "xno"
32   then
33     AS_COMPILER_FLAG(-Werror, ERROR_CFLAGS="$ERROR_CFLAGS -Werror")
34
35     dnl if -Werror isn't suported
36     if test "x$ERROR_CFLAGS" == "x"
37     then
38       dnl try -errwarn=%all,no%E_EMPTY_DECLARATION,no%E_STATEMENT_NOT_REACHED (Sun Forte case)
39       dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon 
40       dnl "statement not reached" disabled because there is g_assert_not_reached () in some places
41       AS_COMPILER_FLAG([-errwarn=%all,no%E_EMPTY_DECLARATION,no%E_STATEMENT_NOT_REACHED],
42                        [ERROR_CFLAGS="-errwarn=%all,no%E_EMPTY_DECLARATION,no%E_STATEMENT_NOT_REACHED"])
43
44       dnl if this also isn't suported, try only for -errwarn=%all
45       if test "x$ERROR_CFLAGS" == "x"
46       then
47         AS_COMPILER_FLAG(-errwarn=%all,
48                          ERROR_CFLAGS="-errwarn=%all")
49       fi
50     fi
51   fi
52
53   AC_SUBST(ERROR_CFLAGS)
54   AC_MSG_NOTICE([set ERROR_CFLAGS to $ERROR_CFLAGS])
55 ])
56
57 dnl Sets the default error level for debugging messages
58 AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT],
59 [
60   dnl define correct errorlevel for debugging messages. We want to have
61   dnl GST_ERROR messages printed when running cvs builds
62   if test "x[$1]" = "xyes"; then
63     GST_LEVEL_DEFAULT=GST_LEVEL_ERROR
64   else
65     GST_LEVEL_DEFAULT=GST_LEVEL_NONE
66   fi
67   AC_DEFINE_UNQUOTED(GST_LEVEL_DEFAULT, $GST_LEVEL_DEFAULT,
68     [Default errorlevel to use])
69   dnl AC_SUBST so we can use it for win32/common/config.h
70   AC_SUBST(GST_LEVEL_DEFAULT)
71 ])