~ubuntu-branches/ubuntu/lucid/pitivi/lucid

« back to all changes in this revision

Viewing changes to common/m4/gst-error.m4

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2009-05-27 14:22:49 UTC
  • mfrom: (1.2.1 upstream) (3.1.13 experimental)
  • Revision ID: james.westby@ubuntu.com-20090527142249-tj0qnkc37320ylml
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
])
 
86
 
 
87
dnl Sets ERROR_CXXFLAGS to something the compiler will accept.
 
88
dnl AC_SUBST them so they are available in Makefile
 
89
 
 
90
dnl -Wall is added if it is supported
 
91
dnl -Werror is added if ADD-WERROR is not "no"
 
92
 
 
93
dnl These flags can be overridden at make time:
 
94
dnl make ERROR_CXXFLAGS=
 
95
AC_DEFUN([AG_GST_SET_ERROR_CXXFLAGS],
 
96
[
 
97
  AC_REQUIRE([AC_PROG_CXX])
 
98
  AC_REQUIRE([AS_CXX_COMPILER_FLAG])
 
99
 
 
100
 
 
101
  dnl if we support -Wall, set it unconditionally
 
102
  AS_CXX_COMPILER_FLAG(-Wall, [
 
103
      ERROR_CXXFLAGS="-Wall"
 
104
  ], [
 
105
      ERROR_CXXFLAGS=""
 
106
  ])
 
107
 
 
108
  dnl if asked for, add -Werror if supported
 
109
  if test "x$1" != "xno"
 
110
  then
 
111
    AS_CXX_COMPILER_FLAG(-Werror, werror_supported=yes, werror_supported=no)
 
112
 
 
113
    if test "x$werror_supported" = "xyes"; then
 
114
        ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror"
 
115
 
 
116
        dnl add exceptions
 
117
        AS_CXX_COMPILER_FLAG([-Wno-non-virtual-dtor], ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-non-virtual-dtor")
 
118
 
 
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
 
121
        dnl warnings.
 
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")
 
125
          ])
 
126
    else
 
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'
 
145
        do
 
146
          AS_CXX_COMPILER_FLAG([-errwarn=%all,$f], [
 
147
            ERROR_CXXFLAGS="$ERROR_CXXFLAGS,$f"
 
148
          ])
 
149
        done
 
150
      fi
 
151
    fi
 
152
  fi
 
153
 
 
154
  AC_SUBST(ERROR_CXXFLAGS)
 
155
  AC_MSG_NOTICE([set ERROR_CXXFLAGS to $ERROR_CXXFLAGS])
 
156
])
 
157
 
 
158
dnl Sets the default error level for debugging messages
 
159
AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT],
 
160
[
 
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
 
165
  else
 
166
    GST_LEVEL_DEFAULT=GST_LEVEL_NONE
 
167
  fi
 
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)
 
172
])