Update version for release
[tftp-hpa.git] / aclocal.m4
blobf53cea923f145100da9be0ac80d5c2e96f855556
1 dnl $Id$
2 dnl  -----------------------------------------------------------------------
3 dnl    
4 dnl    Copyright 1999-2002 H. Peter Anvin - All Rights Reserved
5 dnl 
6 dnl    This program is free software; you can redistribute it and/or modify
7 dnl    it under the terms of the GNU General Public License as published by
8 dnl    the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 dnl    Bostom MA 02111-1307, USA; either version 2 of the License, or
10 dnl    (at your option) any later version; incorporated herein by reference.
11 dnl 
12 dnl  -----------------------------------------------------------------------
14 dnl --------------------------------------------------------------------------
15 dnl PA_ADD_CFLAGS()
16 dnl
17 dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation
18 dnl --------------------------------------------------------------------------
19 AC_DEFUN(PA_ADD_CFLAGS,
20 [AC_MSG_CHECKING([if $CC accepts $1])
21  pa_add_cflags__old_cflags="$CFLAGS"
22  CFLAGS="$CFLAGS $1"
23  AC_TRY_LINK([#include <stdio.h>],
24  [printf("Hello, World!\n");],
25  AC_MSG_RESULT([yes]),
26  AC_MSG_RESULT([no])
27  CFLAGS="$pa_add_cflags__old_cflags")])
29 dnl --------------------------------------------------------------------------
30 dnl PA_SIGSETJMP
31 dnl
32 dnl Do we have sigsetjmp/siglongjmp?  (AC_CHECK_FUNCS doesn't seem to work
33 dnl for these particular functions.)
34 dnl --------------------------------------------------------------------------
35 AC_DEFUN(PA_SIGSETJMP,
36 [AC_MSG_CHECKING([for sigsetjmp])
37  AC_TRY_LINK([
38 #ifdef HAVE_SETJMP_H
39 #include <setjmp.h>
40 #endif],
41  [sigjmp_buf buf;
42   sigsetjmp(buf,1);
43   siglongjmp(buf,2);],
44  AC_MSG_RESULT([yes])
45  $1,
46  AC_MSG_RESULT([no])
47  $2)])
49 dnl --------------------------------------------------------------------------
50 dnl PA_MSGHDR_MSG_CONTROL
51 dnl
52 dnl Does struct msghdr have the msg_control field?
53 dnl --------------------------------------------------------------------------
54 AH_TEMPLATE([HAVE_MSGHDR_MSG_CONTROL],
55 [Define if struct msghdr has the msg_control field.])
57 AC_DEFUN(PA_MSGHDR_MSG_CONTROL,
58  [AC_CHECK_MEMBER(struct msghdr.msg_control,
59   [AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL)],
60   [],
61   [
62 #include <sys/types.h>
63 #include <sys/socket.h>
64 #include <netinet/in.h>
65   ])])
67 dnl ------------------------------------------------------------------------
68 dnl  PA_STRUCT_IN_PKTINFO
69 dnl 
70 dnl Look for definition of struct in_pktinfo, which at least has an
71 dnl ipi_addr member.  Some versions of glibc lack struct in_pktinfo;
72 dnl if so we need to include the definition ourselves -- but we only
73 dnl want to do that if absolutely necessary!
74 dnl
75 dnl We don't use AC_CHECK_MEMBER() here, since at least in autoconf 2.52
76 dnl this is broken for a member of structure type.
77 dnl ------------------------------------------------------------------------
78 AH_TEMPLATE([HAVE_STRUCT_IN_PKTINFO],
79 [Define if struct in_pktinfo is defined.])
81 AC_DEFUN(PA_STRUCT_IN_PKTINFO,
82  [AC_MSG_CHECKING([for definition of struct in_pktinfo])
83   AC_TRY_COMPILE(
84    [
85 #include <sys/types.h>
86 #include <sys/socket.h>
87 #include <netinet/in.h>
88 #include <arpa/inet.h>
89 #include <stdlib.h>
90 #include <sys/uio.h>
91    ],
92    [
93         struct in_pktinfo pktinfo;
94         int foo = sizeof(struct in_pktinfo);
95         void *quux = (void *)(&pktinfo.ipi_addr);
96    ],
97    [
98         AC_DEFINE(HAVE_STRUCT_IN_PKTINFO)
99         AC_MSG_RESULT(yes)
100    ],
101    [
102         AC_MSG_RESULT(no)
103    ])])
105 dnl --------------------------------------------------------------------------
106 dnl PA_HAVE_TCPWRAPPERS
108 dnl Do we have the tcpwrappers -lwrap?  This can't be done using AC_CHECK_LIBS
109 dnl due to the need to provide "allow_severity" and "deny_severity" variables
110 dnl --------------------------------------------------------------------------
111 AH_TEMPLATE([HAVE_TCPWRAPPERS],
112 [Define if we have tcpwrappers (-lwrap) and <tcpd.h>.])
114 AC_DEFUN(PA_HAVE_TCPWRAPPERS,
115 [AC_CHECK_LIB([wrap], [main])
116  AC_MSG_CHECKING([for tcpwrappers])
117  AC_TRY_LINK(
119 #include <tcpd.h>
120 int allow_severity = 0;
121 int deny_severity = 0;
124         hosts_ctl("sample_daemon", STRING_UNKNOWN, STRING_UNKNOWN, STRING_UNKNOWN);
127         AC_DEFINE(HAVE_TCPWRAPPERS)
128         AC_MSG_RESULT([yes])
131         AC_MSG_RESULT([no])
132 ])])
134 dnl ------------------------------------------------------------------------
135 dnl  PA_CHECK_INTTYPES_H_SANE
137 dnl  At least some versions of AIX 4 have <inttypes.h> macros which are
138 dnl  completely broken.  Try to detect those.
139 dnl --------------------------------------------------------------------------
140 AH_TEMPLATE([INTTYPES_H_IS_SANE],
141 [Define if the macros in <inttypes.h> are usable])
143 AC_DEFUN(PA_CHECK_INTTYPES_H_SANE,
144 [AC_CHECK_HEADERS(inttypes.h,
146   AC_MSG_CHECKING([if inttypes.h is sane])
147   AC_TRY_LINK(
148   [
149 #include <inttypes.h>
150 #include <stdio.h>
151   ],
152   [uintmax_t max = UINTMAX_C(0);
153    printf("%"PRIuMAX"\n", max);],
154   AC_MSG_RESULT([yes])
155   AC_DEFINE(INTTYPES_H_IS_SANE),
156   AC_MSG_RESULT([no (AIX, eh?)]))
157  ])
160 dnl ------------------------------------------------------------------------
161 dnl  PA_WITH_BOOL
163 dnl  PA_WITH_BOOL(option, default, help, enable, disable)
165 dnl  Provides a more convenient way to specify --with-option and
166 dnl  --without-option, with a default.  default should be either 0 or 1.
167 dnl ------------------------------------------------------------------------
168 AC_DEFUN(PA_WITH_BOOL,
169 [AC_ARG_WITH([$1], [$3],
170 if test ["$withval"] != no; then
171 [$4]
172 else
173 [$5]
175 if test [$2] -ne 0; then
176 [$4]
177 else
178 [$5]
179 fi)])
181 dnl --------------------------------------------------------------------------
182 dnl  PA_HEADER_DEFINES
184 dnl  PA_HEADER_DEFINES(header, type, value)
185 dnl --------------------------------------------------------------------------
186 AC_DEFUN(PA_HEADER_DEFINES,
187 [AC_MSG_CHECKING([if $1 defines $3])
188  AH_TEMPLATE([HAVE_$3_DEFINITION], [Define if $1 defines $3])
189  AC_TRY_COMPILE([
190 #include <$1>
193 int main()
195         $2 dummy = $3;
196         return 0;
200  pa_header_define=`echo HAVE_$3_DEFINITION | tr '[a-z]' '[A-Z]'`
201  AC_DEFINE_UNQUOTED($pa_header_define)
202  AC_MSG_RESULT(yes)
205  AC_MSG_RESULT(no)
206 ])])