Check if libpthread is required or not.
[strongswan.git] / configure.in
1 dnl  configure.in for linux strongSwan
2 dnl  Copyright (C) 2006 Martin Willi
3 dnl  Hochschule fuer Technik Rapperswil
4 dnl
5 dnl  This program is free software; you can redistribute it and/or modify it
6 dnl  under the terms of the GNU General Public License as published by the
7 dnl  Free Software Foundation; either version 2 of the License, or (at your
8 dnl  option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
9 dnl
10 dnl  This program is distributed in the hope that it will be useful, but
11 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 dnl  for more details.
14
15 dnl ===========================
16 dnl  initialize & set some vars
17 dnl ===========================
18
19 AC_INIT(strongSwan,4.3.6)
20 AM_INIT_AUTOMAKE(tar-ustar)
21 AC_CONFIG_MACRO_DIR([m4/config])
22 PKG_PROG_PKG_CONFIG
23
24 dnl =================================
25 dnl  check --enable-xxx & --with-xxx
26 dnl =================================
27
28 m4_include(m4/macros/with.m4)
29
30 ARG_WITH_SUBST([default-pkcs11],     [/usr/lib/opensc-pkcs11.so], [set the default PKCS11 library])
31 ARG_WITH_SUBST([random-device],      [/dev/random], [set the device to read real random data from])
32 ARG_WITH_SUBST([urandom-device],     [/dev/urandom], [set the device to read pseudo random data from])
33 ARG_WITH_SUBST([strongswan-conf],    [${sysconfdir}/strongswan.conf], [set the strongswan.conf file location])
34 ARG_WITH_SUBST([resolv-conf],        [${sysconfdir}/resolv.conf], [set the file to use in DNS handler plugin])
35 ARG_WITH_SUBST([piddir],             [/var/run], [set path for PID and UNIX socket files])
36 ARG_WITH_SUBST([ipsecdir],           [${libexecdir%/}/ipsec], [set installation path for ipsec tools])
37 ARG_WITH_SUBST([plugindir],          [${ipsecdir%/}/plugins], [set the installation path of plugins])
38 ARG_WITH_SUBST([nm-ca-dir],          [/usr/share/ca-certificates], [directory the NM plugin uses to look up trusted root certificates])
39 ARG_WITH_SUBST([linux-headers],      [\${top_srcdir}/src/include], [set directory of linux header files to use])
40 ARG_WITH_SUBST([routing-table],      [220], [set routing table to use for IPsec routes])
41 ARG_WITH_SUBST([routing-table-prio], [220], [set priority for IPsec routing table])
42
43 ARG_WITH_SET([capabilities],         [no], [set capability dropping library. Currently only the value "libcap" is supported])
44
45 AC_ARG_WITH(
46         [xauth-module],
47         AS_HELP_STRING([--with-xauth-module=lib],[set the path to the XAUTH module]),
48         [AC_DEFINE_UNQUOTED(XAUTH_DEFAULT_LIB, "$withval")],
49 )
50
51 AC_ARG_WITH(
52         [user],
53         AS_HELP_STRING([--with-user=user],[change user of the daemons to "user" after startup (default is "root").]),
54         [AC_DEFINE_UNQUOTED(IPSEC_USER, "$withval") AC_SUBST(ipsecuser, "$withval")],
55         [AC_SUBST(ipsecuser, "root")]
56 )
57
58 AC_ARG_WITH(
59         [group],
60         AS_HELP_STRING([--with-group=group],[change group of the daemons to "group" after startup (default is "root").]),
61         [AC_DEFINE_UNQUOTED(IPSEC_GROUP, "$withval") AC_SUBST(ipsecgroup, "$withval")],
62         [AC_SUBST(ipsecgroup, "root")]
63 )
64
65 m4_include(m4/macros/enable-disable.m4)
66
67 ARG_ENABL_SET([curl],           [enable CURL fetcher plugin to fetch files via libcurl. Requires libcurl.])
68 ARG_ENABL_SET([ldap],           [enable LDAP fetching plugin to fetch files via libldap. Requires openLDAP.])
69 ARG_DISBL_SET([aes],            [disable AES software implementation plugin.])
70 ARG_DISBL_SET([des],            [disable DES/3DES software implementation plugin.])
71 ARG_ENABL_SET([blowfish],       [enable Blowfish software implementation plugin.])
72 ARG_ENABL_SET([md4],            [enable MD4 software implementation plugin.])
73 ARG_DISBL_SET([md5],            [disable MD5 software implementation plugin.])
74 ARG_DISBL_SET([sha1],           [disable SHA1 software implementation plugin.])
75 ARG_DISBL_SET([sha2],           [disable SHA256/SHA384/SHA512 software implementation plugin.])
76 ARG_DISBL_SET([fips-prf],       [disable FIPS PRF software implementation plugin.])
77 ARG_DISBL_SET([gmp],            [disable GNU MP (libgmp) based crypto implementation plugin.])
78 ARG_DISBL_SET([random],         [disable RNG implementation on top of /dev/(u)random.])
79 ARG_DISBL_SET([x509],           [disable X509 certificate implementation plugin.])
80 ARG_DISBL_SET([pubkey],         [disable RAW public key support plugin.])
81 ARG_DISBL_SET([pkcs1],          [disable PKCS1 key decoding plugin.])
82 ARG_DISBL_SET([pgp],            [disable PGP key decoding plugin.])
83 ARG_DISBL_SET([dnskey],         [disable DNS RR key decoding plugin.])
84 ARG_DISBL_SET([pem],            [disable PEM decoding plugin.])
85 ARG_DISBL_SET([hmac],           [disable HMAC crypto implementation plugin.])
86 ARG_DISBL_SET([xcbc],           [disable xcbc crypto implementation plugin.])
87 ARG_ENABL_SET([test-vectors],   [enable plugin providing crypto test vectors.])
88 ARG_ENABL_SET([mysql],          [enable MySQL database support. Requires libmysqlclient_r.])
89 ARG_ENABL_SET([sqlite],         [enable SQLite database support. Requires libsqlite3.])
90 ARG_DISBL_SET([stroke],         [disable charons stroke (pluto compatibility) configuration backend.])
91 ARG_ENABL_SET([medsrv],         [enable mediation server web frontend and daemon plugin.])
92 ARG_ENABL_SET([medcli],         [enable mediation client configuration database plugin.])
93 ARG_ENABL_SET([smp],            [enable SMP configuration and control interface. Requires libxml.])
94 ARG_ENABL_SET([sql],            [enable SQL database configuration backend.])
95 ARG_ENABL_SET([smartcard],      [enable smartcard support.])
96 ARG_ENABL_SET([cisco-quirks],   [enable support of Cisco VPN client.])
97 ARG_ENABL_SET([leak-detective], [enable malloc hooks to find memory leaks.])
98 ARG_ENABL_SET([lock-profiler],  [enable lock/mutex profiling code.])
99 ARG_ENABL_SET([unit-tests],     [enable unit tests on IKEv2 daemon startup.])
100 ARG_ENABL_SET([load-tester],    [enable load testing plugin for IKEv2 daemon.])
101 ARG_ENABL_SET([eap-sim],        [enable SIM authenication module for EAP.])
102 ARG_ENABL_SET([eap-sim-file],   [enable EAP-SIM backend based on a triplet file.])
103 ARG_ENABL_SET([eap-simaka-pseudonym], [enable EAP-SIM/AKA pseudonym storage plugin.])
104 ARG_ENABL_SET([eap-simaka-reauth],    [enable EAP-SIM/AKA reauthentication data storage plugin.])
105 ARG_ENABL_SET([eap-identity],   [enable EAP module providing EAP-Identity helper.])
106 ARG_ENABL_SET([eap-md5],        [enable EAP MD5 (CHAP) authenication module.])
107 ARG_ENABL_SET([eap-gtc],        [enable PAM based EAP GTC authenication module.])
108 ARG_ENABL_SET([eap-aka],        [enable EAP AKA authentication module.])
109 ARG_ENABL_SET([eap-aka-3gpp2],  [enable EAP AKA backend implementing 3GPP2 algorithms in software. Requires libgmp.])
110 ARG_ENABL_SET([eap-mschapv2],   [enable EAP MS-CHAPv2 authenication module.])
111 ARG_ENABL_SET([eap-radius],     [enable RADIUS proxy authenication module.])
112 ARG_DISBL_SET([kernel-netlink], [disable the netlink kernel interface.])
113 ARG_ENABL_SET([kernel-pfkey],   [enable the PF_KEY kernel interface.])
114 ARG_ENABL_SET([kernel-pfroute], [enable the PF_ROUTE kernel interface.])
115 ARG_ENABL_SET([kernel-klips],   [enable the KLIPS kernel interface.])
116 ARG_ENABL_SET([nat-transport],  [enable NAT traversal with IPsec transport mode in pluto.])
117 ARG_DISBL_SET([vendor-id],      [disable the sending of the strongSwan vendor ID in pluto.])
118 ARG_DISBL_SET([xauth-vid],      [disable the sending of the XAUTH vendor ID.])
119 ARG_ENABL_SET([dumm],           [enable the DUMM UML test framework.])
120 ARG_ENABL_SET([fast],           [enable libfast (FastCGI Application Server w/ templates.])
121 ARG_ENABL_SET([manager],        [enable web management console (proof of concept).])
122 ARG_ENABL_SET([mediation],      [enable IKEv2 Mediation Extension.])
123 ARG_ENABL_SET([integrity-test], [enable integrity testing of libstrongswan and plugins.])
124 ARG_DISBL_SET([pluto],          [disable the IKEv1 keying daemon pluto.])
125 ARG_DISBL_SET([threads],        [disable the use of threads in pluto. Charon always uses threads.])
126 ARG_DISBL_SET([charon],         [disable the IKEv2 keying daemon charon.])
127 ARG_DISBL_SET([tools],          [disable additional utilities (openac, scepclient and pki).])
128 ARG_DISBL_SET([scripts],        [disable additional utilities (found in directory scripts).])
129 ARG_DISBL_SET([updown],         [disable updown firewall script plugin.])
130 ARG_DISBL_SET([attr],           [disable strongswan.conf based configuration attribute plugin.])
131 ARG_ENABL_SET([attr-sql],       [enable SQL based configuration attribute plugin.])
132 ARG_DISBL_SET([resolve],        [disable resolve DNS handler plugin.])
133 ARG_ENABL_SET([padlock],        [enables VIA Padlock crypto plugin.])
134 ARG_ENABL_SET([openssl],        [enables the OpenSSL crypto plugin.])
135 ARG_ENABL_SET([gcrypt],         [enables the libgcrypt plugin.])
136 ARG_ENABL_SET([agent],          [enables the ssh-agent signing plugin.])
137 ARG_ENABL_SET([uci],            [enable OpenWRT UCI configuration plugin.])
138 ARG_ENABL_SET([nm],             [enable NetworkManager plugin.])
139 ARG_ENABL_SET([vstr],           [enforce using the Vstr string library to replace glibc-like printf hooks.])
140
141 dnl =========================
142 dnl  set up compiler and flags
143 dnl =========================
144
145 if test -z "$CFLAGS"; then
146         CFLAGS="-g -O2 -Wall -Wno-format -Wno-pointer-sign -Wno-strict-aliasing"
147 fi
148 AC_PROG_CC
149 AC_LIB_PREFIX
150 AC_C_BIGENDIAN
151
152 dnl =========================
153 dnl  check required programs
154 dnl =========================
155
156 AC_PROG_INSTALL
157 AC_PROG_LIBTOOL
158 AC_PROG_EGREP
159 AC_PROG_AWK
160 AC_PROG_LEX
161 AC_PROG_YACC
162 AC_PATH_PROG([PERL], [perl], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
163 AC_PATH_PROG([GPERF], [gperf], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
164
165 dnl because gperf is not needed by end-users we just report it but do not abort on failure
166 AC_MSG_CHECKING([gperf version >= 3.0.0])
167 if test -x "$GPERF"; then
168         if test "`$GPERF --version | $AWK -F' ' '/^GNU gperf/ { print $3 }' | $AWK -F. '{ print $1 }'`" -ge "3"; then
169                 AC_MSG_RESULT([yes])
170         else
171                 AC_MSG_RESULT([no])
172         fi
173 else
174         AC_MSG_RESULT([not found])
175 fi
176
177 dnl translate user/group to numercial ids
178 AC_MSG_CHECKING([for uid of user "$ipsecuser"])
179 ipsecuid=`id -u $ipsecuser 2>/dev/null`
180 if test -n "$ipsecuid"; then
181         AC_MSG_RESULT([$ipsecuid])
182         AC_SUBST(ipsecuid)
183 else
184         AC_MSG_ERROR([not found])
185 fi
186 AC_MSG_CHECKING([for gid of group "$ipsecgroup"])
187 ipsecgid=`$EGREP "^$ipsecgroup:" /etc/group | $AWK -F: '{ print $3 }'`
188 if test -n "$ipsecgid"; then
189         AC_MSG_RESULT([$ipsecgid])
190         AC_SUBST(ipsecgid)
191 else
192         AC_MSG_ERROR([not found])
193 fi
194
195 dnl =========================
196 dnl  dependency calculation
197 dnl =========================
198
199 if test x$eap_aka_3gpp2 = xtrue; then
200         gmp=true;
201 fi
202
203 if test x$eap_aka = xtrue; then
204         fips_prf=true;
205         sha1=true;
206         simaka=true;
207 fi
208
209 if test x$eap_sim = xtrue; then
210         fips_prf=true;
211         simaka=true;
212 fi
213
214 if test x$fips_prf = xtrue; then
215         sha1=true;
216 fi
217
218 if test x$smp = xtrue; then
219         xml=true
220 fi
221
222 if test x$manager = xtrue; then
223         fast=true
224 fi
225
226 if test x$medsrv = xtrue; then
227         mediation=true
228         fast=true
229 fi
230
231 if test x$medcli = xtrue; then
232         mediation=true
233 fi
234
235 dnl ===========================================
236 dnl  check required libraries and header files
237 dnl ===========================================
238
239 AC_HEADER_STDBOOL
240 AC_FUNC_ALLOCA
241
242 dnl libraries needed on some platforms but not on others
243 dnl ====================================================
244 saved_LIBS=$LIBS
245
246 dnl FreeBSD and Mac OS X have dlopen integrated in libc, Linux needs libdl
247 LIBS=""
248 AC_SEARCH_LIBS(dlopen, dl, [DLLIB=$LIBS])
249 AC_SUBST(DLLIB)
250
251 dnl glibc's backtrace() can be replicated on FreeBSD with libexecinfo
252 LIBS=""
253 AC_SEARCH_LIBS(backtrace, execinfo, [BTLIB=$LIBS])
254 AC_CHECK_FUNCS(backtrace)
255 AC_SUBST(BTLIB)
256
257 dnl OpenSolaris needs libsocket and libnsl for socket()
258 LIBS=""
259 AC_SEARCH_LIBS(socket, socket, [SOCKLIB=$LIBS],
260         [AC_CHECK_LIB(nsl, socket, [SOCKLIB="-lsocket -lnsl"], [], [-lsocket])]
261 )
262 AC_SUBST(SOCKLIB)
263
264 dnl FreeBSD has clock_gettime in libc, Linux needs librt
265 LIBS=""
266 AC_SEARCH_LIBS(clock_gettime, rt, [RTLIB=$LIBS])
267 AC_CHECK_FUNCS(clock_gettime)
268 AC_SUBST(RTLIB)
269
270 dnl Android has pthread_* functions in bionic (libc), others need libpthread
271 LIBS=""
272 AC_SEARCH_LIBS(pthread_create, pthread, [PTHREADLIB=$LIBS])
273 AC_SUBST(PTHREADLIB)
274
275 LIBS=$saved_LIBS
276 dnl ======================
277
278 AC_MSG_CHECKING(for dladdr)
279 AC_TRY_COMPILE(
280         [#define _GNU_SOURCE
281          #include <dlfcn.h>],
282         [Dl_info* info = 0;
283          dladdr(0, info);],
284         [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_DLADDR])],
285         [AC_MSG_RESULT([no])]
286 )
287
288 dnl check if pthread_condattr_setclock(CLOCK_MONOTONE) is supported
289 saved_LIBS=$LIBS
290 LIBS=$PTHREADLIB
291 AC_MSG_CHECKING([for pthread_condattr_setclock(CLOCK_MONOTONE)])
292 AC_TRY_RUN(
293         [#include <pthread.h>
294          int main() { pthread_condattr_t attr;
295                 pthread_condattr_init(&attr);
296                 return pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);}],
297         [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_CONDATTR_CLOCK_MONOTONIC])],
298         [AC_MSG_RESULT([no])],
299         dnl Check existence of pthread_condattr_setclock if cross-compiling
300         [AC_MSG_RESULT([unknown]);
301          AC_CHECK_FUNCS(pthread_condattr_setclock,
302                 [AC_DEFINE([HAVE_CONDATTR_CLOCK_MONOTONIC])]
303         )]
304 )
305 dnl check if we actually are able to configure attributes on cond vars
306 AC_CHECK_FUNCS(pthread_condattr_init)
307 dnl check if native rwlocks are available
308 AC_CHECK_FUNCS(pthread_rwlock_init)
309 LIBS=$saved_LIBS
310
311 AC_CHECK_FUNCS(prctl)
312
313 AC_CHECK_HEADERS(sys/sockio.h)
314 AC_CHECK_HEADERS(net/pfkeyv2.h netipsec/ipsec.h netinet6/ipsec.h linux/udp.h)
315
316 AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [],
317 [
318         #include <sys/types.h>
319         #include <sys/socket.h>
320 ])
321
322 AC_CHECK_MEMBERS([struct sadb_x_policy.sadb_x_policy_priority], [], [],
323 [
324         #include <sys/types.h>
325         #ifdef HAVE_NET_PFKEYV2_H
326         #include <net/pfkeyv2.h>
327         #else
328         #include <stdint.h>
329         #include <linux/pfkeyv2.h>
330         #endif
331 ])
332
333 AC_MSG_CHECKING([for IPSEC_MODE_BEET])
334 AC_TRY_COMPILE(
335         [#include <sys/types.h>
336         #ifdef HAVE_NETIPSEC_IPSEC_H
337         #include <netipsec/ipsec.h>
338         #elif defined(HAVE_NETINET6_IPSEC_H)
339         #include <netinet6/ipsec.h>
340         #else
341         #include <stdint.h>
342         #include <linux/ipsec.h>
343         #endif],
344         [int mode = IPSEC_MODE_BEET;
345          return mode;],
346         [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_IPSEC_MODE_BEET])],
347         [AC_MSG_RESULT([no])]
348 )
349
350 AC_MSG_CHECKING([for IPSEC_DIR_FWD])
351 AC_TRY_COMPILE(
352         [#include <sys/types.h>
353         #ifdef HAVE_NETIPSEC_IPSEC_H
354         #include <netipsec/ipsec.h>
355         #elif defined(HAVE_NETINET6_IPSEC_H)
356         #include <netinet6/ipsec.h>
357         #else
358         #include <stdint.h>
359         #include <linux/ipsec.h>
360         #endif],
361         [int dir = IPSEC_DIR_FWD;
362          return dir;],
363         [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_IPSEC_DIR_FWD])],
364         [AC_MSG_RESULT([no])]
365 )
366
367 AC_MSG_CHECKING([for gcc atomic operations])
368 AC_TRY_RUN(
369 [
370         int main() {
371                 volatile int ref = 1;
372                 __sync_fetch_and_add (&ref, 1);
373                 __sync_sub_and_fetch (&ref, 1);
374                 /* Make sure test fails if operations are not supported */
375                 __sync_val_compare_and_swap(&ref, 1, 0);
376                 return ref;
377         }
378 ],
379 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_GCC_ATOMIC_OPERATIONS)],
380 [AC_MSG_RESULT([no])],
381 [AC_MSG_RESULT([no])])
382
383 dnl check for the new register_printf_specifier function with len argument,
384 dnl or the deprecated register_printf_function without
385 AC_CHECK_FUNC(
386         [register_printf_specifier],
387         [AC_DEFINE(HAVE_PRINTF_SPECIFIER)],
388         [AC_CHECK_FUNC(
389                 [register_printf_function],
390                 [AC_DEFINE(HAVE_PRINTF_FUNCTION)],
391                 [
392                         AC_MSG_NOTICE([printf does not support custom format specifiers!])
393                         vstr=true
394                 ]
395         )]
396 )
397
398 if test x$vstr = xtrue; then
399         AC_HAVE_LIBRARY([vstr],[LIBS="$LIBS"],[AC_MSG_ERROR([Vstr string library not found])])
400         AC_DEFINE(USE_VSTR)
401 fi
402
403 if test x$gmp = xtrue; then
404         AC_HAVE_LIBRARY([gmp],[LIBS="$LIBS"],[AC_MSG_ERROR([GNU Multi Precision library gmp not found])])
405         AC_MSG_CHECKING([gmp.h version >= 4.1.4])
406         AC_TRY_COMPILE(
407                 [#include "gmp.h"],
408                 [
409                         #if (__GNU_MP_VERSION*100 +  __GNU_MP_VERSION_MINOR*10 + __GNU_MP_VERSION_PATCHLEVEL) < 414
410                                 #error bad gmp
411                         #endif
412                 ],
413                 [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); AC_MSG_ERROR([No usable gmp.h found!])]
414         )
415 fi
416
417 if test x$ldap = xtrue; then
418         AC_HAVE_LIBRARY([ldap],[LIBS="$LIBS"],[AC_MSG_ERROR([LDAP library ldap not found])])
419         AC_HAVE_LIBRARY([lber],[LIBS="$LIBS"],[AC_MSG_ERROR([LDAP library lber not found])])
420         AC_CHECK_HEADER([ldap.h],,[AC_MSG_ERROR([LDAP header ldap.h not found!])])
421 fi
422
423 if test x$curl = xtrue; then
424         AC_HAVE_LIBRARY([curl],[LIBS="$LIBS"],[AC_MSG_ERROR([CURL library curl not found])])
425         AC_CHECK_HEADER([curl/curl.h],,[AC_MSG_ERROR([CURL header curl/curl.h not found!])])
426 fi
427
428 if test x$xml = xtrue; then
429         PKG_CHECK_MODULES(xml, [libxml-2.0])
430         AC_SUBST(xml_CFLAGS)
431         AC_SUBST(xml_LIBS)
432 fi
433
434 if test x$dumm = xtrue; then
435         PKG_CHECK_MODULES(gtk, [gtk+-2.0 vte])
436         AC_SUBST(gtk_CFLAGS)
437         AC_SUBST(gtk_LIBS)
438         AC_CHECK_PROGS(RUBY, ruby)
439         AC_MSG_CHECKING([for Ruby header files])
440         if test -n "$RUBY"; then
441                 RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null`
442                 if test -n "$RUBYDIR"; then
443                         dirs="$RUBYDIR"
444                         RUBYINCLUDE=none
445                         for i in $dirs; do
446                                 if test -r $i/ruby.h; then
447                                         AC_MSG_RESULT([$i])
448                                         RUBYINCLUDE="-I$i"
449                                         break;
450                                 fi
451                         done
452                         if test x"$RUBYINCLUDE" = xnone; then
453                                 AC_MSG_ERROR([ruby.h not found])
454                         fi
455                         AC_SUBST(RUBYINCLUDE)
456                 else
457                         AC_MSG_ERROR([unable to determine ruby configuration])
458                 fi
459         else
460                 AC_MSG_ERROR([don't know how to run ruby])
461         fi
462 fi
463
464 if test x$fast = xtrue; then
465         AC_HAVE_LIBRARY([neo_cgi],[LIBS="$LIBS"],[AC_MSG_ERROR([ClearSilver library neo_cgi not found!])])
466         AC_HAVE_LIBRARY([neo_utl],[LIBS="$LIBS"],[AC_MSG_ERROR([ClearSilver library neo_utl not found!])])
467         AC_HAVE_LIBRARY([z],[LIBS="$LIBS"],[AC_MSG_ERROR([ClearSilver dependency zlib not found!])])
468 dnl autoconf does not like CamelCase!? How to fix this?
469 dnl     AC_CHECK_HEADER([ClearSilver/ClearSilver.h],,[AC_MSG_ERROR([ClearSilver header file ClearSilver/ClearSilver.h not found!])])
470
471         AC_HAVE_LIBRARY([fcgi],[LIBS="$LIBS"],[AC_MSG_ERROR([FastCGI library fcgi not found!])])
472         AC_CHECK_HEADER([fcgiapp.h],,[AC_MSG_ERROR([FastCGI header file fcgiapp.h not found!])])
473 fi
474
475 if test x$mysql = xtrue; then
476         AC_PATH_PROG([MYSQLCONFIG], [mysql_config], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
477         if test x$MYSQLCONFIG = x; then
478                 AC_MSG_ERROR([mysql_config not found!])
479         fi
480         AC_SUBST(MYSQLLIB, `$MYSQLCONFIG --libs_r`)
481         AC_SUBST(MYSQLCFLAG, `$MYSQLCONFIG --cflags`)
482 fi
483
484 if test x$sqlite = xtrue; then
485         AC_HAVE_LIBRARY([sqlite3],[LIBS="$LIBS"],[AC_MSG_ERROR([SQLite library sqlite3 not found])])
486         AC_CHECK_HEADER([sqlite3.h],,[AC_MSG_ERROR([SQLite header sqlite3.h not found!])])
487         AC_MSG_CHECKING([sqlite3_prepare_v2])
488         AC_TRY_COMPILE(
489                 [#include <sqlite3.h>],
490                 [
491                         void *test = sqlite3_prepare_v2;
492                 ],
493                 [AC_MSG_RESULT([yes])]; AC_DEFINE_UNQUOTED(HAVE_SQLITE3_PREPARE_V2, 1), [AC_MSG_RESULT([no])])
494         AC_MSG_CHECKING([sqlite3.h version >= 3.3.1])
495         AC_TRY_COMPILE(
496                 [#include <sqlite3.h>],
497                 [
498                         #if SQLITE_VERSION_NUMBER < 3003001
499                                 #error bad sqlite
500                         #endif
501                 ],
502                 [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); AC_MSG_ERROR([SQLite version >= 3.3.1 required!])])
503 fi
504
505 if test x$openssl = xtrue; then
506         AC_HAVE_LIBRARY([crypto],[LIBS="$LIBS"],[AC_MSG_ERROR([OpenSSL crypto library not found])])
507         AC_CHECK_HEADER([openssl/evp.h],,[AC_MSG_ERROR([OpenSSL header openssl/evp.h not found!])])
508 fi
509
510 if test x$gcrypt = xtrue; then
511         AC_HAVE_LIBRARY([gcrypt],[LIBS="$LIBS"],[AC_MSG_ERROR([gcrypt library not found])])
512         AC_CHECK_HEADER([gcrypt.h],,[AC_MSG_ERROR([gcrypt header gcrypt.h not found!])])
513         AC_MSG_CHECKING([gcrypt CAMELLIA cipher])
514         AC_TRY_COMPILE(
515                 [#include <gcrypt.h>],
516                 [enum gcry_cipher_algos alg = GCRY_CIPHER_CAMELLIA128;],
517                 [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_GCRY_CIPHER_CAMELLIA])],
518                 [AC_MSG_RESULT([no])]
519         )
520 fi
521
522 if test x$uci = xtrue; then
523         AC_HAVE_LIBRARY([uci],[LIBS="$LIBS"],[AC_MSG_ERROR([UCI library libuci not found])])
524         AC_CHECK_HEADER([uci.h],,[AC_MSG_ERROR([UCI header uci.h not found!])])
525 fi
526
527 if test x$nm = xtrue; then
528         PKG_CHECK_EXISTS([libnm-glib],
529                 [PKG_CHECK_MODULES(nm, [NetworkManager gthread-2.0 libnm-glib libnm-glib-vpn])],
530                 [PKG_CHECK_MODULES(nm, [NetworkManager gthread-2.0 libnm_glib libnm_glib_vpn])]
531         )
532         AC_SUBST(nm_CFLAGS)
533         AC_SUBST(nm_LIBS)
534 fi
535
536 if test x$eap_gtc = xtrue; then
537         AC_HAVE_LIBRARY([pam],[LIBS="$LIBS"],[AC_MSG_ERROR([PAM library not found])])
538         AC_CHECK_HEADER([security/pam_appl.h],,[AC_MSG_ERROR([PAM header security/pam_appl.h not found!])])
539 fi
540
541 if test x$capabilities = xlibcap; then
542         AC_HAVE_LIBRARY([cap],[LIBS="$LIBS"],[AC_MSG_ERROR([libcap library not found])])
543         AC_CHECK_HEADER([sys/capability.h],,[AC_MSG_ERROR([libcap header sys/capability.h not found!])])
544 fi
545
546 if test x$integrity_test = xtrue; then
547         AC_MSG_CHECKING([for dladdr()])
548         AC_TRY_COMPILE(
549                 [#define _GNU_SOURCE
550                  #include <dlfcn.h>],
551                 [Dl_info info; dladdr(main, &info);],
552                 [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]);
553                  AC_MSG_ERROR([dladdr() not supported, required by integrity-test!])]
554         )
555         AC_MSG_CHECKING([for dl_iterate_phdr()])
556         AC_TRY_COMPILE(
557                 [#define _GNU_SOURCE
558                  #include <link.h>],
559                 [dl_iterate_phdr((void*)0, (void*)0);],
560                 [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]);
561                  AC_MSG_ERROR([dl_iterate_phdr() not supported, required by integrity-test!])]
562         )
563 fi
564
565 dnl ======================================
566 dnl  collect all plugins for libstrongswan
567 dnl ======================================
568
569 libstrongswan_plugins=
570 pluto_plugins=
571
572 if test x$test_vectors = xtrue; then
573         libstrongswan_plugins=${libstrongswan_plugins}" test-vectors"
574         pluto_plugins=${pluto_plugins}" test-vectors"
575 fi
576 if test x$curl = xtrue; then
577         libstrongswan_plugins=${libstrongswan_plugins}" curl"
578         pluto_plugins=${pluto_plugins}" curl"
579 fi
580 if test x$ldap = xtrue; then
581         libstrongswan_plugins=${libstrongswan_plugins}" ldap"
582         pluto_plugins=${pluto_plugins}" ldap"
583 fi
584 if test x$aes = xtrue; then
585         libstrongswan_plugins=${libstrongswan_plugins}" aes"
586         pluto_plugins=${pluto_plugins}" aes"
587 fi
588 if test x$des = xtrue; then
589         libstrongswan_plugins=${libstrongswan_plugins}" des"
590         pluto_plugins=${pluto_plugins}" des"
591 fi
592 if test x$blowfish = xtrue; then
593         libstrongswan_plugins=${libstrongswan_plugins}" blowfish"
594         pluto_plugins=${pluto_plugins}" blowfish"
595 fi
596 if test x$sha1 = xtrue; then
597         libstrongswan_plugins=${libstrongswan_plugins}" sha1"
598         pluto_plugins=${pluto_plugins}" sha1"
599 fi
600 if test x$sha2 = xtrue; then
601         libstrongswan_plugins=${libstrongswan_plugins}" sha2"
602         pluto_plugins=${pluto_plugins}" sha2"
603 fi
604 if test x$md4 = xtrue; then
605         libstrongswan_plugins=${libstrongswan_plugins}" md4"
606 fi
607 if test x$md5 = xtrue; then
608         libstrongswan_plugins=${libstrongswan_plugins}" md5"
609         pluto_plugins=${pluto_plugins}" md5"
610 fi
611 if test x$fips_prf = xtrue; then
612         libstrongswan_plugins=${libstrongswan_plugins}" fips-prf"
613 fi
614 if test x$random = xtrue; then
615         libstrongswan_plugins=${libstrongswan_plugins}" random"
616         pluto_plugins=${pluto_plugins}" random"
617 fi
618 if test x$x509 = xtrue; then
619         libstrongswan_plugins=${libstrongswan_plugins}" x509"
620         pluto_plugins=${pluto_plugins}" x509"
621 fi
622 if test x$pubkey = xtrue; then
623         libstrongswan_plugins=${libstrongswan_plugins}" pubkey"
624         pluto_plugins=${pluto_plugins}" pubkey"
625 fi
626 if test x$pkcs1 = xtrue; then
627         libstrongswan_plugins=${libstrongswan_plugins}" pkcs1"
628         pluto_plugins=${pluto_plugins}" pkcs1"
629 fi
630 if test x$pgp = xtrue; then
631         libstrongswan_plugins=${libstrongswan_plugins}" pgp"
632         pluto_plugins=${pluto_plugins}" pgp"
633 fi
634 if test x$dnskey = xtrue; then
635         libstrongswan_plugins=${libstrongswan_plugins}" dnskey"
636         pluto_plugins=${pluto_plugins}" dnskey"
637 fi
638 if test x$pem = xtrue; then
639         libstrongswan_plugins=${libstrongswan_plugins}" pem"
640         pluto_plugins=${pluto_plugins}" pem"
641 fi
642 if test x$mysql = xtrue; then
643         libstrongswan_plugins=${libstrongswan_plugins}" mysql"
644         pluto_plugins=${pluto_plugins}" mysql"
645 fi
646 if test x$sqlite = xtrue; then
647         libstrongswan_plugins=${libstrongswan_plugins}" sqlite"
648         pluto_plugins=${pluto_plugins}" sqlite"
649 fi
650 if test x$attr_sql = xtrue -o x$sql = xtrue; then
651         libstrongswan_plugins=${libstrongswan_plugins}" attr-sql"
652         pluto_plugins=${pluto_plugins}" attr-sql"
653 fi
654 if test x$padlock = xtrue; then
655         libstrongswan_plugins=${libstrongswan_plugins}" padlock"
656 fi
657 if test x$openssl = xtrue; then
658         libstrongswan_plugins=${libstrongswan_plugins}" openssl"
659         pluto_plugins=${pluto_plugins}" openssl"
660 fi
661 if test x$gcrypt = xtrue; then
662         libstrongswan_plugins=${libstrongswan_plugins}" gcrypt"
663         pluto_plugins=${pluto_plugins}" gcrypt"
664 fi
665 if test x$xcbc = xtrue; then
666         libstrongswan_plugins=${libstrongswan_plugins}" xcbc"
667 fi
668 if test x$hmac = xtrue; then
669         libstrongswan_plugins=${libstrongswan_plugins}" hmac"
670         pluto_plugins=${pluto_plugins}" hmac"
671 fi
672 if test x$agent = xtrue; then
673         libstrongswan_plugins=${libstrongswan_plugins}" agent"
674 fi
675 if test x$gmp = xtrue; then
676         libstrongswan_plugins=${libstrongswan_plugins}" gmp"
677         pluto_plugins=${pluto_plugins}" gmp"
678 fi
679
680 AC_SUBST(libstrongswan_plugins)
681 AC_SUBST(pluto_plugins)
682
683 dnl =========================
684 dnl  set Makefile.am vars
685 dnl =========================
686
687 dnl libstrongswan plugins
688 dnl =====================
689 AM_CONDITIONAL(USE_TEST_VECTORS, test x$test_vectors = xtrue)
690 AM_CONDITIONAL(USE_CURL, test x$curl = xtrue)
691 AM_CONDITIONAL(USE_LDAP, test x$ldap = xtrue)
692 AM_CONDITIONAL(USE_AES, test x$aes = xtrue)
693 AM_CONDITIONAL(USE_DES, test x$des = xtrue)
694 AM_CONDITIONAL(USE_BLOWFISH, test x$blowfish = xtrue)
695 AM_CONDITIONAL(USE_MD4, test x$md4 = xtrue)
696 AM_CONDITIONAL(USE_MD5, test x$md5 = xtrue)
697 AM_CONDITIONAL(USE_SHA1, test x$sha1 = xtrue)
698 AM_CONDITIONAL(USE_SHA2, test x$sha2 = xtrue)
699 AM_CONDITIONAL(USE_FIPS_PRF, test x$fips_prf = xtrue)
700 AM_CONDITIONAL(USE_GMP, test x$gmp = xtrue)
701 AM_CONDITIONAL(USE_RANDOM, test x$random = xtrue)
702 AM_CONDITIONAL(USE_X509, test x$x509 = xtrue)
703 AM_CONDITIONAL(USE_PUBKEY, test x$pubkey = xtrue)
704 AM_CONDITIONAL(USE_PKCS1, test x$pkcs1 = xtrue)
705 AM_CONDITIONAL(USE_PGP, test x$pgp = xtrue)
706 AM_CONDITIONAL(USE_DNSKEY, test x$dnskey = xtrue)
707 AM_CONDITIONAL(USE_PEM, test x$pem = xtrue)
708 AM_CONDITIONAL(USE_HMAC, test x$hmac = xtrue)
709 AM_CONDITIONAL(USE_XCBC, test x$xcbc = xtrue)
710 AM_CONDITIONAL(USE_MYSQL, test x$mysql = xtrue)
711 AM_CONDITIONAL(USE_SQLITE, test x$sqlite = xtrue)
712 AM_CONDITIONAL(USE_ATTR_SQL, test x$attr_sql = xtrue -o x$sql = xtrue)
713 AM_CONDITIONAL(USE_PADLOCK, test x$padlock = xtrue)
714 AM_CONDITIONAL(USE_OPENSSL, test x$openssl = xtrue)
715 AM_CONDITIONAL(USE_GCRYPT, test x$gcrypt = xtrue)
716 AM_CONDITIONAL(USE_AGENT, test x$agent = xtrue)
717
718 dnl charon plugins
719 dnl ==============
720 AM_CONDITIONAL(USE_STROKE, test x$stroke = xtrue)
721 AM_CONDITIONAL(USE_MEDSRV, test x$medsrv = xtrue)
722 AM_CONDITIONAL(USE_MEDCLI, test x$medcli = xtrue)
723 AM_CONDITIONAL(USE_NM, test x$nm = xtrue)
724 AM_CONDITIONAL(USE_UCI, test x$uci = xtrue)
725 AM_CONDITIONAL(USE_SMP, test x$smp = xtrue)
726 AM_CONDITIONAL(USE_SQL, test x$sql = xtrue)
727 AM_CONDITIONAL(USE_UPDOWN, test x$updown = xtrue)
728 AM_CONDITIONAL(USE_ATTR, test x$attr = xtrue)
729 AM_CONDITIONAL(USE_RESOLVE, test x$resolve = xtrue)
730 AM_CONDITIONAL(USE_UNIT_TESTS, test x$unit_tests = xtrue)
731 AM_CONDITIONAL(USE_LOAD_TESTER, test x$load_tester = xtrue)
732 AM_CONDITIONAL(USE_EAP_SIM, test x$eap_sim = xtrue)
733 AM_CONDITIONAL(USE_EAP_SIM_FILE, test x$eap_sim_file = xtrue)
734 AM_CONDITIONAL(USE_EAP_SIMAKA_PSEUDONYM, test x$eap_simaka_pseudonym = xtrue)
735 AM_CONDITIONAL(USE_EAP_SIMAKA_REAUTH, test x$eap_simaka_reauth = xtrue)
736 AM_CONDITIONAL(USE_EAP_IDENTITY, test x$eap_identity = xtrue)
737 AM_CONDITIONAL(USE_EAP_MD5, test x$eap_md5 = xtrue)
738 AM_CONDITIONAL(USE_EAP_GTC, test x$eap_gtc = xtrue)
739 AM_CONDITIONAL(USE_EAP_AKA, test x$eap_aka = xtrue)
740 AM_CONDITIONAL(USE_EAP_AKA_3GPP2, test x$eap_aka_3gpp2 = xtrue)
741 AM_CONDITIONAL(USE_EAP_MSCHAPV2, test x$eap_mschapv2 = xtrue)
742 AM_CONDITIONAL(USE_EAP_RADIUS, test x$eap_radius = xtrue)
743 AM_CONDITIONAL(USE_KERNEL_NETLINK, test x$kernel_netlink = xtrue)
744 AM_CONDITIONAL(USE_KERNEL_PFKEY, test x$kernel_pfkey = xtrue)
745 AM_CONDITIONAL(USE_KERNEL_PFROUTE, test x$kernel_pfroute = xtrue)
746 AM_CONDITIONAL(USE_KERNEL_KLIPS, test x$kernel_klips = xtrue)
747
748 dnl other options
749 dnl =============
750 AM_CONDITIONAL(USE_SMARTCARD, test x$smartcard = xtrue)
751 AM_CONDITIONAL(USE_CISCO_QUIRKS, test x$cisco_quirks = xtrue)
752 AM_CONDITIONAL(USE_LEAK_DETECTIVE, test x$leak_detective = xtrue)
753 AM_CONDITIONAL(USE_LOCK_PROFILER, test x$lock_profiler = xtrue)
754 AM_CONDITIONAL(USE_NAT_TRANSPORT, test x$nat_transport = xtrue)
755 AM_CONDITIONAL(USE_VENDORID, test x$vendor_id = xtrue)
756 AM_CONDITIONAL(USE_XAUTH_VID, test x$xauth_vid = xtrue)
757 AM_CONDITIONAL(USE_DUMM, test x$dumm = xtrue)
758 AM_CONDITIONAL(USE_FAST, test x$fast = xtrue)
759 AM_CONDITIONAL(USE_MANAGER, test x$manager = xtrue)
760 AM_CONDITIONAL(USE_ME, test x$mediation = xtrue)
761 AM_CONDITIONAL(USE_INTEGRITY_TEST, test x$integrity_test = xtrue)
762 AM_CONDITIONAL(USE_CAPABILITIES, test x$capabilities = xlibcap)
763 AM_CONDITIONAL(USE_PLUTO, test x$pluto = xtrue)
764 AM_CONDITIONAL(USE_THREADS, test x$threads = xtrue)
765 AM_CONDITIONAL(USE_CHARON, test x$charon = xtrue)
766 AM_CONDITIONAL(USE_TOOLS, test x$tools = xtrue)
767 AM_CONDITIONAL(USE_SCRIPTS, test x$scripts = xtrue)
768 AM_CONDITIONAL(USE_LIBSTRONGSWAN, test x$charon = xtrue -o x$pluto = xtrue -o x$tools = xtrue)
769 AM_CONDITIONAL(USE_FILE_CONFIG, test x$pluto = xtrue -o x$stroke = xtrue)
770 AM_CONDITIONAL(USE_VSTR, test x$vstr = xtrue)
771 AM_CONDITIONAL(USE_SIMAKA, test x$simaka = xtrue)
772
773 dnl ==============================
774 dnl  set global definitions
775 dnl ==============================
776
777 if test x$mediation = xtrue; then
778         AC_DEFINE(ME)
779 fi
780 if test x$capabilities = xlibcap; then
781         AC_DEFINE(CAPABILITIES)
782 fi
783
784 dnl ==============================
785 dnl  build Makefiles
786 dnl ==============================
787
788 AC_OUTPUT(
789         Makefile
790         src/Makefile
791         src/include/Makefile
792         src/libstrongswan/Makefile
793         src/libstrongswan/plugins/aes/Makefile
794         src/libstrongswan/plugins/des/Makefile
795         src/libstrongswan/plugins/blowfish/Makefile
796         src/libstrongswan/plugins/md4/Makefile
797         src/libstrongswan/plugins/md5/Makefile
798         src/libstrongswan/plugins/sha1/Makefile
799         src/libstrongswan/plugins/sha2/Makefile
800         src/libstrongswan/plugins/fips_prf/Makefile
801         src/libstrongswan/plugins/gmp/Makefile
802         src/libstrongswan/plugins/random/Makefile
803         src/libstrongswan/plugins/hmac/Makefile
804         src/libstrongswan/plugins/xcbc/Makefile
805         src/libstrongswan/plugins/x509/Makefile
806         src/libstrongswan/plugins/pubkey/Makefile
807         src/libstrongswan/plugins/pkcs1/Makefile
808         src/libstrongswan/plugins/pgp/Makefile
809         src/libstrongswan/plugins/dnskey/Makefile
810         src/libstrongswan/plugins/pem/Makefile
811         src/libstrongswan/plugins/curl/Makefile
812         src/libstrongswan/plugins/ldap/Makefile
813         src/libstrongswan/plugins/mysql/Makefile
814         src/libstrongswan/plugins/sqlite/Makefile
815         src/libstrongswan/plugins/attr_sql/Makefile
816         src/libstrongswan/plugins/padlock/Makefile
817         src/libstrongswan/plugins/openssl/Makefile
818         src/libstrongswan/plugins/gcrypt/Makefile
819         src/libstrongswan/plugins/agent/Makefile
820         src/libstrongswan/plugins/test_vectors/Makefile
821         src/libfreeswan/Makefile
822         src/libsimaka/Makefile
823         src/pluto/Makefile
824         src/whack/Makefile
825         src/charon/Makefile
826         src/charon/plugins/eap_aka/Makefile
827         src/charon/plugins/eap_aka_3gpp2/Makefile
828         src/charon/plugins/eap_identity/Makefile
829         src/charon/plugins/eap_md5/Makefile
830         src/charon/plugins/eap_gtc/Makefile
831         src/charon/plugins/eap_sim/Makefile
832         src/charon/plugins/eap_sim_file/Makefile
833         src/charon/plugins/eap_simaka_pseudonym/Makefile
834         src/charon/plugins/eap_simaka_reauth/Makefile
835         src/charon/plugins/eap_mschapv2/Makefile
836         src/charon/plugins/eap_radius/Makefile
837         src/charon/plugins/kernel_netlink/Makefile
838         src/charon/plugins/kernel_pfkey/Makefile
839         src/charon/plugins/kernel_pfroute/Makefile
840         src/charon/plugins/kernel_klips/Makefile
841         src/charon/plugins/smp/Makefile
842         src/charon/plugins/sql/Makefile
843         src/charon/plugins/medsrv/Makefile
844         src/charon/plugins/medcli/Makefile
845         src/charon/plugins/nm/Makefile
846         src/charon/plugins/uci/Makefile
847         src/charon/plugins/stroke/Makefile
848         src/charon/plugins/updown/Makefile
849         src/charon/plugins/attr/Makefile
850         src/charon/plugins/resolve/Makefile
851         src/charon/plugins/unit_tester/Makefile
852         src/charon/plugins/load_tester/Makefile
853         src/stroke/Makefile
854         src/ipsec/Makefile
855         src/starter/Makefile
856         src/_updown/Makefile
857         src/_updown_espmark/Makefile
858         src/_copyright/Makefile
859         src/openac/Makefile
860         src/scepclient/Makefile
861         src/pki/Makefile
862         src/dumm/Makefile
863         src/dumm/ext/extconf.rb
864         src/libfast/Makefile
865         src/manager/Makefile
866         src/medsrv/Makefile
867         src/checksum/Makefile
868         scripts/Makefile
869         testing/Makefile
870 )