1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-12-04 14:46:45 -05:00

Update to an unreleased version of ax_cflags_warn_all.m4

This version of the AX_CFLAGS_WARN_ALL macro uses a far more robust
method of detecting compilers to select appropriate warning flags.  It
also uses the AX_PREPEND_FLAG macro instead of AX_APPEND_FLAG.

This version of ax_cflags_warn_all.m4 (and ax_prepend_flag.m4) has been
submitted upstream; see https://savannah.gnu.org/patch/?9673 for details.
This commit is contained in:
John Zaitseff 2018-08-06 15:21:05 +10:00
parent 5caf1ef165
commit 265ed12de8
2 changed files with 117 additions and 81 deletions

View File

@ -4,33 +4,54 @@
# #
# SYNOPSIS # SYNOPSIS
# #
# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_CFLAGS_WARN_ALL [(shellvar[, default[, action-if-found[, action-if-not-found]]])]
# AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_CXXFLAGS_WARN_ALL [(shellvar[, default[, action-if-found[, action-if-not-found]]])]
# AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_FCFLAGS_WARN_ALL [(shellvar[, default[, action-if-found[, action-if-not-found]]])]
# #
# DESCRIPTION # DESCRIPTION
# #
# Try to find a compiler option that enables most reasonable warnings. # Specify compiler options that enable most reasonable warnings. For the
# GNU Compiler Collection (GCC), for example, it will be "-Wall". The
# result is added to shellvar, one of CFLAGS, CXXFLAGS or FCFLAGS if the
# first parameter is not specified.
# #
# For the GNU compiler it will be -Wall (and -ansi -pedantic) The result # Each of these macros accepts the following optional arguments:
# is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default.
# #
# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, # - $1 - shellvar
# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and # shell variable to use (CFLAGS, CXXFLAGS or FCFLAGS if not
# Intel compilers. For a given compiler, the Fortran flags are much more # specified, depending on macro)
# experimental than their C equivalents.
# #
# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS # - $2 - default
# - $2 add-value-if-not-found : nothing # value to use for flags if compiler vendor cannot be determined (by
# - $3 action-if-found : add value to shellvariable # default, "")
# - $4 action-if-not-found : nothing
# #
# NOTE: These macros depend on AX_APPEND_FLAG. # - $3 - action-if-found
# action to take if the compiler vendor has been successfully
# determined (by default, add the appropriate compiler flags to
# shellvar)
#
# - $4 - action-if-not-found
# action to take if the compiler vendor has not been determined or
# is unknown (by default, add the default flags, or "" if not
# specified, to shellvar)
#
# These macros use AX_COMPILER_VENDOR to determine which flags should be
# returned for a given compiler. Not all compilers currently have flags
# defined for them; patches are welcome. If need be, compiler flags may
# be made language-dependent: use a construct like the following:
#
# [vendor_name], [m4_if(_AC_LANG_PREFIX,[C], VAR="--relevant-c-flags",dnl
# m4_if(_AC_LANG_PREFIX,[CXX], VAR="--relevant-c++-flags",dnl
# m4_if(_AC_LANG_PREFIX,[FC], VAR="--relevant-fortran-flags",dnl
# VAR="$2"; FOUND="no")))],
#
# Note: These macros also depend on AX_PREPEND_FLAG.
# #
# LICENSE # LICENSE
# #
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com> # Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
# Copyright (c) 2018 John Zaitseff <J.Zaitseff@zap.org.au>
# #
# This program is free software; you can redistribute it and/or modify it # This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the # under the terms of the GNU General Public License as published by the
@ -58,65 +79,79 @@
# modified version of the Autoconf Macro, you may extend this special # modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well. # exception to the GPL to apply to your modified version as well.
#serial 16 #serial 17
AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl AC_DEFUN([AX_FLAGS_WARN_ALL], [
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl AX_REQUIRE_DEFINED([AX_PREPEND_FLAG])dnl
AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl AC_REQUIRE([AX_COMPILER_VENDOR])dnl
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
VAR,[VAR="no, unknown" AS_VAR_PUSHDEF([FLAGS], [m4_default($1,_AC_LANG_PREFIX[]FLAGS)])dnl
ac_save_[]FLAGS="$[]FLAGS" AS_VAR_PUSHDEF([VAR], [ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
for ac_arg dnl AS_VAR_PUSHDEF([FOUND], [ac_save_[]_AC_LANG_ABBREV[]flags_warn_all_found])dnl
in "-warn all % -warn all" dnl Intel
"-pedantic % -Wall" dnl GCC AC_CACHE_CHECK([FLAGS for most reasonable warnings], VAR, [
"-xstrconst % -v" dnl Solaris C FOUND="yes"
"-std1 % -verbose -w0 -warnprotos" dnl Digital Unix dnl Cases are listed in the order found in ax_compiler_vendor.m4
"-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX AS_CASE("$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor",
"-ansi -ansiE % -fullwarn" dnl IRIX [intel], [VAR="-w2"],
"+ESlit % +w1" dnl HP-UX C [ibm], [VAR="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"],
"-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) [pathscale], [VAR=""],
"-h conform % -h msglevel 2" dnl Cray C (Unicos) [clang], [VAR="-Wall"],
# [cray], [VAR="-h msglevel 2"],
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` [fujitsu], [VAR=""],
AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [sdcc], [VAR=""],
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) [sx], [VAR="-pvctl[,]fullmsg"],
done [portland], [VAR=""],
FLAGS="$ac_save_[]FLAGS" [gnu], [VAR="-Wall"],
]) [sun], [VAR="-v"],
AS_VAR_POPDEF([FLAGS])dnl [hp], [VAR="+w1"],
AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) [dec], [VAR="-verbose -w0 -warnprotos"],
case ".$VAR" in [borland], [VAR=""],
.ok|.ok,*) m4_ifvaln($3,$3) ;; [comeau], [VAR=""],
.|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; [kai], [VAR=""],
*) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; [lcc], [VAR=""],
esac [sgi], [VAR="-fullwarn"],
AS_VAR_POPDEF([VAR])dnl [microsoft], [VAR=""],
[metrowerks], [VAR=""],
[watcom], [VAR=""],
[tcc], [VAR=""],
[unknown], [
VAR="$2"
FOUND="no"
],
[
AC_MSG_WARN([Unknown compiler vendor returned by [AX_COMPILER_VENDOR]])
VAR="$2"
FOUND="no"
]
)
AS_IF([test "x$FOUND" = "xyes"], [dnl
m4_default($3, [AX_PREPEND_FLAG([$VAR], [FLAGS])])
], [dnl
m4_default($4, [m4_ifval($2, [AX_PREPEND_FLAG([$VAR], [FLAGS])], [true])])
])dnl
])dnl
AS_VAR_POPDEF([FOUND])dnl
AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
])dnl AX_FLAGS_WARN_ALL ])dnl AX_FLAGS_WARN_ALL
dnl implementation tactics:
dnl the for-argument contains a list of options. The first part of
dnl these does only exist to detect the compiler - usually it is
dnl a global option to enable -ansi or -extrawarnings. All other
dnl compilers will fail about it. That was needed since a lot of
dnl compilers will give false positives for some option-syntax
dnl like -Woption or -Xoption as they think of it is a pass-through
dnl to later compile stages or something. The "%" is used as a
dnl delimiter. A non-option comment can be given after "%%" marks
dnl which will be shown but not added to the respective C/CXXFLAGS.
AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl AC_DEFUN([AX_CFLAGS_WARN_ALL], [dnl
AC_LANG_PUSH([C]) AC_LANG_PUSH([C])
AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
AC_LANG_POP([C]) AC_LANG_POP([C])
]) ])dnl
AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl AC_DEFUN([AX_CXXFLAGS_WARN_ALL], [dnl
AC_LANG_PUSH([C++]) AC_LANG_PUSH([C++])
AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
AC_LANG_POP([C++]) AC_LANG_POP([C++])
]) ])dnl
AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl AC_DEFUN([AX_FCFLAGS_WARN_ALL], [dnl
AC_LANG_PUSH([Fortran]) AC_LANG_PUSH([Fortran])
AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
AC_LANG_POP([Fortran]) AC_LANG_POP([Fortran])
]) ])dnl

View File

@ -1,36 +1,37 @@
# =========================================================================== # ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html # https://www.gnu.org/software/autoconf-archive/ax_prepend_flag.html
# =========================================================================== # ===========================================================================
# #
# SYNOPSIS # SYNOPSIS
# #
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) # AX_PREPEND_FLAG(FLAG, [FLAGS-VARIABLE])
# #
# DESCRIPTION # DESCRIPTION
# #
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space # FLAG is added to the front of the FLAGS-VARIABLE shell variable, with a
# added in between. # space added in between.
# #
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. # If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
# FLAG. # FLAG.
# #
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. # NOTE: Implementation based on AX_APPEND_FLAG.
# #
# LICENSE # LICENSE
# #
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
# Copyright (c) 2018 John Zaitseff <J.Zaitseff@zap.org.au>
# #
# Copying and distribution of this file, with or without modification, are # Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice # permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any # and this notice are preserved. This file is offered as-is, without any
# warranty. # warranty.
#serial 8 #serial 1
AC_DEFUN([AX_APPEND_FLAG], AC_DEFUN([AX_PREPEND_FLAG],
[dnl [dnl
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
@ -38,7 +39,7 @@ AS_VAR_SET_IF(FLAGS,[
AS_CASE([" AS_VAR_GET(FLAGS) "], AS_CASE([" AS_VAR_GET(FLAGS) "],
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
[ [
AS_VAR_APPEND(FLAGS,[" $1"]) FLAGS="$1 $FLAGS"
AC_RUN_LOG([: FLAGS="$FLAGS"]) AC_RUN_LOG([: FLAGS="$FLAGS"])
]) ])
], ],
@ -47,4 +48,4 @@ AS_VAR_SET_IF(FLAGS,[
AC_RUN_LOG([: FLAGS="$FLAGS"]) AC_RUN_LOG([: FLAGS="$FLAGS"])
]) ])
AS_VAR_POPDEF([FLAGS])dnl AS_VAR_POPDEF([FLAGS])dnl
])dnl AX_APPEND_FLAG ])dnl AX_PREPEND_FLAG