1
dnl Copyright (C) 2009 Sun Microsystems, Inc.
2
dnl This file is free software; Sun Microsystems, Inc.
3
dnl gives unlimited permission to copy and/or distribute it,
4
dnl with or without modifications, as long as this notice is preserved.
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
10
dnl @TODO: remove less-warnings option as soon as Drizzle is clean enough to
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],[$*],[
21
m4_undefine([PW_LESS_WARNINGS])
22
m4_define([PW_LESS_WARNINGS],[yes])
24
[warnings-always-on],[
25
m4_undefine([PW_WARN_ALWAYS_ON])
26
m4_define([PW_WARN_ALWAYS_ON],[yes])
30
m4_if(PW_WARN_ALWAYS_ON, [yes],
31
[ac_cv_warnings_as_errors=yes],
32
AS_IF([test "$pandora_building_from_vc" = "yes"],
33
[ac_cv_warnings_as_errors=yes],
34
[ac_cv_warnings_as_errors=no]))
36
AC_ARG_ENABLE([gcc-profile-mode],
37
[AS_HELP_STRING([--enable-gcc-profile-mode],
38
[Toggle gcc profile mode @<:@default=off@:>@])],
39
[ac_gcc_profile_mode="$enableval"],
40
[ac_gcc_profile_mode="no"])
42
AC_ARG_ENABLE([profiling],
43
[AS_HELP_STRING([--enable-profiling],
44
[Toggle profiling @<:@default=off@:>@])],
45
[ac_profiling="$enableval"],
48
AC_ARG_ENABLE([coverage],
49
[AS_HELP_STRING([--enable-coverage],
50
[Toggle coverage @<:@default=off@:>@])],
51
[ac_coverage="$enableval"],
54
AS_IF([test "$GCC" = "yes"],[
56
AS_IF([test "$ac_profiling" = "yes"],[
58
GCOV_LIBS="-pg -lgcov"
61
AC_CHECK_LIB(c_p, read)
69
AS_IF([test "$ac_coverage" = "yes"],
71
CC_COVERAGE="--coverage"
77
AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],[
79
SPHINX_WARNINGS="-W -n"
80
INTLTOOL_WARNINGS="yes"
83
AC_CACHE_CHECK([whether it is safe to use -fdiagnostics-show-option],
84
[ac_cv_safe_to_use_fdiagnostics_show_option_],
85
[save_CFLAGS="$CFLAGS"
86
CFLAGS="-fdiagnostics-show-option ${AM_CFLAGS} ${CFLAGS}"
88
[AC_LANG_PROGRAM([],[])],
89
[ac_cv_safe_to_use_fdiagnostics_show_option_=yes],
90
[ac_cv_safe_to_use_fdiagnostics_show_option_=no])
91
CFLAGS="$save_CFLAGS"])
93
AS_IF([test "$ac_cv_safe_to_use_fdiagnostics_show_option_" = "yes"],
95
F_DIAGNOSTICS_SHOW_OPTION="-fdiagnostics-show-option"
98
AC_CACHE_CHECK([whether it is safe to use -floop-parallelize-all],
99
[ac_cv_safe_to_use_floop_parallelize_all_],
100
[save_CFLAGS="$CFLAGS"
101
CFLAGS="-Werror -floop-parallelize-all ${AM_CFLAGS} ${CFLAGS}"
103
[AC_LANG_PROGRAM([],[])],
104
[ac_cv_safe_to_use_floop_parallelize_all_=yes],
105
[ac_cv_safe_to_use_floop_parallelize_all_=no])
106
CFLAGS="$save_CFLAGS"])
108
AS_IF([test "$ac_cv_safe_to_use_floop_parallelize_all_" = "yes"],
110
F_LOOP_PARALLELIZE_ALL="-floop-parallelize-all"
113
NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing"
114
NO_SHADOW="-Wno-shadow"
116
AS_IF([test "$INTELCC" = "yes"],[
117
m4_if(PW_LESS_WARNINGS,[no],[
118
BASE_WARNINGS="-w1 -Werror -Wcheck -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 188"
120
dnl 2203 is like old-style-cast
121
dnl 1684 is like strict-aliasing
122
dnl 188 is about using enums as bitfields
123
dnl 1683 is a warning about _EXPLICIT_ casting, which we want
124
BASE_WARNINGS="-w1 -Werror -Wcheck -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 188,981,2259,2203,1683,1684"
126
CC_WARNINGS="${BASE_WARNINGS}"
127
CXX_WARNINGS="${BASE_WARNINGS}"
128
PROTOSKIP_WARNINGS="-diag-disable 188,981,967,2259,1683,1684,2203"
131
m4_if(PW_LESS_WARNINGS,[no],[
132
BASE_WARNINGS_FULL="${W_CONVERSION} -Wstrict-aliasing -Wswitch-enum "
133
CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings"
135
NO_OLD_STYLE_CAST="-Wno-old-style-cast"
136
NO_EFF_CXX="-Wno-effc++"
138
BASE_WARNINGS_FULL="${NO_STRICT_ALIASING}"
141
AS_IF([test "${ac_cv_assert}" = "no"],
142
[NO_UNUSED="-Wno-unused-variable -Wno-unused-parameter"])
144
AC_CACHE_CHECK([whether it is safe to use -Wextra],
145
[ac_cv_safe_to_use_Wextra_],
146
[save_CFLAGS="$CFLAGS"
147
CFLAGS="${W_FAIL} -pedantic -Wextra ${AM_CFLAGS} ${CFLAGS}"
154
[ac_cv_safe_to_use_Wextra_=yes],
155
[ac_cv_safe_to_use_Wextra_=no])
156
CFLAGS="$save_CFLAGS"])
158
BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow -Wparentheses ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${F_LOOP_PARALLELIZE_ALL} ${BASE_WARNINGS_FULL}"
159
AS_IF([test "$ac_cv_safe_to_use_Wextra_" = "yes"],
160
[BASE_WARNINGS="${BASE_WARNINGS} -Wextra"],
161
[BASE_WARNINGS="${BASE_WARNINGS} -W"])
163
AC_CACHE_CHECK([whether it is safe to use -Wformat],
164
[ac_cv_safe_to_use_wformat_],
165
[save_CFLAGS="$CFLAGS"
166
dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
167
dnl conversion warnings to all the tarball folks
168
CFLAGS="-Wformat -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
173
#include <inttypes.h>
178
printf("This is a %" PRIu64 "test\n", test_u);
183
[ac_cv_safe_to_use_wformat_=yes],
184
[ac_cv_safe_to_use_wformat_=no])
185
CFLAGS="$save_CFLAGS"])
186
AS_IF([test "$ac_cv_safe_to_use_wformat_" = "yes"],[
187
BASE_WARNINGS="${BASE_WARNINGS} -Wformat -Wno-format-nonliteral -Wformat-security"
188
BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wformat=2 -Wno-format-nonliteral -Wformat-security"
190
BASE_WARNINGS="${BASE_WARNINGS} -Wno-format"
191
BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wno-format"
196
AC_CACHE_CHECK([whether it is safe to use -Wconversion],
197
[ac_cv_safe_to_use_wconversion_],
198
[save_CFLAGS="$CFLAGS"
199
dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
200
dnl conversion warnings to all the tarball folks
201
CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
212
[ac_cv_safe_to_use_wconversion_=yes],
213
[ac_cv_safe_to_use_wconversion_=no])
214
CFLAGS="$save_CFLAGS"])
216
AS_IF([test "$ac_cv_safe_to_use_wconversion_" = "yes"],
217
[W_CONVERSION="-Wconversion"
218
AC_CACHE_CHECK([whether it is safe to use -Wconversion with htons],
219
[ac_cv_safe_to_use_Wconversion_],
220
[save_CFLAGS="$CFLAGS"
221
dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
222
dnl conversion warnings to all the tarball folks
223
CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
227
#include <netinet/in.h>
229
uint16_t x= htons(80);
231
[ac_cv_safe_to_use_Wconversion_=yes],
232
[ac_cv_safe_to_use_Wconversion_=no])
233
CFLAGS="$save_CFLAGS"])
235
AS_IF([test "$ac_cv_safe_to_use_Wconversion_" = "no"],
236
[NO_CONVERSION="-Wno-conversion"])
239
CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align -Wsign-compare ${CC_WARNINGS_FULL}"
240
CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long -Wsign-compare ${CXX_WARNINGS_FULL}"
242
AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++],
243
[ac_cv_safe_to_use_Wmissing_declarations_],
245
save_CXXFLAGS="$CXXFLAGS"
246
CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}"
253
[ac_cv_safe_to_use_Wmissing_declarations_=yes],
254
[ac_cv_safe_to_use_Wmissing_declarations_=no])
255
CXXFLAGS="$save_CXXFLAGS"
258
AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"],
259
[CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"])
261
AC_CACHE_CHECK([whether it is safe to use -Wframe-larger-than],
262
[ac_cv_safe_to_use_Wframe_larger_than_],
264
save_CXXFLAGS="$CXXFLAGS"
265
CXXFLAGS="-Werror -pedantic -Wframe-larger-than=32768 ${AM_CXXFLAGS}"
272
[ac_cv_safe_to_use_Wframe_larger_than_=yes],
273
[ac_cv_safe_to_use_Wframe_larger_than_=no])
274
CXXFLAGS="$save_CXXFLAGS"
277
AS_IF([test "$ac_cv_safe_to_use_Wframe_larger_than_" = "yes"],
278
[CXX_WARNINGS="${CXX_WARNINGS} -Wframe-larger-than=32768"])
280
AC_CACHE_CHECK([whether it is safe to use -Wredundant-decls from C++],
281
[ac_cv_safe_to_use_Wredundant_decls_],
283
save_CXXFLAGS="${CXXFLAGS}"
284
CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}"
287
template <typename E> struct C { void foo(); };
288
template <typename E> void C<E>::foo() { }
289
template <> void C<int>::foo();
290
AC_INCLUDES_DEFAULT])],
291
[ac_cv_safe_to_use_Wredundant_decls_=yes],
292
[ac_cv_safe_to_use_Wredundant_decls_=no])
293
CXXFLAGS="${save_CXXFLAGS}"
295
AS_IF([test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"],
296
[CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls"],
297
[CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls"])
299
AC_CACHE_CHECK([whether it is safe to use -Wattributes from C++],
300
[ac_cv_safe_to_use_Wattributes_],
302
save_CXXFLAGS="${CXXFLAGS}"
303
CXXFLAGS="${W_FAIL} -pedantic -Wattributes -fvisibility=hidden ${AM_CXXFLAGS}"
306
#include <google/protobuf/message.h>
307
#include <google/protobuf/descriptor.h>
310
const ::google::protobuf::EnumDescriptor* Table_TableOptions_RowType_descriptor();
311
enum Table_TableOptions_RowType {
312
Table_TableOptions_RowType_ROW_TYPE_DEFAULT = 0,
313
Table_TableOptions_RowType_ROW_TYPE_FIXED = 1,
314
Table_TableOptions_RowType_ROW_TYPE_DYNAMIC = 2,
315
Table_TableOptions_RowType_ROW_TYPE_COMPRESSED = 3,
316
Table_TableOptions_RowType_ROW_TYPE_REDUNDANT = 4,
317
Table_TableOptions_RowType_ROW_TYPE_COMPACT = 5,
318
Table_TableOptions_RowType_ROW_TYPE_PAGE = 6
324
inline const EnumDescriptor* GetEnumDescriptor<Table_TableOptions_RowType>() {
325
return Table_TableOptions_RowType_descriptor();
330
[ac_cv_safe_to_use_Wattributes_=yes],
331
[ac_cv_safe_to_use_Wattributes_=no])
332
CXXFLAGS="${save_CXXFLAGS}"
334
AC_CACHE_CHECK([whether it is safe to use -Wno-attributes],
335
[ac_cv_safe_to_use_Wno_attributes_],
336
[save_CFLAGS="$CFLAGS"
337
CFLAGS="${W_FAIL} -pedantic -Wno_attributes_ ${AM_CFLAGS} ${CFLAGS}"
344
[ac_cv_safe_to_use_Wno_attributes_=yes],
345
[ac_cv_safe_to_use_Wno_attributes_=no])
346
CFLAGS="$save_CFLAGS"])
348
dnl GCC 3.4 doesn't have -Wno-attributes, so we can't turn them off
350
AS_IF([test "$ac_cv_safe_to_use_Wattributes_" != "yes"],[
351
AS_IF([test "$ac_cv_safe_to_use_Wno_attributes_" = "yes"],[
352
CC_WARNINGS="${CC_WARNINGS} -Wno-attributes"
353
NO_ATTRIBUTES="-Wno-attributes"])])
356
NO_REDUNDANT_DECLS="-Wno-redundant-decls"
357
dnl TODO: Figure out a better way to deal with this:
358
PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}"
359
NO_WERROR="-Wno-error"
360
PERMISSIVE_WARNINGS="-Wno-error -Wno-unused-function -fpermissive"
361
PERMISSIVE_C_WARNINGS="-Wno-error -Wno-redundant-decls"
362
AS_IF([test "$host_vendor" = "apple"],[
363
BOOSTSKIP_WARNINGS="-Wno-uninitialized"
368
AS_IF([test "$SUNCC" = "yes"],[
370
AS_IF([test "$ac_profiling" = "yes"],
371
[CC_PROFILING="-xinstrument=datarace"])
373
AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],
374
[W_FAIL="-errwarn=%all"])
376
AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable],
377
[ac_cv_paste_result],
379
save_CFLAGS="${CFLAGS}"
380
CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}"
386
[ac_cv_paste_result=yes],
387
[ac_cv_paste_result=no])
388
CFLAGS="${save_CFLAGS}"
390
AS_IF([test $ac_cv_paste_result = yes],
391
[W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"])
394
m4_if(PW_LESS_WARNINGS, [no],[
395
CC_WARNINGS_FULL="-erroff=E_STATEMENT_NOT_REACHED,E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}"
396
CXX_WARNINGS_FULL="-erroff=inllargeuse"
398
CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR,E_STATEMENT_NOT_REACHED"
399
CXX_WARNINGS_FULL="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint"
402
CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL}"
403
CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL}"
404
PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit"
405
BOOSTSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem"
406
PERMISSIVE_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem,notused,badargtype2w,wunreachable"
407
INNOBASE_SKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit,wunreachable"
408
NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED"
409
NO_WERROR="-errwarn=%none"
413
AC_SUBST(NO_CONVERSION)
414
AC_SUBST(NO_REDUNDANT_DECLS)
415
AC_SUBST(NO_UNREACHED)
417
AC_SUBST(NO_STRICT_ALIASING)
419
AC_SUBST(NO_OLD_STYLE_CAST)
420
AC_SUBST(PROTOSKIP_WARNINGS)
421
AC_SUBST(INNOBASE_SKIP_WARNINGS)
422
AC_SUBST(BOOSTSKIP_WARNINGS)
423
AC_SUBST(PERMISSIVE_WARNINGS)
424
AC_SUBST(PERMISSIVE_C_WARNINGS)
426
AC_SUBST([GCOV_LIBS])
427
AC_SUBST([SPHINX_WARNINGS])
428
AC_SUBST([INTLTOOL_WARNINGS])