[8073852] | 1 | # =========================================================================== |
---|
| 2 | # http://autoconf-archive.cryp.to/ax_cflags_warn_all.html |
---|
| 3 | # =========================================================================== |
---|
| 4 | # |
---|
| 5 | # SYNOPSIS |
---|
| 6 | # |
---|
| 7 | # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] |
---|
| 8 | # |
---|
| 9 | # DESCRIPTION |
---|
| 10 | # |
---|
| 11 | # Try to find a compiler option that enables most reasonable warnings. |
---|
| 12 | # This macro is directly derived from VL_PROG_CC_WARNINGS which is split |
---|
| 13 | # up into two AX_CFLAGS_WARN_ALL and AX_CFLAGS_WARN_ALL_ANSI |
---|
| 14 | # |
---|
| 15 | # For the GNU CC compiler it will be -Wall (and -ansi -pedantic) The |
---|
| 16 | # result is added to the shellvar being CFLAGS by default. |
---|
| 17 | # |
---|
| 18 | # Currently this macro knows about GCC, Solaris C compiler, Digital Unix C |
---|
| 19 | # compiler, C for AIX Compiler, HP-UX C compiler, IRIX C compiler, NEC |
---|
| 20 | # SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos 10.0.0.8) C |
---|
| 21 | # compiler. |
---|
| 22 | # |
---|
| 23 | # - $1 shell-variable-to-add-to : CFLAGS |
---|
| 24 | # - $2 add-value-if-not-found : nothing |
---|
| 25 | # - $3 action-if-found : add value to shellvariable |
---|
| 26 | # - $4 action-if-not-found : nothing |
---|
| 27 | # |
---|
| 28 | # LICENSE |
---|
| 29 | # |
---|
| 30 | # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> |
---|
| 31 | # |
---|
| 32 | # This program is free software; you can redistribute it and/or modify it |
---|
| 33 | # under the terms of the GNU General Public License as published by the |
---|
| 34 | # Free Software Foundation; either version 2 of the License, or (at your |
---|
| 35 | # option) any later version. |
---|
| 36 | # |
---|
| 37 | # This program is distributed in the hope that it will be useful, but |
---|
| 38 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 39 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 40 | # Public License for more details. |
---|
| 41 | # |
---|
| 42 | # You should have received a copy of the GNU General Public License along |
---|
| 43 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 44 | # |
---|
| 45 | # As a special exception, the respective Autoconf Macro's copyright owner |
---|
| 46 | # gives unlimited permission to copy, distribute and modify the configure |
---|
| 47 | # scripts that are the output of Autoconf when processing the Macro. You |
---|
| 48 | # need not follow the terms of the GNU General Public License when using |
---|
| 49 | # or distributing such scripts, even though portions of the text of the |
---|
| 50 | # Macro appear in them. The GNU General Public License (GPL) does govern |
---|
| 51 | # all other use of the material that constitutes the Autoconf Macro. |
---|
| 52 | # |
---|
| 53 | # This special exception to the GPL applies to versions of the Autoconf |
---|
| 54 | # Macro released by the Autoconf Archive. When you make and distribute a |
---|
| 55 | # modified version of the Autoconf Macro, you may extend this special |
---|
| 56 | # exception to the GPL to apply to your modified version as well. |
---|
| 57 | |
---|
| 58 | AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl |
---|
| 59 | AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl |
---|
| 60 | AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl |
---|
| 61 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], |
---|
| 62 | VAR,[VAR="no, unknown" |
---|
| 63 | AC_LANG_SAVE |
---|
| 64 | AC_LANG_C |
---|
| 65 | ac_save_[]FLAGS="$[]FLAGS" |
---|
| 66 | for ac_arg dnl |
---|
| 67 | in "-pedantic % -Wall" dnl GCC |
---|
| 68 | "-xstrconst % -v" dnl Solaris C |
---|
| 69 | "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix |
---|
| 70 | "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX |
---|
| 71 | "-ansi -ansiE % -fullwarn" dnl IRIX |
---|
| 72 | "+ESlit % +w1" dnl HP-UX C |
---|
| 73 | "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) |
---|
| 74 | "-h conform % -h msglevel 2" dnl Cray C (Unicos) |
---|
| 75 | # |
---|
| 76 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` |
---|
| 77 | AC_TRY_COMPILE([],[return 0;], |
---|
| 78 | [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) |
---|
| 79 | done |
---|
| 80 | FLAGS="$ac_save_[]FLAGS" |
---|
| 81 | AC_LANG_RESTORE |
---|
| 82 | ]) |
---|
| 83 | case ".$VAR" in |
---|
| 84 | .ok|.ok,*) m4_ifvaln($3,$3) ;; |
---|
| 85 | .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ |
---|
| 86 | AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) |
---|
| 87 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; |
---|
| 88 | *) m4_ifvaln($3,$3,[ |
---|
| 89 | if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null |
---|
| 90 | then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) |
---|
| 91 | else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) |
---|
| 92 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" |
---|
| 93 | fi ]) ;; |
---|
| 94 | esac |
---|
| 95 | AS_VAR_POPDEF([VAR])dnl |
---|
| 96 | AS_VAR_POPDEF([FLAGS])dnl |
---|
| 97 | ]) |
---|
| 98 | |
---|
| 99 | dnl the only difference - the LANG selection... and the default FLAGS |
---|
| 100 | |
---|
| 101 | AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl |
---|
| 102 | AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl |
---|
| 103 | AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_warn_all])dnl |
---|
| 104 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], |
---|
| 105 | VAR,[VAR="no, unknown" |
---|
| 106 | AC_LANG_SAVE |
---|
| 107 | AC_LANG_CPLUSPLUS |
---|
| 108 | ac_save_[]FLAGS="$[]FLAGS" |
---|
| 109 | for ac_arg dnl |
---|
| 110 | in "-pedantic % -Wall" dnl GCC |
---|
| 111 | "-xstrconst % -v" dnl Solaris C |
---|
| 112 | "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix |
---|
| 113 | "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX |
---|
| 114 | "-ansi -ansiE % -fullwarn" dnl IRIX |
---|
| 115 | "+ESlit % +w1" dnl HP-UX C |
---|
| 116 | "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) |
---|
| 117 | "-h conform % -h msglevel 2" dnl Cray C (Unicos) |
---|
| 118 | # |
---|
| 119 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` |
---|
| 120 | AC_TRY_COMPILE([],[return 0;], |
---|
| 121 | [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) |
---|
| 122 | done |
---|
| 123 | FLAGS="$ac_save_[]FLAGS" |
---|
| 124 | AC_LANG_RESTORE |
---|
| 125 | ]) |
---|
| 126 | case ".$VAR" in |
---|
| 127 | .ok|.ok,*) m4_ifvaln($3,$3) ;; |
---|
| 128 | .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ |
---|
| 129 | AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) |
---|
| 130 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; |
---|
| 131 | *) m4_ifvaln($3,$3,[ |
---|
| 132 | if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null |
---|
| 133 | then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) |
---|
| 134 | else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) |
---|
| 135 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" |
---|
| 136 | fi ]) ;; |
---|
| 137 | esac |
---|
| 138 | AS_VAR_POPDEF([VAR])dnl |
---|
| 139 | AS_VAR_POPDEF([FLAGS])dnl |
---|
| 140 | ]) |
---|
| 141 | |
---|
| 142 | dnl implementation tactics: |
---|
| 143 | dnl the for-argument contains a list of options. The first part of |
---|
| 144 | dnl these does only exist to detect the compiler - usually it is |
---|
| 145 | dnl a global option to enable -ansi or -extrawarnings. All other |
---|
| 146 | dnl compilers will fail about it. That was needed since a lot of |
---|
| 147 | dnl compilers will give false positives for some option-syntax |
---|
| 148 | dnl like -Woption or -Xoption as they think of it is a pass-through |
---|
| 149 | dnl to later compile stages or something. The "%" is used as a |
---|
| 150 | dnl delimimiter. A non-option comment can be given after "%%" marks |
---|
| 151 | dnl which will be shown but not added to the respective C/CXXFLAGS. |
---|