1*1fd5a2e1SPrashanth Swaminathan# =========================================================================== 2*1fd5a2e1SPrashanth Swaminathan# https://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html 3*1fd5a2e1SPrashanth Swaminathan# =========================================================================== 4*1fd5a2e1SPrashanth Swaminathan# 5*1fd5a2e1SPrashanth Swaminathan# SYNOPSIS 6*1fd5a2e1SPrashanth Swaminathan# 7*1fd5a2e1SPrashanth Swaminathan# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] 8*1fd5a2e1SPrashanth Swaminathan# AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] 9*1fd5a2e1SPrashanth Swaminathan# AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] 10*1fd5a2e1SPrashanth Swaminathan# 11*1fd5a2e1SPrashanth Swaminathan# DESCRIPTION 12*1fd5a2e1SPrashanth Swaminathan# 13*1fd5a2e1SPrashanth Swaminathan# Try to find a compiler option that enables most reasonable warnings. 14*1fd5a2e1SPrashanth Swaminathan# 15*1fd5a2e1SPrashanth Swaminathan# For the GNU compiler it will be -Wall (and -ansi -pedantic) The result 16*1fd5a2e1SPrashanth Swaminathan# is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. 17*1fd5a2e1SPrashanth Swaminathan# 18*1fd5a2e1SPrashanth Swaminathan# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, 19*1fd5a2e1SPrashanth Swaminathan# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and 20*1fd5a2e1SPrashanth Swaminathan# Intel compilers. For a given compiler, the Fortran flags are much more 21*1fd5a2e1SPrashanth Swaminathan# experimental than their C equivalents. 22*1fd5a2e1SPrashanth Swaminathan# 23*1fd5a2e1SPrashanth Swaminathan# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS 24*1fd5a2e1SPrashanth Swaminathan# - $2 add-value-if-not-found : nothing 25*1fd5a2e1SPrashanth Swaminathan# - $3 action-if-found : add value to shellvariable 26*1fd5a2e1SPrashanth Swaminathan# - $4 action-if-not-found : nothing 27*1fd5a2e1SPrashanth Swaminathan# 28*1fd5a2e1SPrashanth Swaminathan# NOTE: These macros depend on AX_APPEND_FLAG. 29*1fd5a2e1SPrashanth Swaminathan# 30*1fd5a2e1SPrashanth Swaminathan# LICENSE 31*1fd5a2e1SPrashanth Swaminathan# 32*1fd5a2e1SPrashanth Swaminathan# Copyright (c) 2008 Guido U. Draheim <[email protected]> 33*1fd5a2e1SPrashanth Swaminathan# Copyright (c) 2010 Rhys Ulerich <[email protected]> 34*1fd5a2e1SPrashanth Swaminathan# 35*1fd5a2e1SPrashanth Swaminathan# This program is free software; you can redistribute it and/or modify it 36*1fd5a2e1SPrashanth Swaminathan# under the terms of the GNU General Public License as published by the 37*1fd5a2e1SPrashanth Swaminathan# Free Software Foundation; either version 3 of the License, or (at your 38*1fd5a2e1SPrashanth Swaminathan# option) any later version. 39*1fd5a2e1SPrashanth Swaminathan# 40*1fd5a2e1SPrashanth Swaminathan# This program is distributed in the hope that it will be useful, but 41*1fd5a2e1SPrashanth Swaminathan# WITHOUT ANY WARRANTY; without even the implied warranty of 42*1fd5a2e1SPrashanth Swaminathan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 43*1fd5a2e1SPrashanth Swaminathan# Public License for more details. 44*1fd5a2e1SPrashanth Swaminathan# 45*1fd5a2e1SPrashanth Swaminathan# You should have received a copy of the GNU General Public License along 46*1fd5a2e1SPrashanth Swaminathan# with this program. If not, see <https://www.gnu.org/licenses/>. 47*1fd5a2e1SPrashanth Swaminathan# 48*1fd5a2e1SPrashanth Swaminathan# As a special exception, the respective Autoconf Macro's copyright owner 49*1fd5a2e1SPrashanth Swaminathan# gives unlimited permission to copy, distribute and modify the configure 50*1fd5a2e1SPrashanth Swaminathan# scripts that are the output of Autoconf when processing the Macro. You 51*1fd5a2e1SPrashanth Swaminathan# need not follow the terms of the GNU General Public License when using 52*1fd5a2e1SPrashanth Swaminathan# or distributing such scripts, even though portions of the text of the 53*1fd5a2e1SPrashanth Swaminathan# Macro appear in them. The GNU General Public License (GPL) does govern 54*1fd5a2e1SPrashanth Swaminathan# all other use of the material that constitutes the Autoconf Macro. 55*1fd5a2e1SPrashanth Swaminathan# 56*1fd5a2e1SPrashanth Swaminathan# This special exception to the GPL applies to versions of the Autoconf 57*1fd5a2e1SPrashanth Swaminathan# Macro released by the Autoconf Archive. When you make and distribute a 58*1fd5a2e1SPrashanth Swaminathan# modified version of the Autoconf Macro, you may extend this special 59*1fd5a2e1SPrashanth Swaminathan# exception to the GPL to apply to your modified version as well. 60*1fd5a2e1SPrashanth Swaminathan 61*1fd5a2e1SPrashanth Swaminathan#serial 16 62*1fd5a2e1SPrashanth Swaminathan 63*1fd5a2e1SPrashanth SwaminathanAC_DEFUN([AX_FLAGS_WARN_ALL],[dnl 64*1fd5a2e1SPrashanth SwaminathanAS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl 65*1fd5a2e1SPrashanth SwaminathanAS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl 66*1fd5a2e1SPrashanth SwaminathanAC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 67*1fd5a2e1SPrashanth SwaminathanVAR,[VAR="no, unknown" 68*1fd5a2e1SPrashanth Swaminathanac_save_[]FLAGS="$[]FLAGS" 69*1fd5a2e1SPrashanth Swaminathanfor ac_arg dnl 70*1fd5a2e1SPrashanth Swaminathanin "-warn all % -warn all" dnl Intel 71*1fd5a2e1SPrashanth Swaminathan "-pedantic % -Wall" dnl GCC 72*1fd5a2e1SPrashanth Swaminathan "-xstrconst % -v" dnl Solaris C 73*1fd5a2e1SPrashanth Swaminathan "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix 74*1fd5a2e1SPrashanth Swaminathan "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX 75*1fd5a2e1SPrashanth Swaminathan "-ansi -ansiE % -fullwarn" dnl IRIX 76*1fd5a2e1SPrashanth Swaminathan "+ESlit % +w1" dnl HP-UX C 77*1fd5a2e1SPrashanth Swaminathan "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) 78*1fd5a2e1SPrashanth Swaminathan "-h conform % -h msglevel 2" dnl Cray C (Unicos) 79*1fd5a2e1SPrashanth Swaminathan # 80*1fd5a2e1SPrashanth Swaminathando FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 81*1fd5a2e1SPrashanth Swaminathan AC_COMPILE_IFELSE([AC_LANG_PROGRAM], 82*1fd5a2e1SPrashanth Swaminathan [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) 83*1fd5a2e1SPrashanth Swaminathandone 84*1fd5a2e1SPrashanth SwaminathanFLAGS="$ac_save_[]FLAGS" 85*1fd5a2e1SPrashanth Swaminathan]) 86*1fd5a2e1SPrashanth SwaminathanAS_VAR_POPDEF([FLAGS])dnl 87*1fd5a2e1SPrashanth SwaminathanAX_REQUIRE_DEFINED([AX_APPEND_FLAG]) 88*1fd5a2e1SPrashanth Swaminathancase ".$VAR" in 89*1fd5a2e1SPrashanth Swaminathan .ok|.ok,*) m4_ifvaln($3,$3) ;; 90*1fd5a2e1SPrashanth Swaminathan .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; 91*1fd5a2e1SPrashanth Swaminathan *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; 92*1fd5a2e1SPrashanth Swaminathanesac 93*1fd5a2e1SPrashanth SwaminathanAS_VAR_POPDEF([VAR])dnl 94*1fd5a2e1SPrashanth Swaminathan])dnl AX_FLAGS_WARN_ALL 95*1fd5a2e1SPrashanth Swaminathandnl implementation tactics: 96*1fd5a2e1SPrashanth Swaminathandnl the for-argument contains a list of options. The first part of 97*1fd5a2e1SPrashanth Swaminathandnl these does only exist to detect the compiler - usually it is 98*1fd5a2e1SPrashanth Swaminathandnl a global option to enable -ansi or -extrawarnings. All other 99*1fd5a2e1SPrashanth Swaminathandnl compilers will fail about it. That was needed since a lot of 100*1fd5a2e1SPrashanth Swaminathandnl compilers will give false positives for some option-syntax 101*1fd5a2e1SPrashanth Swaminathandnl like -Woption or -Xoption as they think of it is a pass-through 102*1fd5a2e1SPrashanth Swaminathandnl to later compile stages or something. The "%" is used as a 103*1fd5a2e1SPrashanth Swaminathandnl delimiter. A non-option comment can be given after "%%" marks 104*1fd5a2e1SPrashanth Swaminathandnl which will be shown but not added to the respective C/CXXFLAGS. 105*1fd5a2e1SPrashanth Swaminathan 106*1fd5a2e1SPrashanth SwaminathanAC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl 107*1fd5a2e1SPrashanth SwaminathanAC_LANG_PUSH([C]) 108*1fd5a2e1SPrashanth SwaminathanAX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) 109*1fd5a2e1SPrashanth SwaminathanAC_LANG_POP([C]) 110*1fd5a2e1SPrashanth Swaminathan]) 111*1fd5a2e1SPrashanth Swaminathan 112*1fd5a2e1SPrashanth SwaminathanAC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl 113*1fd5a2e1SPrashanth SwaminathanAC_LANG_PUSH([C++]) 114*1fd5a2e1SPrashanth SwaminathanAX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) 115*1fd5a2e1SPrashanth SwaminathanAC_LANG_POP([C++]) 116*1fd5a2e1SPrashanth Swaminathan]) 117*1fd5a2e1SPrashanth Swaminathan 118*1fd5a2e1SPrashanth SwaminathanAC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl 119*1fd5a2e1SPrashanth SwaminathanAC_LANG_PUSH([Fortran]) 120*1fd5a2e1SPrashanth SwaminathanAX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) 121*1fd5a2e1SPrashanth SwaminathanAC_LANG_POP([Fortran]) 122*1fd5a2e1SPrashanth Swaminathan]) 123