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