beta-0.89.2
[luatex.git] / source / libs / zziplib / zziplib-0.13.62 / m4 / ax_cflags_strict_prototypes.m4
blobbd19c17962bb12d95a999d30661f94fd4c7bc798
1 dnl /usr/share/aclocal/guidod-cvs/ax_cflags_strict_prototypes.m4
2 dnl @synopsis AX_CFLAGS_STRICT_PROTOTYPES [(shellvar [,default, [A/NA]]
3 dnl
4 dnl Try to find a compiler option that requires strict prototypes.
5 dnl
6 dnl The sanity check is done by looking at sys/signal.h which has a set
7 dnl of macro-definitions SIG_DFL and SIG_IGN that are cast to the local
8 dnl signal-handler type. If that signal-handler type is not fully
9 dnl qualified then the system headers are not seen as strictly
10 dnl prototype clean.
11 dnl
12 dnl For the GNU CC compiler it will be -fstrict-prototypes
13 dnl -Wstrict-prototypes The result is added to the shellvar being
14 dnl CFLAGS by default.
15 dnl
16 dnl DEFAULTS:
17 dnl
18 dnl  - $1 shell-variable-to-add-to : CFLAGS
19 dnl  - $2 add-value-if-not-found : nothing
20 dnl  - $3 action-if-found : add value to shellvariable
21 dnl  - $4 action-if-not-found : nothing
22 dnl
23 dnl @category C
24 dnl @author Guido U. Draheim <guidod@gmx.de>
25 dnl @version 2006-12-12
26 dnl @license GPLWithACException
28 AC_DEFUN([AX_CFLAGS_STRICT_PROTOTYPES],[dnl
29 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
30 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_strict_prototypes])dnl
31 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for strict prototypes],
32 VAR,[VAR="no, unknown"
33  AC_LANG_SAVE
34  AC_LANG_C
35  ac_save_[]FLAGS="$[]FLAGS"
36 for ac_arg dnl
37 in "-pedantic % -fstrict-prototypes -Wstrict-prototypes" dnl   GCC
38    "-pedantic % -Wstrict-prototypes" dnl try to warn atleast
39    "-pedantic % -Wmissing-prototypes" dnl or another warning
40    "-pedantic % -Werror-implicit-function-declaration" dnl
41    "-pedantic % -Wimplicit-function-declaration" dnl
42    #
43 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
44    AC_TRY_COMPILE([],[return 0;],
45    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
46 done
47 case ".$VAR" in
48    .|.no|.no,*) ;;
49    *) # sanity check with signal() from sys/signal.h
50     cp config.log config.tmp
51     AC_TRY_COMPILE([#include <signal.h>],[
52     if (signal (SIGINT, SIG_IGN) == SIG_DFL) return 1;
53     if (signal (SIGINT, SIG_IGN) != SIG_DFL) return 2;],
54     dnl the original did use test -n `$CC testprogram.c`
55     [if test `diff config.log config.tmp | grep -i warning | wc -l` != 0
56 then if test `diff config.log config.tmp | grep -i warning | wc -l` != 1
57 then VAR="no, suppressed, signal.h," ; fi ; fi],
58     [VAR="no, suppressed, signal.h"])
59     rm config.tmp
60   ;;
61 esac
62  FLAGS="$ac_save_[]FLAGS"
63  AC_LANG_RESTORE
65 case ".$VAR" in
66      .ok|.ok,*) m4_ifvaln($3,$3) ;;
67    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
68         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
69                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
70    *) m4_ifvaln($3,$3,[
71    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
72    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
73    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
74                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
75    fi ]) ;;
76 esac
77 AS_VAR_POPDEF([VAR])dnl
78 AS_VAR_POPDEF([FLAGS])dnl
81 dnl the only difference - the LANG selection... and the default FLAGS
83 AC_DEFUN([AX_CXXFLAGS_STRICT_PROTOTYPES],[dnl
84 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
85 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_strict_prototypes])dnl
86 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for strict prototypes],
87 VAR,[VAR="no, unknown"
88  AC_LANG_SAVE
89  AC_LANG_CPLUSPLUS
90  ac_save_[]FLAGS="$[]FLAGS"
91 for ac_arg dnl
92 in "-pedantic -Werror % -fstrict-prototypes -Wstrict-prototypes" dnl   GCC
93    "-pedantic -Werror % -Wstrict-prototypes" dnl try to warn atleast
94    "-pedantic -Werror % -Wmissing-prototypes" dnl try to warn atleast
95    "-pedantic -Werror % -Werror-implicit-function-declaration" dnl
96    "-pedantic -Werror % -Wimplicit-function-declaration" dnl
97    "-pedantic % -Wstrict-prototypes %% no, unsupported in C++" dnl oops
98    #
99 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
100    AC_TRY_COMPILE([],[return 0;],
101    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
102 done
103 case ".$VAR" in
104    .|.no|.no,*) ;;
105    *) # sanity check with signal() from sys/signal.h
106     cp config.log config.tmp
107     AC_TRY_COMPILE([#include <signal.h>],[
108     if (signal (SIGINT, SIG_IGN) == SIG_DFL) return 1;
109     if (signal (SIGINT, SIG_IGN) != SIG_DFL) return 2;],
110     dnl the original did use test -n `$CC testprogram.c`
111     [if test `diff config.log config.tmp | grep -i warning | wc -l` != 0
112 then if test `diff config.log config.tmp | grep -i warning | wc -l` != 1
113 then VAR="no, suppressed, signal.h," ; fi ; fi],
114     [VAR="no, suppressed, signal.h"])
115     rm config.tmp
116   ;;
117 esac
118  FLAGS="$ac_save_[]FLAGS"
119  AC_LANG_RESTORE
121 case ".$VAR" in
122      .ok|.ok,*) m4_ifvaln($3,$3) ;;
123    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
124         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
125                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
126    *) m4_ifvaln($3,$3,[
127    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
128    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
129    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
130                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
131    fi ]) ;;
132 esac
133 AS_VAR_POPDEF([VAR])dnl
134 AS_VAR_POPDEF([FLAGS])dnl