configure.ac revision 1.1.1.4
1dnl -*- mode: m4 -*-
2dnl Id: configure.ac,v 1.47.2.3 2005/03/14 07:55:03 manubsd Exp
3
4AC_PREREQ(2.52)
5AC_INIT(ipsec-tools, 0.5pre)
6AC_CONFIG_SRCDIR([configure.ac])
7AM_CONFIG_HEADER(config.h)
8
9AM_INIT_AUTOMAKE(dist-bzip2)
10
11AC_ENABLE_SHARED(no)
12
13AC_PROG_CC
14AM_PROG_CC_STDC
15AC_HEADER_STDC
16AC_PROG_LIBTOOL
17AC_PROG_YACC
18AM_PROG_LEX
19AC_SUBST(LEXLIB)
20AC_PROG_EGREP
21
22CFLAGS_ADD="$CFLAGS_ADD -Wall -Werror -Wno-unused"
23
24case $host in
25*netbsd*)
26	LDFLAGS="-Wl,-R/usr/pkg/lib $LDFLAGS"
27	;;
28*linux*)
29	LIBS="$LIBS -lresolv"
30	INSTALL_OPTS="-o bin -g bin"
31	INCLUDE_GLIBC="include-glibc"
32	RPM="rpm"
33	AC_SUBST(INSTALL_OPTS)
34	AC_SUBST(INCLUDE_GLIBC)
35	AC_SUBST(RPM)
36	;;
37esac
38
39# Look up some IPsec-related headers
40AC_CHECK_HEADER(net/pfkeyv2.h, [have_net_pfkey=yes], [have_net_pfkey=no])
41AC_CHECK_HEADER(netinet/ipsec.h, [have_netinet_ipsec=yes], [have_netinet_ipsec=no])
42AC_CHECK_HEADER(netinet6/ipsec.h, [have_netinet6_ipsec=yes], [have_netinet6_ipsec=no])
43
44# NetBSD has <netinet6/ipsec.h> but not <netinet/ipsec.h>
45if test "$have_netinet_ipsec$have_netinet6_ipsec" = noyes; then
46    have_netinet_ipsec=yes
47    AC_DEFINE(HAVE_NETINET6_IPSEC, [], [Use <netinet6/ipsec.h>])
48fi
49
50case "$host_os" in
51 *linux*)
52    AC_ARG_WITH(kernel-headers,
53	AC_HELP_STRING([--with-kernel-headers=/lib/modules/<uname>/build/include],
54		       [where your Linux Kernel headers are installed]),
55	    [ KERNEL_INCLUDE="$with_kernel_headers" 
56	      CONFIGURE_AMFLAGS="--with-kernel-headers=$with_kernel_headers"
57	      AC_SUBST(CONFIGURE_AMFLAGS) ],
58	    [ KERNEL_INCLUDE="/lib/modules/`uname -r`/build/include" ])
59
60    AC_CHECK_FILE($KERNEL_INCLUDE/linux/pfkeyv2.h, ,
61	[ AC_CHECK_FILE(/usr/src/linux/include/linux/pfkeyv2.h,
62	  KERNEL_INCLUDE=/usr/src/linux/include ,
63	  [ AC_MSG_ERROR([Unable to find linux-2.6 kernel headers. Aborting.]) ] ) ] )
64    AC_SUBST(KERNEL_INCLUDE)
65    # We need the configure script to run with correct kernel headers.
66    # However we don't want to point to kernel source tree in compile time,
67    # i.e. this will be removed from CPPFLAGS at the end of configure.
68    CPPFLAGS="-I$KERNEL_INCLUDE $CPPFLAGS"
69
70    AC_CHECK_MEMBER(struct sadb_x_policy.sadb_x_policy_priority, 
71    	[AC_DEFINE(HAVE_PFKEY_POLICY_PRIORITY, [],
72               	[Are PF_KEY policy priorities supported?])], [],
73    	[#include "$KERNEL_INCLUDE/linux/pfkeyv2.h"])
74
75    GLIBC_BUGS='-include ${top_srcdir}/src/include-glibc/glibc-bugs.h -I${top_srcdir}/src/include-glibc -I${top_builddir}/src/include-glibc'
76    AC_SUBST(GLIBC_BUGS)
77    GLIBC_BUGS_LOCAL="-include ${srcdir-.}/src/include-glibc/glibc-bugs.h -I${srcdir-.}/src/include-glibc -I./src/include-glibc"
78    CPPFLAGS="$GLIBC_BUGS_LOCAL $CPPFLAGS"
79    ;;
80 *)
81    if test "$have_net_pfkey$have_netinet_ipsec" != yesyes; then
82      if test "$have_net_pfkey" = yes; then
83	AC_MSG_ERROR([Found net/pfkeyv2.h but not netinet/ipsec.h. Aborting.])
84      else
85	AC_MSG_ERROR([Found netinet/ipsec.h but not net/pfkeyv2.h. Aborting.])
86      fi
87    fi
88    ;;
89esac
90
91### Some basic toolchain checks
92
93# Checks for header files.
94AC_HEADER_STDC
95AC_HEADER_SYS_WAIT
96AC_CHECK_HEADERS(limits.h sys/time.h unistd.h stdarg.h varargs.h)
97
98# Checks for typedefs, structures, and compiler characteristics.
99AC_C_CONST
100AC_TYPE_PID_T
101AC_TYPE_SIZE_T
102AC_HEADER_TIME
103AC_STRUCT_TM
104
105# Checks for library functions.
106AC_FUNC_MEMCMP
107AC_TYPE_SIGNAL
108AC_FUNC_VPRINTF
109AC_CHECK_FUNCS(gettimeofday select socket strerror strtol strtoul strlcpy)
110AC_REPLACE_FUNCS(strdup)
111RACOON_CHECK_VA_COPY
112
113# Check if printf accepts "%z" type modifier for size_t argument
114AC_MSG_CHECKING(if printf accepts %z)
115saved_CFLAGS=$CFLAGS
116CFLAGS="$CFLAGS -Wall -Werror"
117AC_TRY_COMPILE([
118#include <stdio.h>
119], [
120printf("%zu\n", (size_t)-1);
121],
122	[AC_MSG_RESULT(yes)],
123	[AC_MSG_RESULT(no); CFLAGS_ADD="$CFLAGS_ADD -Wno-format"])
124CFLAGS=$saved_CFLAGS
125
126# Can we use __func__ macro?
127AC_MSG_CHECKING(if __func__ is available)
128AC_TRY_COMPILE(
129[#include <stdio.h>
130], [char *x = __func__;],
131	[AC_DEFINE([HAVE_FUNC_MACRO], [], [Have __func__ macro])
132	AC_MSG_RESULT(yes)],
133	[AC_MSG_RESULT(no)])
134
135# Check if readline support is requested
136AC_MSG_CHECKING(if readline support is requested)
137AC_ARG_WITH(readline,
138	[  --with-readline         support readline input (yes by default)],
139	[with_readline="$withval"], [with_readline="yes"])
140AC_MSG_RESULT($with_readline)
141
142# Is readline available?
143if test $with_readline != "no"; then
144	AC_CHECK_HEADER([readline/readline.h], 
145		[AC_CHECK_LIB(readline, readline, [
146				AC_DEFINE(HAVE_READLINE, [],
147					[Is readline available?])
148				LIBS="$LIBS -lreadline"
149		], [])], [])
150fi
151
152# Check if a different OpenSSL directory was specified
153AC_MSG_CHECKING(if --with-openssl option is specified)
154AC_ARG_WITH(openssl, [  --with-openssl=DIR      specify OpenSSL directory],
155	[crypto_dir=$withval])
156AC_MSG_RESULT(${crypto_dir-default})
157
158if test "x$crypto_dir" != "x"; then
159	LIBS="$LIBS -L${crypto_dir}/lib"
160	CPPFLAGS_ADD="-I${crypto_dir}/include $CPPFLAGS_ADD"
161fi
162AC_MSG_CHECKING(openssl version)
163AC_EGREP_CPP(yes, [#include <openssl/opensslv.h>
164#if OPENSSL_VERSION_NUMBER >= 0x0090602fL
165yes
166#endif], [AC_MSG_RESULT(ok)], [AC_MSG_RESULT(too old)
167	AC_MSG_ERROR([OpenSSL version must be 0.9.6 or higher. Aborting.])
168	])
169AC_CHECK_HEADERS(openssl/engine.h)
170
171# checking rijndael
172AC_CHECK_HEADERS([openssl/aes.h], [], 
173	[CRYPTOBJS="$CRYPTOBJS rijndael-api-fst.o rijndael-alg-fst.o"])
174
175# checking sha2
176AC_MSG_CHECKING(sha2 support)
177AC_DEFINE([WITH_SHA2], [], [SHA2 support])
178AC_CHECK_HEADER(openssl/sha2.h, [], [
179	CPPFLAGS_ADD="$CPPFLAGS_ADD -I./\${top_srcdir}/src/racoon/missing"
180	AC_LIBOBJ([sha2])
181	CRYPTOBJS="$CRYPTOBJS sha2.o"])
182AC_SUBST(CRYPTOBJS)
183
184# Option --enable-adminport 
185AC_MSG_CHECKING(if --enable-adminport option is specified)
186AC_ARG_ENABLE(adminport,
187	[  --enable-adminport      enable admin port],
188	[], [enable_adminport=no])
189if test $enable_adminport = "yes"; then
190	AC_DEFINE([ENABLE_ADMINPORT], [], [Enable admin port])
191fi
192AC_MSG_RESULT($enable_adminport)
193
194# Option RC5
195AC_MSG_CHECKING(if --enable-rc5 option is specified)
196AC_ARG_ENABLE(rc5,
197	[  --enable-rc5		enable RC5 encryption (patented)],
198	[], [enable_rc5=no])
199AC_MSG_RESULT($enable_rc5)
200
201if test $enable_rc5 = "yes"; then
202	AC_CHECK_HEADERS([openssl/rc5.h])
203	AC_CHECK_LIB([crypto_rc5], [RC5_32_encrypt],
204	    [EXTRA_CRYPTO="$EXTRA_CRYPTO -lcrypto_rc5"])
205fi
206
207# Option IDEA
208AC_MSG_CHECKING(if --enable-idea option is specified)
209AC_ARG_ENABLE(idea,
210	[  --enable-idea	enable IDEA encryption (patented)],
211	[], [enable_idea=no])
212AC_MSG_RESULT($enable_idea)
213
214if test $enable_idea = "yes"; then
215	AC_CHECK_HEADERS([openssl/idea.h])
216	AC_CHECK_LIB([crypto_idea], [idea_encrypt], 
217	    [EXTRA_CRYPTO="$EXTRA_CRYPTO -lcrypto_idea"])
218fi
219AC_SUBST(EXTRA_CRYPTO)
220
221# For dynamic libradius
222RACOON_PATH_LIBS(MD5_Init, crypto)
223
224# Check for Kerberos5 support
225AC_MSG_CHECKING(if --enable-gssapi option is specified)
226AC_ARG_ENABLE(gssapi,
227	[  --enable-gssapi         enable GSS-API authentication],
228	[], [enable_gssapi=no])
229AC_MSG_RESULT($enable_gssapi)
230AC_PATH_PROG(KRB5_CONFIG,krb5-config,no)
231if test "x$enable_gssapi" = "xyes"; then
232	if test "$KRB5_CONFIG" != "no"; then
233		krb5_incdir="`$KRB5_CONFIG --cflags gssapi`"
234		krb5_libs="`$KRB5_CONFIG --libs gssapi`"
235	else
236		# No krb5-config; let's make some assumptions based on
237		# the OS.
238		case $host_os in
239		netbsd*)
240			krb5_incdir="-I/usr/include/krb5"
241			krb5_libs="-lgssapi -lkrb5 -lcom_err -lroken -lasn1"
242			;;
243		*)
244			AC_MSG_ERROR([krb5-config not found, but needed for GSSAPI support. Aborting.])
245			;;
246		esac
247	fi
248	LIBS="$LIBS $krb5_libs"
249	CPPFLAGS_ADD="$krb5_incdir $CPPFLAGS_ADD"
250	AC_DEFINE([HAVE_GSSAPI], [], [Enable GSS API])
251fi
252
253AC_MSG_CHECKING([if --enable-hybrid option is specified])
254AC_ARG_ENABLE(hybrid, 
255    [  --enable-hybrid	  enable hybrid, both mode-cfg and xauth support],
256    [
257	LIBS="$LIBS -lcrypt"; 
258	enable_hybrid=yes;
259	HYBRID_OBJS="isakmp_xauth.o isakmp_cfg.o isakmp_unity.o throttle.o"
260	AC_SUBST(HYBRID_OBJS)
261	AC_DEFINE([ENABLE_HYBRID], [], [Hybrid authentication support])
262    ],
263    [enable_hybrid=no])
264AC_MSG_RESULT($enable_hybrid)
265
266AC_MSG_CHECKING([if --enable-frag option is specified])
267AC_ARG_ENABLE(frag, 
268    [  --enable-frag           enable IKE fragmentation payload support],
269    [
270	LIBS="$LIBS -lcrypt"; 
271	enable_frag=yes;
272	FRAG_OBJS="isakmp_frag.o"
273	AC_SUBST(FRAG_OBJS)
274	AC_DEFINE([ENABLE_FRAG], [], [IKE fragmentation support])
275    ],
276    [enable_frag=no])
277AC_MSG_RESULT($enable_frag)
278
279AC_MSG_CHECKING(if --with-libradius option is specified)
280AC_ARG_WITH(libradius, 
281    [  --with-libradius=DIR    specify libradius path (like/usr/pkg)],
282    [libradius_dir=$withval], 
283    [libradius_dir=no])
284AC_MSG_RESULT($libradius_dir)
285if test "$libradius_dir" != "no"; then
286	if test "$libradius_dir" = "yes" ; then
287		  libradius_dir="";
288	fi;
289	if test "x$libradius_dir" = "x"; then
290		RACOON_PATH_LIBS(rad_create_request, radius)
291	else
292		if test -d "$libradius_dir/lib" -a \
293		    -d "$libradius_dir/include" ; then
294			RACOON_PATH_LIBS(rad_create_request, radius, "$libradius_dir/lib")
295			CPPFLAGS_ADD="$CPPFLAGS_ADD -I$libradius_dir/include"
296		else
297			AC_MSG_ERROR([RADIUS libs or includes not found. Aborting.])
298	  	fi
299	fi
300	AC_DEFINE([HAVE_LIBRADIUS], [], [Hybrid authentication uses RADIUS])
301	LIBS="$LIBS -L$libradius_dir/lib -R$libradius_dir/lib -lradius"
302	AC_CHECK_FUNCS(rad_create_request)
303fi
304
305AC_MSG_CHECKING(if --with-libpam option is specified)
306AC_ARG_WITH(libpam, 
307    [  --with-libpam=DIR    specify libpam path (like/usr/pkg)],
308    [libpam_dir=$withval], 
309    [libpam_dir=no])
310AC_MSG_RESULT($libpam_dir)
311if test "$libpam_dir" != "no"; then
312	if test "$libpam_dir" = "yes" ; then
313		  libpam_dir="";
314	fi;
315	if test "x$libpam_dir" = "x"; then
316		RACOON_PATH_LIBS(pam_start, pam)
317	else
318		if test -d "$libpam_dir/lib" -a \
319		    -d "$libpam_dir/include" ; then
320			RACOON_PATH_LIBS(pam_start, pam, "$libpam_dir/lib")
321			CPPFLAGS_ADD="$CPPFLAGS_ADD -I$libpam_dir/include"
322		else
323			AC_MSG_ERROR([PAM libs or includes not found. Aborting.])
324	  	fi
325	fi
326	AC_DEFINE([HAVE_LIBPAM], [], [Hybrid authentication uses PAM])
327	LIBS="$LIBS -L$libpam_dir/lib -R$libpam_dir/lib -lpam"
328	AC_CHECK_FUNCS(pam_start)
329fi
330
331AC_MSG_CHECKING(if --enable-stats option is specified)
332AC_ARG_ENABLE(stats,
333        [  --enable-stats          enable statistics logging function],
334        [], [enable_stats=no])
335if test "x$enable_stats" = "xyes"; then
336	AC_DEFINE([ENABLE_STATS], [], [Enable statictics])
337fi
338AC_MSG_RESULT($enable_stats)
339
340AC_MSG_CHECKING(if --enable-dpd option is specified)
341AC_ARG_ENABLE(dpd,
342        [  --enable-dpd            enable dead peer detection],
343        [], [enable_dpd=no])
344if test "x$enable_dpd" = "xyes"; then
345	AC_DEFINE([ENABLE_DPD], [], [Enable dead peer detection])
346fi
347AC_MSG_RESULT($enable_dpd)
348
349
350AC_MSG_CHECKING(if --enable-samode-unspec option is specified)
351AC_ARG_ENABLE(samode-unspec,
352        [  --enable-samode-unspec  enable to use unspecified a mode of SA],
353        [], [enable_samode_unspec=no])
354if test "x$enable_samode_unspec" = "xyes"; then
355	AC_DEFINE([ENABLE_SAMODE_UNSPECIFIED], [], [Enable samode-unspec])
356fi
357AC_MSG_RESULT($enable_samode_unspec)
358
359# Checks if IPv6 is requested
360AC_MSG_CHECKING([whether to enable ipv6])
361AC_ARG_ENABLE(ipv6,
362[  --disable-ipv6          disable ipv6 support],
363[ case "$enableval" in
364  no)
365       AC_MSG_RESULT(no)
366       ipv6=no
367       ;;
368  *)   AC_MSG_RESULT(yes)
369       ipv6=yes
370       ;;
371  esac ],
372
373  AC_TRY_RUN([ /* AF_INET6 avalable check */
374#include <sys/types.h>
375#include <sys/socket.h>
376main()
377{
378  exit(0);
379 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
380   exit(1);
381 else
382   exit(0);
383}
384],
385  AC_MSG_RESULT(yes)
386  AC_DEFINE([INET6], [], [Support IPv6])
387  ipv6=yes,
388  AC_MSG_RESULT(no)
389  ipv6=no,
390  AC_MSG_RESULT(no)
391  ipv6=no
392))
393
394if test "$ipv6" = "yes"; then
395	AC_MSG_CHECKING(for advanced API support)
396	AC_TRY_COMPILE([#ifndef INET6
397#define INET6
398#endif
399#include <sys/types.h>
400#include <netinet/in.h>],
401		[struct in6_pktinfo a;],
402		[AC_MSG_RESULT(yes)
403		 AC_DEFINE([INET6_ADVAPI], [], [Use advanced IPv6 API])],
404		[AC_MSG_RESULT(no)])
405fi
406
407RACOON_CHECK_BUGGY_GETADDRINFO
408if test "$buggygetaddrinfo" = "yes"; then
409	AC_MSG_ERROR([Broken getaddrinfo() is no longer supported. Aborting.])
410fi
411
412# Check if kernel support is available for NAT-T, defaults to no. 
413kernel_natt="no"
414
415AC_MSG_CHECKING(kernel NAT-Traversal support)
416case $host_os in
417linux*)
418# Linux kernel NAT-T check
419AC_EGREP_CPP(yes, 
420[#include <linux/pfkeyv2.h>
421#ifdef SADB_X_EXT_NAT_T_TYPE
422yes
423#endif
424], [kernel_natt="yes"])
425	;;
426freebsd*|netbsd*)
427# NetBSD case
428# Same check for FreeBSD
429AC_CHECK_MEMBER(struct sadb_x_nat_t_type.sadb_x_nat_t_type_len,
430       [kernel_natt="yes"],, [
431#define _KERNEL
432#include <sys/types.h>
433#include <net/pfkeyv2.h>
434])
435	;;
436esac
437AC_MSG_RESULT($kernel_natt)
438
439AC_MSG_CHECKING(whether to support NAT-T)
440AC_ARG_ENABLE(natt,
441	[  --enable-natt           enable NAT-Traversal (yes/no/kernel)],
442        [if test "$enable_natt" = "kernel"; then enable_natt=$kernel_natt; fi],
443	[enable_natt=$kernel_natt])
444AC_MSG_RESULT($enable_natt)
445
446if test "$enable_natt" = "yes"; then
447	if test "$kernel_natt" = "no" ; then 
448		AC_MSG_ERROR([NAT-T requested, but no kernel support! Aborting.])
449	else
450		AC_DEFINE([ENABLE_NATT], [], [Enable NAT-Traversal])
451		NATT_OBJS="nattraversal.o"
452		AC_SUBST(NATT_OBJS)
453	fi
454fi
455
456# Set up defines for supported NAT-T versions.
457natt_versions_default="00,02,rfc"
458AC_MSG_CHECKING(which NAT-T versions to support)
459AC_ARG_ENABLE(natt_versions,
460	[  --enable-natt-versions=list    list of supported NAT-T versions delimited by coma.],
461	[ test "$enable_natt_versions" = "yes" && enable_natt_versions=$natt_versions_default ],
462	[ enable_natt_versions=$natt_versions_default ])
463if test "$enable_natt" = "yes"; then
464	AC_MSG_RESULT($enable_natt_versions)
465	for i in `echo $enable_natt_versions | tr ',cfr' ' CFR'`; do
466		case $i in 
467			0|00) AC_DEFINE([ENABLE_NATT_00], [], [Enable NAT-Traversal draft 00]) ;;
468			1|01) AC_DEFINE([ENABLE_NATT_01], [], [Enable NAT-Traversal draft 01]) ;;
469			2|02) AC_DEFINE([ENABLE_NATT_02], [], [Enable NAT-Traversal draft 02]) ;;
470			3|03) AC_DEFINE([ENABLE_NATT_03], [], [Enable NAT-Traversal draft 03]) ;;
471			4|04) AC_DEFINE([ENABLE_NATT_04], [], [Enable NAT-Traversal draft 04]) ;;
472			5|05) AC_DEFINE([ENABLE_NATT_05], [], [Enable NAT-Traversal draft 05]) ;;
473			6|06) AC_DEFINE([ENABLE_NATT_06], [], [Enable NAT-Traversal draft 06]) ;;
474			7|07) AC_DEFINE([ENABLE_NATT_07], [], [Enable NAT-Traversal draft 07]) ;;
475			8|08) AC_DEFINE([ENABLE_NATT_08], [], [Enable NAT-Traversal draft 08]) ;;
476			RFC)  AC_DEFINE([ENABLE_NATT_RFC], [], [Enable NAT-Traversal RFC version]) ;;
477			*) AC_MSG_ERROR([Unknown NAT-T version. Aborting.]) ;;
478		esac
479	done
480	unset i
481else
482	AC_MSG_RESULT([none])
483fi
484
485AC_MSG_CHECKING(whether we support FWD policy)
486case $host in
487	*linux*)
488		AC_TRY_COMPILE([
489		#include <inttypes.h>
490		#include <linux/ipsec.h>
491			], [
492			int fwd = IPSEC_DIR_FWD;
493			],
494			[AC_MSG_RESULT(yes)
495			 AC_DEFINE([HAVE_POLICY_FWD], [], [Have forward policy])],
496			[AC_MSG_RESULT(no)])
497		;;
498	*)
499		AC_MSG_RESULT(no)
500		;;
501esac
502
503CFLAGS="$CFLAGS $CFLAGS_ADD"
504CPPFLAGS="$CPPFLAGS $CPPFLAGS_ADD"
505
506case $host in
507	*linux*)
508		# Remove KERNEL_INCLUDE from CPPFLAGS. It will
509		# be symlinked to src/include-glibc/linux in
510		# compile time.
511		CPPFLAGS=`echo $CPPFLAGS | sed "s,-I$KERNEL_INCLUDE,,"`
512		;;
513esac
514
515include_racoondir=${includedir}/racoon
516AC_SUBST(include_racoondir)
517
518AC_CONFIG_FILES([
519  Makefile
520  package_version.h
521  src/Makefile
522  src/include-glibc/Makefile
523  src/libipsec/Makefile
524  src/setkey/Makefile
525  src/racoon/Makefile
526  src/racoon/samples/psk.txt
527  src/racoon/samples/racoon.conf
528  rpm/Makefile
529  rpm/suse/Makefile
530  ])
531AC_OUTPUT
532