No easy way to properly detect header files...
[tinc] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl $Id: configure.in,v 1.13.2.78 2003/07/31 13:18:34 guus Exp $
4
5 AC_PREREQ(2.57)
6 AC_INIT(src/tincd.c)
7 AM_INIT_AUTOMAKE(tinc, 1.0-cvs)
8 AM_CONFIG_HEADER(config.h)
9 AM_MAINTAINER_MODE
10
11 dnl Include the macros from the m4/ directory
12 AM_ACLOCAL_INCLUDE(m4)
13
14 AM_GNU_GETTEXT([external])
15 AM_GNU_GETTEXT_VERSION(0.12.1)
16
17 # Enable GNU extensions.
18 # Define this here, not in acconfig's @TOP@ section, since definitions
19 # in the latter don't make it into the configure-time tests.
20 AC_DEFINE([_GNU_SOURCE], 1, [Enable GNU extenstions])
21 AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions])
22
23 ALL_LINGUAS="nl"
24
25 dnl Checks for programs.
26 AC_PROG_CC
27 AC_PROG_CPP
28 AC_PROG_GCC_TRADITIONAL
29 AC_PROG_AWK
30 AC_PROG_INSTALL
31 AC_PROG_LN_S
32 AC_PROG_MAKE_SET
33 AC_PROG_RANLIB
34
35 AC_ISC_POSIX
36
37 dnl Check and set OS
38
39 #AC_CANONICAL_HOST
40
41 case $host_os in
42   *linux*)
43     AC_DEFINE(HAVE_LINUX, 1, [Linux])
44     [ rm -f src/device.c; ln -sf linux/device.c src/device.c ]
45   ;;
46   *freebsd*)
47     AC_DEFINE(HAVE_FREEBSD, 1, [FreeBSD])
48     [ rm -f src/device.c; ln -sf freebsd/device.c src/device.c ]
49   ;;
50   *darwin*)
51     AC_DEFINE(HAVE_DARWIN, 1, [Darwin (MacOS/X)])
52     [ rm -f src/device.c; ln -sf darwin/device.c src/device.c ]
53   ;;
54   *solaris*)
55     AC_DEFINE(HAVE_SOLARIS, 1, [Solaris/SunOS])
56     [ rm -f src/device.c; ln -sf solaris/device.c src/device.c ]
57   ;;
58   *openbsd*)
59     AC_DEFINE(HAVE_OPENBSD, 1, [OpenBSD])
60     [ rm -f src/device.c; ln -sf openbsd/device.c src/device.c ]
61   ;;
62   *netbsd*)
63     AC_DEFINE(HAVE_NETBSD, 1, [NetBSD])
64     [ rm -f src/device.c; ln -sf netbsd/device.c src/device.c ]
65   ;;
66   *cygwin*)
67     AC_DEFINE(HAVE_CYGWIN, 1, [Cygwin])
68     [ rm -f src/device.c; ln -sf cygwin/device.c src/device.c ]
69   ;;
70   *mingw*)
71     AC_DEFINE(HAVE_MINGW, 1, [MinGW])
72     [ rm -f src/device.c; ln -sf mingw/device.c src/device.c ]
73   ;;
74   *)
75     AC_MSG_ERROR("Unknown operating system.")
76   ;;
77 esac
78
79 AC_CACHE_SAVE
80
81 if test -d /sw/include ; then
82   CPPFLAGS="$CPPFLAGS -I/sw/include"
83 fi
84 if test -d /sw/lib ; then
85   LIBS="$LIBS -L/sw/lib"
86 fi
87
88 dnl Checks for libraries.
89
90 dnl Checks for header files.
91 dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
92
93 AC_HEADER_STDC
94 AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/param.h sys/time.h sys/socket.h sys/wait.h sys/mman.h netdb.h arpa/inet.h])
95 AC_CHECK_HEADERS([net/if.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h],
96   [], [],
97   [#ifdef HAVE_SYS_TYPES_H
98    #include <sys/types.h>
99    #endif
100    #ifdef HAVE_NETDB_H
101    #include <netdb.h>
102    #endif
103    #ifdef HAVE_ARPA_INET_H
104    #include <arpa/inet.h>
105    #endif
106    #ifdef HAVE_SYS_SOCKET_H
107    #include <sys/socket.h>
108    #endif
109   ]
110 )
111 AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h],
112   [], [],
113   [#ifdef HAVE_SYS_TYPES_H
114    #include <sys/types.h>
115    #endif
116    #ifdef HAVE_NETDB_H
117    #include <netdb.h>
118    #endif
119    #ifdef HAVE_ARPA_INET_H
120    #include <arpa/inet.h>
121    #endif
122    #ifdef HAVE_SYS_SOCKET_H
123    #include <sys/socket.h>
124    #endif
125    #ifdef HAVE_NET_IF_H
126    #include <net/if.h>
127    #endif
128    #ifdef HAVE_NETINET_IN_SYSTM_H
129    #include <netinet/in_systm.h>
130    #endif
131    #ifdef HAVE_NETINET_IN_H
132    #include <netinet/in.h>
133    #endif
134    #ifdef HAVE_NETINET_IN6_H
135    #include <netinet/in6.h>
136    #endif
137    #ifdef HAVE_NET_ETHERNET_H
138    #include <net/ethernet.h>
139    #endif
140    #ifdef HAVE_NET_IF_ARP_H
141    #include <net/if_arp.h>
142    #endif
143   ]
144 )
145 AC_CHECK_HEADERS([netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h],
146   [], [],
147   [#ifdef HAVE_SYS_TYPES_H
148    #include <sys/types.h>
149    #endif
150    #ifdef HAVE_NETDB_H
151    #include <netdb.h>
152    #endif
153    #ifdef HAVE_ARPA_INET_H
154    #include <arpa/inet.h>
155    #endif
156    #ifdef HAVE_SYS_SOCKET_H
157    #include <sys/socket.h>
158    #endif
159    #ifdef HAVE_NET_IF_H
160    #include <net/if.h>
161    #endif
162    #ifdef HAVE_NETINET_IN_SYSTM_H
163    #include <netinet/in_systm.h>
164    #endif
165    #ifdef HAVE_NETINET_IN_H
166    #include <netinet/in.h>
167    #endif
168    #ifdef HAVE_NETINET_IP_H
169    #include <netinet/ip.h>
170    #endif
171    #ifdef HAVE_NETINET_IN6_H
172    #include <netinet/in6.h>
173    #endif
174    #ifdef HAVE_NETINET_IP6_H
175    #include <netinet/ip6.h>
176    #endif
177    #ifdef HAVE_NET_ETHERNET_H
178    #include <net/ethernet.h>
179    #endif
180    #ifdef HAVE_NET_IF_ARP_H
181    #include <net/if_arp.h>
182    #endif
183    #ifdef HAVE_NETINET_IF_ETHER_H
184    #include <netinet/if_ether.h>
185    #endif
186   ]
187 )
188
189 dnl Checks for typedefs, structures, and compiler characteristics.
190 AC_C_CONST
191 AC_C_VOLATILE
192 AC_TYPE_PID_T
193 AC_TYPE_SIZE_T
194 AC_HEADER_TIME
195 AC_STRUCT_TM
196
197 tinc_ATTRIBUTE(__malloc__)
198
199 AC_CHECK_TYPES([socklen_t, struct arphdr, struct ether_arp, struct in_addr, struct addrinfo, struct ip, struct icmp, struct in6_addr, struct sockaddr_in6, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , ,
200   [#ifdef HAVE_SYS_TYPES_H
201    #include <sys/types.h>
202    #endif
203    #ifdef HAVE_NETDB_H
204    #include <netdb.h>
205    #endif
206    #ifdef HAVE_ARPA_INET_H
207    #include <arpa/inet.h>
208    #endif
209    #ifdef HAVE_SYS_SOCKET_H
210    #include <sys/socket.h>
211    #endif
212    #ifdef HAVE_NET_IF_H
213    #include <net/if.h>
214    #endif
215    #ifdef HAVE_NETINET_IN_SYSTM_H
216    #include <netinet/in_systm.h>
217    #endif
218    #ifdef HAVE_NETINET_IN_H
219    #include <netinet/in.h>
220    #endif
221    #ifdef HAVE_NETINET_IP_H
222    #include <netinet/ip.h>
223    #endif
224    #ifdef HAVE_NETINET_TCP_H
225    #include <netinet/tcp.h>
226    #endif
227    #ifdef HAVE_NETINET_IN6_H
228    #include <netinet/in6.h>
229    #endif
230    #ifdef HAVE_NETINET_IP6_H
231    #include <netinet/ip6.h>
232    #endif
233    #ifdef HAVE_NET_ETHERNET_H
234    #include <net/ethernet.h>
235    #endif
236    #ifdef HAVE_NET_IF_ARP_H
237    #include <net/if_arp.h>
238    #endif
239    #ifdef HAVE_NETINET_IF_ETHER_H
240    #include <netinet/if_ether.h>
241    #endif
242    #ifdef HAVE_NETINET_IP_ICMP_H
243    #include <netinet/ip_icmp.h>
244    #endif
245    #ifdef HAVE_NETINET_ICMP6_H
246    #include <netinet/icmp6.h>
247    #endif
248   ]
249 )
250
251 dnl Checks for library functions.
252 AC_FUNC_MEMCMP
253 AC_FUNC_ALLOCA
254 AC_TYPE_SIGNAL
255 AC_CHECK_FUNCS([asprintf daemon fcloseall flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol unsetenv vsyslog])
256 jm_FUNC_MALLOC
257 jm_FUNC_REALLOC
258
259 dnl Support for SunOS
260
261 AC_CHECK_FUNC(socket, [], [
262   AC_CHECK_LIB(socket, connect)
263 ])
264 AC_CHECK_FUNC(gethostbyname, [], [
265   AC_CHECK_LIB(nsl, gethostbyname)
266 ])
267
268 AC_CHECK_FUNCS([freeaddrinfo gai_strerror getaddrinfo getnameinfo inet_aton])
269
270 AC_CACHE_SAVE
271
272 dnl These are defined in files in m4/
273
274 case $host_os in
275   *linux*)
276     tinc_TUNTAP
277   ;;
278 esac
279
280 tinc_OPENSSL
281 tinc_ZLIB
282 tinc_LZO
283
284 dnl Check if support for jumbograms is requested 
285 AC_ARG_ENABLE(jumbograms,
286   AC_HELP_STRING([--enable-jumbograms], [enable support for jumbograms (packets up to 9000 bytes)]),
287   [ AC_DEFINE(ENABLE_JUMBOGRAMS, 1, [Support for jumbograms (packets up to 9000 bytes)]) ]
288 )
289
290 dnl Check if checkpoint tracing has to be enabled
291 AC_ARG_ENABLE(tracing,
292   AC_HELP_STRING([--enable-tracing], [enable checkpoint tracing (debugging only)]),
293   [ AC_DEFINE(ENABLE_TRACING, 1, [Checkpoint tracing]) ]
294 )
295
296 AC_SUBST(INCLUDES)
297
298 AC_OUTPUT(Makefile 
299 src/Makefile
300 doc/Makefile
301 lib/Makefile
302 po/Makefile.in
303 m4/Makefile
304 )