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