1 dnl /usr/share/aclocal/guidod-cvs/ax_cflags_strict_prototypes.m4
2 dnl @synopsis AX_CFLAGS_STRICT_PROTOTYPES [(shellvar [,default, [A/NA]]
4 dnl Try to find a compiler option that requires strict prototypes.
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
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.
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
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"
35 ac_save_[]FLAGS="$[]FLAGS"
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
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])
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"])
62 FLAGS="$ac_save_[]FLAGS"
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"])]) ;;
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"
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"
90 ac_save_[]FLAGS="$[]FLAGS"
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
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])
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"])
118 FLAGS="$ac_save_[]FLAGS"
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"])]) ;;
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"
133 AS_VAR_POPDEF([VAR])dnl
134 AS_VAR_POPDEF([FLAGS])dnl