beta-0.89.2
[luatex.git] / source / libs / zziplib / zziplib-0.13.62 / m4 / ax_cflags_warn_all.m4
blob15b3f3948140d6bc4f9ba5842bb3ce594282752c
1 dnl /usr/share/aclocal/guidod-cvs/ax_cflags_warn_all.m4
2 dnl @synopsis AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
3 dnl
4 dnl Try to find a compiler option that enables most reasonable
5 dnl warnings. This macro is directly derived from VL_PROG_CC_WARNINGS
6 dnl which is split up into two AX_CFLAGS_WARN_ALL and
7 dnl AX_CFLAGS_WARN_ALL_ANSI
8 dnl
9 dnl For the GNU CC compiler it will be -Wall (and -ansi -pedantic) The
10 dnl result is added to the shellvar being CFLAGS by default.
11 dnl
12 dnl Currently this macro knows about GCC, Solaris C compiler, Digital
13 dnl Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C
14 dnl compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos
15 dnl 10.0.0.8) C compiler.
16 dnl
17 dnl  - $1 shell-variable-to-add-to : CFLAGS
18 dnl  - $2 add-value-if-not-found : nothing
19 dnl  - $3 action-if-found : add value to shellvariable
20 dnl  - $4 action-if-not-found : nothing
21 dnl
22 dnl @category C
23 dnl @author Guido U. Draheim <guidod@gmx.de>
24 dnl @version 2006-12-12
25 dnl @license GPLWithACException
27 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
28 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
29 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl
30 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
31 VAR,[VAR="no, unknown"
32  AC_LANG_SAVE
33  AC_LANG_C
34  ac_save_[]FLAGS="$[]FLAGS"
35 for ac_arg dnl
36 in "-pedantic  % -Wall"       dnl   GCC
37    "-xstrconst % -v"          dnl Solaris C
38    "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
39    "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
40    "-ansi -ansiE % -fullwarn" dnl IRIX
41    "+ESlit     % +w1"         dnl HP-UX C
42    "-Xc        % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
43    "-h conform % -h msglevel 2" dnl Cray C (Unicos)
44    #
45 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
46    AC_TRY_COMPILE([],[return 0;],
47    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
48 done
49  FLAGS="$ac_save_[]FLAGS"
50  AC_LANG_RESTORE
52 case ".$VAR" in
53      .ok|.ok,*) m4_ifvaln($3,$3) ;;
54    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
55         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
56                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
57    *) m4_ifvaln($3,$3,[
58    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
59    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
60    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
61                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
62    fi ]) ;;
63 esac
64 AS_VAR_POPDEF([VAR])dnl
65 AS_VAR_POPDEF([FLAGS])dnl
68 dnl the only difference - the LANG selection... and the default FLAGS
70 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
71 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
72 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_warn_all])dnl
73 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
74 VAR,[VAR="no, unknown"
75  AC_LANG_SAVE
76  AC_LANG_CPLUSPLUS
77  ac_save_[]FLAGS="$[]FLAGS"
78 for ac_arg dnl
79 in "-pedantic  % -Wall"       dnl   GCC
80    "-xstrconst % -v"          dnl Solaris C
81    "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
82    "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
83    "-ansi -ansiE % -fullwarn" dnl IRIX
84    "+ESlit     % +w1"         dnl HP-UX C
85    "-Xc        % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
86    "-h conform % -h msglevel 2" dnl Cray C (Unicos)
87    #
88 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
89    AC_TRY_COMPILE([],[return 0;],
90    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
91 done
92  FLAGS="$ac_save_[]FLAGS"
93  AC_LANG_RESTORE
95 case ".$VAR" in
96      .ok|.ok,*) m4_ifvaln($3,$3) ;;
97    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
98         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
99                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
100    *) m4_ifvaln($3,$3,[
101    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
102    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
103    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
104                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
105    fi ]) ;;
106 esac
107 AS_VAR_POPDEF([VAR])dnl
108 AS_VAR_POPDEF([FLAGS])dnl
111 dnl  implementation tactics:
112 dnl   the for-argument contains a list of options. The first part of
113 dnl   these does only exist to detect the compiler - usually it is
114 dnl   a global option to enable -ansi or -extrawarnings. All other
115 dnl   compilers will fail about it. That was needed since a lot of
116 dnl   compilers will give false positives for some option-syntax
117 dnl   like -Woption or -Xoption as they think of it is a pass-through
118 dnl   to later compile stages or something. The "%" is used as a
119 dnl   delimimiter. A non-option comment can be given after "%%" marks
120 dnl   which will be shown but not added to the respective C/CXXFLAGS.