~drizzle-trunk/drizzle/development

1085.1.4 by Monty Taylor
pandora-build v1
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
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
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
1085.1.7 by Monty Taylor
pandora-build r0.7
9
10
dnl @TODO: remove less-warnings option as soon as Drizzle is clean enough to
11
dnl        allow it
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
12
 
13
AC_DEFUN([PANDORA_WARNINGS],[
1085.1.4 by Monty Taylor
pandora-build v1
14
  m4_define([PW_LESS_WARNINGS],[no])
15
  m4_define([PW_WARN_ALWAYS_ON],[no])
1085.1.7 by Monty Taylor
pandora-build r0.7
16
  ifdef([m4_define],,[define([m4_define],   defn([define]))])
17
  ifdef([m4_undefine],,[define([m4_undefine],   defn([undefine]))])
1085.3.4 by Monty Taylor
pandora-build v0.8
18
  m4_foreach([pw_arg],[$*],[
1085.1.4 by Monty Taylor
pandora-build v1
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
  ])
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
29
30
  AC_REQUIRE([PANDORA_BUILDING_FROM_VC])
1085.1.4 by Monty Taylor
pandora-build v1
31
  m4_if(PW_WARN_ALWAYS_ON, [yes],
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
32
    [ac_cv_warnings_as_errors=yes],
1273.12.1 by Monty Taylor
pandora-build v0.100 - Fixes several bugs found by cb1kenobi. Add several thoughts from folks at LCA.
33
    AS_IF([test "$pandora_building_from_vc" = "yes"],
1085.1.4 by Monty Taylor
pandora-build v1
34
          [ac_cv_warnings_as_errors=yes],
35
          [ac_cv_warnings_as_errors=no]))
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
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"
1192.3.77 by Monty Taylor
Fixed dynamic loading with lcov and gprof.
53
      GCOV_LIBS="-pg -lgcov"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
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"],
1192.3.77 by Monty Taylor
Fixed dynamic loading with lcov and gprof.
65
          [
66
            CC_COVERAGE="--coverage"
67
            GCOV_LIBS="-lgcov"
68
          ])
69
70
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
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"
1093.2.1 by Monty Taylor
pandora-build v0.16
78
       CFLAGS="-fdiagnostics-show-option ${AM_CFLAGS} ${CFLAGS}"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
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"
1085.1.7 by Monty Taylor
pandora-build r0.7
93
       dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
94
       dnl conversion warnings to all the tarball folks
1093.2.1 by Monty Taylor
pandora-build v0.16
95
       CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
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"
1085.1.7 by Monty Taylor
pandora-build r0.7
115
         dnl Use -Werror here instead of ${W_FAIL} so that we don't spew
116
         dnl conversion warnings to all the tarball folks
1093.2.1 by Monty Taylor
pandora-build v0.16
117
         CFLAGS="-Wconversion -Werror -pedantic ${AM_CFLAGS} ${CFLAGS}"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
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"
1093.4.1 by Monty Taylor
pandora-build v0.22 - fixes solaris build.
134
    NO_SHADOW="-Wno-shadow"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
135
1093.2.2 by mordred
pandora-build v0.18
136
    AS_IF([test "$INTELCC" = "yes"],[
1093.2.3 by mordred
pandora-build v0.20
137
      m4_if(PW_LESS_WARNINGS,[no],[
1192.3.61 by Monty Taylor
Turned off remarks in ICC.
138
        BASE_WARNINGS="-w1 -Werror -Wcheck -Wformat -Wp64 -Woverloaded-virtual -Wcast-qual"
1093.2.3 by mordred
pandora-build v0.20
139
      ],[
1192.3.61 by Monty Taylor
Turned off remarks in ICC.
140
        BASE_WARNINGS="-w1 -Wcheck -Wformat -Wp64 -Woverloaded-virtual -Wcast-qual -diag-disable 981"
1093.2.3 by mordred
pandora-build v0.20
141
      ])
1093.2.2 by mordred
pandora-build v0.18
142
      CC_WARNINGS="${BASE_WARNINGS}"
143
      CXX_WARNINGS="${BASE_WARNINGS}"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
144
    ],[
1093.2.2 by mordred
pandora-build v0.18
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="-Weffc++ -Wold-style-cast"
149
      ],[
150
        BASE_WARNINGS_FULL="-Wformat ${NO_STRICT_ALIASING}"
151
      ])
152
153
      AS_IF([test "${ac_cv_assert}" = "no"],
154
            [NO_UNUSED="-Wno-unused-variable -Wno-unused-parameter"])
155
  
1192.3.1 by Monty Taylor
pandora-build v0.64
156
      AC_CACHE_CHECK([whether it is safe to use -Wextra],
157
        [ac_cv_safe_to_use_Wextra_],
158
        [save_CFLAGS="$CFLAGS"
159
         CFLAGS="${W_FAIL} -pedantic -Wextra ${AM_CFLAGS} ${CFLAGS}"
160
         AC_COMPILE_IFELSE([
161
           AC_LANG_PROGRAM(
162
           [[
163
#include <stdio.h>
164
           ]], [[]])
165
        ],
166
        [ac_cv_safe_to_use_Wextra_=yes],
167
        [ac_cv_safe_to_use_Wextra_=no])
168
      CFLAGS="$save_CFLAGS"])
169
170
      BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${CFLAG_VISIBILITY} ${BASE_WARNINGS_FULL}"
171
      AS_IF([test "$ac_cv_safe_to_use_Wextra_" = "yes"],
172
            [BASE_WARNINGS="${BASE_WARNINGS} -Wextra"],
173
            [BASE_WARNINGS="${BASE_WARNINGS} -W"])
174
  
1093.2.2 by mordred
pandora-build v0.18
175
      CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align ${CC_WARNINGS_FULL}"
176
      CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long ${CXX_WARNINGS_FULL}"
177
178
      AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++],
179
        [ac_cv_safe_to_use_Wmissing_declarations_],
180
        [AC_LANG_PUSH(C++)
181
         save_CXXFLAGS="$CXXFLAGS"
182
         CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}"
183
         AC_COMPILE_IFELSE([
184
           AC_LANG_PROGRAM(
185
           [[
186
#include <stdio.h>
187
           ]], [[]])
188
        ],
189
        [ac_cv_safe_to_use_Wmissing_declarations_=yes],
190
        [ac_cv_safe_to_use_Wmissing_declarations_=no])
191
        CXXFLAGS="$save_CXXFLAGS"
192
        AC_LANG_POP()
193
      ])
194
      AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"],
195
            [CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"])
196
  
197
      AC_CACHE_CHECK([whether it is safe to use -Wlogical-op],
198
        [ac_cv_safe_to_use_Wlogical_op_],
199
        [save_CFLAGS="$CFLAGS"
200
         CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS} ${CFLAGS}"
201
         AC_COMPILE_IFELSE([
202
           AC_LANG_PROGRAM(
203
           [[
204
#include <stdio.h>
205
           ]], [[]])
206
        ],
207
        [ac_cv_safe_to_use_Wlogical_op_=yes],
208
        [ac_cv_safe_to_use_Wlogical_op_=no])
209
      CFLAGS="$save_CFLAGS"])
210
      AS_IF([test "$ac_cv_safe_to_use_Wlogical_op_" = "yes"],
211
            [CC_WARNINGS="${CC_WARNINGS} -Wlogical-op"])
212
  
213
      AC_CACHE_CHECK([whether it is safe to use -Wredundant-decls from C++],
214
        [ac_cv_safe_to_use_Wredundant_decls_],
215
        [AC_LANG_PUSH(C++)
216
         save_CXXFLAGS="${CXXFLAGS}"
217
         CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}"
218
         AC_COMPILE_IFELSE(
219
           [AC_LANG_PROGRAM([
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
220
template <typename E> struct C { void foo(); };
221
template <typename E> void C<E>::foo() { }
222
template <> void C<int>::foo();
1093.2.2 by mordred
pandora-build v0.18
223
            AC_INCLUDES_DEFAULT])],
224
            [ac_cv_safe_to_use_Wredundant_decls_=yes],
225
            [ac_cv_safe_to_use_Wredundant_decls_=no])
1241.9.10 by Monty Taylor
pandora-build v0.85 - Fixed the C++ standard setting in the build checks.
226
         CXXFLAGS="${save_CXXFLAGS}"
227
         AC_LANG_POP()])
1093.2.2 by mordred
pandora-build v0.18
228
      AS_IF([test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"],
229
            [CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls"],
230
            [CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls"])
1126.7.3 by mordred
pandora-build v0.60 - check for -Wattributes with -fvisibility=hidden issues.
231
232
      AC_CACHE_CHECK([whether it is safe to use -Wattributes from C++],
233
        [ac_cv_safe_to_use_Wattributes_],
234
        [AC_LANG_PUSH(C++)
235
         save_CXXFLAGS="${CXXFLAGS}"
236
         CXXFLAGS="${W_FAIL} -pedantic -Wattributes -fvisibility=hidden ${AM_CXXFLAGS}"
237
         AC_COMPILE_IFELSE(
238
           [AC_LANG_PROGRAM([
239
#include <google/protobuf/message.h>
240
#include <google/protobuf/descriptor.h>
241
242
243
const ::google::protobuf::EnumDescriptor* Table_TableOptions_RowType_descriptor();
244
enum Table_TableOptions_RowType {
245
  Table_TableOptions_RowType_ROW_TYPE_DEFAULT = 0,
246
  Table_TableOptions_RowType_ROW_TYPE_FIXED = 1,
247
  Table_TableOptions_RowType_ROW_TYPE_DYNAMIC = 2,
248
  Table_TableOptions_RowType_ROW_TYPE_COMPRESSED = 3,
249
  Table_TableOptions_RowType_ROW_TYPE_REDUNDANT = 4,
250
  Table_TableOptions_RowType_ROW_TYPE_COMPACT = 5,
251
  Table_TableOptions_RowType_ROW_TYPE_PAGE = 6
252
};
253
254
namespace google {
255
namespace protobuf {
256
template <>
257
inline const EnumDescriptor* GetEnumDescriptor<Table_TableOptions_RowType>() {
258
  return Table_TableOptions_RowType_descriptor();
259
}
260
}
261
}
262
            ])],
263
            [ac_cv_safe_to_use_Wattributes_=yes],
264
            [ac_cv_safe_to_use_Wattributes_=no])
265
          CXXFLAGS="${save_CXXFLAGS}"
266
          AC_LANG_POP()])
1192.3.1 by Monty Taylor
pandora-build v0.64
267
      AC_CACHE_CHECK([whether it is safe to use -Wno-attributes],
268
        [ac_cv_safe_to_use_Wno_attributes_],
269
        [save_CFLAGS="$CFLAGS"
270
         CFLAGS="${W_FAIL} -pedantic -Wno_attributes_ ${AM_CFLAGS} ${CFLAGS}"
271
         AC_COMPILE_IFELSE([
272
           AC_LANG_PROGRAM(
273
           [[
274
#include <stdio.h>
275
           ]], [[]])
276
        ],
277
        [ac_cv_safe_to_use_Wno_attributes_=yes],
278
        [ac_cv_safe_to_use_Wno_attributes_=no])
279
      CFLAGS="$save_CFLAGS"])
280
281
      dnl GCC 3.4 doesn't have -Wno-attributes, so we can't turn them off
282
      dnl by using that. 
283
      AS_IF([test "$ac_cv_safe_to_use_Wattributes_" != "yes"],[
284
        AS_IF([test "$ac_cv_safe_to_use_Wno_attributes_" = "yes"],[
285
          CC_WARNINGS="${CC_WARNINGS} -Wno-attributes"
286
          NO_ATTRIBUTES="-Wno-attributes"])])
287
  
1093.2.2 by mordred
pandora-build v0.18
288
  
289
      NO_REDUNDANT_DECLS="-Wno-redundant-decls"
1099.1.10 by Monty Taylor
Avoid cast-align warnings on InnoDB.
290
      dnl TODO: Figure out a better way to deal with this:
1192.3.1 by Monty Taylor
pandora-build v0.64
291
      PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow -Wno-missing-braces ${NO_ATTRIBUTES}"
1093.9.17 by Monty Taylor
pandora-build v0.45 - added a -Wno-error option for chunks of code like generated protobuf files
292
      NO_WERROR="-Wno-error"
1099.1.10 by Monty Taylor
Avoid cast-align warnings on InnoDB.
293
      INNOBASE_SKIP_WARNINGS="-Wno-shadow -Wno-cast-align"
1093.2.2 by mordred
pandora-build v0.18
294
      
295
    ])
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
296
  ])
297
298
  AS_IF([test "$SUNCC" = "yes"],[
299
300
    AS_IF([test "$ac_profiling" = "yes"],
301
          [CC_PROFILING="-xinstrument=datarace"])
302
303
    AS_IF([test "$ac_cv_warnings_as_errors" = "yes"],
304
          [W_FAIL="-errwarn=%all"])
305
306
    AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable],
307
      [ac_cv_paste_result],
308
      [
309
        save_CFLAGS="${CFLAGS}"
310
        CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}"
311
        AC_COMPILE_IFELSE(
312
          [AC_LANG_PROGRAM([
313
            AC_INCLUDES_DEFAULT
314
          ],[
315
            int x= 0;])],
316
          [ac_cv_paste_result=yes],
317
          [ac_cv_paste_result=no])
318
        CFLAGS="${save_CFLAGS}"
319
      ])
320
    AS_IF([test $ac_cv_paste_result = yes],
321
      [W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"])
322
323
1085.1.4 by Monty Taylor
pandora-build v1
324
    m4_if(PW_LESS_WARNINGS, [no],[
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
325
      CC_WARNINGS_FULL="-erroff=E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}"
1093.2.3 by mordred
pandora-build v0.20
326
      CXX_WARNINGS_FULL="-erroff=inllargeuse"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
327
    ],[
328
      CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR"
329
      CXX_WARNINGS_FULL="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint"
330
    ])
331
1259.2.1 by Monty Taylor
Updates to pandora-build visibility settings.
332
    CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL} ${CFLAG_VISIBILITY}"
333
    CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL} ${CFLAG_VISIBILITY}"
1093.9.11 by Monty Taylor
pandora-build v0.41 - added more warning exceptions for protobuf
334
    PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn,partinit,notused,badargtype2w,wbadinit"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
335
    NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED"
1093.9.17 by Monty Taylor
pandora-build v0.45 - added a -Wno-error option for chunks of code like generated protobuf files
336
    NO_WERROR="-errwarn=%none"
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
337
338
  ])
339
340
  AC_SUBST(NO_CONVERSION)
341
  AC_SUBST(NO_REDUNDANT_DECLS)
342
  AC_SUBST(NO_UNREACHED)
343
  AC_SUBST(NO_SHADOW)
344
  AC_SUBST(NO_STRICT_ALIASING)
345
  AC_SUBST(PROTOSKIP_WARNINGS)
1099.1.14 by Monty Taylor
pandora-build v0.31
346
  AC_SUBST(INNOBASE_SKIP_WARNINGS)
1093.9.17 by Monty Taylor
pandora-build v0.45 - added a -Wno-error option for chunks of code like generated protobuf files
347
  AC_SUBST(NO_WERROR)
1192.3.77 by Monty Taylor
Fixed dynamic loading with lcov and gprof.
348
  AC_SUBST([GCOV_LIBS])
1085.1.3 by Monty Taylor
Split out warnings - start using the pandora build system.
349
350
])