~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/pandora_warnings.m4

  • Committer: Brian Aker
  • Date: 2009-07-09 19:49:32 UTC
  • mfrom: (1085.1.10 mordred)
  • Revision ID: brian@gaz-20090709194932-o90qfzgk9xem5di1
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl  Copyright (C) 2009 Sun Microsystems
 
2
dnl This file is free software; Sun Microsystems
 
3
dnl gives unlimited permission to copy and/or distribute it,
 
4
dnl with or without modifications, as long as this notice is preserved.
 
5
 
 
6
dnl AC_PANDORA_WARNINGS([less-warnings|warnings-always-on])
 
7
dnl   less-warnings turn on a limited set of warnings
 
8
dnl   warnings-always-on always set warnings=error regardless of tarball/vc
 
9
 
 
10
dnl @TODO: remove less-warnings option as soon as Drizzle is clean enough to
 
11
dnl        allow it
 
12
 
 
13
AC_DEFUN([PANDORA_WARNINGS],[
 
14
  m4_define([PW_LESS_WARNINGS],[no])
 
15
  m4_define([PW_WARN_ALWAYS_ON],[no])
 
16
  ifdef([m4_define],,[define([m4_define],   defn([define]))])
 
17
  ifdef([m4_undefine],,[define([m4_undefine],   defn([undefine]))])
 
18
  m4_foreach([pw_arg],[$*],[
 
19
    m4_case(pw_arg,
 
20
      [less-warnings],[
 
21
        m4_undefine([PW_LESS_WARNINGS])
 
22
        m4_define([PW_LESS_WARNINGS],[yes])
 
23
      ],
 
24
      [warnings-always-on],[
 
25
        m4_undefine([PW_WARN_ALWAYS_ON])
 
26
        m4_define([PW_WARN_ALWAYS_ON],[yes])
 
27
    ]) 
 
28
  ])
 
29
 
 
30
  AC_REQUIRE([PANDORA_BUILDING_FROM_VC])
 
31
  m4_if(PW_WARN_ALWAYS_ON, [yes],
 
32
    [ac_cv_warnings_as_errors=yes],
 
33
    AS_IF([test "$ac_cv_building_from_vc" = "yes"],
 
34
          [ac_cv_warnings_as_errors=yes],
 
35
          [ac_cv_warnings_as_errors=no]))
 
36
 
 
37
  AC_ARG_ENABLE([profiling],
 
38
      [AS_HELP_STRING([--enable-profiling],
 
39
         [Toggle profiling @<:@default=off@:>@])],
 
40
      [ac_profiling="$enableval"],
 
41
      [ac_profiling="no"])
 
42
 
 
43
  AC_ARG_ENABLE([coverage],
 
44
      [AS_HELP_STRING([--enable-coverage],
 
45
         [Toggle coverage @<:@default=off@:>@])],
 
46
      [ac_coverage="$enableval"],
 
47
      [ac_coverage="no"])
 
48
 
 
49
  AS_IF([test "$GCC" = "yes"],[
 
50
 
 
51
    AS_IF([test "$ac_profiling" = "yes"],[
 
52
      CC_PROFILING="-pg"
 
53
      save_LIBS="${LIBS}"
 
54
      LIBS=""
 
55
      AC_CHECK_LIB(c_p, read)
 
56
      LIBC_P="${LIBS}"
 
57
      LIBS="${save_LIBS}"
 
58
      AC_SUBST(LIBC_P)
 
59
    ],[
 
60
      CC_PROFILING=" "
 
61
    ])
 
62
 
 
63
    AS_IF([test "$ac_coverage" = "yes"],
 
64
          [CC_COVERAGE="-fprofile-arcs -ftest-coverage"])
 
65
         
 
66
    AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],
 
67
          [W_FAIL="-Werror"])
 
68
 
 
69
    AC_CACHE_CHECK([whether it is safe to use -fdiagnostics-show-option],
 
70
      [ac_cv_safe_to_use_fdiagnostics_show_option_],
 
71
      [save_CFLAGS="$CFLAGS"
 
72
       CFLAGS="-fdiagnostics-show-option ${AM_CFLAGS}"
 
73
       AC_COMPILE_IFELSE(
 
74
         [AC_LANG_PROGRAM([],[])],
 
75
         [ac_cv_safe_to_use_fdiagnostics_show_option_=yes],
 
76
         [ac_cv_safe_to_use_fdiagnostics_show_option_=no])
 
77
       CFLAGS="$save_CFLAGS"])
 
78
 
 
79
    AS_IF([test "$ac_cv_safe_to_use_fdiagnostics_show_option_" = "yes"],
 
80
          [
 
81
            F_DIAGNOSTICS_SHOW_OPTION="-fdiagnostics-show-option"
 
82
          ])
 
83
 
 
84
    AC_CACHE_CHECK([whether it is safe to use -Wconversion],
 
85
      [ac_cv_safe_to_use_wconversion_],
 
86
      [save_CFLAGS="$CFLAGS"
 
87
       dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
 
88
       dnl conversion warnings to all the tarball folks
 
89
       CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS}"
 
90
       AC_COMPILE_IFELSE(
 
91
         [AC_LANG_PROGRAM([[
 
92
#include <stdbool.h>
 
93
void foo(bool a)
 
94
{
 
95
  (void)a;
 
96
}
 
97
         ]],[[
 
98
foo(0);
 
99
         ]])],
 
100
         [ac_cv_safe_to_use_wconversion_=yes],
 
101
         [ac_cv_safe_to_use_wconversion_=no])
 
102
       CFLAGS="$save_CFLAGS"])
 
103
 
 
104
    AS_IF([test "$ac_cv_safe_to_use_wconversion_" = "yes"],
 
105
      [W_CONVERSION="-Wconversion"
 
106
      AC_CACHE_CHECK([whether it is safe to use -Wconversion with htons],
 
107
        [ac_cv_safe_to_use_Wconversion_],
 
108
        [save_CFLAGS="$CFLAGS"
 
109
         dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
 
110
         dnl conversion warnings to all the tarball folks
 
111
         CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS}"
 
112
         AC_COMPILE_IFELSE(
 
113
           [AC_LANG_PROGRAM(
 
114
             [[
 
115
#include <netinet/in.h>
 
116
             ]],[[
 
117
uint16_t x= htons(80);
 
118
             ]])],
 
119
           [ac_cv_safe_to_use_Wconversion_=yes],
 
120
           [ac_cv_safe_to_use_Wconversion_=no])
 
121
         CFLAGS="$save_CFLAGS"])
 
122
 
 
123
      AS_IF([test "$ac_cv_safe_to_use_Wconversion_" = "no"],
 
124
            [NO_CONVERSION="-Wno-conversion"])
 
125
    ])
 
126
 
 
127
    NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing"
 
128
    NO_SHADOW="-Wno-shadow"
 
129
 
 
130
    m4_if(PW_LESS_WARNINGS,[no],[
 
131
      BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing"
 
132
      CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings"
 
133
      CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast"
 
134
    ],[
 
135
      BASE_WARNINGS_FULL="-Wformat ${NO_STRICT_ALIASING}"
 
136
    ])
 
137
 
 
138
    BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wextra -Wundef -Wshadow ${F_DIAGNOSTICS_SHOW_OPTION} ${CFLAG_VISIBILITY} ${BASE_WARNINGS_FULL}"
 
139
    CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align ${CC_WARNINGS_FULL}"
 
140
    CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long ${CXX_WARNINGS_FULL}"
 
141
 
 
142
    AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++],
 
143
      [ac_cv_safe_to_use_Wmissing_declarations_],
 
144
      [AC_LANG_PUSH(C++)
 
145
       save_CXXFLAGS="$CXXFLAGS"
 
146
       CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}"
 
147
       AC_COMPILE_IFELSE([
 
148
         AC_LANG_PROGRAM(
 
149
         [[
 
150
#include <stdio.h>
 
151
         ]], [[]])
 
152
      ],
 
153
      [ac_cv_safe_to_use_Wmissing_declarations_=yes],
 
154
      [ac_cv_safe_to_use_Wmissing_declarations_=no])
 
155
      CXXFLAGS="$save_CXXFLAGS"
 
156
      AC_LANG_POP()
 
157
    ])
 
158
    AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"],
 
159
          [CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"])
 
160
 
 
161
    AC_CACHE_CHECK([whether it is safe to use -Wlogical-op],
 
162
      [ac_cv_safe_to_use_Wlogical_op_],
 
163
      [save_CFLAGS="$CFLAGS"
 
164
       CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS}"
 
165
       AC_COMPILE_IFELSE([
 
166
         AC_LANG_PROGRAM(
 
167
         [[
 
168
#include <stdio.h>
 
169
         ]], [[]])
 
170
      ],
 
171
      [ac_cv_safe_to_use_Wlogical_op_=yes],
 
172
      [ac_cv_safe_to_use_Wlogical_op_=no])
 
173
    CFLAGS="$save_CFLAGS"])
 
174
    AS_IF([test "$ac_cv_safe_to_use_Wlogical_op_" = "yes"],
 
175
          [CC_WARNINGS="${CC_WARNINGS} -Wlogical-op"])
 
176
 
 
177
    AC_CACHE_CHECK([whether it is safe to use -Wredundant-decls from C++],
 
178
      [ac_cv_safe_to_use_Wredundant_decls_],
 
179
      [AC_LANG_PUSH(C++)
 
180
       save_CXXFLAGS="${CXXFLAGS}"
 
181
       CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}"
 
182
       AC_COMPILE_IFELSE(
 
183
         [AC_LANG_PROGRAM([
 
184
template <typename E> struct C { void foo(); };
 
185
template <typename E> void C<E>::foo() { }
 
186
template <> void C<int>::foo();
 
187
          AC_INCLUDES_DEFAULT])],
 
188
          [ac_cv_safe_to_use_Wredundant_decls_=yes],
 
189
          [ac_cv_safe_to_use_Wredundant_decls_=no])
 
190
        CXXFLAGS="${save_CXXFLAGS}"
 
191
        AC_LANG_POP()])
 
192
    AS_IF([test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"],
 
193
          [CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls"],
 
194
          [CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls"])
 
195
 
 
196
    NO_REDUNDANT_DECLS="-Wno-redundant-decls"
 
197
    PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow"
 
198
    
 
199
  ])
 
200
 
 
201
  AS_IF([test "$SUNCC" = "yes"],[
 
202
 
 
203
    AS_IF([test "$ac_profiling" = "yes"],
 
204
          [CC_PROFILING="-xinstrument=datarace"])
 
205
 
 
206
    AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],
 
207
          [W_FAIL="-errwarn=%all"])
 
208
 
 
209
    AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable],
 
210
      [ac_cv_paste_result],
 
211
      [
 
212
        save_CFLAGS="${CFLAGS}"
 
213
        CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}"
 
214
        AC_COMPILE_IFELSE(
 
215
          [AC_LANG_PROGRAM([
 
216
            AC_INCLUDES_DEFAULT
 
217
          ],[
 
218
            int x= 0;])],
 
219
          [ac_cv_paste_result=yes],
 
220
          [ac_cv_paste_result=no])
 
221
        CFLAGS="${save_CFLAGS}"
 
222
      ])
 
223
    AS_IF([test $ac_cv_paste_result = yes],
 
224
      [W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"])
 
225
 
 
226
 
 
227
    m4_if(PW_LESS_WARNINGS, [no],[
 
228
      CC_WARNINGS_FULL="-erroff=E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}"
 
229
    ],[
 
230
      CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR"
 
231
      CXX_WARNINGS_FULL="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint"
 
232
    ])
 
233
 
 
234
    CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL}"
 
235
    CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL}"
 
236
    PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn"
 
237
    NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED"
 
238
 
 
239
  ])
 
240
 
 
241
  AC_SUBST(NO_CONVERSION)
 
242
  AC_SUBST(NO_REDUNDANT_DECLS)
 
243
  AC_SUBST(NO_UNREACHED)
 
244
  AC_SUBST(NO_SHADOW)
 
245
  AC_SUBST(NO_STRICT_ALIASING)
 
246
  AC_SUBST(PROTOSKIP_WARNINGS)
 
247
 
 
248
])