~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/pandora_warnings.m4

  • Committer: Monty Taylor
  • Date: 2008-10-23 00:05:28 UTC
  • Revision ID: monty@inaugust.com-20081023000528-grdvrd8c4058nutm
Moved my_handler to myisam, which is where it actually belongs.

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 "$pandora_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
 
      GCOV_LIBS="-pg -lgcov"
54
 
      save_LIBS="${LIBS}"
55
 
      LIBS=""
56
 
      AC_CHECK_LIB(c_p, read)
57
 
      LIBC_P="${LIBS}"
58
 
      LIBS="${save_LIBS}"
59
 
      AC_SUBST(LIBC_P)
60
 
    ],[
61
 
      CC_PROFILING=" "
62
 
    ])
63
 
 
64
 
    AS_IF([test "$ac_coverage" = "yes"],
65
 
          [
66
 
            CC_COVERAGE="--coverage"
67
 
            GCOV_LIBS="-lgcov"
68
 
          ])
69
 
 
70
 
 
71
 
         
72
 
    AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],
73
 
          [W_FAIL="-Werror"])
74
 
 
75
 
    AC_CACHE_CHECK([whether it is safe to use -fdiagnostics-show-option],
76
 
      [ac_cv_safe_to_use_fdiagnostics_show_option_],
77
 
      [save_CFLAGS="$CFLAGS"
78
 
       CFLAGS="-fdiagnostics-show-option ${AM_CFLAGS} ${CFLAGS}"
79
 
       AC_COMPILE_IFELSE(
80
 
         [AC_LANG_PROGRAM([],[])],
81
 
         [ac_cv_safe_to_use_fdiagnostics_show_option_=yes],
82
 
         [ac_cv_safe_to_use_fdiagnostics_show_option_=no])
83
 
       CFLAGS="$save_CFLAGS"])
84
 
 
85
 
    AS_IF([test "$ac_cv_safe_to_use_fdiagnostics_show_option_" = "yes"],
86
 
          [
87
 
            F_DIAGNOSTICS_SHOW_OPTION="-fdiagnostics-show-option"
88
 
          ])
89
 
 
90
 
    AC_CACHE_CHECK([whether it is safe to use -Wformat],
91
 
      [ac_cv_safe_to_use_wformat_],
92
 
      [save_CFLAGS="$CFLAGS"
93
 
       dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
94
 
       dnl conversion warnings to all the tarball folks
95
 
       CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
96
 
       AC_COMPILE_IFELSE(
97
 
         [AC_LANG_PROGRAM([[
98
 
#include <stdio.h>
99
 
#include <stdint.h>
100
 
#include <inttypes.h>
101
 
void foo(bool a)
102
 
{
103
 
  uint64_t test_u= 0;
104
 
  printf("This is a %" PRIu64 "test\n", test_u);
105
 
}
106
 
         ]],[[
107
 
foo(0);
108
 
         ]])],
109
 
         [ac_cv_safe_to_use_wformat_=yes],
110
 
         [ac_cv_safe_to_use_wformat_=no])
111
 
       CFLAGS="$save_CFLAGS"])
112
 
    AS_IF([test "$ac_cv_safe_to_use_wformat_" = "yes"],[
113
 
      W_FORMAT="-Wformat"
114
 
      W_FORMAT_2="-Wformat=2"
115
 
      NO_FORMAT="-Wno-format"
116
 
      ],[
117
 
      W_FORMAT="-Wno-format"
118
 
      W_FORMAT_2="-Wno-format"
119
 
      NO_FORMAT="-Wno-format"
120
 
    ])
121
 
 
122
 
 
123
 
 
124
 
    AC_CACHE_CHECK([whether it is safe to use -Wconversion],
125
 
      [ac_cv_safe_to_use_wconversion_],
126
 
      [save_CFLAGS="$CFLAGS"
127
 
       dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
128
 
       dnl conversion warnings to all the tarball folks
129
 
       CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
130
 
       AC_COMPILE_IFELSE(
131
 
         [AC_LANG_PROGRAM([[
132
 
#include <stdbool.h>
133
 
void foo(bool a)
134
 
{
135
 
  (void)a;
136
 
}
137
 
         ]],[[
138
 
foo(0);
139
 
         ]])],
140
 
         [ac_cv_safe_to_use_wconversion_=yes],
141
 
         [ac_cv_safe_to_use_wconversion_=no])
142
 
       CFLAGS="$save_CFLAGS"])
143
 
 
144
 
    AS_IF([test "$ac_cv_safe_to_use_wconversion_" = "yes"],
145
 
      [W_CONVERSION="-Wconversion"
146
 
      AC_CACHE_CHECK([whether it is safe to use -Wconversion with htons],
147
 
        [ac_cv_safe_to_use_Wconversion_],
148
 
        [save_CFLAGS="$CFLAGS"
149
 
         dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
150
 
         dnl conversion warnings to all the tarball folks
151
 
         CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
152
 
         AC_COMPILE_IFELSE(
153
 
           [AC_LANG_PROGRAM(
154
 
             [[
155
 
#include <netinet/in.h>
156
 
             ]],[[
157
 
uint16_t x= htons(80);
158
 
             ]])],
159
 
           [ac_cv_safe_to_use_Wconversion_=yes],
160
 
           [ac_cv_safe_to_use_Wconversion_=no])
161
 
         CFLAGS="$save_CFLAGS"])
162
 
 
163
 
      AS_IF([test "$ac_cv_safe_to_use_Wconversion_" = "no"],
164
 
            [NO_CONVERSION="-Wno-conversion"])
165
 
    ])
166
 
 
167
 
    NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing"
168
 
    NO_SHADOW="-Wno-shadow"
169
 
 
170
 
    AS_IF([test "$INTELCC" = "yes"],[
171
 
      m4_if(PW_LESS_WARNINGS,[no],[
172
 
        BASE_WARNINGS="-w1 -Werror -Wcheck ${W_FORMAT} -Wp64 -Woverloaded-virtual -Wcast-qual"
173
 
      ],[
174
 
        BASE_WARNINGS="-w1 -Wcheck ${W_FORMAT} -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 981"
175
 
      ])
176
 
      CC_WARNINGS="${BASE_WARNINGS}"
177
 
      CXX_WARNINGS="${BASE_WARNINGS}"
178
 
    ],[
179
 
      m4_if(PW_LESS_WARNINGS,[no],[
180
 
        BASE_WARNINGS_FULL="${W_FORMAT_2} ${W_CONVERSION} -Wstrict-aliasing"
181
 
        CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings"
182
 
        CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast"
183
 
        NO_OLD_STYLE_CAST="-Wno-old-style-cast"
184
 
        NO_EFF_CXX="-Wno-effc++"
185
 
      ],[
186
 
        BASE_WARNINGS_FULL="${W_FORMAT_2} ${NO_STRICT_ALIASING}"
187
 
      ])
188
 
 
189
 
      AS_IF([test "${ac_cv_assert}" = "no"],
190
 
            [NO_UNUSED="-Wno-unused-variable -Wno-unused-parameter"])
191
 
  
192
 
      AC_CACHE_CHECK([whether it is safe to use -Wextra],
193
 
        [ac_cv_safe_to_use_Wextra_],
194
 
        [save_CFLAGS="$CFLAGS"
195
 
         CFLAGS="${W_FAIL} -pedantic -Wextra ${AM_CFLAGS} ${CFLAGS}"
196
 
         AC_COMPILE_IFELSE([
197
 
           AC_LANG_PROGRAM(
198
 
           [[
199
 
#include <stdio.h>
200
 
           ]], [[]])
201
 
        ],
202
 
        [ac_cv_safe_to_use_Wextra_=yes],
203
 
        [ac_cv_safe_to_use_Wextra_=no])
204
 
      CFLAGS="$save_CFLAGS"])
205
 
 
206
 
      BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${BASE_WARNINGS_FULL}"
207
 
      AS_IF([test "$ac_cv_safe_to_use_Wextra_" = "yes"],
208
 
            [BASE_WARNINGS="${BASE_WARNINGS} -Wextra"],
209
 
            [BASE_WARNINGS="${BASE_WARNINGS} -W"])
210
 
  
211
 
      CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align ${CC_WARNINGS_FULL}"
212
 
      CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long ${CXX_WARNINGS_FULL}"
213
 
 
214
 
      AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++],
215
 
        [ac_cv_safe_to_use_Wmissing_declarations_],
216
 
        [AC_LANG_PUSH(C++)
217
 
         save_CXXFLAGS="$CXXFLAGS"
218
 
         CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}"
219
 
         AC_COMPILE_IFELSE([
220
 
           AC_LANG_PROGRAM(
221
 
           [[
222
 
#include <stdio.h>
223
 
           ]], [[]])
224
 
        ],
225
 
        [ac_cv_safe_to_use_Wmissing_declarations_=yes],
226
 
        [ac_cv_safe_to_use_Wmissing_declarations_=no])
227
 
        CXXFLAGS="$save_CXXFLAGS"
228
 
        AC_LANG_POP()
229
 
      ])
230
 
      AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"],
231
 
            [CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"])
232
 
  
233
 
      AC_CACHE_CHECK([whether it is safe to use -Wlogical-op],
234
 
        [ac_cv_safe_to_use_Wlogical_op_],
235
 
        [save_CFLAGS="$CFLAGS"
236
 
         CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS} ${CFLAGS}"
237
 
         AC_COMPILE_IFELSE([
238
 
           AC_LANG_PROGRAM(
239
 
           [[
240
 
#include <stdio.h>
241
 
           ]], [[]])
242
 
        ],
243
 
        [ac_cv_safe_to_use_Wlogical_op_=yes],
244
 
        [ac_cv_safe_to_use_Wlogical_op_=no])
245
 
      CFLAGS="$save_CFLAGS"])
246
 
      AS_IF([test "$ac_cv_safe_to_use_Wlogical_op_" = "yes"],
247
 
            [CC_WARNINGS="${CC_WARNINGS} -Wlogical-op"])
248
 
  
249
 
      AC_CACHE_CHECK([whether it is safe to use -Wredundant-decls from C++],
250
 
        [ac_cv_safe_to_use_Wredundant_decls_],
251
 
        [AC_LANG_PUSH(C++)
252
 
         save_CXXFLAGS="${CXXFLAGS}"
253
 
         CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}"
254
 
         AC_COMPILE_IFELSE(
255
 
           [AC_LANG_PROGRAM([
256
 
template <typename E> struct C { void foo(); };
257
 
template <typename E> void C<E>::foo() { }
258
 
template <> void C<int>::foo();
259
 
            AC_INCLUDES_DEFAULT])],
260
 
            [ac_cv_safe_to_use_Wredundant_decls_=yes],
261
 
            [ac_cv_safe_to_use_Wredundant_decls_=no])
262
 
         CXXFLAGS="${save_CXXFLAGS}"
263
 
         AC_LANG_POP()])
264
 
      AS_IF([test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"],
265
 
            [CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls"],
266
 
            [CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls"])
267
 
 
268
 
      AC_CACHE_CHECK([whether it is safe to use -Wattributes from C++],
269
 
        [ac_cv_safe_to_use_Wattributes_],
270
 
        [AC_LANG_PUSH(C++)
271
 
         save_CXXFLAGS="${CXXFLAGS}"
272
 
         CXXFLAGS="${W_FAIL} -pedantic -Wattributes -fvisibility=hidden ${AM_CXXFLAGS}"
273
 
         AC_COMPILE_IFELSE(
274
 
           [AC_LANG_PROGRAM([
275
 
#include <google/protobuf/message.h>
276
 
#include <google/protobuf/descriptor.h>
277
 
 
278
 
 
279
 
const ::google::protobuf::EnumDescriptor* Table_TableOptions_RowType_descriptor();
280
 
enum Table_TableOptions_RowType {
281
 
  Table_TableOptions_RowType_ROW_TYPE_DEFAULT = 0,
282
 
  Table_TableOptions_RowType_ROW_TYPE_FIXED = 1,
283
 
  Table_TableOptions_RowType_ROW_TYPE_DYNAMIC = 2,
284
 
  Table_TableOptions_RowType_ROW_TYPE_COMPRESSED = 3,
285
 
  Table_TableOptions_RowType_ROW_TYPE_REDUNDANT = 4,
286
 
  Table_TableOptions_RowType_ROW_TYPE_COMPACT = 5,
287
 
  Table_TableOptions_RowType_ROW_TYPE_PAGE = 6
288
 
};
289
 
 
290
 
namespace google {
291
 
namespace protobuf {
292
 
template <>
293
 
inline const EnumDescriptor* GetEnumDescriptor<Table_TableOptions_RowType>() {
294
 
  return Table_TableOptions_RowType_descriptor();
295
 
}
296
 
}
297
 
}
298
 
            ])],
299
 
            [ac_cv_safe_to_use_Wattributes_=yes],
300
 
            [ac_cv_safe_to_use_Wattributes_=no])
301
 
          CXXFLAGS="${save_CXXFLAGS}"
302
 
          AC_LANG_POP()])
303
 
      AC_CACHE_CHECK([whether it is safe to use -Wno-attributes],
304
 
        [ac_cv_safe_to_use_Wno_attributes_],
305
 
        [save_CFLAGS="$CFLAGS"
306
 
         CFLAGS="${W_FAIL} -pedantic -Wno_attributes_ ${AM_CFLAGS} ${CFLAGS}"
307
 
         AC_COMPILE_IFELSE([
308
 
           AC_LANG_PROGRAM(
309
 
           [[
310
 
#include <stdio.h>
311
 
           ]], [[]])
312
 
        ],
313
 
        [ac_cv_safe_to_use_Wno_attributes_=yes],
314
 
        [ac_cv_safe_to_use_Wno_attributes_=no])
315
 
      CFLAGS="$save_CFLAGS"])
316
 
 
317
 
      dnl GCC 3.4 doesn't have -Wno-attributes, so we can't turn them off
318
 
      dnl by using that. 
319
 
      AS_IF([test "$ac_cv_safe_to_use_Wattributes_" != "yes"],[
320
 
        AS_IF([test "$ac_cv_safe_to_use_Wno_attributes_" = "yes"],[
321
 
          CC_WARNINGS="${CC_WARNINGS} -Wno-attributes"
322
 
          NO_ATTRIBUTES="-Wno-attributes"])])
323
 
  
324
 
  
325
 
      NO_REDUNDANT_DECLS="-Wno-redundant-decls"
326
 
      dnl TODO: Figure out a better way to deal with this:
327
 
      PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}"
328
 
      NO_WERROR="-Wno-error"
329
 
      INNOBASE_SKIP_WARNINGS="-Wno-shadow -Wno-cast-align"
330
 
      AS_IF([test "$host_vendor" = "apple"],[
331
 
        BOOSTSKIP_WARNINGS="-Wno-uninitialized"
332
 
      ])
333
 
    ])
334
 
  ])
335
 
 
336
 
  AS_IF([test "$SUNCC" = "yes"],[
337
 
 
338
 
    AS_IF([test "$ac_profiling" = "yes"],
339
 
          [CC_PROFILING="-xinstrument=datarace"])
340
 
 
341
 
    AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],
342
 
          [W_FAIL="-errwarn=%all"])
343
 
 
344
 
    AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable],
345
 
      [ac_cv_paste_result],
346
 
      [
347
 
        save_CFLAGS="${CFLAGS}"
348
 
        CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}"
349
 
        AC_COMPILE_IFELSE(
350
 
          [AC_LANG_PROGRAM([
351
 
            AC_INCLUDES_DEFAULT
352
 
          ],[
353
 
            int x= 0;])],
354
 
          [ac_cv_paste_result=yes],
355
 
          [ac_cv_paste_result=no])
356
 
        CFLAGS="${save_CFLAGS}"
357
 
      ])
358
 
    AS_IF([test $ac_cv_paste_result = yes],
359
 
      [W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"])
360
 
 
361
 
 
362
 
    m4_if(PW_LESS_WARNINGS, [no],[
363
 
      CC_WARNINGS_FULL="-erroff=E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}"
364
 
      CXX_WARNINGS_FULL="-erroff=inllargeuse"
365
 
    ],[
366
 
      CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR"
367
 
      CXX_WARNINGS_FULL="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint"
368
 
    ])
369
 
 
370
 
    CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL}"
371
 
    CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL}"
372
 
    PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit"
373
 
    BOOSTSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem"
374
 
    NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED"
375
 
    NO_WERROR="-errwarn=%none"
376
 
 
377
 
  ])
378
 
 
379
 
  AC_SUBST(NO_CONVERSION)
380
 
  AC_SUBST(NO_REDUNDANT_DECLS)
381
 
  AC_SUBST(NO_UNREACHED)
382
 
  AC_SUBST(NO_SHADOW)
383
 
  AC_SUBST(NO_STRICT_ALIASING)
384
 
  AC_SUBST(NO_EFF_CXX)
385
 
  AC_SUBST(NO_OLD_STYLE_CAST)
386
 
  AC_SUBST(PROTOSKIP_WARNINGS)
387
 
  AC_SUBST(BOOSTSKIP_WARNINGS)
388
 
  AC_SUBST(INNOBASE_SKIP_WARNINGS)
389
 
  AC_SUBST(NO_WERROR)
390
 
  AC_SUBST([GCOV_LIBS])
391
 
 
392
 
])