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
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]))
37
AC_ARG_ENABLE([gcc-profile-mode],
38
[AS_HELP_STRING([--enable-gcc-profile-mode],
39
[Toggle gcc profile mode @<:@default=off@:>@])],
40
[ac_gcc_profile_mode="$enableval"],
41
[ac_gcc_profile_mode="no"])
43
AC_ARG_ENABLE([profiling],
44
[AS_HELP_STRING([--enable-profiling],
45
[Toggle profiling @<:@default=off@:>@])],
46
[ac_profiling="$enableval"],
49
AC_ARG_ENABLE([coverage],
50
[AS_HELP_STRING([--enable-coverage],
51
[Toggle coverage @<:@default=off@:>@])],
52
[ac_coverage="$enableval"],
55
AS_IF([test "$GCC" = "yes"],[
57
AS_IF([test "$ac_profiling" = "yes"],[
59
GCOV_LIBS="-pg -lgcov"
62
AC_CHECK_LIB(c_p, read)
70
AS_IF([test "$ac_coverage" = "yes"],
72
CC_COVERAGE="--coverage"
78
AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],[
81
INTLTOOL_WARNINGS="yes"
84
AC_CACHE_CHECK([whether it is safe to use -fdiagnostics-show-option],
85
[ac_cv_safe_to_use_fdiagnostics_show_option_],
86
[save_CFLAGS="$CFLAGS"
87
CFLAGS="-fdiagnostics-show-option ${AM_CFLAGS} ${CFLAGS}"
89
[AC_LANG_PROGRAM([],[])],
90
[ac_cv_safe_to_use_fdiagnostics_show_option_=yes],
91
[ac_cv_safe_to_use_fdiagnostics_show_option_=no])
92
CFLAGS="$save_CFLAGS"])
94
AS_IF([test "$ac_cv_safe_to_use_fdiagnostics_show_option_" = "yes"],
96
F_DIAGNOSTICS_SHOW_OPTION="-fdiagnostics-show-option"
99
AC_CACHE_CHECK([whether it is safe to use -floop-parallelize-all],
100
[ac_cv_safe_to_use_floop_parallelize_all_],
101
[save_CFLAGS="$CFLAGS"
102
CFLAGS="-floop-parallelize-all ${AM_CFLAGS} ${CFLAGS}"
104
[AC_LANG_PROGRAM([],[])],
105
[ac_cv_safe_to_use_floop_parallelize_all_=yes],
106
[ac_cv_safe_to_use_floop_parallelize_all_=no])
107
CFLAGS="$save_CFLAGS"])
109
AS_IF([test "$ac_cv_safe_to_use_floop_parallelize_all_" = "yes"],
111
F_LOOP_PARALLELIZE_ALL="-floop-parallelize-all"
114
NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing"
115
NO_SHADOW="-Wno-shadow"
117
AS_IF([test "$INTELCC" = "yes"],[
118
m4_if(PW_LESS_WARNINGS,[no],[
119
BASE_WARNINGS="-w1 -Werror -Wcheck -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 188"
121
dnl 2203 is like old-style-cast
122
dnl 1684 is like strict-aliasing
123
dnl 188 is about using enums as bitfields
124
dnl 1683 is a warning about _EXPLICIT_ casting, which we want
125
BASE_WARNINGS="-w1 -Werror -Wcheck -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 188,981,2259,2203,1683,1684"
127
CC_WARNINGS="${BASE_WARNINGS}"
128
CXX_WARNINGS="${BASE_WARNINGS}"
129
PROTOSKIP_WARNINGS="-diag-disable 188,981,967,2259,1683,1684,2203"
132
m4_if(PW_LESS_WARNINGS,[no],[
133
BASE_WARNINGS_FULL="${W_CONVERSION} -Wstrict-aliasing"
134
CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum -Wwrite-strings"
135
CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast"
136
NO_OLD_STYLE_CAST="-Wno-old-style-cast"
137
NO_EFF_CXX="-Wno-effc++"
139
BASE_WARNINGS_FULL="${NO_STRICT_ALIASING}"
142
AS_IF([test "${ac_cv_assert}" = "no"],
143
[NO_UNUSED="-Wno-unused-variable -Wno-unused-parameter"])
145
AC_CACHE_CHECK([whether it is safe to use -Wextra],
146
[ac_cv_safe_to_use_Wextra_],
147
[save_CFLAGS="$CFLAGS"
148
CFLAGS="${W_FAIL} -pedantic -Wextra ${AM_CFLAGS} ${CFLAGS}"
155
[ac_cv_safe_to_use_Wextra_=yes],
156
[ac_cv_safe_to_use_Wextra_=no])
157
CFLAGS="$save_CFLAGS"])
159
BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${F_LOOP_PARALLELIZE_ALL} ${BASE_WARNINGS_FULL}"
160
AS_IF([test "$ac_cv_safe_to_use_Wextra_" = "yes"],
161
[BASE_WARNINGS="${BASE_WARNINGS} -Wextra"],
162
[BASE_WARNINGS="${BASE_WARNINGS} -W"])
164
AC_CACHE_CHECK([whether it is safe to use -Wformat],
165
[ac_cv_safe_to_use_wformat_],
166
[save_CFLAGS="$CFLAGS"
167
dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
168
dnl conversion warnings to all the tarball folks
169
CFLAGS="-Wformat -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
174
#include <inttypes.h>
179
printf("This is a %" PRIu64 "test\n", test_u);
184
[ac_cv_safe_to_use_wformat_=yes],
185
[ac_cv_safe_to_use_wformat_=no])
186
CFLAGS="$save_CFLAGS"])
187
AS_IF([test "$ac_cv_safe_to_use_wformat_" = "yes"],[
188
BASE_WARNINGS="${BASE_WARNINGS} -Wformat -Wno-format-nonliteral -Wno-format-security"
189
BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wformat=2 -Wno-format-nonliteral -Wno-format-security"
191
BASE_WARNINGS="${BASE_WARNINGS} -Wno-format"
192
BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wno-format"
197
AC_CACHE_CHECK([whether it is safe to use -Wconversion],
198
[ac_cv_safe_to_use_wconversion_],
199
[save_CFLAGS="$CFLAGS"
200
dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
201
dnl conversion warnings to all the tarball folks
202
CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
213
[ac_cv_safe_to_use_wconversion_=yes],
214
[ac_cv_safe_to_use_wconversion_=no])
215
CFLAGS="$save_CFLAGS"])
217
AS_IF([test "$ac_cv_safe_to_use_wconversion_" = "yes"],
218
[W_CONVERSION="-Wconversion"
219
AC_CACHE_CHECK([whether it is safe to use -Wconversion with htons],
220
[ac_cv_safe_to_use_Wconversion_],
221
[save_CFLAGS="$CFLAGS"
222
dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
223
dnl conversion warnings to all the tarball folks
224
CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
228
#include <netinet/in.h>
230
uint16_t x= htons(80);
232
[ac_cv_safe_to_use_Wconversion_=yes],
233
[ac_cv_safe_to_use_Wconversion_=no])
234
CFLAGS="$save_CFLAGS"])
236
AS_IF([test "$ac_cv_safe_to_use_Wconversion_" = "no"],
237
[NO_CONVERSION="-Wno-conversion"])
240
CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align ${CC_WARNINGS_FULL}"
241
CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long ${CXX_WARNINGS_FULL}"
243
AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++],
244
[ac_cv_safe_to_use_Wmissing_declarations_],
246
save_CXXFLAGS="$CXXFLAGS"
247
CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}"
254
[ac_cv_safe_to_use_Wmissing_declarations_=yes],
255
[ac_cv_safe_to_use_Wmissing_declarations_=no])
256
CXXFLAGS="$save_CXXFLAGS"
259
AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"],
260
[CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"])
262
AC_CACHE_CHECK([whether it is safe to use -Wframe-larger-than],
263
[ac_cv_safe_to_use_Wframe_larger_than_],
265
save_CXXFLAGS="$CXXFLAGS"
266
CXXFLAGS="-Werror -pedantic -Wframe-larger-than=32768 ${AM_CXXFLAGS}"
273
[ac_cv_safe_to_use_Wframe_larger_than_=yes],
274
[ac_cv_safe_to_use_Wframe_larger_than_=no])
275
CXXFLAGS="$save_CXXFLAGS"
278
AS_IF([test "$ac_cv_safe_to_use_Wframe_larger_than_" = "yes"],
279
[CXX_WARNINGS="${CXX_WARNINGS} -Wframe-larger-than=32768"])
281
AC_CACHE_CHECK([whether it is safe to use -Wlogical-op],
282
[ac_cv_safe_to_use_Wlogical_op_],
283
[save_CFLAGS="$CFLAGS"
284
CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS} ${CFLAGS}"
291
[ac_cv_safe_to_use_Wlogical_op_=yes],
292
[ac_cv_safe_to_use_Wlogical_op_=no])
293
CFLAGS="$save_CFLAGS"])
294
AS_IF([test "$ac_cv_safe_to_use_Wlogical_op_" = "yes"],
295
[CC_WARNINGS="${CC_WARNINGS} -Wlogical-op"])
297
AC_CACHE_CHECK([whether it is safe to use -Wredundant-decls from C++],
298
[ac_cv_safe_to_use_Wredundant_decls_],
300
save_CXXFLAGS="${CXXFLAGS}"
301
CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}"
304
template <typename E> struct C { void foo(); };
305
template <typename E> void C<E>::foo() { }
306
template <> void C<int>::foo();
307
AC_INCLUDES_DEFAULT])],
308
[ac_cv_safe_to_use_Wredundant_decls_=yes],
309
[ac_cv_safe_to_use_Wredundant_decls_=no])
310
CXXFLAGS="${save_CXXFLAGS}"
312
AS_IF([test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"],
313
[CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls"],
314
[CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls"])
316
AC_CACHE_CHECK([whether it is safe to use -Wattributes from C++],
317
[ac_cv_safe_to_use_Wattributes_],
319
save_CXXFLAGS="${CXXFLAGS}"
320
CXXFLAGS="${W_FAIL} -pedantic -Wattributes -fvisibility=hidden ${AM_CXXFLAGS}"
323
#include <google/protobuf/message.h>
324
#include <google/protobuf/descriptor.h>
327
const ::google::protobuf::EnumDescriptor* Table_TableOptions_RowType_descriptor();
328
enum Table_TableOptions_RowType {
329
Table_TableOptions_RowType_ROW_TYPE_DEFAULT = 0,
330
Table_TableOptions_RowType_ROW_TYPE_FIXED = 1,
331
Table_TableOptions_RowType_ROW_TYPE_DYNAMIC = 2,
332
Table_TableOptions_RowType_ROW_TYPE_COMPRESSED = 3,
333
Table_TableOptions_RowType_ROW_TYPE_REDUNDANT = 4,
334
Table_TableOptions_RowType_ROW_TYPE_COMPACT = 5,
335
Table_TableOptions_RowType_ROW_TYPE_PAGE = 6
341
inline const EnumDescriptor* GetEnumDescriptor<Table_TableOptions_RowType>() {
342
return Table_TableOptions_RowType_descriptor();
347
[ac_cv_safe_to_use_Wattributes_=yes],
348
[ac_cv_safe_to_use_Wattributes_=no])
349
CXXFLAGS="${save_CXXFLAGS}"
351
AC_CACHE_CHECK([whether it is safe to use -Wno-attributes],
352
[ac_cv_safe_to_use_Wno_attributes_],
353
[save_CFLAGS="$CFLAGS"
354
CFLAGS="${W_FAIL} -pedantic -Wno_attributes_ ${AM_CFLAGS} ${CFLAGS}"
361
[ac_cv_safe_to_use_Wno_attributes_=yes],
362
[ac_cv_safe_to_use_Wno_attributes_=no])
363
CFLAGS="$save_CFLAGS"])
365
dnl GCC 3.4 doesn't have -Wno-attributes, so we can't turn them off
367
AS_IF([test "$ac_cv_safe_to_use_Wattributes_" != "yes"],[
368
AS_IF([test "$ac_cv_safe_to_use_Wno_attributes_" = "yes"],[
369
CC_WARNINGS="${CC_WARNINGS} -Wno-attributes"
370
NO_ATTRIBUTES="-Wno-attributes"])])
373
NO_REDUNDANT_DECLS="-Wno-redundant-decls"
374
dnl TODO: Figure out a better way to deal with this:
375
PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}"
376
NO_WERROR="-Wno-error"
377
PERMISSIVE_WARNINGS="-Wno-error -Wno-unused-function -fpermissive"
378
PERMISSIVE_C_WARNINGS="-Wno-error -Wno-redundant-decls"
379
AS_IF([test "$host_vendor" = "apple"],[
380
BOOSTSKIP_WARNINGS="-Wno-uninitialized"
385
AS_IF([test "$SUNCC" = "yes"],[
387
AS_IF([test "$ac_profiling" = "yes"],
388
[CC_PROFILING="-xinstrument=datarace"])
390
AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],
391
[W_FAIL="-errwarn=%all"])
393
AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable],
394
[ac_cv_paste_result],
396
save_CFLAGS="${CFLAGS}"
397
CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}"
403
[ac_cv_paste_result=yes],
404
[ac_cv_paste_result=no])
405
CFLAGS="${save_CFLAGS}"
407
AS_IF([test $ac_cv_paste_result = yes],
408
[W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"])
411
m4_if(PW_LESS_WARNINGS, [no],[
412
CC_WARNINGS_FULL="-erroff=E_STATEMENT_NOT_REACHED,E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}"
413
CXX_WARNINGS_FULL="-erroff=inllargeuse"
415
CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR,E_STATEMENT_NOT_REACHED"
416
CXX_WARNINGS_FULL="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint"
419
CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL}"
420
CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL}"
421
PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit"
422
BOOSTSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem"
423
PERMISSIVE_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem,notused,badargtype2w,wunreachable"
424
INNOBASE_SKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit,wunreachable"
425
NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED"
426
NO_WERROR="-errwarn=%none"
430
AC_SUBST(NO_CONVERSION)
431
AC_SUBST(NO_REDUNDANT_DECLS)
432
AC_SUBST(NO_UNREACHED)
434
AC_SUBST(NO_STRICT_ALIASING)
436
AC_SUBST(NO_OLD_STYLE_CAST)
437
AC_SUBST(PROTOSKIP_WARNINGS)
438
AC_SUBST(INNOBASE_SKIP_WARNINGS)
439
AC_SUBST(BOOSTSKIP_WARNINGS)
440
AC_SUBST(PERMISSIVE_WARNINGS)
441
AC_SUBST(PERMISSIVE_C_WARNINGS)
443
AC_SUBST([GCOV_LIBS])
444
AC_SUBST([SPHINX_WARNINGS])
445
AC_SUBST([INTLTOOL_WARNINGS])