~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/pandora_warnings.m4

pandora-buildĀ v1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
1
6
dnl AC_PANDORA_WARNINGS([less-warnings|warnings-always-on])
2
7
dnl   less-warnings turn on a limited set of warnings
3
8
dnl   warnings-always-on always set warnings=error regardless of tarball/vc
4
9
 
5
10
AC_DEFUN([PANDORA_WARNINGS],[
6
 
  PW_FULL_WARNINGS=yes
7
 
  PW_VC_WARN_OFF=yes
8
 
  for arg in $@ ; do
9
 
    case "$arg" in
10
 
      less-warnings)
11
 
        PW_FULL_WARNINGS=no
12
 
        ;;
13
 
      warnings-always-on)
14
 
        PW_VC_WARN_OFF=no
15
 
        ;;
16
 
    esac
17
 
  done
 
11
  m4_define([PW_LESS_WARNINGS],[no])
 
12
  m4_define([PW_WARN_ALWAYS_ON],[no])
 
13
  m4_foreach_w([pw_arg],$@,[
 
14
    m4_case(pw_arg,
 
15
      [less-warnings],[
 
16
        m4_undefine([PW_LESS_WARNINGS])
 
17
        m4_define([PW_LESS_WARNINGS],[yes])
 
18
      ],
 
19
      [warnings-always-on],[
 
20
        m4_undefine([PW_WARN_ALWAYS_ON])
 
21
        m4_define([PW_WARN_ALWAYS_ON],[yes])
 
22
    ]) 
 
23
  ])
18
24
 
19
25
  AC_REQUIRE([PANDORA_BUILDING_FROM_VC])
20
 
  AS_IF([test "${PW_VC_WARN_OFF}" = "no" -o "$ac_cv_building_from_vc" = "yes"],
 
26
  m4_if(PW_WARN_ALWAYS_ON, [yes],
21
27
    [ac_cv_warnings_as_errors=yes],
22
 
    [ac_cv_warnings_as_errors=no])
 
28
    AS_IF([test "$ac_cv_building_from_vc" = "yes"],
 
29
          [ac_cv_warnings_as_errors=yes],
 
30
          [ac_cv_warnings_as_errors=no]))
23
31
 
24
32
  AC_ARG_ENABLE([profiling],
25
33
      [AS_HELP_STRING([--enable-profiling],
110
118
    NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing"
111
119
    NO_SHADOW="-Wno-shadow"
112
120
 
113
 
    AS_IF([test "${PW_FULL_WARNINGS}" = "yes"],[
 
121
    m4_if(PW_LESS_WARNINGS,[no],[
114
122
      BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing"
115
123
      CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum"
116
124
      CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast"
118
126
      BASE_WARNINGS_FULL="-Wformat ${NO_STRICT_ALIASING}"
119
127
    ])
120
128
 
121
 
    BASE_WARNINGS="-pedantic -Wall -Wextra ${W_FAIL} -Wundef -Wshadow -Wmissing-declarations -Wstrict-aliasing ${F_DIAGNOSTICS_SHOW_OPTION} ${CFLAG_VISIBILITY} ${BASE_WARNINGS_FULL}"
122
 
    CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls ${CC_WARNINGS_FULL} -Wcast-align"
 
129
    BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wextra -Wundef -Wshadow -Wstrict-aliasing ${F_DIAGNOSTICS_SHOW_OPTION} ${CFLAG_VISIBILITY} ${BASE_WARNINGS_FULL}"
 
130
    CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align ${CC_WARNINGS_FULL}"
123
131
    CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long ${CXX_WARNINGS_FULL}"
124
132
 
 
133
    AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++],
 
134
      [ac_cv_safe_to_use_Wmissing_declarations_],
 
135
      [AC_LANG_PUSH(C++)
 
136
       save_CXXFLAGS="$CXXFLAGS"
 
137
       CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}"
 
138
       AC_COMPILE_IFELSE([
 
139
         AC_LANG_PROGRAM(
 
140
         [[
 
141
#include <stdio.h>
 
142
         ]], [[]])
 
143
      ],
 
144
      [ac_cv_safe_to_use_Wmissing_declarations_=yes],
 
145
      [ac_cv_safe_to_use_Wmissing_declarations_=no])
 
146
      CXXFLAGS="$save_CXXFLAGS"
 
147
      AC_LANG_POP()
 
148
    ])
 
149
    AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"],
 
150
          [CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"])
 
151
 
125
152
    AC_CACHE_CHECK([whether it is safe to use -Wlogical-op],
126
153
      [ac_cv_safe_to_use_Wlogical_op_],
127
154
      [save_CFLAGS="$CFLAGS"
128
 
       CFLAGS="-Wlogical-op -Werror -pedantic ${AM_CFLAGS}"
 
155
       CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS}"
129
156
       AC_COMPILE_IFELSE([
130
157
         AC_LANG_PROGRAM(
131
158
         [[
142
169
      [ac_cv_safe_to_use_Wredundant_decls_],
143
170
      [AC_LANG_PUSH(C++)
144
171
       save_CXXFLAGS="${CXXFLAGS}"
145
 
       CXXFLAGS="-Wredundant-decls ${W_FAIL} -pedantic -Wredundant-decls"
 
172
       CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}"
146
173
       AC_COMPILE_IFELSE(
147
174
         [AC_LANG_PROGRAM([
148
175
template <typename E> struct C { void foo(); };
188
215
      [W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"])
189
216
 
190
217
 
191
 
    AS_IF([test "${PW_FULL_WARNINGS}" = "yes"],[
 
218
    m4_if(PW_LESS_WARNINGS, [no],[
192
219
      CC_WARNINGS_FULL="-erroff=E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}"
193
220
    ],[
194
221
      CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR"
209
236
  AC_SUBST(NO_STRICT_ALIASING)
210
237
  AC_SUBST(PROTOSKIP_WARNINGS)
211
238
 
212
 
 
213
239
])