[8073852] | 1 | # =========================================================================== |
---|
[378ede7] | 2 | # http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html |
---|
[8073852] | 3 | # =========================================================================== |
---|
| 4 | # |
---|
| 5 | # SYNOPSIS |
---|
| 6 | # |
---|
[378ede7] | 7 | # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] |
---|
| 8 | # AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] |
---|
| 9 | # AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] |
---|
[8073852] | 10 | # |
---|
| 11 | # DESCRIPTION |
---|
| 12 | # |
---|
| 13 | # Try to find a compiler option that enables most reasonable warnings. |
---|
| 14 | # |
---|
[378ede7] | 15 | # For the GNU compiler it will be -Wall (and -ansi -pedantic) The result |
---|
| 16 | # is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. |
---|
[8073852] | 17 | # |
---|
[378ede7] | 18 | # Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, |
---|
| 19 | # HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and |
---|
| 20 | # Intel compilers. For a given compiler, the Fortran flags are much more |
---|
| 21 | # experimental than their C equivalents. |
---|
[8073852] | 22 | # |
---|
[378ede7] | 23 | # - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS |
---|
[8073852] | 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> |
---|
[378ede7] | 31 | # Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com> |
---|
[8073852] | 32 | # |
---|
| 33 | # This program is free software; you can redistribute it and/or modify it |
---|
| 34 | # under the terms of the GNU General Public License as published by the |
---|
[378ede7] | 35 | # Free Software Foundation; either version 3 of the License, or (at your |
---|
[8073852] | 36 | # option) any later version. |
---|
| 37 | # |
---|
| 38 | # This program is distributed in the hope that it will be useful, but |
---|
| 39 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 40 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 41 | # Public License for more details. |
---|
| 42 | # |
---|
| 43 | # You should have received a copy of the GNU General Public License along |
---|
| 44 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 45 | # |
---|
| 46 | # As a special exception, the respective Autoconf Macro's copyright owner |
---|
| 47 | # gives unlimited permission to copy, distribute and modify the configure |
---|
| 48 | # scripts that are the output of Autoconf when processing the Macro. You |
---|
| 49 | # need not follow the terms of the GNU General Public License when using |
---|
| 50 | # or distributing such scripts, even though portions of the text of the |
---|
| 51 | # Macro appear in them. The GNU General Public License (GPL) does govern |
---|
| 52 | # all other use of the material that constitutes the Autoconf Macro. |
---|
| 53 | # |
---|
| 54 | # This special exception to the GPL applies to versions of the Autoconf |
---|
| 55 | # Macro released by the Autoconf Archive. When you make and distribute a |
---|
| 56 | # modified version of the Autoconf Macro, you may extend this special |
---|
| 57 | # exception to the GPL to apply to your modified version as well. |
---|
| 58 | |
---|
[378ede7] | 59 | #serial 10 |
---|
| 60 | |
---|
[8073852] | 61 | AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl |
---|
| 62 | AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl |
---|
| 63 | AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl |
---|
| 64 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], |
---|
| 65 | VAR,[VAR="no, unknown" |
---|
[378ede7] | 66 | AC_LANG_PUSH([C]) |
---|
[8073852] | 67 | ac_save_[]FLAGS="$[]FLAGS" |
---|
| 68 | for ac_arg dnl |
---|
| 69 | in "-pedantic % -Wall" dnl GCC |
---|
| 70 | "-xstrconst % -v" dnl Solaris C |
---|
| 71 | "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix |
---|
| 72 | "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX |
---|
| 73 | "-ansi -ansiE % -fullwarn" dnl IRIX |
---|
| 74 | "+ESlit % +w1" dnl HP-UX C |
---|
| 75 | "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) |
---|
| 76 | "-h conform % -h msglevel 2" dnl Cray C (Unicos) |
---|
| 77 | # |
---|
| 78 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` |
---|
[378ede7] | 79 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM], |
---|
| 80 | [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) |
---|
[8073852] | 81 | done |
---|
| 82 | FLAGS="$ac_save_[]FLAGS" |
---|
[378ede7] | 83 | AC_LANG_POP([C]) |
---|
[8073852] | 84 | ]) |
---|
| 85 | case ".$VAR" in |
---|
| 86 | .ok|.ok,*) m4_ifvaln($3,$3) ;; |
---|
| 87 | .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ |
---|
| 88 | AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) |
---|
| 89 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; |
---|
| 90 | *) m4_ifvaln($3,$3,[ |
---|
| 91 | if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null |
---|
| 92 | then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) |
---|
| 93 | else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) |
---|
| 94 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" |
---|
| 95 | fi ]) ;; |
---|
| 96 | esac |
---|
| 97 | AS_VAR_POPDEF([VAR])dnl |
---|
| 98 | AS_VAR_POPDEF([FLAGS])dnl |
---|
| 99 | ]) |
---|
| 100 | |
---|
| 101 | dnl the only difference - the LANG selection... and the default FLAGS |
---|
| 102 | |
---|
| 103 | AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl |
---|
| 104 | AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl |
---|
[378ede7] | 105 | AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl |
---|
[8073852] | 106 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], |
---|
| 107 | VAR,[VAR="no, unknown" |
---|
[378ede7] | 108 | AC_LANG_PUSH([C++]) |
---|
[8073852] | 109 | ac_save_[]FLAGS="$[]FLAGS" |
---|
| 110 | for ac_arg dnl |
---|
| 111 | in "-pedantic % -Wall" dnl GCC |
---|
| 112 | "-xstrconst % -v" dnl Solaris C |
---|
| 113 | "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix |
---|
| 114 | "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX |
---|
| 115 | "-ansi -ansiE % -fullwarn" dnl IRIX |
---|
| 116 | "+ESlit % +w1" dnl HP-UX C |
---|
| 117 | "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) |
---|
| 118 | "-h conform % -h msglevel 2" dnl Cray C (Unicos) |
---|
| 119 | # |
---|
| 120 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` |
---|
[378ede7] | 121 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM], |
---|
| 122 | [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) |
---|
| 123 | done |
---|
| 124 | FLAGS="$ac_save_[]FLAGS" |
---|
| 125 | AC_LANG_POP([C++]) |
---|
| 126 | ]) |
---|
| 127 | case ".$VAR" in |
---|
| 128 | .ok|.ok,*) m4_ifvaln($3,$3) ;; |
---|
| 129 | .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ |
---|
| 130 | AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) |
---|
| 131 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; |
---|
| 132 | *) m4_ifvaln($3,$3,[ |
---|
| 133 | if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null |
---|
| 134 | then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) |
---|
| 135 | else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) |
---|
| 136 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" |
---|
| 137 | fi ]) ;; |
---|
| 138 | esac |
---|
| 139 | AS_VAR_POPDEF([VAR])dnl |
---|
| 140 | AS_VAR_POPDEF([FLAGS])dnl |
---|
| 141 | ]) |
---|
| 142 | |
---|
| 143 | dnl the only difference - the LANG selection... and the default FLAGS |
---|
| 144 | |
---|
| 145 | AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl |
---|
| 146 | AS_VAR_PUSHDEF([FLAGS],[FCFLAGS])dnl |
---|
| 147 | AS_VAR_PUSHDEF([VAR],[ax_cv_fcflags_warn_all])dnl |
---|
| 148 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], |
---|
| 149 | VAR,[VAR="no, unknown" |
---|
| 150 | AC_LANG_PUSH([Fortran]) |
---|
| 151 | ac_save_[]FLAGS="$[]FLAGS" |
---|
| 152 | for ac_arg dnl |
---|
| 153 | in "-warn all % -warn all" dnl Intel |
---|
| 154 | "-pedantic % -Wall" dnl GCC |
---|
| 155 | "-xstrconst % -v" dnl Solaris C |
---|
| 156 | "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix |
---|
| 157 | "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX |
---|
| 158 | "-ansi -ansiE % -fullwarn" dnl IRIX |
---|
| 159 | "+ESlit % +w1" dnl HP-UX C |
---|
| 160 | "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) |
---|
| 161 | "-h conform % -h msglevel 2" dnl Cray C (Unicos) |
---|
| 162 | # |
---|
| 163 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` |
---|
| 164 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM], |
---|
| 165 | [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) |
---|
[8073852] | 166 | done |
---|
| 167 | FLAGS="$ac_save_[]FLAGS" |
---|
[378ede7] | 168 | AC_LANG_POP([Fortran]) |
---|
[8073852] | 169 | ]) |
---|
| 170 | case ".$VAR" in |
---|
| 171 | .ok|.ok,*) m4_ifvaln($3,$3) ;; |
---|
| 172 | .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ |
---|
| 173 | AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) |
---|
| 174 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; |
---|
| 175 | *) m4_ifvaln($3,$3,[ |
---|
| 176 | if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null |
---|
| 177 | then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) |
---|
| 178 | else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) |
---|
| 179 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" |
---|
| 180 | fi ]) ;; |
---|
| 181 | esac |
---|
| 182 | AS_VAR_POPDEF([VAR])dnl |
---|
| 183 | AS_VAR_POPDEF([FLAGS])dnl |
---|
| 184 | ]) |
---|
| 185 | |
---|
| 186 | dnl implementation tactics: |
---|
| 187 | dnl the for-argument contains a list of options. The first part of |
---|
| 188 | dnl these does only exist to detect the compiler - usually it is |
---|
| 189 | dnl a global option to enable -ansi or -extrawarnings. All other |
---|
| 190 | dnl compilers will fail about it. That was needed since a lot of |
---|
| 191 | dnl compilers will give false positives for some option-syntax |
---|
| 192 | dnl like -Woption or -Xoption as they think of it is a pass-through |
---|
| 193 | dnl to later compile stages or something. The "%" is used as a |
---|
[378ede7] | 194 | dnl delimiter. A non-option comment can be given after "%%" marks |
---|
[8073852] | 195 | dnl which will be shown but not added to the respective C/CXXFLAGS. |
---|