Add a few feature test macros to benefit Digital Unix
[tftp-hpa.git] / aclocal.m4
blob310d5b025797b3dabba1ebbf9e421ee405410a6a
1 dnl --------------------------------------------------------------------------
2 dnl PA_ADD_CFLAGS()
3 dnl
4 dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation
5 dnl --------------------------------------------------------------------------
6 AC_DEFUN(PA_ADD_CFLAGS,
7 [AC_MSG_CHECKING([if $CC accepts $1])
8  pa_add_cflags__old_cflags="$CFLAGS"
9  CFLAGS="$CFLAGS $1"
10  AC_TRY_COMPILE([#include <stdio.h>],
11  [printf("Hello, World!\n");],
12  AC_MSG_RESULT([yes]),
13  AC_MSG_RESULT([no])
14  CFLAGS="$pa_add_cflags__old_cflags")])
16 dnl --------------------------------------------------------------------------
17 dnl PA_SIGSETJMP
18 dnl
19 dnl Do we have sigsetjmp/siglongjmp?  (AC_CHECK_FUNCS doesn't seem to work
20 dnl for these particular functions.)
21 dnl --------------------------------------------------------------------------
22 AC_DEFUN(PA_SIGSETJMP,
23 [AC_MSG_CHECKING([for sigsetjmp])
24  AC_TRY_LINK(
25  [#include <setjmp.h>],
26  [sigjmp_buf buf;
27   sigsetjmp(buf,1);
28   siglongjmp(buf,2);],
29  AC_MSG_RESULT([yes])
30  $1,
31  AC_MSG_RESULT([no])
32  $2)])
34 dnl --------------------------------------------------------------------------
35 dnl PA_MSGHDR_MSG_CONTROL
36 dnl
37 dnl Does struct msghdr have the msg_control field?
38 dnl --------------------------------------------------------------------------
39 AH_TEMPLATE([HAVE_MSGHDR_MSG_CONTROL],
40 [Define if struct msghdr has the msg_control field.])
42 AC_DEFUN(PA_MSGHDR_MSG_CONTROL,
43 [AC_MSG_CHECKING([for msg_control in struct msghdr])
44  AC_TRY_COMPILE(
46 #define _XPG4_2         /* Needed on Solaris */
47 #include <sys/types.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
52         struct msghdr msg;
53         void *p = (void *) &msg.msg_control;
56         AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL)
57         AC_MSG_RESULT([yes])
60         AC_MSG_RESULT([no])
61 ])])
63 dnl ------------------------------------------------------------------------
64 dnl  PA_STRUCT_IN_PKTINFO
65 dnl
66 dnl Look for definition of struct in_pktinfo.  Some versions of glibc
67 dnl lack struct in_pktinfo; if so we need to include the definition
68 dnl ourselves -- but we only want to do that if absolutely necessary!
69 dnl ------------------------------------------------------------------------
70 AH_TEMPLATE([HAVE_STRUCT_IN_PKTINFO],
71 [Define if struct in_pktinfo is defined.])
73 AC_DEFUN(PA_STRUCT_IN_PKTINFO,
74 [AC_MSG_CHECKING([for definition of struct in_pktinfo])
75  AC_TRY_COMPILE(
77 #include <sys/types.h>
78 #include <sys/socket.h>
79 #include <netinet/in.h>
80 #include <arpa/inet.h>
81 #include <stdlib.h>
82 #include <sys/uio.h>
85         struct in_pktinfo pktinfo;
86         int foo = sizeof(struct in_pktinfo);
87         void *quux = (void *)(&pktinfo.ipi_addr);
90         AC_DEFINE(HAVE_STRUCT_IN_PKTINFO)
91         AC_MSG_RESULT([yes])
94         AC_MSG_RESULT([no])
95 ])])
97 dnl --------------------------------------------------------------------------
98 dnl PA_HAVE_TCPWRAPPERS
99 dnl
100 dnl Do we have the tcpwrappers -lwrap?  This can't be done using AC_CHECK_LIBS
101 dnl due to the need to provide "allow_severity" and "deny_severity" variables
102 dnl --------------------------------------------------------------------------
103 AH_TEMPLATE([HAVE_TCPWRAPPERS],
104 [Define if we have tcpwrappers (-lwrap) and <tcpd.h>.])
106 AC_DEFUN(PA_HAVE_TCPWRAPPERS,
107 [AC_CHECK_LIB([wrap], [main])
108  AC_MSG_CHECKING([for tcpwrappers])
109  AC_TRY_LINK(
111 #include <tcpd.h>
112 int allow_severity = 0;
113 int deny_severity = 0;
116         hosts_ctl("sample_daemon", STRING_UNKNOWN, STRING_UNKNOWN, STRING_UNKNOWN);
119         AC_DEFINE(HAVE_TCPWRAPPERS)
120         AC_MSG_RESULT([yes])
123         AC_MSG_RESULT([no])
124 ])])
126 dnl ------------------------------------------------------------------------
127 dnl  PA_WITH_BOOL
129 dnl  PA_WITH_BOOL(option, default, help, enable, disable)
131 dnl  Provides a more convenient way to specify --with-option and
132 dnl  --without-option, with a default.  default should be either 0 or 1.
133 dnl ------------------------------------------------------------------------
134 AC_DEFUN(PA_WITH_BOOL,
135 [AC_ARG_WITH([$1], [$3],
136 if test ["$withval"] != no; then
137 [$4]
138 else
139 [$5]
141 if test [$2] -ne 0; then
142 [$4]
143 else
144 [$5]
145 fi)])
147 dnl --------------------------------------------------------------------------
148 dnl  PA_HEADER_DEFINES
150 dnl  PA_HEADER_DEFINES(header, type, value)
151 dnl --------------------------------------------------------------------------
152 AC_DEFUN(PA_HEADER_DEFINES,
153 [AC_MSG_CHECKING([if $1 defines $3])
154  AC_TRY_COMPILE([
155 #include <$1>
158 int main()
160         $2 dummy = $3;
161         return 0;
165  pa_header_define=`echo HAVE_$3_DEFINITION | tr '[a-z]' '[A-Z]'`
166  AC_DEFINE_UNQUOTED($pa_header_define)
167  AC_MSG_RESULT(yes)
170  AC_MSG_RESULT(no)
171 ])])