Move all source code to src/.
[tinc] / configure.ac
1 AC_PREREQ(2.61)
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/tincd.c])
4 AM_INIT_AUTOMAKE(tinc, 2.0-svn)
5 AC_CONFIG_HEADERS([config.h])
6 AM_MAINTAINER_MODE
7
8 AM_GNU_GETTEXT([external])
9 AM_GNU_GETTEXT_VERSION(0.16.1)
10
11 AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions])
12
13 dnl ALL_LINGUAS="nl"
14
15 dnl Checks for programs.
16 AC_PROG_CC
17 AC_PROG_CPP
18 AC_PROG_INSTALL
19 AC_PROG_LN_S
20
21 AC_GNU_SOURCE
22
23 dnl Check and set OS
24
25 AC_CANONICAL_HOST
26
27 case $host_os in
28   *linux*)
29     AC_DEFINE(HAVE_LINUX, 1, [Linux])
30   ;;
31   *freebsd*)
32     AC_DEFINE(HAVE_FREEBSD, 1, [FreeBSD])
33   ;;
34   *darwin*)
35     AC_DEFINE(HAVE_DARWIN, 1, [Darwin (MacOS/X)])
36   ;;
37   *solaris*)
38     AC_DEFINE(HAVE_SOLARIS, 1, [Solaris/SunOS])
39   ;;
40   *openbsd*)
41     AC_DEFINE(HAVE_OPENBSD, 1, [OpenBSD])
42   ;;
43   *netbsd*)
44     AC_DEFINE(HAVE_NETBSD, 1, [NetBSD])
45   ;;
46   *cygwin*)
47     AC_DEFINE(HAVE_CYGWIN, 1, [Cygwin])
48   ;;
49   *mingw*)
50     AC_DEFINE(HAVE_MINGW, 1, [MinGW])
51     LIBS="$LIBS -lws2_32"
52   ;;
53   *)
54     AC_MSG_ERROR("Unknown operating system.")
55   ;;
56 esac
57
58 AC_CACHE_SAVE
59
60 dnl Checks for libraries.
61
62 dnl Checks for header files.
63 dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
64
65 AC_HEADER_STDC
66 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])
67 AC_CHECK_HEADERS([net/if.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h],
68   [], [],
69   [#ifdef HAVE_SYS_TYPES_H
70    #include <sys/types.h>
71    #endif
72    #ifdef HAVE_NETDB_H
73    #include <netdb.h>
74    #endif
75    #ifdef HAVE_ARPA_INET_H
76    #include <arpa/inet.h>
77    #endif
78    #ifdef HAVE_SYS_SOCKET_H
79    #include <sys/socket.h>
80    #endif
81   ]
82 )
83 AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h],
84   [], [],
85   [#ifdef HAVE_SYS_TYPES_H
86    #include <sys/types.h>
87    #endif
88    #ifdef HAVE_NETDB_H
89    #include <netdb.h>
90    #endif
91    #ifdef HAVE_ARPA_INET_H
92    #include <arpa/inet.h>
93    #endif
94    #ifdef HAVE_SYS_SOCKET_H
95    #include <sys/socket.h>
96    #endif
97    #ifdef HAVE_NET_IF_H
98    #include <net/if.h>
99    #endif
100    #ifdef HAVE_NETINET_IN_SYSTM_H
101    #include <netinet/in_systm.h>
102    #endif
103    #ifdef HAVE_NETINET_IN_H
104    #include <netinet/in.h>
105    #endif
106    #ifdef HAVE_NETINET_IN6_H
107    #include <netinet/in6.h>
108    #endif
109    #ifdef HAVE_NET_ETHERNET_H
110    #include <net/ethernet.h>
111    #endif
112    #ifdef HAVE_NET_IF_ARP_H
113    #include <net/if_arp.h>
114    #endif
115   ]
116 )
117 AC_CHECK_HEADERS([netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h],
118   [], [],
119   [#ifdef HAVE_SYS_TYPES_H
120    #include <sys/types.h>
121    #endif
122    #ifdef HAVE_NETDB_H
123    #include <netdb.h>
124    #endif
125    #ifdef HAVE_ARPA_INET_H
126    #include <arpa/inet.h>
127    #endif
128    #ifdef HAVE_SYS_SOCKET_H
129    #include <sys/socket.h>
130    #endif
131    #ifdef HAVE_NET_IF_H
132    #include <net/if.h>
133    #endif
134    #ifdef HAVE_NETINET_IN_SYSTM_H
135    #include <netinet/in_systm.h>
136    #endif
137    #ifdef HAVE_NETINET_IN_H
138    #include <netinet/in.h>
139    #endif
140    #ifdef HAVE_NETINET_IP_H
141    #include <netinet/ip.h>
142    #endif
143    #ifdef HAVE_NETINET_IN6_H
144    #include <netinet/in6.h>
145    #endif
146    #ifdef HAVE_NETINET_IP6_H
147    #include <netinet/ip6.h>
148    #endif
149    #ifdef HAVE_NET_ETHERNET_H
150    #include <net/ethernet.h>
151    #endif
152    #ifdef HAVE_NET_IF_ARP_H
153    #include <net/if_arp.h>
154    #endif
155    #ifdef HAVE_NETINET_IF_ETHER_H
156    #include <netinet/if_ether.h>
157    #endif
158   ]
159 )
160
161 dnl Checks for typedefs, structures, and compiler characteristics.
162 AC_C_CONST
163 AC_C_VOLATILE
164 AC_TYPE_PID_T
165 AC_TYPE_SIZE_T
166 AC_HEADER_TIME
167 AC_STRUCT_TM
168
169 dnl tinc_ATTRIBUTE(__malloc__)
170
171 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], , ,
172   [#ifdef HAVE_SYS_TYPES_H
173    #include <sys/types.h>
174    #endif
175    #ifdef HAVE_NETDB_H
176    #include <netdb.h>
177    #endif
178    #ifdef HAVE_ARPA_INET_H
179    #include <arpa/inet.h>
180    #endif
181    #ifdef HAVE_SYS_SOCKET_H
182    #include <sys/socket.h>
183    #endif
184    #ifdef HAVE_NET_IF_H
185    #include <net/if.h>
186    #endif
187    #ifdef HAVE_NETINET_IN_SYSTM_H
188    #include <netinet/in_systm.h>
189    #endif
190    #ifdef HAVE_NETINET_IN_H
191    #include <netinet/in.h>
192    #endif
193    #ifdef HAVE_NETINET_IP_H
194    #include <netinet/ip.h>
195    #endif
196    #ifdef HAVE_NETINET_TCP_H
197    #include <netinet/tcp.h>
198    #endif
199    #ifdef HAVE_NETINET_IN6_H
200    #include <netinet/in6.h>
201    #endif
202    #ifdef HAVE_NETINET_IP6_H
203    #include <netinet/ip6.h>
204    #endif
205    #ifdef HAVE_NET_ETHERNET_H
206    #include <net/ethernet.h>
207    #endif
208    #ifdef HAVE_NET_IF_ARP_H
209    #include <net/if_arp.h>
210    #endif
211    #ifdef HAVE_NETINET_IF_ETHER_H
212    #include <netinet/if_ether.h>
213    #endif
214    #ifdef HAVE_NETINET_IP_ICMP_H
215    #include <netinet/ip_icmp.h>
216    #endif
217    #ifdef HAVE_NETINET_ICMP6_H
218    #include <netinet/icmp6.h>
219    #endif
220   ]
221 )
222
223 dnl Checks for library functions.
224 AC_FUNC_MEMCMP
225 AC_FUNC_ALLOCA
226 AC_TYPE_SIGNAL
227 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])
228 AC_FUNC_MALLOC
229 AC_FUNC_REALLOC
230
231 dnl Support for SunOS
232
233 AC_CHECK_FUNC(socket, [], [
234   AC_CHECK_LIB(socket, connect)
235 ])
236 AC_CHECK_FUNC(gethostbyname, [], [
237   AC_CHECK_LIB(nsl, gethostbyname)
238 ])
239
240 AC_CHECK_FUNCS([freeaddrinfo gai_strerror getaddrinfo getnameinfo inet_aton])
241
242 AC_CACHE_SAVE
243
244 tinc_LIBEVENT
245 tinc_LZO
246 AM_PATH_LIBGNUTLS([1.4.0], [], [AC_MSG_ERROR([GNUTLS library not found.]); break])
247 AM_PATH_LIBGNUTLS_EXTRA([1.4.0], [], [AC_MSG_ERROR([GNUTLS extra library not found.]); break])
248 AM_PATH_LIBGCRYPT([1.2.0], [], [AC_MSG_ERROR([Gcrypt library not found.]); break])
249
250 AC_CONFIG_FILES([Makefile m4/Makefile])
251
252 AC_OUTPUT