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