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"],[
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="-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 ${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 -Wlogical-op],
281 [ac_cv_safe_to_use_Wlogical_op_],
282 [save_CFLAGS="$CFLAGS"
283 CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS} ${CFLAGS}"
290 [ac_cv_safe_to_use_Wlogical_op_=yes],
291 [ac_cv_safe_to_use_Wlogical_op_=no])
292 CFLAGS="$save_CFLAGS"])
293 AS_IF([test "$ac_cv_safe_to_use_Wlogical_op_" = "yes"],
294 [CC_WARNINGS="${CC_WARNINGS} -Wlogical-op"])
296 AC_CACHE_CHECK([whether it is safe to use -Wredundant-decls from C++],
297 [ac_cv_safe_to_use_Wredundant_decls_],
299 save_CXXFLAGS="${CXXFLAGS}"
300 CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}"
303 template <typename E> struct C { void foo(); };
304 template <typename E> void C<E>::foo() { }
305 template <> void C<int>::foo();
306 AC_INCLUDES_DEFAULT])],
307 [ac_cv_safe_to_use_Wredundant_decls_=yes],
308 [ac_cv_safe_to_use_Wredundant_decls_=no])
309 CXXFLAGS="${save_CXXFLAGS}"
311 AS_IF([test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"],
312 [CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls"],
313 [CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls"])
315 AC_CACHE_CHECK([whether it is safe to use -Wattributes from C++],
316 [ac_cv_safe_to_use_Wattributes_],
318 save_CXXFLAGS="${CXXFLAGS}"
319 CXXFLAGS="${W_FAIL} -pedantic -Wattributes -fvisibility=hidden ${AM_CXXFLAGS}"
322 #include <google/protobuf/message.h>
323 #include <google/protobuf/descriptor.h>
326 const ::google::protobuf::EnumDescriptor* Table_TableOptions_RowType_descriptor();
327 enum Table_TableOptions_RowType {
328 Table_TableOptions_RowType_ROW_TYPE_DEFAULT = 0,
329 Table_TableOptions_RowType_ROW_TYPE_FIXED = 1,
330 Table_TableOptions_RowType_ROW_TYPE_DYNAMIC = 2,
331 Table_TableOptions_RowType_ROW_TYPE_COMPRESSED = 3,
332 Table_TableOptions_RowType_ROW_TYPE_REDUNDANT = 4,
333 Table_TableOptions_RowType_ROW_TYPE_COMPACT = 5,
334 Table_TableOptions_RowType_ROW_TYPE_PAGE = 6
340 inline const EnumDescriptor* GetEnumDescriptor<Table_TableOptions_RowType>() {
341 return Table_TableOptions_RowType_descriptor();
346 [ac_cv_safe_to_use_Wattributes_=yes],
347 [ac_cv_safe_to_use_Wattributes_=no])
348 CXXFLAGS="${save_CXXFLAGS}"
350 AC_CACHE_CHECK([whether it is safe to use -Wno-attributes],
351 [ac_cv_safe_to_use_Wno_attributes_],
352 [save_CFLAGS="$CFLAGS"
353 CFLAGS="${W_FAIL} -pedantic -Wno_attributes_ ${AM_CFLAGS} ${CFLAGS}"
360 [ac_cv_safe_to_use_Wno_attributes_=yes],
361 [ac_cv_safe_to_use_Wno_attributes_=no])
362 CFLAGS="$save_CFLAGS"])
364 dnl GCC 3.4 doesn't have -Wno-attributes, so we can't turn them off
366 AS_IF([test "$ac_cv_safe_to_use_Wattributes_" != "yes"],[
367 AS_IF([test "$ac_cv_safe_to_use_Wno_attributes_" = "yes"],[
368 CC_WARNINGS="${CC_WARNINGS} -Wno-attributes"
369 NO_ATTRIBUTES="-Wno-attributes"])])
372 NO_REDUNDANT_DECLS="-Wno-redundant-decls"
373 dnl TODO: Figure out a better way to deal with this:
374 PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}"
375 NO_WERROR="-Wno-error"
376 PERMISSIVE_WARNINGS="-Wno-error -Wno-unused-function -fpermissive"
377 PERMISSIVE_C_WARNINGS="-Wno-error -Wno-redundant-decls"
378 AS_IF([test "$host_vendor" = "apple"],[
379 BOOSTSKIP_WARNINGS="-Wno-uninitialized"
384 AS_IF([test "$SUNCC" = "yes"],[
386 AS_IF([test "$ac_profiling" = "yes"],
387 [CC_PROFILING="-xinstrument=datarace"])
389 AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],
390 [W_FAIL="-errwarn=%all"])
392 AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable],
393 [ac_cv_paste_result],
395 save_CFLAGS="${CFLAGS}"
396 CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}"
402 [ac_cv_paste_result=yes],
403 [ac_cv_paste_result=no])
404 CFLAGS="${save_CFLAGS}"
406 AS_IF([test $ac_cv_paste_result = yes],
407 [W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"])
410 m4_if(PW_LESS_WARNINGS, [no],[
411 CC_WARNINGS_FULL="-erroff=E_STATEMENT_NOT_REACHED,E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}"
412 CXX_WARNINGS_FULL="-erroff=inllargeuse"
414 CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR,E_STATEMENT_NOT_REACHED"
415 CXX_WARNINGS_FULL="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint"
418 CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL}"
419 CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL}"
420 PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit"
421 BOOSTSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem"
422 PERMISSIVE_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint,hidef,wvarhidenmem,notused,badargtype2w,wunreachable"
423 INNOBASE_SKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit,wunreachable"
424 NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED"
425 NO_WERROR="-errwarn=%none"
429 AC_SUBST(NO_CONVERSION)
430 AC_SUBST(NO_REDUNDANT_DECLS)
431 AC_SUBST(NO_UNREACHED)
433 AC_SUBST(NO_STRICT_ALIASING)
435 AC_SUBST(NO_OLD_STYLE_CAST)
436 AC_SUBST(PROTOSKIP_WARNINGS)
437 AC_SUBST(INNOBASE_SKIP_WARNINGS)
438 AC_SUBST(BOOSTSKIP_WARNINGS)
439 AC_SUBST(PERMISSIVE_WARNINGS)
440 AC_SUBST(PERMISSIVE_C_WARNINGS)
442 AC_SUBST([GCOV_LIBS])
443 AC_SUBST([SPHINX_WARNINGS])
444 AC_SUBST([INTLTOOL_WARNINGS])