|
| 1 | +# =========================================================================== |
| 2 | +# https://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html |
| 3 | +# =========================================================================== |
| 4 | +# |
| 5 | +# SYNOPSIS |
| 6 | +# |
| 7 | +# AX_CFLAGS_WARN_ALL [(shellvar[, default[, action-if-found[, action-if-not-found]]])] |
| 8 | +# AX_CXXFLAGS_WARN_ALL [(shellvar[, default[, action-if-found[, action-if-not-found]]])] |
| 9 | +# AX_FCFLAGS_WARN_ALL [(shellvar[, default[, action-if-found[, action-if-not-found]]])] |
| 10 | +# |
| 11 | +# DESCRIPTION |
| 12 | +# |
| 13 | +# Specify compiler options that enable most reasonable warnings. For the |
| 14 | +# GNU Compiler Collection (GCC), for example, it will be "-Wall". The |
| 15 | +# result is added to shellvar, one of CFLAGS, CXXFLAGS or FCFLAGS if the |
| 16 | +# first parameter is not specified. |
| 17 | +# |
| 18 | +# Each of these macros accepts the following optional arguments: |
| 19 | +# |
| 20 | +# - $1 - shellvar |
| 21 | +# shell variable to use (CFLAGS, CXXFLAGS or FCFLAGS if not |
| 22 | +# specified, depending on macro) |
| 23 | +# |
| 24 | +# - $2 - default |
| 25 | +# value to use for flags if compiler vendor cannot be determined (by |
| 26 | +# default, "") |
| 27 | +# |
| 28 | +# - $3 - action-if-found |
| 29 | +# action to take if the compiler vendor has been successfully |
| 30 | +# determined (by default, add the appropriate compiler flags to |
| 31 | +# shellvar) |
| 32 | +# |
| 33 | +# - $4 - action-if-not-found |
| 34 | +# action to take if the compiler vendor has not been determined or |
| 35 | +# is unknown (by default, add the default flags, or "" if not |
| 36 | +# specified, to shellvar) |
| 37 | +# |
| 38 | +# These macros use AX_COMPILER_VENDOR to determine which flags should be |
| 39 | +# returned for a given compiler. Not all compilers currently have flags |
| 40 | +# defined for them; patches are welcome. If need be, compiler flags may |
| 41 | +# be made language-dependent: use a construct like the following: |
| 42 | +# |
| 43 | +# [vendor_name], [m4_if(_AC_LANG_PREFIX,[C], VAR="--relevant-c-flags",dnl |
| 44 | +# m4_if(_AC_LANG_PREFIX,[CXX], VAR="--relevant-c++-flags",dnl |
| 45 | +# m4_if(_AC_LANG_PREFIX,[FC], VAR="--relevant-fortran-flags",dnl |
| 46 | +# VAR="$2"; FOUND="no")))], |
| 47 | +# |
| 48 | +# Note: These macros also depend on AX_PREPEND_FLAG. |
| 49 | +# |
| 50 | +# LICENSE |
| 51 | +# |
| 52 | +# Copyright (c) 2008 Guido U. Draheim <[email protected]> |
| 53 | +# Copyright (c) 2010 Rhys Ulerich <[email protected]> |
| 54 | +# Copyright (c) 2018 John Zaitseff <[email protected]> |
| 55 | +# |
| 56 | +# This program is free software; you can redistribute it and/or modify it |
| 57 | +# under the terms of the GNU General Public License as published by the |
| 58 | +# Free Software Foundation; either version 3 of the License, or (at your |
| 59 | +# option) any later version. |
| 60 | +# |
| 61 | +# This program is distributed in the hope that it will be useful, but |
| 62 | +# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 63 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
| 64 | +# Public License for more details. |
| 65 | +# |
| 66 | +# You should have received a copy of the GNU General Public License along |
| 67 | +# with this program. If not, see <https://www.gnu.org/licenses/>. |
| 68 | +# |
| 69 | +# As a special exception, the respective Autoconf Macro's copyright owner |
| 70 | +# gives unlimited permission to copy, distribute and modify the configure |
| 71 | +# scripts that are the output of Autoconf when processing the Macro. You |
| 72 | +# need not follow the terms of the GNU General Public License when using |
| 73 | +# or distributing such scripts, even though portions of the text of the |
| 74 | +# Macro appear in them. The GNU General Public License (GPL) does govern |
| 75 | +# all other use of the material that constitutes the Autoconf Macro. |
| 76 | +# |
| 77 | +# This special exception to the GPL applies to versions of the Autoconf |
| 78 | +# Macro released by the Autoconf Archive. When you make and distribute a |
| 79 | +# modified version of the Autoconf Macro, you may extend this special |
| 80 | +# exception to the GPL to apply to your modified version as well. |
| 81 | + |
| 82 | +#serial 25 |
| 83 | + |
| 84 | +AC_DEFUN([AX_FLAGS_WARN_ALL], [ |
| 85 | + AX_REQUIRE_DEFINED([AX_PREPEND_FLAG])dnl |
| 86 | + AC_REQUIRE([AX_COMPILER_VENDOR])dnl |
| 87 | +
|
| 88 | + AS_VAR_PUSHDEF([FLAGS], [m4_default($1,_AC_LANG_PREFIX[]FLAGS)])dnl |
| 89 | + AS_VAR_PUSHDEF([VAR], [ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl |
| 90 | + AS_VAR_PUSHDEF([FOUND], [ac_save_[]_AC_LANG_ABBREV[]flags_warn_all_found])dnl |
| 91 | +
|
| 92 | + AC_CACHE_CHECK([FLAGS for most reasonable warnings], VAR, [ |
| 93 | + VAR="" |
| 94 | + FOUND="yes" |
| 95 | + dnl Cases are listed in the order found in ax_compiler_vendor.m4 |
| 96 | + AS_CASE("$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor", |
| 97 | + [intel], [VAR="-w2"], |
| 98 | + [ibm], [VAR="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"], |
| 99 | + [pathscale], [], |
| 100 | + [clang], [VAR="-Wall"], |
| 101 | + [cray], [VAR="-h msglevel 2"], |
| 102 | + [fujitsu], [], |
| 103 | + [sdcc], [], |
| 104 | + [sx], [VAR="-pvctl[,]fullmsg"], |
| 105 | + [portland], [], |
| 106 | + [gnu], [VAR="-Wall"], |
| 107 | + [sun], [VAR="-v"], |
| 108 | + [hp], [VAR="+w1"], |
| 109 | + [dec], [VAR="-verbose -w0 -warnprotos"], |
| 110 | + [borland], [], |
| 111 | + [comeau], [], |
| 112 | + [kai], [], |
| 113 | + [lcc], [], |
| 114 | + [sgi], [VAR="-fullwarn"], |
| 115 | + [microsoft], [], |
| 116 | + [metrowerks], [], |
| 117 | + [watcom], [], |
| 118 | + [tcc], [], |
| 119 | + [unknown], [ |
| 120 | + VAR="$2" |
| 121 | + FOUND="no" |
| 122 | + ], |
| 123 | + [ |
| 124 | + AC_MSG_WARN([Unknown compiler vendor returned by [AX_COMPILER_VENDOR]]) |
| 125 | + VAR="$2" |
| 126 | + FOUND="no" |
| 127 | + ] |
| 128 | + ) |
| 129 | +
|
| 130 | + AS_IF([test "x$FOUND" = "xyes"], [dnl |
| 131 | + m4_default($3, [AS_IF([test "x$VAR" != "x"], [AX_PREPEND_FLAG([$VAR], [FLAGS])])]) |
| 132 | + ], [dnl |
| 133 | + m4_default($4, [m4_ifval($2, [AX_PREPEND_FLAG([$VAR], [FLAGS])], [true])]) |
| 134 | + ])dnl |
| 135 | + ])dnl |
| 136 | +
|
| 137 | + AS_VAR_POPDEF([FOUND])dnl |
| 138 | + AS_VAR_POPDEF([VAR])dnl |
| 139 | + AS_VAR_POPDEF([FLAGS])dnl |
| 140 | +])dnl AX_FLAGS_WARN_ALL |
| 141 | + |
| 142 | +AC_DEFUN([AX_CFLAGS_WARN_ALL], [dnl |
| 143 | + AC_LANG_PUSH([C]) |
| 144 | + AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) |
| 145 | + AC_LANG_POP([C]) |
| 146 | +])dnl |
| 147 | + |
| 148 | +AC_DEFUN([AX_CXXFLAGS_WARN_ALL], [dnl |
| 149 | + AC_LANG_PUSH([C++]) |
| 150 | + AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) |
| 151 | + AC_LANG_POP([C++]) |
| 152 | +])dnl |
| 153 | + |
| 154 | +AC_DEFUN([AX_FCFLAGS_WARN_ALL], [dnl |
| 155 | + AC_LANG_PUSH([Fortran]) |
| 156 | + AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) |
| 157 | + AC_LANG_POP([Fortran]) |
| 158 | +])dnl |
0 commit comments