1 # ===========================================================================
2 # https://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
3 # ===========================================================================
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]]])]
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.
18 # Each of these macros accepts the following optional arguments:
21 # shell variable to use (CFLAGS, CXXFLAGS or FCFLAGS if not
22 # specified, depending on macro)
25 # value to use for flags if compiler vendor cannot be determined (by
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
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)
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:
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")))],
48 # Note: These macros also depend on AX_PREPEND_FLAG.
52 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
53 # Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
54 # Copyright (c) 2018 John Zaitseff <J.Zaitseff@zap.org.au>
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.
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.
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/>.
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.
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.
84 AC_DEFUN([AX_FLAGS_WARN_ALL], [
85 AX_REQUIRE_DEFINED([AX_PREPEND_FLAG])dnl
86 AC_REQUIRE([AX_COMPILER_VENDOR])dnl
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
92 AC_CACHE_CHECK([FLAGS for most reasonable warnings], VAR, [
95 dnl Cases are listed in the order found in ax_compiler_vendor.m4
96 AS_CASE("$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor",
98 [ibm], [VAR="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"],
100 [clang], [VAR="-Wall"],
101 [cray], [VAR="-h msglevel 2"],
104 [sx], [VAR="-pvctl[,]fullmsg"],
106 [gnu], [VAR="-Wall"],
109 [dec], [VAR="-verbose -w0 -warnprotos"],
114 [sgi], [VAR="-fullwarn"],
124 AC_MSG_WARN([Unknown compiler vendor returned by [AX_COMPILER_VENDOR]])
130 AS_IF([test "x$FOUND" = "xyes"], [dnl
131 m4_default($3, [AS_IF([test "x$VAR" != "x"], [AX_PREPEND_FLAG([$VAR], [FLAGS])])])
133 m4_default($4, [m4_ifval($2, [AX_PREPEND_FLAG([$VAR], [FLAGS])], [true])])
137 AS_VAR_POPDEF([FOUND])dnl
138 AS_VAR_POPDEF([VAR])dnl
139 AS_VAR_POPDEF([FLAGS])dnl
140 ])dnl AX_FLAGS_WARN_ALL
142 AC_DEFUN([AX_CFLAGS_WARN_ALL], [dnl
144 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
148 AC_DEFUN([AX_CXXFLAGS_WARN_ALL], [dnl
150 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
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])