| 1 |
dnl Copyright 2010 Google Inc. |
| 2 |
dnl All rights reserved. |
| 3 |
dnl |
| 4 |
dnl Redistribution and use in source and binary forms, with or without |
| 5 |
dnl modification, are permitted provided that the following conditions are |
| 6 |
dnl met: |
| 7 |
dnl |
| 8 |
dnl * Redistributions of source code must retain the above copyright |
| 9 |
dnl notice, this list of conditions and the following disclaimer. |
| 10 |
dnl * Redistributions in binary form must reproduce the above copyright |
| 11 |
dnl notice, this list of conditions and the following disclaimer in the |
| 12 |
dnl documentation and/or other materials provided with the distribution. |
| 13 |
dnl * Neither the name of Google Inc. nor the names of its contributors |
| 14 |
dnl may be used to endorse or promote products derived from this software |
| 15 |
dnl without specific prior written permission. |
| 16 |
dnl |
| 17 |
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 |
dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 |
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 |
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 |
dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 |
dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 |
dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 |
dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 |
dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 |
dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 |
dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 |
|
| 29 |
dnl \file developer-mode.m4 |
| 30 |
dnl |
| 31 |
dnl "Developer mode" is a mode in which the build system reports any |
| 32 |
dnl build-time warnings as fatal errors. This helps in minimizing the |
| 33 |
dnl amount of trivial coding problems introduced in the code. |
| 34 |
dnl Unfortunately, this is not bullet-proof due to the wide variety of |
| 35 |
dnl compilers available and their different warning diagnostics. |
| 36 |
dnl |
| 37 |
dnl When developer mode support is added to a package, the compilation will |
| 38 |
dnl gain a bunch of extra warning diagnostics. These will NOT be enforced |
| 39 |
dnl unless developer mode is enabled. |
| 40 |
dnl |
| 41 |
dnl Developer mode is enabled when the user requests it through the |
| 42 |
dnl configure command line, or when building from the repository. The |
| 43 |
dnl latter is to minimize the risk of committing new code with warnings |
| 44 |
dnl into the tree. |
| 45 |
|
| 46 |
|
| 47 |
dnl Adds "developer mode" support to the package. |
| 48 |
dnl |
| 49 |
dnl This macro performs the actual definition of the --enable-developer |
| 50 |
dnl flag and implements all of its logic. See the file-level comment for |
| 51 |
dnl details as to what this implies. |
| 52 |
AC_DEFUN([KYUA_DEVELOPER_MODE], [ |
| 53 |
m4_foreach([language], [$1], [m4_set_add([languages], language)]) |
| 54 |
|
| 55 |
AC_ARG_ENABLE( |
| 56 |
[developer], |
| 57 |
AS_HELP_STRING([--enable-developer], [enable developer features]),, |
| 58 |
[if test -d ${srcdir}/.git; then |
| 59 |
AC_MSG_NOTICE([building from HEAD; developer mode autoenabled]) |
| 60 |
enable_developer=yes |
| 61 |
else |
| 62 |
enable_developer=no |
| 63 |
fi]) |
| 64 |
|
| 65 |
# |
| 66 |
# The following warning flags should also be enabled but cannot be. |
| 67 |
# Reasons given below. |
| 68 |
# |
| 69 |
# -Wold-style-cast: Raises errors when using TIOCGWINSZ, at least under |
| 70 |
# Mac OS X. This is due to the way _IOR is defined. |
| 71 |
# |
| 72 |
|
| 73 |
try_c_cxx_flags="-D_FORTIFY_SOURCE=2 \ |
| 74 |
-Wall \ |
| 75 |
-Wcast-qual \ |
| 76 |
-Wextra \ |
| 77 |
-Wpointer-arith \ |
| 78 |
-Wredundant-decls \ |
| 79 |
-Wreturn-type \ |
| 80 |
-Wshadow \ |
| 81 |
-Wsign-compare \ |
| 82 |
-Wswitch \ |
| 83 |
-Wwrite-strings" |
| 84 |
|
| 85 |
try_c_flags="-Wmissing-prototypes \ |
| 86 |
-Wno-traditional \ |
| 87 |
-Wstrict-prototypes" |
| 88 |
|
| 89 |
try_cxx_flags="-Wabi \ |
| 90 |
-Wctor-dtor-privacy \ |
| 91 |
-Wno-deprecated \ |
| 92 |
-Wno-non-template-friend \ |
| 93 |
-Wno-pmf-conversions \ |
| 94 |
-Wnon-virtual-dtor \ |
| 95 |
-Woverloaded-virtual \ |
| 96 |
-Wreorder \ |
| 97 |
-Wsign-promo \ |
| 98 |
-Wsynth" |
| 99 |
|
| 100 |
if test ${enable_developer} = yes; then |
| 101 |
try_werror=yes |
| 102 |
try_c_cxx_flags="${try_c_cxx_flags} -g -Werror" |
| 103 |
else |
| 104 |
try_werror=no |
| 105 |
try_c_cxx_flags="${try_c_cxx_flags} -DNDEBUG" |
| 106 |
fi |
| 107 |
|
| 108 |
m4_set_contains([languages], [C], |
| 109 |
[KYUA_CC_FLAGS(${try_c_cxx_flags} ${try_c_flags})]) |
| 110 |
m4_set_contains([languages], [C++], |
| 111 |
[KYUA_CXX_FLAGS(${try_c_cxx_flags} ${try_cxx_flags})]) |
| 112 |
]) |