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