1 dnl -----------------------------------------------------------------------
3 dnl Copyright 1999-2007 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!
74 dnl We don't use AC_CHECK_MEMBER() here, since at least in autoconf 2.52
75 dnl this is broken for a member of structure type.
76 dnl ------------------------------------------------------------------------
77 AH_TEMPLATE([HAVE_STRUCT_IN_PKTINFO],
78 [Define if struct in_pktinfo is defined.])
80 AC_DEFUN(PA_STRUCT_IN_PKTINFO,
81 [AC_MSG_CHECKING([for definition of struct in_pktinfo])
84 #include <sys/types.h>
85 #include <sys/socket.h>
86 #include <netinet/in.h>
87 #include <arpa/inet.h>
92 struct in_pktinfo pktinfo;
93 int foo = sizeof(struct in_pktinfo);
94 void *quux = (void *)(&pktinfo.ipi_addr);
97 AC_DEFINE(HAVE_STRUCT_IN_PKTINFO)
104 dnl --------------------------------------------------------------------------
105 dnl PA_HAVE_TCPWRAPPERS
107 dnl Do we have the tcpwrappers -lwrap? This can't be done using AC_CHECK_LIBS
108 dnl due to the need to provide "allow_severity" and "deny_severity" variables
109 dnl --------------------------------------------------------------------------
110 AH_TEMPLATE([HAVE_TCPWRAPPERS],
111 [Define if we have tcpwrappers (-lwrap) and <tcpd.h>.])
113 AC_DEFUN(PA_HAVE_TCPWRAPPERS,
114 [AC_CHECK_LIB([wrap], [main])
115 AC_MSG_CHECKING([for tcpwrappers])
119 int allow_severity = 0;
120 int deny_severity = 0;
123 hosts_ctl("sample_daemon", STRING_UNKNOWN, STRING_UNKNOWN, STRING_UNKNOWN);
126 AC_DEFINE(HAVE_TCPWRAPPERS)
133 dnl ------------------------------------------------------------------------
134 dnl PA_CHECK_INTTYPES_H_SANE
136 dnl At least some versions of AIX 4 have <inttypes.h> macros which are
137 dnl completely broken. Try to detect those.
138 dnl --------------------------------------------------------------------------
139 AH_TEMPLATE([INTTYPES_H_IS_SANE],
140 [Define if the macros in <inttypes.h> are usable])
142 AC_DEFUN(PA_CHECK_INTTYPES_H_SANE,
143 [AC_CHECK_HEADERS(inttypes.h,
145 AC_MSG_CHECKING([if inttypes.h is sane])
148 #include <inttypes.h>
151 [uintmax_t max = UINTMAX_C(0);
152 printf("%"PRIuMAX"\n", max);],
154 AC_DEFINE(INTTYPES_H_IS_SANE),
155 AC_MSG_RESULT([no (AIX, eh?)]))
159 dnl ------------------------------------------------------------------------
162 dnl PA_WITH_BOOL(option, default, help, enable, disable)
164 dnl Provides a more convenient way to specify --with-option and
165 dnl --without-option, with a default. default should be either 0 or 1.
166 dnl ------------------------------------------------------------------------
167 AC_DEFUN(PA_WITH_BOOL,
168 [AC_ARG_WITH([$1], [$3],
169 if test ["$withval"] != no; then
174 if test [$2] -ne 0; then
180 dnl --------------------------------------------------------------------------
181 dnl PA_HEADER_DEFINES
183 dnl PA_HEADER_DEFINES(header, type, value)
184 dnl --------------------------------------------------------------------------
185 AC_DEFUN(PA_HEADER_DEFINES,
186 [AC_MSG_CHECKING([if $1 defines $3])
187 AH_TEMPLATE([HAVE_$3_DEFINITION], [Define if $1 defines $3])
199 pa_header_define=`echo HAVE_$3_DEFINITION | tr '[a-z]' '[A-Z]'`
200 AC_DEFINE_UNQUOTED($pa_header_define)