Add EditorConfig support
[tftp-hpa.git] / aclocal.m4
blobc07702c9e0ac76c62e680fb3fe3561dba538b97f
1 dnl  -----------------------------------------------------------------------
2 dnl    
3 dnl    Copyright 1999-2008 H. Peter Anvin - All Rights Reserved
4 dnl 
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.
10 dnl 
11 dnl  -----------------------------------------------------------------------
13 dnl --------------------------------------------------------------------------
14 dnl PA_ADD_CFLAGS()
15 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"
21  CFLAGS="$CFLAGS $1"
22  AC_TRY_LINK([#include <stdio.h>],
23  [printf("Hello, World!\n");],
24  AC_MSG_RESULT([yes]),
25  AC_MSG_RESULT([no])
26  CFLAGS="$pa_add_cflags__old_cflags")])
28 dnl --------------------------------------------------------------------------
29 dnl PA_SIGSETJMP
30 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])
36  AC_TRY_LINK([
37 #ifdef HAVE_SETJMP_H
38 #include <setjmp.h>
39 #endif],
40  [sigjmp_buf buf;
41   sigsetjmp(buf,1);
42   siglongjmp(buf,2);],
43  AC_MSG_RESULT([yes])
44  $1,
45  AC_MSG_RESULT([no])
46  $2)])
48 dnl --------------------------------------------------------------------------
49 dnl PA_MSGHDR_MSG_CONTROL
50 dnl
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)],
59   [],
60   [
61 #include <sys/types.h>
62 #include <sys/socket.h>
63 #include <netinet/in.h>
64   ])])
66 dnl ------------------------------------------------------------------------
67 dnl  PA_STRUCT_IN_PKTINFO
68 dnl 
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)],
80   [],
81   [
82 #include <sys/types.h>
83 #include <sys/socket.h>
84 #include <netinet/in.h>
85 #include <arpa/inet.h>
86 #include <stdlib.h>
87 #include <sys/uio.h>
88   ])])
91 dnl ------------------------------------------------------------------------
92 dnl  PA_STRUCT_SOCKADDR_IN6
93 dnl
94 dnl Look for definition of struct sockaddr_in6, which at least has an
95 dnl sin6_addr member
96 dnl
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,
102   [
103    AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
104    HAVE_INET6=true;
105   ],
106   [
107    HAVE_INET6=false;
108   ],
109   [
110 #include <sys/types.h>
111 #include <sys/socket.h>
112 #include <netinet/in.h>
113 #include <arpa/inet.h>
114   ])])
116 dnl ------------------------------------------------------------------------
117 dnl  PA_STRUCT_ADDRINFO
119 dnl Look for definition of struct addrinfo, which at least has an
120 dnl ai_addr member
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)],
128   [],
129   [
130 #include <sys/types.h>
131 #include <sys/socket.h>
132 #include <netdb.h>
133   ])])
135 dnl ------------------------------------------------------------------------
136 dnl  PA_STRUCT_IN6_PKTINFO
138 dnl Look for definition of struct in6_pktinfo, which at least has an
139 dnl ipi6_addr member
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)],
147   [],
148   [
149 #include <sys/types.h>
150 #include <sys/socket.h>
151 #include <netinet/in.h>
152 #include <arpa/inet.h>
153   ])])
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])
167  AC_TRY_LINK(
169 #include <tcpd.h>
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)
178         AC_MSG_RESULT([yes])
181         AC_MSG_RESULT([no])
182 ])])
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])
197   AC_TRY_LINK(
198   [
199 #include <inttypes.h>
200 #include <stdio.h>
201   ],
202   [uintmax_t max = UINTMAX_C(0);
203    printf("%"PRIuMAX"\n", max);],
204   AC_MSG_RESULT([yes])
205   AC_DEFINE(INTTYPES_H_IS_SANE),
206   AC_MSG_RESULT([no (AIX, eh?)]))
207  ])
210 dnl ------------------------------------------------------------------------
211 dnl  PA_WITH_BOOL
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
221 [$4]
222 else
223 [$5]
225 if test [$2] -ne 0; then
226 [$4]
227 else
228 [$5]
229 fi)])
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])
239  AC_TRY_COMPILE([
240 #include <$1>
243 int main()
245         $2 dummy = $3;
246         return 0;
250  pa_header_define=`echo HAVE_$3_DEFINITION | tr '[a-z]' '[A-Z]'`
251  AC_DEFINE_UNQUOTED($pa_header_define)
252  AC_MSG_RESULT(yes)
255  AC_MSG_RESULT(no)
256 ])])
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,
268    [
269     AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1))
270     pa_add_$1=false;
271    ],
272    [
273     XTRA=true;
274     if test $# -eq 3; then
275       AC_LIBOBJ($3)
276     else
277       AC_LIBOBJ($1)
278     fi
279     pa_add_$1=true;
280    ])])