source: m4/ax_cflags_strict_prototypes.m4 @ 5934b87

release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 5934b87 was de8945b, checked in by Anders Kaseorg <andersk@mit.edu>, 15 years ago
Require strict prototypes. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Property mode set to 100644
File size: 6.7 KB
Line 
1# ===========================================================================
2#      http://autoconf-archive.cryp.to/ax_cflags_strict_prototypes.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_CFLAGS_STRICT_PROTOTYPES [(shellvar [,default, [A/NA]]
8#
9# DESCRIPTION
10#
11#   Try to find a compiler option that requires strict prototypes.
12#
13#   The sanity check is done by looking at sys/signal.h which has a set of
14#   macro-definitions SIG_DFL and SIG_IGN that are cast to the local
15#   signal-handler type. If that signal-handler type is not fully qualified
16#   then the system headers are not seen as strictly prototype clean.
17#
18#   For the GNU CC compiler it will be -fstrict-prototypes
19#   -Wstrict-prototypes The result is added to the shellvar being CFLAGS by
20#   default.
21#
22#   DEFAULTS:
23#
24#    - $1 shell-variable-to-add-to : CFLAGS
25#    - $2 add-value-if-not-found : nothing
26#    - $3 action-if-found : add value to shellvariable
27#    - $4 action-if-not-found : nothing
28#
29# LICENSE
30#
31#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
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
35#   Free Software Foundation; either version 2 of the License, or (at your
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
59AC_DEFUN([AX_CFLAGS_STRICT_PROTOTYPES],[dnl
60AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
61AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_strict_prototypes])dnl
62AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for strict prototypes],
63VAR,[VAR="no, unknown"
64 AC_LANG_SAVE
65 AC_LANG_C
66 ac_save_[]FLAGS="$[]FLAGS"
67for ac_arg dnl
68in "-pedantic % -fstrict-prototypes -Wstrict-prototypes" dnl   GCC
69   "-pedantic % -Wstrict-prototypes" dnl try to warn atleast
70   "-pedantic % -Wmissing-prototypes" dnl or another warning
71   "-pedantic % -Werror-implicit-function-declaration" dnl
72   "-pedantic % -Wimplicit-function-declaration" dnl
73   #
74do 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])
77done
78case ".$VAR" in
79   .|.no|.no,*) ;;
80   *) # sanity check with signal() from sys/signal.h
81    cp config.log config.tmp
82    AC_TRY_COMPILE([#include <signal.h>],[
83    if (signal (SIGINT, SIG_IGN) == SIG_DFL) return 1;
84    if (signal (SIGINT, SIG_IGN) != SIG_DFL) return 2;],
85    dnl the original did use test -n `$CC testprogram.c`
86    [if test `diff config.log config.tmp | grep -i warning | wc -l` != 0
87then if test `diff config.log config.tmp | grep -i warning | wc -l` != 1
88then VAR="no, suppressed, signal.h," ; fi ; fi],
89    [VAR="no, suppressed, signal.h"])
90    rm config.tmp
91  ;;
92esac
93 FLAGS="$ac_save_[]FLAGS"
94 AC_LANG_RESTORE
95])
96case ".$VAR" in
97     .ok|.ok,*) m4_ifvaln($3,$3) ;;
98   .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
99        AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
100                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
101   *) m4_ifvaln($3,$3,[
102   if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
103   then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
104   else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
105                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
106   fi ]) ;;
107esac
108AS_VAR_POPDEF([VAR])dnl
109AS_VAR_POPDEF([FLAGS])dnl
110])
111
112dnl the only difference - the LANG selection... and the default FLAGS
113
114AC_DEFUN([AX_CXXFLAGS_STRICT_PROTOTYPES],[dnl
115AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
116AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_strict_prototypes])dnl
117AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for strict prototypes],
118VAR,[VAR="no, unknown"
119 AC_LANG_SAVE
120 AC_LANG_CPLUSPLUS
121 ac_save_[]FLAGS="$[]FLAGS"
122for ac_arg dnl
123in "-pedantic -Werror % -fstrict-prototypes -Wstrict-prototypes" dnl   GCC
124   "-pedantic -Werror % -Wstrict-prototypes" dnl try to warn atleast
125   "-pedantic -Werror % -Wmissing-prototypes" dnl try to warn atleast
126   "-pedantic -Werror % -Werror-implicit-function-declaration" dnl
127   "-pedantic -Werror % -Wimplicit-function-declaration" dnl
128   "-pedantic % -Wstrict-prototypes %% no, unsupported in C++" dnl oops
129   #
130do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
131   AC_TRY_COMPILE([],[return 0;],
132   [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
133done
134case ".$VAR" in
135   .|.no|.no,*) ;;
136   *) # sanity check with signal() from sys/signal.h
137    cp config.log config.tmp
138    AC_TRY_COMPILE([#include <signal.h>],[
139    if (signal (SIGINT, SIG_IGN) == SIG_DFL) return 1;
140    if (signal (SIGINT, SIG_IGN) != SIG_DFL) return 2;],
141    dnl the original did use test -n `$CC testprogram.c`
142    [if test `diff config.log config.tmp | grep -i warning | wc -l` != 0
143then if test `diff config.log config.tmp | grep -i warning | wc -l` != 1
144then VAR="no, suppressed, signal.h," ; fi ; fi],
145    [VAR="no, suppressed, signal.h"])
146    rm config.tmp
147  ;;
148esac
149 FLAGS="$ac_save_[]FLAGS"
150 AC_LANG_RESTORE
151])
152case ".$VAR" in
153     .ok|.ok,*) m4_ifvaln($3,$3) ;;
154   .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
155        AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
156                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
157   *) m4_ifvaln($3,$3,[
158   if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
159   then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
160   else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
161                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
162   fi ]) ;;
163esac
164AS_VAR_POPDEF([VAR])dnl
165AS_VAR_POPDEF([FLAGS])dnl
166])
Note: See TracBrowser for help on using the repository browser.