Use wrapped mutex_t/condvar_t instead of pthread_mutex/cond_t
[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.5)
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([sim-reader],         [${plugindir%/}/libeapsim-file.so], [set library containing the sim_run_alg()/sim_get_triplet() functions for EAP-SIM])
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. Currenlty 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-tests],     [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-identity],   [enable EAP module providing EAP-Identity helper.])
104 ARG_ENABL_SET([enable-eap-md5], [enable EAP MD5 (CHAP) authenication module.])
105 ARG_ENABL_SET([enable-eap-gtc], [enable PAM based EAP GTC authenication module.])
106 ARG_ENABL_SET([eap-aka],        [enable EAP AKA authentication module.])
107 ARG_ENABL_SET([eap-mschapv2],   [enable EAP MS-CHAPv2 authenication module.])
108 ARG_ENABL_SET([eap-radius],     [enable RADIUS proxy authenication module.])
109 ARG_DISBL_SET([kernel-netlink], [disable the netlink kernel interface.])
110 ARG_ENABL_SET([kernel-pfkey],   [enable the PF_KEY kernel interface.])
111 ARG_ENABL_SET([kernel-pfroute], [enable the PF_ROUTE kernel interface.])
112 ARG_ENABL_SET([kernel-klips],   [enable the KLIPS kernel interface.])
113 ARG_ENABL_SET([nat-transport],  [enable NAT traversal with IPsec transport mode in pluto.])
114 ARG_DISBL_SET([vendor-id],      [disable the sending of the strongSwan vendor ID in pluto.])
115 ARG_DISBL_SET([xauth-vid],      [disable the sending of the XAUTH vendor ID.])
116 ARG_ENABL_SET([dumm],           [enable the DUMM UML test framework.])
117 ARG_ENABL_SET([fast],           [enable libfast (FastCGI Application Server w/ templates.])
118 ARG_ENABL_SET([manager],        [enable web management console (proof of concept).])
119 ARG_ENABL_SET([mediation],      [enable IKEv2 Mediation Extension.])
120 ARG_ENABL_SET([integrity-test], [enable integrity testing of libstrongswan and plugins.])
121 ARG_DISBL_SET([pluto],          [disable the IKEv1 keying daemon pluto.])
122 ARG_DISBL_SET([threads],        [disable the use of threads in pluto. Charon always uses threads.])
123 ARG_DISBL_SET([charon],         [disable the IKEv2 keying daemon charon.])
124 ARG_DISBL_SET([tools],          [disable additional utilities (openac, scepclient and pki).])
125 ARG_DISBL_SET([scripts],        [disable additional utilities (found in directory scripts).])
126 ARG_DISBL_SET([updown],         [disable updown firewall script plugin.])
127 ARG_DISBL_SET([attr],           [disable strongswan.conf based configuration attribute plugin.])
128 ARG_DISBL_SET([resolv-conf],    [disable resolv.conf DNS handler plugin.])
129 ARG_ENABL_SET([padlock],        [enables VIA Padlock crypto plugin.])
130 ARG_ENABL_SET([openssl],        [enables the OpenSSL crypto plugin.])
131 ARG_ENABL_SET([gcrypt],         [enables the libgcrypt plugin.])
132 ARG_ENABL_SET([agent],          [enables the ssh-agent signing plugin.])
133 ARG_ENABL_SET([uci],            [enable OpenWRT UCI configuration plugin.])
134 ARG_ENABL_SET([nm],             [enable NetworkManager plugin.])
135 ARG_ENABL_SET([vstr],           [enforce using the Vstr string library to replace glibc-like printf hooks.])
136
137 dnl =========================
138 dnl  set up compiler and flags
139 dnl =========================
140
141 if test -z "$CFLAGS"; then
142         CFLAGS="-g -O2 -Wall -Wno-format -Wno-pointer-sign -Wno-strict-aliasing"
143 fi
144 AC_PROG_CC
145 AC_LIB_PREFIX
146 AC_C_BIGENDIAN
147
148 dnl =========================
149 dnl  check required programs
150 dnl =========================
151
152 AC_PROG_INSTALL
153 AC_PROG_LIBTOOL
154 AC_PROG_EGREP
155 AC_PROG_AWK
156 AC_PROG_LEX
157 AC_PROG_YACC
158 AC_PATH_PROG([PERL], [perl], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
159 AC_PATH_PROG([GPERF], [gperf], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
160
161 dnl because gperf is not needed by end-users we just report it but do not abort on failure
162 AC_MSG_CHECKING([gperf version >= 3.0.0])
163 if test -x "$GPERF"; then
164         if test "`$GPERF --version | $AWK -F' ' '/^GNU gperf/ { print $3 }' | $AWK -F. '{ print $1 }'`" -ge "3"; then
165                 AC_MSG_RESULT([yes])
166         else
167                 AC_MSG_RESULT([no])
168         fi
169 else
170         AC_MSG_RESULT([not found])
171 fi
172
173 dnl translate user/group to numercial ids
174 AC_MSG_CHECKING([for uid of user "$ipsecuser"])
175 ipsecuid=`id -u $ipsecuser 2>/dev/null`
176 if test -n "$ipsecuid"; then
177         AC_MSG_RESULT([$ipsecuid])
178         AC_SUBST(ipsecuid)
179 else
180         AC_MSG_ERROR([not found])
181 fi
182 AC_MSG_CHECKING([for gid of group "$ipsecgroup"])
183 ipsecgid=`$EGREP "^$ipsecgroup:" /etc/group | $AWK -F: '{ print $3 }'`
184 if test -n "$ipsecgid"; then
185         AC_MSG_RESULT([$ipsecgid])
186         AC_SUBST(ipsecgid)
187 else
188         AC_MSG_ERROR([not found])
189 fi
190
191 dnl =========================
192 dnl  dependency calculation
193 dnl =========================
194
195 if test x$eap_aka = xtrue; then
196         gmp=true;
197         fips_prf=true;
198         sha1=true;
199 fi
200
201 if test x$eap_sim = xtrue; then
202         fips_prf=true;
203 fi
204
205 if test x$fips_prf = xtrue; then
206         sha1=true;
207 fi
208
209 if test x$smp = xtrue; then
210         xml=true
211 fi
212
213 if test x$manager = xtrue; then
214         fast=true
215 fi
216
217 if test x$medsrv = xtrue; then
218         me=true
219         fast=true
220 fi
221
222 if test x$medcli = xtrue; then
223         me=true
224 fi
225
226 dnl ===========================================
227 dnl  check required libraries and header files
228 dnl ===========================================
229
230 AC_HEADER_STDBOOL
231 AC_FUNC_ALLOCA
232
233 dnl libraries needed on some platforms but not on others
234 dnl ====================================================
235 saved_LIBS=$LIBS
236
237 dnl FreeBSD and Mac OS X have dlopen integrated in libc, Linux needs libdl
238 LIBS=""
239 AC_SEARCH_LIBS(dlopen, dl, [DLLIB=$LIBS])
240 AC_SUBST(DLLIB)
241
242 dnl glibc's backtrace() can be replicated on FreeBSD with libexecinfo
243 LIBS=""
244 AC_SEARCH_LIBS(backtrace, execinfo, [BTLIB=$LIBS])
245 AC_CHECK_FUNCS(backtrace)
246 AC_SUBST(BTLIB)
247
248 dnl OpenSolaris needs libsocket and libnsl for socket()
249 LIBS=""
250 AC_SEARCH_LIBS(socket, socket, [SOCKLIB=$LIBS],
251         [AC_CHECK_LIB(nsl, socket, [SOCKLIB="-lsocket -lnsl"], [], [-lsocket])]
252 )
253 AC_SUBST(SOCKLIB)
254
255 dnl FreeBSD has clock_gettime in libc, Linux needs librt
256 LIBS=""
257 AC_SEARCH_LIBS(clock_gettime, rt, [RTLIB=$LIBS])
258 AC_CHECK_FUNCS(clock_gettime)
259 AC_SUBST(RTLIB)
260
261 LIBS=$saved_LIBS
262 dnl ======================
263
264 AC_MSG_CHECKING(for dladdr)
265 AC_TRY_COMPILE(
266         [#define _GNU_SOURCE
267          #include <dlfcn.h>],
268         [Dl_info* info = 0;
269          dladdr(0, info);],
270         [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_DLADDR])],
271         [AC_MSG_RESULT([no])]
272 )
273
274 dnl check if pthread_condattr_setclock(CLOCK_MONOTONE) is supported
275 saved_LIBS=$LIBS
276 LIBS="-lpthread"
277 AC_MSG_CHECKING([for pthread_condattr_setclock(CLOCK_MONOTONE)])
278 AC_TRY_RUN(
279         [#include <pthread.h>
280          int main() { pthread_condattr_t attr;
281                 pthread_condattr_init(&attr);
282                 return pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);}],
283         [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_CONDATTR_CLOCK_MONOTONIC])],
284         [AC_MSG_RESULT([no])]
285 )
286 LIBS=$saved_LIBS
287
288 AC_CHECK_FUNCS(prctl)
289
290 AC_CHECK_HEADERS(sys/sockio.h)
291 AC_CHECK_HEADERS(net/pfkeyv2.h netipsec/ipsec.h netinet6/ipsec.h linux/udp.h)
292
293 AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [],
294 [
295         #include <sys/types.h>
296         #include <sys/socket.h>
297 ])
298
299 AC_CHECK_MEMBERS([struct sadb_x_policy.sadb_x_policy_priority], [], [],
300 [
301         #include <sys/types.h>
302         #ifdef HAVE_NET_PFKEYV2_H
303         #include <net/pfkeyv2.h>
304         #else
305         #include <stdint.h>
306         #include <linux/pfkeyv2.h>
307         #endif
308 ])
309
310 AC_MSG_CHECKING([for IPSEC_MODE_BEET])
311 AC_TRY_COMPILE(
312         [#include <sys/types.h>
313         #ifdef HAVE_NETIPSEC_IPSEC_H
314         #include <netipsec/ipsec.h>
315         #elif defined(HAVE_NETINET6_IPSEC_H)
316         #include <netinet6/ipsec.h>
317         #else
318         #include <stdint.h>
319         #include <linux/ipsec.h>
320         #endif],
321         [int mode = IPSEC_MODE_BEET;
322          return mode;],
323         [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_IPSEC_MODE_BEET])],
324         [AC_MSG_RESULT([no])]
325 )
326
327 AC_MSG_CHECKING([for IPSEC_DIR_FWD])
328 AC_TRY_COMPILE(
329         [#include <sys/types.h>
330         #ifdef HAVE_NETIPSEC_IPSEC_H
331         #include <netipsec/ipsec.h>
332         #elif defined(HAVE_NETINET6_IPSEC_H)
333         #include <netinet6/ipsec.h>
334         #else
335         #include <stdint.h>
336         #include <linux/ipsec.h>
337         #endif],
338         [int dir = IPSEC_DIR_FWD;
339          return dir;],
340         [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_IPSEC_DIR_FWD])],
341         [AC_MSG_RESULT([no])]
342 )
343
344 AC_MSG_CHECKING([for gcc atomic operations])
345 AC_TRY_RUN(
346 [
347         int main() {
348                 volatile int ref = 1;
349                 __sync_fetch_and_add (&ref, 1);
350                 __sync_sub_and_fetch (&ref, 1);
351                 /* Make sure test fails if operations are not supported */
352                 __sync_val_compare_and_swap(&ref, 1, 0);
353                 return ref;
354         }
355 ],
356 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_GCC_ATOMIC_OPERATIONS)],
357 [AC_MSG_RESULT([no])],
358 [AC_MSG_RESULT([no])])
359
360 AC_CHECK_FUNC(
361         [register_printf_function],
362         [AC_DEFINE(HAVE_PRINTF_HOOKS)],
363         [
364                 AC_MSG_NOTICE([printf does not support custom format specifiers!])
365                 vstr=true
366         ]
367 )
368
369 if test x$vstr = xtrue; then
370         AC_HAVE_LIBRARY([vstr],[LIBS="$LIBS"],[AC_MSG_ERROR([Vstr string library not found])])
371         AC_DEFINE(USE_VSTR)
372 fi
373
374 if test x$gmp = xtrue; then
375         AC_HAVE_LIBRARY([gmp],[LIBS="$LIBS"],[AC_MSG_ERROR([GNU Multi Precision library gmp not found])])
376         AC_MSG_CHECKING([gmp.h version >= 4.1.4])
377         AC_TRY_COMPILE(
378                 [#include "gmp.h"],
379                 [
380                         #if (__GNU_MP_VERSION*100 +  __GNU_MP_VERSION_MINOR*10 + __GNU_MP_VERSION_PATCHLEVEL) < 414
381                                 #error bad gmp
382                         #endif
383                 ],
384                 [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); AC_MSG_ERROR([No usable gmp.h found!])]
385         )
386 fi
387
388 if test x$ldap = xtrue; then
389         AC_HAVE_LIBRARY([ldap],[LIBS="$LIBS"],[AC_MSG_ERROR([LDAP library ldap not found])])
390         AC_HAVE_LIBRARY([lber],[LIBS="$LIBS"],[AC_MSG_ERROR([LDAP library lber not found])])
391         AC_CHECK_HEADER([ldap.h],,[AC_MSG_ERROR([LDAP header ldap.h not found!])])
392 fi
393
394 if test x$curl = xtrue; then
395         AC_HAVE_LIBRARY([curl],[LIBS="$LIBS"],[AC_MSG_ERROR([CURL library curl not found])])
396         AC_CHECK_HEADER([curl/curl.h],,[AC_MSG_ERROR([CURL header curl/curl.h not found!])])
397 fi
398
399 if test x$xml = xtrue; then
400         PKG_CHECK_MODULES(xml, [libxml-2.0])
401         AC_SUBST(xml_CFLAGS)
402         AC_SUBST(xml_LIBS)
403 fi
404
405 if test x$dumm = xtrue; then
406         PKG_CHECK_MODULES(gtk, [gtk+-2.0 vte])
407         AC_SUBST(gtk_CFLAGS)
408         AC_SUBST(gtk_LIBS)
409         AC_CHECK_PROGS(RUBY, ruby)
410         AC_MSG_CHECKING([for Ruby header files])
411         if test -n "$RUBY"; then
412                 RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null`
413                 if test -n "$RUBYDIR"; then
414                         dirs="$RUBYDIR"
415                         RUBYINCLUDE=none
416                         for i in $dirs; do
417                                 if test -r $i/ruby.h; then
418                                         AC_MSG_RESULT([$i])
419                                         RUBYINCLUDE="-I$i"
420                                         break;
421                                 fi
422                         done
423                         if test x"$RUBYINCLUDE" = xnone; then
424                                 AC_MSG_ERROR([ruby.h not found])
425                         fi
426                         AC_SUBST(RUBYINCLUDE)
427                 else
428                         AC_MSG_ERROR([unable to determine ruby configuration])
429                 fi
430         else
431                 AC_MSG_ERROR([don't know how to run ruby])
432         fi
433 fi
434
435 if test x$fast = xtrue; then
436         AC_HAVE_LIBRARY([neo_cgi],[LIBS="$LIBS"],[AC_MSG_ERROR([ClearSilver library neo_cgi not found!])])
437         AC_HAVE_LIBRARY([neo_utl],[LIBS="$LIBS"],[AC_MSG_ERROR([ClearSilver library neo_utl not found!])])
438         AC_HAVE_LIBRARY([z],[LIBS="$LIBS"],[AC_MSG_ERROR([ClearSilver dependency zlib not found!])])
439 dnl autoconf does not like CamelCase!? How to fix this?
440 dnl     AC_CHECK_HEADER([ClearSilver/ClearSilver.h],,[AC_MSG_ERROR([ClearSilver header file ClearSilver/ClearSilver.h not found!])])
441
442         AC_HAVE_LIBRARY([fcgi],[LIBS="$LIBS"],[AC_MSG_ERROR([FastCGI library fcgi not found!])])
443         AC_CHECK_HEADER([fcgiapp.h],,[AC_MSG_ERROR([FastCGI header file fcgiapp.h not found!])])
444 fi
445
446 if test x$mysql = xtrue; then
447         AC_HAVE_LIBRARY([mysqlclient_r],[LIBS="$LIBS"],[AC_MSG_ERROR([MySQL library mysqlclient_r not found])])
448         AC_CHECK_HEADER([mysql/mysql.h],,[AC_MSG_ERROR([MySQL header mysql/mysql.h not found!])])
449 fi
450
451 if test x$sqlite = xtrue; then
452         AC_HAVE_LIBRARY([sqlite3],[LIBS="$LIBS"],[AC_MSG_ERROR([SQLite library sqlite3 not found])])
453         AC_CHECK_HEADER([sqlite3.h],,[AC_MSG_ERROR([SQLite header sqlite3.h not found!])])
454         AC_MSG_CHECKING([sqlite3_prepare_v2])
455         AC_TRY_COMPILE(
456                 [#include <sqlite3.h>],
457                 [
458                         void *test = sqlite3_prepare_v2;
459                 ],
460                 [AC_MSG_RESULT([yes])]; AC_DEFINE_UNQUOTED(HAVE_SQLITE3_PREPARE_V2, 1), [AC_MSG_RESULT([no])])
461         AC_MSG_CHECKING([sqlite3.h version >= 3.3.1])
462         AC_TRY_COMPILE(
463                 [#include <sqlite3.h>],
464                 [
465                         #if SQLITE_VERSION_NUMBER < 3003001
466                                 #error bad sqlite
467                         #endif
468                 ],
469                 [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); AC_MSG_ERROR([SQLite version >= 3.3.1 required!])])
470 fi
471
472 if test x$openssl = xtrue; then
473         AC_HAVE_LIBRARY([crypto],[LIBS="$LIBS"],[AC_MSG_ERROR([OpenSSL crypto library not found])])
474         AC_CHECK_HEADER([openssl/evp.h],,[AC_MSG_ERROR([OpenSSL header openssl/evp.h not found!])])
475 fi
476
477 if test x$gcrypt = xtrue; then
478         AC_HAVE_LIBRARY([gcrypt],[LIBS="$LIBS"],[AC_MSG_ERROR([gcrypt library not found])])
479         AC_CHECK_HEADER([gcrypt.h],,[AC_MSG_ERROR([gcrypt header gcrypt.h not found!])])
480         AC_MSG_CHECKING([gcrypt CAMELLIA cipher])
481         AC_TRY_COMPILE(
482                 [#include <gcrypt.h>],
483                 [enum gcry_cipher_algos alg = GCRY_CIPHER_CAMELLIA128;],
484                 [AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_GCRY_CIPHER_CAMELLIA])],
485                 [AC_MSG_RESULT([no])]
486         )
487 fi
488
489 if test x$uci = xtrue; then
490         AC_HAVE_LIBRARY([uci],[LIBS="$LIBS"],[AC_MSG_ERROR([UCI library libuci not found])])
491         AC_CHECK_HEADER([uci.h],,[AC_MSG_ERROR([UCI header uci.h not found!])])
492 fi
493
494 if test x$nm = xtrue; then
495         PKG_CHECK_MODULES(nm, [NetworkManager libnm_glib_vpn gthread-2.0])
496         AC_SUBST(nm_CFLAGS)
497         AC_SUBST(nm_LIBS)
498 fi
499
500 if test x$eap_gtc = xtrue; then
501         AC_HAVE_LIBRARY([pam],[LIBS="$LIBS"],[AC_MSG_ERROR([PAM library not found])])
502         AC_CHECK_HEADER([security/pam_appl.h],,[AC_MSG_ERROR([PAM header security/pam_appl.h not found!])])
503 fi
504
505 if test x$capabilities = xlibcap; then
506         AC_HAVE_LIBRARY([cap],[LIBS="$LIBS"],[AC_MSG_ERROR([libcap library not found])])
507         AC_CHECK_HEADER([sys/capability.h],,[AC_MSG_ERROR([libcap header sys/capability.h not found!])])
508 fi
509
510 if test x$integrity_test = xtrue; then
511         AC_MSG_CHECKING([for dladdr()])
512         AC_TRY_COMPILE(
513                 [#define _GNU_SOURCE
514                  #include <dlfcn.h>],
515                 [Dl_info info; dladdr(main, &info);],
516                 [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]);
517                  AC_MSG_ERROR([dladdr() not supported, required by integrity-test!])]
518         )
519         AC_MSG_CHECKING([for dl_iterate_phdr()])
520         AC_TRY_COMPILE(
521                 [#define _GNU_SOURCE
522                  #include <link.h>],
523                 [dl_iterate_phdr((void*)0, (void*)0);],
524                 [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]);
525                  AC_MSG_ERROR([dl_iterate_phdr() not supported, required by integrity-test!])]
526         )
527 fi
528
529 dnl ======================================
530 dnl  collect all plugins for libstrongswan
531 dnl ======================================
532
533 libstrongswan_plugins=
534 pluto_plugins=
535
536 if test x$test_vectors = xtrue; then
537         libstrongswan_plugins=${libstrongswan_plugins}" test-vectors"
538         pluto_plugins=${pluto_plugins}" test-vectors"
539 fi
540 if test x$curl = xtrue; then
541         libstrongswan_plugins=${libstrongswan_plugins}" curl"
542         pluto_plugins=${pluto_plugins}" curl"
543 fi
544 if test x$ldap = xtrue; then
545         libstrongswan_plugins=${libstrongswan_plugins}" ldap"
546         pluto_plugins=${pluto_plugins}" ldap"
547 fi
548 if test x$aes = xtrue; then
549         libstrongswan_plugins=${libstrongswan_plugins}" aes"
550         pluto_plugins=${pluto_plugins}" aes"
551 fi
552 if test x$des = xtrue; then
553         libstrongswan_plugins=${libstrongswan_plugins}" des"
554         pluto_plugins=${pluto_plugins}" des"
555 fi
556 if test x$blowfish = xtrue; then
557         libstrongswan_plugins=${libstrongswan_plugins}" blowfish"
558         pluto_plugins=${pluto_plugins}" blowfish"
559 fi
560 if test x$sha1 = xtrue; then
561         libstrongswan_plugins=${libstrongswan_plugins}" sha1"
562         pluto_plugins=${pluto_plugins}" sha1"
563 fi
564 if test x$sha2 = xtrue; then
565         libstrongswan_plugins=${libstrongswan_plugins}" sha2"
566         pluto_plugins=${pluto_plugins}" sha2"
567 fi
568 if test x$md4 = xtrue; then
569         libstrongswan_plugins=${libstrongswan_plugins}" md4"
570 fi
571 if test x$md5 = xtrue; then
572         libstrongswan_plugins=${libstrongswan_plugins}" md5"
573         pluto_plugins=${pluto_plugins}" md5"
574 fi
575 if test x$fips_prf = xtrue; then
576         libstrongswan_plugins=${libstrongswan_plugins}" fips-prf"
577 fi
578 if test x$random = xtrue; then
579         libstrongswan_plugins=${libstrongswan_plugins}" random"
580         pluto_plugins=${pluto_plugins}" random"
581 fi
582 if test x$x509 = xtrue; then
583         libstrongswan_plugins=${libstrongswan_plugins}" x509"
584 fi
585 if test x$pubkey = xtrue; then
586         libstrongswan_plugins=${libstrongswan_plugins}" pubkey"
587         pluto_plugins=${pluto_plugins}" pubkey"
588 fi
589 if test x$pkcs1 = xtrue; then
590         libstrongswan_plugins=${libstrongswan_plugins}" pkcs1"
591         pluto_plugins=${pluto_plugins}" pkcs1"
592 fi
593 if test x$pgp = xtrue; then
594         libstrongswan_plugins=${libstrongswan_plugins}" pgp"
595         pluto_plugins=${pluto_plugins}" pgp"
596 fi
597 if test x$dnskey = xtrue; then
598         libstrongswan_plugins=${libstrongswan_plugins}" dnskey"
599         pluto_plugins=${pluto_plugins}" dnskey"
600 fi
601 if test x$pem = xtrue; then
602         libstrongswan_plugins=${libstrongswan_plugins}" pem"
603         pluto_plugins=${pluto_plugins}" pem"
604 fi
605 if test x$mysql = xtrue; then
606         libstrongswan_plugins=${libstrongswan_plugins}" mysql"
607 fi
608 if test x$sqlite = xtrue; then
609         libstrongswan_plugins=${libstrongswan_plugins}" sqlite"
610 fi
611 if test x$padlock = xtrue; then
612         libstrongswan_plugins=${libstrongswan_plugins}" padlock"
613 fi
614 if test x$openssl = xtrue; then
615         libstrongswan_plugins=${libstrongswan_plugins}" openssl"
616         pluto_plugins=${pluto_plugins}" openssl"
617 fi
618 if test x$gcrypt = xtrue; then
619         libstrongswan_plugins=${libstrongswan_plugins}" gcrypt"
620         pluto_plugins=${pluto_plugins}" gcrypt"
621 fi
622 if test x$xcbc = xtrue; then
623         libstrongswan_plugins=${libstrongswan_plugins}" xcbc"
624 fi
625 if test x$hmac = xtrue; then
626         libstrongswan_plugins=${libstrongswan_plugins}" hmac"
627         pluto_plugins=${pluto_plugins}" hmac"
628 fi
629 if test x$agent = xtrue; then
630         libstrongswan_plugins=${libstrongswan_plugins}" agent"
631 fi
632 if test x$gmp = xtrue; then
633         libstrongswan_plugins=${libstrongswan_plugins}" gmp"
634         pluto_plugins=${pluto_plugins}" gmp"
635 fi
636
637 AC_SUBST(libstrongswan_plugins)
638 AC_SUBST(pluto_plugins)
639
640 dnl =========================
641 dnl  set Makefile.am vars
642 dnl =========================
643
644 dnl libstrongswan plugins
645 dnl =====================
646 AM_CONDITIONAL(USE_TEST_VECTORS, test x$test_vectors = xtrue)
647 AM_CONDITIONAL(USE_CURL, test x$curl = xtrue)
648 AM_CONDITIONAL(USE_LDAP, test x$ldap = xtrue)
649 AM_CONDITIONAL(USE_AES, test x$aes = xtrue)
650 AM_CONDITIONAL(USE_DES, test x$des = xtrue)
651 AM_CONDITIONAL(USE_BLOWFISH, test x$blowfish = xtrue)
652 AM_CONDITIONAL(USE_MD4, test x$md4 = xtrue)
653 AM_CONDITIONAL(USE_MD5, test x$md5 = xtrue)
654 AM_CONDITIONAL(USE_SHA1, test x$sha1 = xtrue)
655 AM_CONDITIONAL(USE_SHA2, test x$sha2 = xtrue)
656 AM_CONDITIONAL(USE_FIPS_PRF, test x$fips_prf = xtrue)
657 AM_CONDITIONAL(USE_GMP, test x$gmp = xtrue)
658 AM_CONDITIONAL(USE_RANDOM, test x$random = xtrue)
659 AM_CONDITIONAL(USE_X509, test x$x509 = xtrue)
660 AM_CONDITIONAL(USE_PUBKEY, test x$pubkey = xtrue)
661 AM_CONDITIONAL(USE_PKCS1, test x$pkcs1 = xtrue)
662 AM_CONDITIONAL(USE_PGP, test x$pgp = xtrue)
663 AM_CONDITIONAL(USE_DNSKEY, test x$dnskey = xtrue)
664 AM_CONDITIONAL(USE_PEM, test x$pem = xtrue)
665 AM_CONDITIONAL(USE_HMAC, test x$hmac = xtrue)
666 AM_CONDITIONAL(USE_XCBC, test x$xcbc = xtrue)
667 AM_CONDITIONAL(USE_MYSQL, test x$mysql = xtrue)
668 AM_CONDITIONAL(USE_SQLITE, test x$sqlite = xtrue)
669 AM_CONDITIONAL(USE_PADLOCK, test x$padlock = xtrue)
670 AM_CONDITIONAL(USE_OPENSSL, test x$openssl = xtrue)
671 AM_CONDITIONAL(USE_GCRYPT, test x$gcrypt = xtrue)
672 AM_CONDITIONAL(USE_AGENT, test x$agent = xtrue)
673
674 dnl charon plugins
675 dnl ==============
676 AM_CONDITIONAL(USE_STROKE, test x$stroke = xtrue)
677 AM_CONDITIONAL(USE_MEDSRV, test x$medsrv = xtrue)
678 AM_CONDITIONAL(USE_MEDCLI, test x$medcli = xtrue)
679 AM_CONDITIONAL(USE_NM, test x$nm = xtrue)
680 AM_CONDITIONAL(USE_UCI, test x$uci = xtrue)
681 AM_CONDITIONAL(USE_SMP, test x$smp = xtrue)
682 AM_CONDITIONAL(USE_SQL, test x$sql = xtrue)
683 AM_CONDITIONAL(USE_UPDOWN, test x$updown = xtrue)
684 AM_CONDITIONAL(USE_ATTR, test x$attr = xtrue)
685 AM_CONDITIONAL(USE_RESOLV_CONF, test x$resolvconf = xtrue)
686 AM_CONDITIONAL(USE_UNIT_TESTS, test x$unittest = xtrue)
687 AM_CONDITIONAL(USE_LOAD_TESTS, test x$loadtest = xtrue)
688 AM_CONDITIONAL(USE_EAP_SIM, test x$eap_sim = xtrue)
689 AM_CONDITIONAL(USE_EAP_SIM_FILE, test x$eap_sim_file = xtrue)
690 AM_CONDITIONAL(USE_EAP_IDENTITY, test x$eap_identity = xtrue)
691 AM_CONDITIONAL(USE_EAP_MD5, test x$eap_md5 = xtrue)
692 AM_CONDITIONAL(USE_EAP_GTC, test x$eap_gtc = xtrue)
693 AM_CONDITIONAL(USE_EAP_AKA, test x$eap_aka = xtrue)
694 AM_CONDITIONAL(USE_EAP_MSCHAPV2, test x$eap_mschapv2 = xtrue)
695 AM_CONDITIONAL(USE_EAP_RADIUS, test x$eap_radius = xtrue)
696 AM_CONDITIONAL(USE_KERNEL_NETLINK, test x$kernel_netlink = xtrue)
697 AM_CONDITIONAL(USE_KERNEL_PFKEY, test x$kernel_pfkey = xtrue)
698 AM_CONDITIONAL(USE_KERNEL_PFROUTE, test x$kernel_pfroute = xtrue)
699 AM_CONDITIONAL(USE_KERNEL_KLIPS, test x$kernel_klips = xtrue)
700
701 dnl other options
702 dnl =============
703 AM_CONDITIONAL(USE_SMARTCARD, test x$smartcard = xtrue)
704 AM_CONDITIONAL(USE_CISCO_QUIRKS, test x$cisco_quirks = xtrue)
705 AM_CONDITIONAL(USE_LEAK_DETECTIVE, test x$leak_detective = xtrue)
706 AM_CONDITIONAL(USE_LOCK_PROFILER, test x$lock_profiler = xtrue)
707 AM_CONDITIONAL(USE_NAT_TRANSPORT, test x$nat_transport = xtrue)
708 AM_CONDITIONAL(USE_VENDORID, test x$vendor_id = xtrue)
709 AM_CONDITIONAL(USE_XAUTH_VID, test x$xauth_vid = xtrue)
710 AM_CONDITIONAL(USE_DUMM, test x$dumm = xtrue)
711 AM_CONDITIONAL(USE_FAST, test x$fast = xtrue)
712 AM_CONDITIONAL(USE_MANAGER, test x$manager = xtrue)
713 AM_CONDITIONAL(USE_ME, test x$me = xtrue)
714 AM_CONDITIONAL(USE_INTEGRITY_TEST, test x$integrity_test = xtrue)
715 AM_CONDITIONAL(USE_CAPABILITIES, test x$capabilities = xlibcap)
716 AM_CONDITIONAL(USE_PLUTO, test x$pluto = xtrue)
717 AM_CONDITIONAL(USE_THREADS, test x$threads = xtrue)
718 AM_CONDITIONAL(USE_CHARON, test x$charon = xtrue)
719 AM_CONDITIONAL(USE_TOOLS, test x$tools = xtrue)
720 AM_CONDITIONAL(USE_SCRIPTS, test x$scripts = xtrue)
721 AM_CONDITIONAL(USE_LIBSTRONGSWAN, test x$charon = xtrue -o x$pluto = xtrue -o x$tools = xtrue)
722 AM_CONDITIONAL(USE_FILE_CONFIG, test x$pluto = xtrue -o x$stroke = xtrue)
723 AM_CONDITIONAL(USE_VSTR, test x$vstr = xtrue)
724
725 dnl ==============================
726 dnl  set global definitions
727 dnl ==============================
728
729 if test x$me = xtrue; then
730         AC_DEFINE(ME)
731 fi
732 if test x$capabilities = xlibcap; then
733         AC_DEFINE(CAPABILITIES)
734 fi
735
736 dnl ==============================
737 dnl  build Makefiles
738 dnl ==============================
739
740 AC_OUTPUT(
741         Makefile
742         src/Makefile
743         src/include/Makefile
744         src/libstrongswan/Makefile
745         src/libstrongswan/plugins/aes/Makefile
746         src/libstrongswan/plugins/des/Makefile
747         src/libstrongswan/plugins/blowfish/Makefile
748         src/libstrongswan/plugins/md4/Makefile
749         src/libstrongswan/plugins/md5/Makefile
750         src/libstrongswan/plugins/sha1/Makefile
751         src/libstrongswan/plugins/sha2/Makefile
752         src/libstrongswan/plugins/fips_prf/Makefile
753         src/libstrongswan/plugins/gmp/Makefile
754         src/libstrongswan/plugins/random/Makefile
755         src/libstrongswan/plugins/hmac/Makefile
756         src/libstrongswan/plugins/xcbc/Makefile
757         src/libstrongswan/plugins/x509/Makefile
758         src/libstrongswan/plugins/pubkey/Makefile
759         src/libstrongswan/plugins/pkcs1/Makefile
760         src/libstrongswan/plugins/pgp/Makefile
761         src/libstrongswan/plugins/dnskey/Makefile
762         src/libstrongswan/plugins/pem/Makefile
763         src/libstrongswan/plugins/curl/Makefile
764         src/libstrongswan/plugins/ldap/Makefile
765         src/libstrongswan/plugins/mysql/Makefile
766         src/libstrongswan/plugins/sqlite/Makefile
767         src/libstrongswan/plugins/padlock/Makefile
768         src/libstrongswan/plugins/openssl/Makefile
769         src/libstrongswan/plugins/gcrypt/Makefile
770         src/libstrongswan/plugins/agent/Makefile
771         src/libstrongswan/plugins/test_vectors/Makefile
772         src/libfreeswan/Makefile
773         src/pluto/Makefile
774         src/whack/Makefile
775         src/charon/Makefile
776         src/charon/plugins/eap_aka/Makefile
777         src/charon/plugins/eap_identity/Makefile
778         src/charon/plugins/eap_md5/Makefile
779         src/charon/plugins/eap_gtc/Makefile
780         src/charon/plugins/eap_sim/Makefile
781         src/charon/plugins/eap_sim_file/Makefile
782         src/charon/plugins/eap_mschapv2/Makefile
783         src/charon/plugins/eap_radius/Makefile
784         src/charon/plugins/kernel_netlink/Makefile
785         src/charon/plugins/kernel_pfkey/Makefile
786         src/charon/plugins/kernel_pfroute/Makefile
787         src/charon/plugins/kernel_klips/Makefile
788         src/charon/plugins/smp/Makefile
789         src/charon/plugins/sql/Makefile
790         src/charon/plugins/medsrv/Makefile
791         src/charon/plugins/medcli/Makefile
792         src/charon/plugins/nm/Makefile
793         src/charon/plugins/uci/Makefile
794         src/charon/plugins/stroke/Makefile
795         src/charon/plugins/updown/Makefile
796         src/charon/plugins/attr/Makefile
797         src/charon/plugins/resolv_conf/Makefile
798         src/charon/plugins/unit_tester/Makefile
799         src/charon/plugins/load_tester/Makefile
800         src/stroke/Makefile
801         src/ipsec/Makefile
802         src/starter/Makefile
803         src/_updown/Makefile
804         src/_updown_espmark/Makefile
805         src/_copyright/Makefile
806         src/openac/Makefile
807         src/scepclient/Makefile
808         src/pki/Makefile
809         src/dumm/Makefile
810         src/dumm/ext/extconf.rb
811         src/libfast/Makefile
812         src/manager/Makefile
813         src/medsrv/Makefile
814         src/checksum/Makefile
815         scripts/Makefile
816         testing/Makefile
817 )