1 dnl -----------------------------------------------------------------------
3 dnl Copyright 1999-2008 H. Peter Anvin - All Rights Reserved
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 dnl Bostom MA 02111-1307, USA; either version 2 of the License, or
9 dnl (at your option) any later version; incorporated herein by reference.
11 dnl -----------------------------------------------------------------------
13 dnl --------------------------------------------------------------------------
16 dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation
17 dnl --------------------------------------------------------------------------
18 AC_DEFUN(PA_ADD_CFLAGS,
19 [AC_MSG_CHECKING([if $CC accepts $1])
20 pa_add_cflags__old_cflags="$CFLAGS"
22 AC_TRY_LINK([#include <stdio.h>],
23 [printf("Hello, World!\n");],
26 CFLAGS="$pa_add_cflags__old_cflags")])
28 dnl --------------------------------------------------------------------------
31 dnl Do we have sigsetjmp/siglongjmp? (AC_CHECK_FUNCS doesn't seem to work
32 dnl for these particular functions.)
33 dnl --------------------------------------------------------------------------
34 AC_DEFUN(PA_SIGSETJMP,
35 [AC_MSG_CHECKING([for sigsetjmp])
48 dnl --------------------------------------------------------------------------
49 dnl PA_MSGHDR_MSG_CONTROL
51 dnl Does struct msghdr have the msg_control field?
52 dnl --------------------------------------------------------------------------
53 AH_TEMPLATE([HAVE_MSGHDR_MSG_CONTROL],
54 [Define if struct msghdr has the msg_control field.])
56 AC_DEFUN(PA_MSGHDR_MSG_CONTROL,
57 [AC_CHECK_MEMBER(struct msghdr.msg_control,
58 [AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL)],
61 #include <sys/types.h>
62 #include <sys/socket.h>
63 #include <netinet/in.h>
66 dnl ------------------------------------------------------------------------
67 dnl PA_STRUCT_IN_PKTINFO
69 dnl Look for definition of struct in_pktinfo, which at least has an
70 dnl ipi_addr member. Some versions of glibc lack struct in_pktinfo;
71 dnl if so we need to include the definition ourselves -- but we only
72 dnl want to do that if absolutely necessary!
73 dnl ------------------------------------------------------------------------
74 AH_TEMPLATE([HAVE_STRUCT_IN_PKTINFO],
75 [Define if struct in_pktinfo is defined.])
77 AC_DEFUN(PA_STRUCT_IN_PKTINFO,
78 [AC_CHECK_MEMBER(struct in_pktinfo.ipi_addr,
79 [AC_DEFINE(HAVE_STRUCT_IN_PKTINFO)],
82 #include <sys/types.h>
83 #include <sys/socket.h>
84 #include <netinet/in.h>
85 #include <arpa/inet.h>
91 dnl ------------------------------------------------------------------------
92 dnl PA_STRUCT_SOCKADDR_IN6
94 dnl Look for definition of struct sockaddr_in6, which at least has an
97 AH_TEMPLATE([HAVE_STRUCT_SOCKADDR_IN6],
98 [Define if struct sockaddr_in6 is defined.])
100 AC_DEFUN(PA_STRUCT_SOCKADDR_IN6,
101 [AC_CHECK_MEMBER(struct sockaddr_in6.sin6_addr,
103 AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
110 #include <sys/types.h>
111 #include <sys/socket.h>
112 #include <netinet/in.h>
113 #include <arpa/inet.h>
116 dnl ------------------------------------------------------------------------
117 dnl PA_STRUCT_ADDRINFO
119 dnl Look for definition of struct addrinfo, which at least has an
122 AH_TEMPLATE([HAVE_STRUCT_ADDRINFO],
123 [Define if struct addrinfo is defined.])
125 AC_DEFUN(PA_STRUCT_ADDRINFO,
126 [AC_CHECK_MEMBER(struct addrinfo.ai_addr,
127 [AC_DEFINE(HAVE_STRUCT_ADDRINFO)],
130 #include <sys/types.h>
131 #include <sys/socket.h>
135 dnl ------------------------------------------------------------------------
136 dnl PA_STRUCT_IN6_PKTINFO
138 dnl Look for definition of struct in6_pktinfo, which at least has an
141 AH_TEMPLATE([HAVE_STRUCT_IN6_PKTINFO],
142 [Define if struct in6_pktinfo is defined.])
144 AC_DEFUN(PA_STRUCT_IN6_PKTINFO,
145 [AC_CHECK_MEMBER(struct in6_pktinfo.ipi6_addr,
146 [AC_DEFINE(HAVE_STRUCT_IN6_PKTINFO)],
149 #include <sys/types.h>
150 #include <sys/socket.h>
151 #include <netinet/in.h>
152 #include <arpa/inet.h>
155 dnl --------------------------------------------------------------------------
156 dnl PA_HAVE_TCPWRAPPERS
158 dnl Do we have the tcpwrappers -lwrap? This can't be done using AC_CHECK_LIBS
159 dnl due to the need to provide "allow_severity" and "deny_severity" variables
160 dnl --------------------------------------------------------------------------
161 AH_TEMPLATE([HAVE_TCPWRAPPERS],
162 [Define if we have tcpwrappers (-lwrap) and <tcpd.h>.])
164 AC_DEFUN(PA_HAVE_TCPWRAPPERS,
165 [AC_CHECK_LIB([wrap], [main])
166 AC_MSG_CHECKING([for tcpwrappers])
170 int allow_severity = 0;
171 int deny_severity = 0;
174 hosts_ctl("sample_daemon", STRING_UNKNOWN, STRING_UNKNOWN, STRING_UNKNOWN);
177 AC_DEFINE(HAVE_TCPWRAPPERS)
184 dnl ------------------------------------------------------------------------
185 dnl PA_CHECK_INTTYPES_H_SANE
187 dnl At least some versions of AIX 4 have <inttypes.h> macros which are
188 dnl completely broken. Try to detect those.
189 dnl --------------------------------------------------------------------------
190 AH_TEMPLATE([INTTYPES_H_IS_SANE],
191 [Define if the macros in <inttypes.h> are usable])
193 AC_DEFUN(PA_CHECK_INTTYPES_H_SANE,
194 [AC_CHECK_HEADERS(inttypes.h,
196 AC_MSG_CHECKING([if inttypes.h is sane])
199 #include <inttypes.h>
202 [uintmax_t max = UINTMAX_C(0);
203 printf("%"PRIuMAX"\n", max);],
205 AC_DEFINE(INTTYPES_H_IS_SANE),
206 AC_MSG_RESULT([no (AIX, eh?)]))
210 dnl ------------------------------------------------------------------------
213 dnl PA_WITH_BOOL(option, default, help, enable, disable)
215 dnl Provides a more convenient way to specify --with-option and
216 dnl --without-option, with a default. default should be either 0 or 1.
217 dnl ------------------------------------------------------------------------
218 AC_DEFUN(PA_WITH_BOOL,
219 [AC_ARG_WITH([$1], [$3],
220 if test ["$withval"] != no; then
225 if test [$2] -ne 0; then
231 dnl --------------------------------------------------------------------------
232 dnl PA_HEADER_DEFINES
234 dnl PA_HEADER_DEFINES(header, type, value)
235 dnl --------------------------------------------------------------------------
236 AC_DEFUN(PA_HEADER_DEFINES,
237 [AC_MSG_CHECKING([if $1 defines $3])
238 AH_TEMPLATE([HAVE_$3_DEFINITION], [Define if $1 defines $3])
250 pa_header_define=`echo HAVE_$3_DEFINITION | tr '[a-z]' '[A-Z]'`
251 AC_DEFINE_UNQUOTED($pa_header_define)
258 dnl --------------------------------------------------------------------------
259 dnl PA_SEARCH_LIBS_AND_ADD
261 dnl PA_SEARCH_LIBS_AND_ADD(function, libraries [,function to add])
262 dnl --------------------------------------------------------------------------
264 AC_DEFUN(PA_SEARCH_LIBS_AND_ADD,
266 AH_TEMPLATE(AS_TR_CPP(HAVE_$1), [Define if $1 function was found])
267 AC_SEARCH_LIBS($1, $2,
269 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1))
274 if test $# -eq 3; then