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