xref: /minix3/external/bsd/dhcp/dist/configure.ac (revision 83ee113ee0d94f3844d44065af2311604e9a30ad)
1AC_INIT([DHCP],[4.3.0],[dhcp-users@isc.org])
2
3# we specify "foreign" to avoid having to have the GNU mandated files,
4# like AUTHORS, COPYING, and such
5AM_INIT_AUTOMAKE([foreign])
6
7# we specify AM_MAINTAINER_MODE to avoid problems with rebuilding
8# the configure and makefiles.  Without it users doing things that
9# change the timestamps on the code, like checking it into a cvs
10# tree, could trigger a rebuild of the infrastructure files which
11# might fail if they don't have the correct tools.
12AM_MAINTAINER_MODE
13
14AC_CANONICAL_HOST
15
16# We want to turn on warnings if we are using gcc and the user did
17# not specify CFLAGS. The autoconf check for the C compiler sets the
18# CFLAGS if gcc is used, so we will save it before we run that check.
19SAVE_CFLAGS="$CFLAGS"
20
21# Now find our C compiler.
22AC_PROG_CC
23
24# Suppress warnings about --datarootdir
25AC_DEFUN([AC_DATAROOTDIR_CHECKED])
26
27# If we have gcc, and AC_PROG_CC changed the flags, then we know the
28# user did not specify any flags. Add warnings in this case.
29if test "$GCC" = "yes"; then
30	if test "$CFLAGS" != "$SAVE_CFLAGS"; then
31		STD_CWARNINGS="$STD_CWARNINGS -Wall -Werror -fno-strict-aliasing"
32	fi
33fi
34
35# POSIX doesn't include the IPv6 Advanced Socket API and glibc hides
36# parts of the IPv6 Advanced Socket API as a result.  This is stupid
37# as it breaks how the two halves (Basic and Advanced) of the IPv6
38# Socket API were designed to be used but we have to live with it.
39# Use this to define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
40AC_USE_SYSTEM_EXTENSIONS
41
42AC_PROG_RANLIB
43AC_CONFIG_HEADERS([includes/config.h])
44
45# we sometimes need to know byte order for building packets
46AC_C_BIGENDIAN(AC_SUBST(byte_order, BIG_ENDIAN),
47	       AC_SUBST(byte_order, LITTLE_ENDIAN))
48AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
49		   [Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs)
50		    or LITTLE_ENDIAN for LSB (Intel CPUs).])
51
52# Optional compile-time DEBUGging.
53AC_ARG_ENABLE(debug,
54	AS_HELP_STRING([--enable-debug],[create a debug-only version of the software (default is no).]),
55		[enable_debug=yes],[enable_debug=no])
56# This is very much off by default.
57if test "$enable_debug" = "yes" ; then
58	AC_DEFINE([DEBUG], [1],
59		[Define to compile debug-only DHCP software.])
60	# Just override CFLAGS to totally to remove optimization.
61	CFLAGS="-g"
62fi
63# XXX: there are actually quite a lot more DEBUG_ features we could enable,
64# but I don't want to pollute the --help space.
65#
66#/* #define DEBUG_TOKENS */
67#/* #define DEBUG_PACKET */
68#/* #define DEBUG_EXPRESSIONS */
69#/* #define DEBUG_FIND_LEASE */
70#/* #define DEBUG_EXPRESSION_PARSE */
71#/* #define DEBUG_CLASS_MATCHING */
72#/* #define DEBUG_MEMORY_LEAKAGE */
73#/* #define DEBUG_MALLOC_POOL */
74#/* #define DEBUG_LEASE_STATE_TRANSITIONS */
75#/* #define DEBUG_RC_HISTORY */
76#/* #define DEBUG_RC_HISTORY_EXHAUSTIVELY */
77#/* #define RC_HISTORY_MAX 10240 */
78#/* #define POINTER_DEBUG */
79#/* #define DEBUG_FAILOVER_MESSAGES */
80#/* #define DEBUG_FAILOVER_TIMING */
81#/* #define DEBUG_DUMP_ALL_LEASES */
82
83# Failover optional compile-time feature.
84AC_ARG_ENABLE(failover,
85	AS_HELP_STRING([--enable-failover],[enable support for failover (default is yes)]))
86# Failover is on by default, so define if it is not explicitly disabled.
87if test "$enable_failover" != "no"; then
88	AC_DEFINE([FAILOVER_PROTOCOL], [1],
89		  [Define to include Failover Protocol support.])
90fi
91
92# execute() support.
93AC_ARG_ENABLE(execute,
94	AS_HELP_STRING([--enable-execute],[enable support for execute() in config (default is yes)]))
95# execute() is on by default, so define if it is not explicitly disabled.
96if test "$enable_execute" != "no" ; then
97	AC_DEFINE([ENABLE_EXECUTE], [1],
98		  [Define to include execute() config language support.])
99fi
100
101# Server tracing support.
102AC_ARG_ENABLE(tracing,
103	AS_HELP_STRING([--enable-tracing],[enable support for server activity tracing (default is yes)]))
104# tracing is on by default, so define if it is not explicitly disabled.
105if test "$enable_tracing" != "no" ; then
106	AC_DEFINE([TRACING], [1],
107		  [Define to include server activity tracing support.])
108fi
109
110# Delayed-ack feature support (experimental).
111AC_ARG_ENABLE(delayed_ack,
112	AS_HELP_STRING([--enable-delayed-ack],[queues multiple DHCPACK replies (default is no)]))
113if test "$enable_delayed_ack" = "yes"; then
114	AC_DEFINE([DELAYED_ACK], [1],
115		  [Define to queue multiple DHCPACK replies per fsync.])
116fi
117
118# DHCPv6 optional compile-time feature.
119AC_ARG_ENABLE(dhcpv6,
120	AS_HELP_STRING([--enable-dhcpv6],[enable support for DHCPv6 (default is yes)]))
121# DHCPv6 is on by default, so define if it is not explicitly disabled.
122if test "$enable_dhcpv6" != "no"; then
123	AC_DEFINE([DHCPv6], [1],
124		  [Define to 1 to include DHCPv6 support.])
125fi
126
127# PARANOIA is off by default (until we can test it with all features)
128AC_ARG_ENABLE(paranoia,
129	AS_HELP_STRING([--enable-paranoia],[enable support for chroot/setuid (default is no)]))
130AC_ARG_ENABLE(early_chroot,
131	AS_HELP_STRING([--enable-early-chroot],[enable chrooting prior to configuration (default is no)]))
132# If someone enables early chroot, but does not enable paranoia, do so for
133# them.
134if test "$enable_paranoia" != "yes" && \
135   test "$enable_early_chroot" = "yes" ; then
136	enable_paranoia="yes"
137fi
138
139if test "$enable_paranoia" = "yes" ; then
140	AC_DEFINE([PARANOIA], [1],
141		  [Define to any value to include Ari's PARANOIA patch.])
142fi
143if test "$enable_early_chroot" = "yes" ; then
144	AC_DEFINE([EARLY_CHROOT], [1],
145		  [Define to any value to chroot() prior to loading config.])
146fi
147
148AC_ARG_ENABLE(ipv4_pktinfo,
149	AS_HELP_STRING([--enable-ipv4-pktinfo],[enable use of pktinfo on IPv4 sockets (default is no)]))
150
151if test "$enable_ipv4_pktinfo" = "yes"; then
152	AC_DEFINE([USE_V4_PKTINFO], [1],
153		[Define to 1 to enable IPv4 packet info support.])
154fi
155
156AC_ARG_ENABLE(use_sockets,
157	AS_HELP_STRING([--enable-use-sockets],[use the standard BSD socket API (default is no)]))
158
159if test "$enable_use_sockets" = "yes"; then
160	AC_DEFINE([USE_SOCKETS], [1],
161		[Define to 1 to use the standard BSD socket API.])
162fi
163
164# Try to hnadle incorrect byte order for secs field
165# This is off by default
166AC_ARG_ENABLE(secs_byteorder,
167	AS_HELP_STRING([--enable-secs-byteorder],[Correct bad byteorders in the secs field (default is no).]))
168
169if test "$enable_secs_byteorder" = "yes" ; then
170	AC_DEFINE([SECS_BYTEORDER], [1],
171		[Define to correct bad byteorders in secs field.])
172fi
173
174# Testing section
175
176atf_path="no"
177AC_ARG_WITH([atf],
178    AS_HELP_STRING([--with-atf=PATH],[specify location where atf was installed]),
179    [atf_path="$withval"])
180if test "$atf_path" != "no" ; then
181    # Config path for pkg-config
182    atf_pcp=""
183    if test "$atf_path" != "yes" ; then
184        if test -f $atf_path/lib/pkgconfig/atf-c.pc ; then
185            atf_pcp=$atf_path/lib/pkgconfig
186        elif test -f $atf_path/lib64/pkgconfig/atf-c.pc ; then
187            atf_pcp=$atf_path/lib64/pkgconfig
188        fi
189    else
190        # Not specified, try some common paths
191        atf_dirs="/usr /usr/local /usr/pkg /opt /opt/local"
192        for d in $atf_dirs
193        do
194            if test -f $d/lib/pkgconfig/atf-c.pc ; then
195                atf_pcp=$d/lib/pkgconfig
196            elif test -f $d/lib64/pkgconfig/atf-c.pc ; then
197                atf_pcp=$d/lib64/pkgconfig
198            fi
199        done
200    fi
201    if test "$atf_pcp" = "" ; then
202        AC_MSG_ERROR([Unable to find atf files in location specified])
203    else
204        ATF_CFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --cflags atf-c` -DUNIT_TEST"
205        ATF_LDFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --libs atf-c`"
206        AC_SUBST(ATF_CFLAGS)
207        AC_SUBST(ATF_LDFLAGS)
208    fi
209fi
210
211AM_CONDITIONAL(HAVE_ATF, test "$atf_pcp" != "")
212### Uncomment this once docs.lab.isc.org upgrades to automake 1.11
213### AM_COND_IF([HAVE_ATF], [AC_DEFINE([HAVE_ATF], [1], [ATF framework specified?])])
214
215###
216### Path fun.  Older versions of DHCP were installed in /usr/sbin, so we
217### need to look there and potentially overwrite by default (but not if
218### the user configures an alternate value).  LOCALSTATEDIR is totally
219### braindead.  No one uses /usr/local/var/db/ nor /usr/local/var/run, and
220### they would be insane for suggesting it.  We need to look in /var/for
221### 'db' and 'state/dhcp' for db files, and /var/run for pid files by
222### default.
223###
224AC_PREFIX_PROGRAM(dhcpd)
225
226# XXX - isn't there SOME WAY to default autoconf to /var instead of
227# /usr/local/var/no/one/has/this/please/stop/trying?
228case "$localstatedir" in
229	'${prefix}/var')
230		localstatedir=/var
231		;;
232esac
233
234# Allow specification of alternate state files
235AC_ARG_WITH(srv-lease-file,
236	AS_HELP_STRING([--with-srv-lease-file=PATH],[File for dhcpd leases
237		        (default is LOCALSTATEDIR/db/dhcpd.leases)]),
238	AC_DEFINE_UNQUOTED([_PATH_DHCPD_DB], ["$withval"],
239			   [File for dhcpd leases.]))
240
241echo -n "checking for dhcpd.leases location..."
242if [[ "x$with_srv_lease_file" = "x" ]] ; then
243	if [[ -d "${localstatedir}/db" ]] ; then
244		with_srv_lease_file="${localstatedir}/db/dhcpd.leases"
245	elif [[ -d "${localstatedir}/state" ]] ; then
246		if [[ -d "${localstatedir}/state/dhcp" ]] ; then
247			with_srv_lease_file="${localstatedir}/state/dhcp/dhcpd.leases"
248		else
249			with_srv_lease_file="${localstatedir}/state/dhcpd.leases"
250		fi
251	elif [[ -d "${localstatedir}/lib" ]] ; then
252		if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
253			with_srv_lease_file="${localstatedir}/lib/dhcp/dhcpd.leases"
254		else
255			with_srv_lease_file="${localstatedir}/lib/dhcpd.leases"
256		fi
257	elif [[ -d "${localstatedir}/etc" ]] ; then
258		with_srv_lease_file="${localstatedir}/etc/dhcpd.leases"
259	else
260		with_srv_lease_file="/etc/dhcpd.leases"
261	fi
262fi
263echo "$with_srv_lease_file"
264
265AC_ARG_WITH(srv6-lease-file,
266	AS_HELP_STRING([--with-srv6-lease-file=PATH],[File for dhcpd6 leases
267		        (default is LOCALSTATEDIR/db/dhcpd6.leases)]),
268	AC_DEFINE_UNQUOTED([_PATH_DHCPD6_DB], ["$withval"],
269			   [File for dhcpd6 leases.]))
270
271echo -n "checking for dhcpd6.leases location..."
272if [[ "x$with_srv6_lease_file" = "x" ]] ; then
273	if [[ -d "${localstatedir}/db" ]] ; then
274		with_srv6_lease_file="${localstatedir}/db/dhcpd6.leases"
275	elif [[ -d "${localstatedir}/state" ]] ; then
276		if [[ -d "${localstatedir}/state/dhcp" ]] ; then
277			with_srv6_lease_file="${localstatedir}/state/dhcp/dhcpd6.leases"
278		else
279			with_srv6_lease_file="${localstatedir}/state/dhcpd6.leases"
280		fi
281	elif [[ -d "${localstatedir}/lib" ]] ; then
282		if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
283			with_srv6_lease_file="${localstatedir}/lib/dhcp/dhcpd6.leases"
284		else
285			with_srv6_lease_file="${localstatedir}/lib/dhcpd6.leases"
286		fi
287	elif [[ -d "${localstatedir}/etc" ]] ; then
288		with_srv6_lease_file="${localstatedir}/etc/dhcpd6.leases"
289	else
290		with_srv6_lease_file="/etc/dhcpd6.leases"
291	fi
292fi
293echo "$with_srv6_lease_file"
294
295AC_ARG_WITH(cli-lease-file,
296	AS_HELP_STRING([--with-cli-lease-file=PATH],[File for dhclient leases
297		        (default is LOCALSTATEDIR/db/dhclient.leases)]),
298	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_DB], ["$withval"],
299			   [File for dhclient leases.]))
300
301echo -n "checking for dhclient.leases location..."
302if [[ "x$with_cli_lease_file" = "x" ]] ; then
303	if [[ -d "${localstatedir}/db" ]] ; then
304		with_cli_lease_file="${localstatedir}/db/dhclient.leases"
305	elif [[ -d "${localstatedir}/state" ]] ; then
306		if [[ -d "${localstatedir}/state/dhcp" ]] ; then
307			with_cli_lease_file="${localstatedir}/state/dhcp/dhclient.leases"
308		else
309			with_cli_lease_file="${localstatedir}/state/dhclient.leases"
310		fi
311	elif [[ -d "${localstatedir}/lib" ]] ; then
312		if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
313			with_cli_lease_file="${localstatedir}/lib/dhcp/dhclient.leases"
314		else
315			with_cli_lease_file="${localstatedir}/lib/dhclient.leases"
316		fi
317	elif [[ -d "${localstatedir}/etc" ]] ; then
318		with_cli_lease_file="${localstatedir}/etc/dhclient.leases"
319	else
320		with_cli_lease_file="/etc/dhclient.leases"
321	fi
322fi
323echo "$with_cli_lease_file"
324
325AC_ARG_WITH(cli6-lease-file,
326	AS_HELP_STRING([--with-cli6-lease-file=PATH],[File for dhclient6 leases
327		        (default is LOCALSTATEDIR/db/dhclient6.leases)]),
328	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_DB], ["$withval"],
329			   [File for dhclient6 leases.]))
330
331echo -n "checking for dhclient6.leases location..."
332if [[ "x$with_cli6_lease_file" = "x" ]] ; then
333	if [[ -d "${localstatedir}/db" ]] ; then
334		with_cli6_lease_file="${localstatedir}/db/dhclient6.leases"
335	elif [[ -d "${localstatedir}/state" ]] ; then
336		if [[ -d "${localstatedir}/state/dhcp" ]] ; then
337			with_cli6_lease_file="${localstatedir}/state/dhcp/dhclient6.leases"
338		else
339			with_cli6_lease_file="${localstatedir}/state/dhclient6.leases"
340		fi
341	elif [[ -d "${localstatedir}/lib" ]] ; then
342		if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
343			with_cli6_lease_file="${localstatedir}/lib/dhcp/dhclient6.leases"
344		else
345			with_cli6_lease_file="${localstatedir}/lib/dhclient6.leases"
346		fi
347	elif [[ -d "${localstatedir}/etc" ]] ; then
348		with_cli6_lease_file="${localstatedir}/etc/dhclient6.leases"
349	else
350		with_cli6_lease_file="/etc/dhclient6.leases"
351	fi
352fi
353echo "$with_cli6_lease_file"
354
355AC_ARG_WITH(srv-pid-file,
356	AS_HELP_STRING([--with-srv-pid-file=PATH],[File for dhcpd process information
357		        (default is LOCALSTATEDIR/run/dhcpd.pid)]),
358	AC_DEFINE_UNQUOTED([_PATH_DHCPD_PID], ["$withval"],
359			   [File for dhcpd process information.]))
360AC_ARG_WITH(srv6-pid-file,
361	AS_HELP_STRING([--with-srv6-pid-file=PATH],[File for dhcpd6 process information
362		        (default is LOCALSTATEDIR/run/dhcpd6.pid)]),
363	AC_DEFINE_UNQUOTED([_PATH_DHCPD6_PID], ["$withval"],
364			   [File for dhcpd6 process information.]))
365AC_ARG_WITH(cli-pid-file,
366	AS_HELP_STRING([--with-cli-pid-file=PATH],[File for dhclient process information
367		        (default is LOCALSTATEDIR/run/dhclient.pid)]),
368	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_PID], ["$withval"],
369			   [File for dhclient process information.]))
370AC_ARG_WITH(cli6-pid-file,
371	AS_HELP_STRING([--with-cli6-pid-file=PATH],[File for dhclient6 process information
372		        (default is LOCALSTATEDIR/run/dhclient6.pid)]),
373	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_PID], ["$withval"],
374			   [File for dhclient6 process information.]))
375AC_ARG_WITH(relay-pid-file,
376	AS_HELP_STRING([--with-relay-pid-file=PATH],[File for dhcrelay process information
377		        (default is LOCALSTATEDIR/run/dhcrelay.pid)]),
378	AC_DEFINE_UNQUOTED([_PATH_DHCRELAY_PID], ["$withval"],
379			   [File for dhcrelay process information.]))
380AC_ARG_WITH(relay6-pid-file,
381	AS_HELP_STRING([--with-relay6-pid-file=PATH],[File for dhcrelay6 process information
382		        (default is LOCALSTATEDIR/run/dhcrelay6.pid)]),
383	AC_DEFINE_UNQUOTED([_PATH_DHCRELAY6_PID], ["$withval"],
384			   [File for dhcrelay6 process information.]))
385
386# Check basic types.
387AC_TYPE_INT8_T
388AC_TYPE_INT16_T
389AC_TYPE_INT32_T
390AC_TYPE_INT64_T
391
392# Some systems need the u_intX_t types defined across.
393AC_CHECK_TYPE([u_int8_t], [], [
394  AC_TYPE_UINT8_T
395  AC_DEFINE(u_int8_t, [uint8_t], [Define a type for 8-bit unsigned
396				  integers.])
397])
398AC_CHECK_TYPE([u_int16_t], [], [
399  AC_TYPE_UINT16_T
400  AC_DEFINE(u_int16_t, [uint16_t], [Define a type for 16-bit unsigned
401				    integers.])
402])
403AC_CHECK_TYPE([u_int32_t], [], [
404  AC_TYPE_UINT32_T
405  AC_DEFINE(u_int32_t, [uint32_t], [Define a type for 32-bit unsigned
406				    integers.])
407])
408AC_CHECK_TYPE([u_int64_t], [], [
409  AC_TYPE_UINT64_T
410  AC_DEFINE(u_int64_t, [uint64_t], [Define a type for 64-bit unsigned
411				    integers.])
412])
413
414# see if ifaddrs.h is available
415AC_CHECK_HEADERS(ifaddrs.h)
416
417# figure out what IPv4 interface code to use
418AC_CHECK_HEADERS(linux/types.h)  # needed for linux/filter.h on old systems
419
420AC_CHECK_HEADER(linux/filter.h, DO_LPF=1, ,
421[
422#ifdef HAVE_LINUX_TYPES_H
423#include <linux/types.h>
424#endif
425])
426if test -n "$DO_LPF"
427then
428	AC_DEFINE([HAVE_LPF], [1],
429		  [Define to 1 to use the Linux Packet Filter interface code.])
430else
431	AC_CHECK_HEADER(sys/dlpi.h, DO_DLPI=1)
432	if test -n "$DO_DLPI"
433	then
434		AC_DEFINE([HAVE_DLPI], [1],
435			  [Define to 1 to use DLPI interface code.])
436	else
437		AC_CHECK_HEADER(net/bpf.h, DO_BPF=1)
438		if test -n "$DO_BPF"
439		then
440			AC_DEFINE([HAVE_BPF], [1],
441	  			  [Define to 1 to use the
442				   Berkeley Packet Filter interface code.])
443		fi
444	fi
445fi
446
447# SIOCGLIFCONF uses some transport structures.  Trick is not all platforms
448# use the same structures.  We like to use 'struct lifconf' and 'struct
449# lifreq', but we'll use these other structures if they're present.  HPUX
450# does not define 'struct lifnum', but does use SIOCGLIFNUM - they use an
451# int value.
452#
453AC_MSG_CHECKING([for struct lifnum])
454AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
455  #include <sys/socket.h>
456  #include <net/if.h>
457]], [[ struct lifnum a;
458]])],[AC_MSG_RESULT(yes)
459	 AC_DEFINE([ISC_PLATFORM_HAVELIFNUM], [1],
460		   [Define to 1 if the system has 'struct lifnum'.])],[AC_MSG_RESULT(no)])
461
462AC_MSG_CHECKING([for struct if_laddrconf])
463AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
464  #include <net/if6.h>
465]], [[ struct if_laddrconf a;
466]])],[AC_MSG_RESULT(yes)
467	 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRCONF], [1],
468		   [Define to 1 if the system has 'struct if_laddrconf'.])],[AC_MSG_RESULT(no)])
469
470AC_MSG_CHECKING([for struct if_laddrreq])
471AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
472 #include <net/if6.h>
473]], [[ struct if_laddrreq a;
474]])],[AC_MSG_RESULT(yes)
475	 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRREQ], [1],
476		   [Define to 1 if the system has 'struct if_laddrreq'.])],[AC_MSG_RESULT(no)])
477
478#
479# check for GCC noreturn attribute
480#
481AC_MSG_CHECKING(for GCC noreturn attribute)
482AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[void foo() __attribute__((noreturn));]])],[AC_MSG_RESULT(yes)
483	 AC_DEFINE([ISC_DHCP_NORETURN], [__attribute__((noreturn))],
484		   [Define to the string for a noreturn attribute.])],[AC_MSG_RESULT(no)
485	 AC_DEFINE([ISC_DHCP_NORETURN], [],
486		   [Define to the string for a noreturn attribute.])])
487
488# Look for optional headers.
489AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
490
491# Solaris needs some libraries for functions
492AC_SEARCH_LIBS(socket, [socket])
493AC_SEARCH_LIBS(inet_ntoa, [nsl])
494
495AC_SEARCH_LIBS(inet_aton, [socket nsl], ,
496	AC_DEFINE([NEED_INET_ATON], [1],
497		  [Define to 1 if the inet_aton() function is missing.]))
498
499# Check for a standalone regex library.
500AC_SEARCH_LIBS(regcomp, [regex])
501
502AC_CHECK_FUNCS(strlcat)
503
504# For HP/UX we need -lipv6 for if_nametoindex, perhaps others.
505AC_SEARCH_LIBS(if_nametoindex, [ipv6])
506
507# check for /dev/random (declares HAVE_DEV_RANDOM)
508AC_CHECK_FILE(/dev/random,
509	AC_DEFINE([HAVE_DEV_RANDOM], [1],
510		  [Define to 1 if you have the /dev/random file.]))
511
512# see if there is a "sa_len" field in our interface information structure
513AC_CHECK_MEMBER(struct sockaddr.sa_len,
514	AC_DEFINE([HAVE_SA_LEN], [],
515		  [Define to 1 if the sockaddr structure has a length field.]),
516	,
517	[#include <sys/socket.h>])
518
519# figure out pointer size
520AC_CHECK_SIZEOF(struct iaddr *, , [
521#include "includes/inet.h"
522#include <stdio.h>
523])
524
525# Solaris does not have the msg_control or msg_controlen members
526# in the msghdr structure unless you define:
527#
528#   _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, and __EXTENSIONS__
529#
530# See the "standards" man page for details.
531#
532# We check for the msg_control member, and if it is not found, we check
533# again with the appropriate defines added to the CFLAGS. (In order to
534# do this we have to remove the check from the cache, which is what the
535# "unset" is for.)
536AC_CHECK_MEMBER(struct msghdr.msg_control,,
537	[CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
538	 CFLAGS="$CFLAGS -D__EXTENSIONS__"
539	 unset ac_cv_member_struct_msghdr_msg_control
540	 AC_CHECK_MEMBER(struct msghdr.msg_control,,
541	 	[AC_MSG_ERROR([Missing msg_control member in
542			       msg_control structure.])],
543		[
544#include <sys/types.h>
545#include <sys/socket.h>
546		])
547	],
548	[
549#include <sys/types.h>
550#include <sys/socket.h>
551	])
552
553libbind=
554AC_ARG_WITH(libbind,
555	AS_HELP_STRING([--with-libbind=PATH],[bind includes and libraries are in PATH
556		        (default is ./bind)]),
557	use_libbind="$withval", use_libbind="no")
558case "$use_libbind" in
559yes)
560	libbind="\${top_srcdir}/bind"
561	;;
562no)
563	libbind="\${top_srcdir}/bind"
564	;;
565*)
566	libbind="$use_libbind"
567	;;
568esac
569
570# OpenLDAP support.
571AC_ARG_WITH(ldap,
572    AS_HELP_STRING([--with-ldap],[enable OpenLDAP support in dhcpd (default is no)]),
573    [ldap=$withval],
574    [ldap=no])
575
576# OpenLDAP with SSL support.
577AC_ARG_WITH(ldapcrypto,
578    AS_HELP_STRING([--with-ldapcrypto],[enable OpenLDAP crypto support in dhcpd (default is no)]),
579    [ldapcrypto=$withval],
580    [ldapcrypto=no])
581
582# OpenLDAP support is disabled by default, if enabled then SSL support is an
583# extra optional that is also disabled by default.  Enabling LDAP SSL support
584# implies enabling LDAP support.
585if test x$ldap = xyes || test x$ldapcrypto = xyes ; then
586    AC_SEARCH_LIBS(ldap_initialize, [ldap], ,
587		   AC_MSG_FAILURE([*** Cannot find ldap_initialize with -lldap - do you need to install an OpenLDAP2 Devel package?]))
588    AC_SEARCH_LIBS(ber_pvt_opt_on, [lber], ,
589		   AC_MSG_FAILURE([*** Cannot find ber_pvt_opt_on with -llber - do you need to install an OpenLDAP2 Devel package?]))
590
591    if test x$ldapcrypto = xyes ; then
592	AC_SUBST(LDAP_CFLAGS, ["-DLDAP_CONFIGURATION -DLDAP_USE_SSL"])
593    else
594	AC_SUBST(LDAP_CFLAGS, ["-DLDAP_CONFIGURATION"])
595    fi
596fi
597
598# Append selected warning levels to CFLAGS before substitution (but after
599# AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
600CFLAGS="$CFLAGS $STD_CWARNINGS"
601
602# Try to add the bind include directory
603CFLAGS="$CFLAGS -I$libbind/include"
604
605case "$host" in
606*-darwin*)
607    CFLAGS="$CFLAGS -D__APPLE_USE_RFC_3542" ;;
608esac
609
610AC_C_FLEXIBLE_ARRAY_MEMBER
611
612AC_CONFIG_FILES([
613  Makefile
614  client/Makefile
615  common/Makefile
616  common/tests/Makefile
617  dhcpctl/Makefile
618  dst/Makefile
619  includes/Makefile
620  omapip/Makefile
621  relay/Makefile
622  server/Makefile
623  tests/Makefile
624  server/tests/Makefile
625  doc/devel/doxyfile
626])
627AC_OUTPUT
628
629sh util/bindvar.sh
630
631cat > config.report << END
632
633     ISC DHCP source configure results:
634    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
635
636Package:
637  Name:          $PACKAGE_NAME
638  Version:       $PACKAGE_VERSION
639
640C Compiler:      $CC
641
642Flags:
643  DEFS:          $DEFS
644  CFLAGS:        $CFLAGS
645
646Features:
647  debug:         $enable_debug
648  failover:      $enable_failover
649  execute:       $enable_execute
650
651Developer:
652  ATF unittests : $atf_path
653
654END
655# TODO: Add Perl system tests
656
657if test "$atf_path" != "no"
658then
659echo "ATF_CFLAGS  : $ATF_CFLAGS" >> config.report
660echo "ATF_LDFLAGS : $ATF_LDFLAGS" >> config.report
661echo
662fi
663
664cat config.report
665
666echo
667echo Now you can type "make" to build ISC DHCP
668echo
669