Get rid of $Id$ tags and update copyright dates
[tftp-hpa.git] / aclocal.m4
blob7b29e86f424891b9ef3d26df1345e3cf69448c11
1 dnl  -----------------------------------------------------------------------
2 dnl    
3 dnl    Copyright 1999-2007 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 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])
82   AC_TRY_COMPILE(
83    [
84 #include <sys/types.h>
85 #include <sys/socket.h>
86 #include <netinet/in.h>
87 #include <arpa/inet.h>
88 #include <stdlib.h>
89 #include <sys/uio.h>
90    ],
91    [
92         struct in_pktinfo pktinfo;
93         int foo = sizeof(struct in_pktinfo);
94         void *quux = (void *)(&pktinfo.ipi_addr);
95    ],
96    [
97         AC_DEFINE(HAVE_STRUCT_IN_PKTINFO)
98         AC_MSG_RESULT(yes)
99    ],
100    [
101         AC_MSG_RESULT(no)
102    ])])
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])
116  AC_TRY_LINK(
118 #include <tcpd.h>
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)
127         AC_MSG_RESULT([yes])
130         AC_MSG_RESULT([no])
131 ])])
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])
146   AC_TRY_LINK(
147   [
148 #include <inttypes.h>
149 #include <stdio.h>
150   ],
151   [uintmax_t max = UINTMAX_C(0);
152    printf("%"PRIuMAX"\n", max);],
153   AC_MSG_RESULT([yes])
154   AC_DEFINE(INTTYPES_H_IS_SANE),
155   AC_MSG_RESULT([no (AIX, eh?)]))
156  ])
159 dnl ------------------------------------------------------------------------
160 dnl  PA_WITH_BOOL
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
170 [$4]
171 else
172 [$5]
174 if test [$2] -ne 0; then
175 [$4]
176 else
177 [$5]
178 fi)])
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])
188  AC_TRY_COMPILE([
189 #include <$1>
192 int main()
194         $2 dummy = $3;
195         return 0;
199  pa_header_define=`echo HAVE_$3_DEFINITION | tr '[a-z]' '[A-Z]'`
200  AC_DEFINE_UNQUOTED($pa_header_define)
201  AC_MSG_RESULT(yes)
204  AC_MSG_RESULT(no)
205 ])])