summaryrefslogtreecommitdiff
path: root/aclocal.m4
blob: c07702c9e0ac76c62e680fb3fe3561dba538b97f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
dnl  -----------------------------------------------------------------------
dnl    
dnl    Copyright 1999-2008 H. Peter Anvin - All Rights Reserved
dnl 
dnl    This program is free software; you can redistribute it and/or modify
dnl    it under the terms of the GNU General Public License as published by
dnl    the Free Software Foundation, Inc., 53 Temple Place Ste 330,
dnl    Bostom MA 02111-1307, USA; either version 2 of the License, or
dnl    (at your option) any later version; incorporated herein by reference.
dnl 
dnl  -----------------------------------------------------------------------

dnl --------------------------------------------------------------------------
dnl PA_ADD_CFLAGS()
dnl
dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation
dnl --------------------------------------------------------------------------
AC_DEFUN(PA_ADD_CFLAGS,
[AC_MSG_CHECKING([if $CC accepts $1])
 pa_add_cflags__old_cflags="$CFLAGS"
 CFLAGS="$CFLAGS $1"
 AC_TRY_LINK([#include <stdio.h>],
 [printf("Hello, World!\n");],
 AC_MSG_RESULT([yes]),
 AC_MSG_RESULT([no])
 CFLAGS="$pa_add_cflags__old_cflags")])

dnl --------------------------------------------------------------------------
dnl PA_SIGSETJMP
dnl
dnl Do we have sigsetjmp/siglongjmp?  (AC_CHECK_FUNCS doesn't seem to work
dnl for these particular functions.)
dnl --------------------------------------------------------------------------
AC_DEFUN(PA_SIGSETJMP,
[AC_MSG_CHECKING([for sigsetjmp])
 AC_TRY_LINK([
#ifdef HAVE_SETJMP_H
#include <setjmp.h>
#endif],
 [sigjmp_buf buf;
  sigsetjmp(buf,1);
  siglongjmp(buf,2);],
 AC_MSG_RESULT([yes])
 $1,
 AC_MSG_RESULT([no])
 $2)])

dnl --------------------------------------------------------------------------
dnl PA_MSGHDR_MSG_CONTROL
dnl
dnl Does struct msghdr have the msg_control field?
dnl --------------------------------------------------------------------------
AH_TEMPLATE([HAVE_MSGHDR_MSG_CONTROL],
[Define if struct msghdr has the msg_control field.])

AC_DEFUN(PA_MSGHDR_MSG_CONTROL,
 [AC_CHECK_MEMBER(struct msghdr.msg_control,
  [AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL)],
  [],
  [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
  ])])

dnl ------------------------------------------------------------------------
dnl  PA_STRUCT_IN_PKTINFO
dnl 
dnl Look for definition of struct in_pktinfo, which at least has an
dnl ipi_addr member.  Some versions of glibc lack struct in_pktinfo;
dnl if so we need to include the definition ourselves -- but we only
dnl want to do that if absolutely necessary!
dnl ------------------------------------------------------------------------
AH_TEMPLATE([HAVE_STRUCT_IN_PKTINFO],
[Define if struct in_pktinfo is defined.])

AC_DEFUN(PA_STRUCT_IN_PKTINFO,
 [AC_CHECK_MEMBER(struct in_pktinfo.ipi_addr,
  [AC_DEFINE(HAVE_STRUCT_IN_PKTINFO)],
  [],
  [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/uio.h>
  ])])


dnl ------------------------------------------------------------------------
dnl  PA_STRUCT_SOCKADDR_IN6
dnl
dnl Look for definition of struct sockaddr_in6, which at least has an
dnl sin6_addr member
dnl
AH_TEMPLATE([HAVE_STRUCT_SOCKADDR_IN6],
[Define if struct sockaddr_in6 is defined.])

AC_DEFUN(PA_STRUCT_SOCKADDR_IN6,
 [AC_CHECK_MEMBER(struct sockaddr_in6.sin6_addr,
  [
   AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
   HAVE_INET6=true;
  ],
  [
   HAVE_INET6=false;
  ],
  [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
  ])])

dnl ------------------------------------------------------------------------
dnl  PA_STRUCT_ADDRINFO
dnl
dnl Look for definition of struct addrinfo, which at least has an
dnl ai_addr member
dnl
AH_TEMPLATE([HAVE_STRUCT_ADDRINFO],
[Define if struct addrinfo is defined.])

AC_DEFUN(PA_STRUCT_ADDRINFO,
 [AC_CHECK_MEMBER(struct addrinfo.ai_addr,
  [AC_DEFINE(HAVE_STRUCT_ADDRINFO)],
  [],
  [
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
  ])])

dnl ------------------------------------------------------------------------
dnl  PA_STRUCT_IN6_PKTINFO
dnl
dnl Look for definition of struct in6_pktinfo, which at least has an
dnl ipi6_addr member
dnl
AH_TEMPLATE([HAVE_STRUCT_IN6_PKTINFO],
[Define if struct in6_pktinfo is defined.])

AC_DEFUN(PA_STRUCT_IN6_PKTINFO,
 [AC_CHECK_MEMBER(struct in6_pktinfo.ipi6_addr,
  [AC_DEFINE(HAVE_STRUCT_IN6_PKTINFO)],
  [],
  [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
  ])])

dnl --------------------------------------------------------------------------
dnl PA_HAVE_TCPWRAPPERS
dnl
dnl Do we have the tcpwrappers -lwrap?  This can't be done using AC_CHECK_LIBS
dnl due to the need to provide "allow_severity" and "deny_severity" variables
dnl --------------------------------------------------------------------------
AH_TEMPLATE([HAVE_TCPWRAPPERS],
[Define if we have tcpwrappers (-lwrap) and <tcpd.h>.])

AC_DEFUN(PA_HAVE_TCPWRAPPERS,
[AC_CHECK_LIB([wrap], [main])
 AC_MSG_CHECKING([for tcpwrappers])
 AC_TRY_LINK(
[
#include <tcpd.h>
int allow_severity = 0;
int deny_severity = 0;
],
[
	hosts_ctl("sample_daemon", STRING_UNKNOWN, STRING_UNKNOWN, STRING_UNKNOWN);
],
[
	AC_DEFINE(HAVE_TCPWRAPPERS)
	AC_MSG_RESULT([yes])
],
[
	AC_MSG_RESULT([no])
])])

dnl ------------------------------------------------------------------------
dnl  PA_CHECK_INTTYPES_H_SANE
dnl
dnl  At least some versions of AIX 4 have <inttypes.h> macros which are
dnl  completely broken.  Try to detect those.
dnl --------------------------------------------------------------------------
AH_TEMPLATE([INTTYPES_H_IS_SANE],
[Define if the macros in <inttypes.h> are usable])

AC_DEFUN(PA_CHECK_INTTYPES_H_SANE,
[AC_CHECK_HEADERS(inttypes.h,
 [
  AC_MSG_CHECKING([if inttypes.h is sane])
  AC_TRY_LINK(
  [
#include <inttypes.h>
#include <stdio.h>
  ],
  [uintmax_t max = UINTMAX_C(0);
   printf("%"PRIuMAX"\n", max);],
  AC_MSG_RESULT([yes])
  AC_DEFINE(INTTYPES_H_IS_SANE),
  AC_MSG_RESULT([no (AIX, eh?)]))
 ])
])

dnl ------------------------------------------------------------------------
dnl  PA_WITH_BOOL
dnl
dnl  PA_WITH_BOOL(option, default, help, enable, disable)
dnl
dnl  Provides a more convenient way to specify --with-option and
dnl  --without-option, with a default.  default should be either 0 or 1.
dnl ------------------------------------------------------------------------
AC_DEFUN(PA_WITH_BOOL,
[AC_ARG_WITH([$1], [$3],
if test ["$withval"] != no; then
[$4]
else
[$5]
fi,
if test [$2] -ne 0; then
[$4]
else
[$5]
fi)])

dnl --------------------------------------------------------------------------
dnl  PA_HEADER_DEFINES
dnl
dnl  PA_HEADER_DEFINES(header, type, value)
dnl --------------------------------------------------------------------------
AC_DEFUN(PA_HEADER_DEFINES,
[AC_MSG_CHECKING([if $1 defines $3])
 AH_TEMPLATE([HAVE_$3_DEFINITION], [Define if $1 defines $3])
 AC_TRY_COMPILE([
#include <$1>
],
[
int main()
{
	$2 dummy = $3;
	return 0;
}
],
[
 pa_header_define=`echo HAVE_$3_DEFINITION | tr '[a-z]' '[A-Z]'`
 AC_DEFINE_UNQUOTED($pa_header_define)
 AC_MSG_RESULT(yes)
],
[
 AC_MSG_RESULT(no)
])])

dnl --------------------------------------------------------------------------
dnl  PA_SEARCH_LIBS_AND_ADD
dnl
dnl  PA_SEARCH_LIBS_AND_ADD(function, libraries [,function to add])
dnl --------------------------------------------------------------------------

AC_DEFUN(PA_SEARCH_LIBS_AND_ADD,
 [
  AH_TEMPLATE(AS_TR_CPP(HAVE_$1), [Define if $1 function was found])
  AC_SEARCH_LIBS($1, $2,
   [
    AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1))
    pa_add_$1=false;
   ],
   [
    XTRA=true;
    if test $# -eq 3; then
      AC_LIBOBJ($3)
    else
      AC_LIBOBJ($1)
    fi
    pa_add_$1=true;
   ])])