1 AC_INIT([DHCP], [4.2.0], [dhcp-users@isc.org])
3 # we specify "foreign" to avoid having to have the GNU mandated files,
4 # like AUTHORS, COPYING, and such
5 AM_INIT_AUTOMAKE([foreign])
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.
14 # We want to turn on warnings if we are using gcc and the user did
15 # not specify CFLAGS. The autoconf check for the C compiler sets the
16 # CFLAGS if gcc is used, so we will save it before we run that check.
19 # Now find our C compiler.
22 # Suppress warnings about --datarootdir
23 AC_DEFUN([AC_DATAROOTDIR_CHECKED])
25 # If we have gcc, and AC_PROG_CC changed the flags, then we know the
26 # user did not specify any flags. Add warnings in this case.
27 if test "$GCC" = "yes"; then
28 if test "$CFLAGS" != "$SAVE_CFLAGS"; then
29 STD_CWARNINGS="$STD_CWARNINGS -Wall -Werror -fno-strict-aliasing"
33 # POSIX doesn't include the IPv6 Advanced Socket API and glibc hides
34 # parts of the IPv6 Advanced Socket API as a result. This is stupid
35 # as it breaks how the two halves (Basic and Advanced) of the IPv6
36 # Socket API were designed to be used but we have to live with it.
37 # Use this to define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
38 AC_USE_SYSTEM_EXTENSIONS
41 AC_CONFIG_HEADERS([includes/config.h])
43 # we sometimes need to know byte order for building packets
44 AC_C_BIGENDIAN(AC_SUBST(byte_order, BIG_ENDIAN),
45 AC_SUBST(byte_order, LITTLE_ENDIAN))
46 AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
47 [Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs)
48 or LITTLE_ENDIAN for LSB (Intel CPUs).])
50 # Optional compile-time DEBUGging.
52 AC_HELP_STRING([--enable-debug],
53 [create a debug-only version of the software (default is no).]))
54 # This is very much off by default.
55 if test "$enable_debug" = "yes" ; then
56 AC_DEFINE([DEBUG], [1],
57 [Define to compile debug-only DHCP software.])
58 # Just override CFLAGS to totally to remove optimization.
61 # XXX: there are actually quite a lot more DEBUG_ features we could enable,
62 # but I don't want to pollute the --help space.
64 #/* #define DEBUG_TOKENS */
65 #/* #define DEBUG_PACKET */
66 #/* #define DEBUG_EXPRESSIONS */
67 #/* #define DEBUG_FIND_LEASE */
68 #/* #define DEBUG_EXPRESSION_PARSE */
69 #/* #define DEBUG_CLASS_MATCHING */
70 #/* #define DEBUG_MEMORY_LEAKAGE */
71 #/* #define DEBUG_MALLOC_POOL */
72 #/* #define DEBUG_LEASE_STATE_TRANSITIONS */
73 #/* #define DEBUG_RC_HISTORY */
74 #/* #define DEBUG_RC_HISTORY_EXHAUSTIVELY */
75 #/* #define RC_HISTORY_MAX 10240 */
76 #/* #define POINTER_DEBUG */
77 #/* #define DEBUG_FAILOVER_MESSAGES */
78 #/* #define DEBUG_FAILOVER_TIMING */
79 #/* #define DEBUG_DUMP_ALL_LEASES */
81 # Failover optional compile-time feature.
82 AC_ARG_ENABLE(failover,
83 AC_HELP_STRING([--enable-failover],
84 [enable support for failover (default is yes)]))
85 # Failover is on by default, so define if it is not explicitly disabled.
86 if test "$enable_failover" != "no"; then
87 AC_DEFINE([FAILOVER_PROTOCOL], [1],
88 [Define to include Failover Protocol support.])
92 AC_ARG_ENABLE(execute,
93 AC_HELP_STRING([--enable-execute],
94 [enable support for execute() in config (default is yes)]))
95 # execute() is on by default, so define if it is not explicitly disabled.
96 if test "$enable_execute" != "no" ; then
97 AC_DEFINE([ENABLE_EXECUTE], [1],
98 [Define to include execute() config language support.])
101 # Server tracing support.
102 AC_ARG_ENABLE(tracing,
103 AC_HELP_STRING([--enable-tracing],
104 [enable support for server activity tracing (default is yes)]))
105 # tracing is on by default, so define if it is not explicitly disabled.
106 if test "$enable_tracing" != "no" ; then
107 AC_DEFINE([TRACING], [1],
108 [Define to include server activity tracing support.])
111 # Delayed-ack feature support (experimental).
112 AC_ARG_ENABLE(delayed_ack,
113 AC_HELP_STRING([--enable-delayed-ack],
114 [queues multiple DHCPACK replies (default is no)]))
115 if test "$enable_delayed_ack" = "yes"; then
116 AC_DEFINE([DELAYED_ACK], [1],
117 [Define to queue multiple DHCPACK replies per fsync.])
120 # DHCPv6 optional compile-time feature.
121 AC_ARG_ENABLE(dhcpv6,
122 AC_HELP_STRING([--enable-dhcpv6],
123 [enable support for DHCPv6 (default is yes)]))
124 # DHCPv6 is on by default, so define if it is not explicitly disabled.
125 if test "$enable_dhcpv6" != "no"; then
126 AC_DEFINE([DHCPv6], [1],
127 [Define to 1 to include DHCPv6 support.])
130 # PARANOIA is off by default (until we can test it with all features)
131 AC_ARG_ENABLE(paranoia,
132 AC_HELP_STRING([--enable-paranoia],
133 [enable support for chroot/setuid (default is no)]))
134 AC_ARG_ENABLE(early_chroot,
135 AC_HELP_STRING([--enable-early-chroot],
136 [enable chrooting prior to configuration (default is no)]))
137 # If someone enables early chroot, but does not enable paranoia, do so for
139 if test "$enable_paranoia" != "yes" && \
140 test "$enable_early_chroot" = "yes" ; then
141 enable_paranoia="yes"
144 if test "$enable_paranoia" = "yes" ; then
145 AC_DEFINE([PARANOIA], [1],
146 [Define to any value to include Ari's PARANOIA patch.])
148 if test "$enable_early_chroot" = "yes" ; then
149 AC_DEFINE([EARLY_CHROOT], [1],
150 [Define to any value to chroot() prior to loading config.])
153 AC_ARG_ENABLE(ipv4_pktinfo,
154 AC_HELP_STRING([--enable-ipv4-pktinfo],
155 [enable use of pktinfo on IPv4 sockets (default is no)]))
157 if test "$enable_ipv4_pktinfo" = "yes"; then
158 AC_DEFINE([USE_V4_PKTINFO], [1],
159 [Define to 1 to enable IPv4 packet info support.])
162 AC_ARG_ENABLE(use_sockets,
163 AC_HELP_STRING([--enable-use-sockets],
164 [use the standard BSD socket API (default is no)]))
166 if test "$enable_use_sockets" = "yes"; then
167 AC_DEFINE([USE_SOCKETS], [1],
168 [Define to 1 to use the standard BSD socket API.])
172 ### Path fun. Older versions of DHCP were installed in /usr/sbin, so we
173 ### need to look there and potentially overwrite by default (but not if
174 ### the user configures an alternate value). LOCALSTATEDIR is totally
175 ### braindead. No one uses /usr/local/var/db/ nor /usr/local/var/run, and
176 ### they would be insane for suggesting it. We need to look in /var/for
177 ### 'db' and 'state/dhcp' for db files, and /var/run for pid files by
180 AC_PREFIX_PROGRAM(dhcpd)
182 # XXX - isn't there SOME WAY to default autoconf to /var instead of
183 # /usr/local/var/no/one/has/this/please/stop/trying?
184 case "$localstatedir" in
190 # Allow specification of alternate state files
191 AC_ARG_WITH(srv-lease-file,
192 AC_HELP_STRING([--with-srv-lease-file=PATH],
193 [File for dhcpd leases
194 (default is LOCALSTATEDIR/db/dhcpd.leases)]),
195 AC_DEFINE_UNQUOTED([_PATH_DHCPD_DB], ["$withval"],
196 [File for dhcpd leases.]))
198 echo -n "checking for dhcpd.leases location..."
199 if [[ "x$with_srv_lease_file" = "x" ]] ; then
200 if [[ -d "${localstatedir}/db" ]] ; then
201 with_srv_lease_file="${localstatedir}/db/dhcpd.leases"
202 elif [[ -d "${localstatedir}/state" ]] ; then
203 if [[ -d "${localstatedir}/state/dhcp" ]] ; then
204 with_srv_lease_file="${localstatedir}/state/dhcp/dhcpd.leases"
206 with_srv_lease_file="${localstatedir}/state/dhcpd.leases"
208 elif [[ -d "${localstatedir}/lib" ]] ; then
209 if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
210 with_srv_lease_file="${localstatedir}/lib/dhcp/dhcpd.leases"
212 with_srv_lease_file="${localstatedir}/lib/dhcpd.leases"
214 elif [[ -d "${localstatedir}/etc" ]] ; then
215 with_srv_lease_file="${localstatedir}/etc/dhcpd.leases"
217 with_srv_lease_file="/etc/dhcpd.leases"
220 echo "$with_srv_lease_file"
222 AC_ARG_WITH(srv6-lease-file,
223 AC_HELP_STRING([--with-srv6-lease-file=PATH],
224 [File for dhcpd6 leases
225 (default is LOCALSTATEDIR/db/dhcpd6.leases)]),
226 AC_DEFINE_UNQUOTED([_PATH_DHCPD6_DB], ["$withval"],
227 [File for dhcpd6 leases.]))
229 echo -n "checking for dhcpd6.leases location..."
230 if [[ "x$with_srv6_lease_file" = "x" ]] ; then
231 if [[ -d "${localstatedir}/db" ]] ; then
232 with_srv6_lease_file="${localstatedir}/db/dhcpd6.leases"
233 elif [[ -d "${localstatedir}/state" ]] ; then
234 if [[ -d "${localstatedir}/state/dhcp" ]] ; then
235 with_srv6_lease_file="${localstatedir}/state/dhcp/dhcpd6.leases"
237 with_srv6_lease_file="${localstatedir}/state/dhcpd6.leases"
239 elif [[ -d "${localstatedir}/lib" ]] ; then
240 if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
241 with_srv6_lease_file="${localstatedir}/lib/dhcp/dhcpd6.leases"
243 with_srv6_lease_file="${localstatedir}/lib/dhcpd6.leases"
245 elif [[ -d "${localstatedir}/etc" ]] ; then
246 with_srv6_lease_file="${localstatedir}/etc/dhcpd6.leases"
248 with_srv6_lease_file="/etc/dhcpd6.leases"
251 echo "$with_srv6_lease_file"
253 AC_ARG_WITH(cli-lease-file,
254 AC_HELP_STRING([--with-cli-lease-file=PATH],
255 [File for dhclient leases
256 (default is LOCALSTATEDIR/db/dhclient.leases)]),
257 AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_DB], ["$withval"],
258 [File for dhclient leases.]))
260 echo -n "checking for dhclient.leases location..."
261 if [[ "x$with_cli_lease_file" = "x" ]] ; then
262 if [[ -d "${localstatedir}/db" ]] ; then
263 with_cli_lease_file="${localstatedir}/db/dhclient.leases"
264 elif [[ -d "${localstatedir}/state" ]] ; then
265 if [[ -d "${localstatedir}/state/dhcp" ]] ; then
266 with_cli_lease_file="${localstatedir}/state/dhcp/dhclient.leases"
268 with_cli_lease_file="${localstatedir}/state/dhclient.leases"
270 elif [[ -d "${localstatedir}/lib" ]] ; then
271 if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
272 with_cli_lease_file="${localstatedir}/lib/dhcp/dhclient.leases"
274 with_cli_lease_file="${localstatedir}/lib/dhclient.leases"
276 elif [[ -d "${localstatedir}/etc" ]] ; then
277 with_cli_lease_file="${localstatedir}/etc/dhclient.leases"
279 with_cli_lease_file="/etc/dhclient.leases"
282 echo "$with_cli_lease_file"
284 AC_ARG_WITH(cli6-lease-file,
285 AC_HELP_STRING([--with-cli6-lease-file=PATH],
286 [File for dhclient6 leases
287 (default is LOCALSTATEDIR/db/dhclient6.leases)]),
288 AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_DB], ["$withval"],
289 [File for dhclient6 leases.]))
291 echo -n "checking for dhclient6.leases location..."
292 if [[ "x$with_cli6_lease_file" = "x" ]] ; then
293 if [[ -d "${localstatedir}/db" ]] ; then
294 with_cli6_lease_file="${localstatedir}/db/dhclient6.leases"
295 elif [[ -d "${localstatedir}/state" ]] ; then
296 if [[ -d "${localstatedir}/state/dhcp" ]] ; then
297 with_cli6_lease_file="${localstatedir}/state/dhcp/dhclient6.leases"
299 with_cli6_lease_file="${localstatedir}/state/dhclient6.leases"
301 elif [[ -d "${localstatedir}/lib" ]] ; then
302 if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
303 with_cli6_lease_file="${localstatedir}/lib/dhcp/dhclient6.leases"
305 with_cli6_lease_file="${localstatedir}/lib/dhclient6.leases"
307 elif [[ -d "${localstatedir}/etc" ]] ; then
308 with_cli6_lease_file="${localstatedir}/etc/dhclient6.leases"
310 with_cli6_lease_file="/etc/dhclient6.leases"
313 echo "$with_cli6_lease_file"
315 AC_ARG_WITH(srv-pid-file,
316 AC_HELP_STRING([--with-srv-pid-file=PATH],
317 [File for dhcpd process information
318 (default is LOCALSTATEDIR/run/dhcpd.pid)]),
319 AC_DEFINE_UNQUOTED([_PATH_DHCPD_PID], ["$withval"],
320 [File for dhcpd process information.]))
321 AC_ARG_WITH(srv6-pid-file,
322 AC_HELP_STRING([--with-srv6-pid-file=PATH],
323 [File for dhcpd6 process information
324 (default is LOCALSTATEDIR/run/dhcpd6.pid)]),
325 AC_DEFINE_UNQUOTED([_PATH_DHCPD6_PID], ["$withval"],
326 [File for dhcpd6 process information.]))
327 AC_ARG_WITH(cli-pid-file,
328 AC_HELP_STRING([--with-cli-pid-file=PATH],
329 [File for dhclient process information
330 (default is LOCALSTATEDIR/run/dhclient.pid)]),
331 AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_PID], ["$withval"],
332 [File for dhclient process information.]))
333 AC_ARG_WITH(cli6-pid-file,
334 AC_HELP_STRING([--with-cli6-pid-file=PATH],
335 [File for dhclient6 process information
336 (default is LOCALSTATEDIR/run/dhclient6.pid)]),
337 AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_PID], ["$withval"],
338 [File for dhclient6 process information.]))
339 AC_ARG_WITH(relay-pid-file,
340 AC_HELP_STRING([--with-relay-pid-file=PATH],
341 [File for dhcrelay process information
342 (default is LOCALSTATEDIR/run/dhcrelay.pid)]),
343 AC_DEFINE_UNQUOTED([_PATH_DHCRELAY_PID], ["$withval"],
344 [File for dhcrelay process information.]))
345 AC_ARG_WITH(relay6-pid-file,
346 AC_HELP_STRING([--with-relay6-pid-file=PATH],
347 [File for dhcrelay6 process information
348 (default is LOCALSTATEDIR/run/dhcrelay6.pid)]),
349 AC_DEFINE_UNQUOTED([_PATH_DHCRELAY6_PID], ["$withval"],
350 [File for dhcrelay6 process information.]))
358 # Some systems need the u_intX_t types defined across.
359 AC_CHECK_TYPE([u_int8_t], [], [
361 AC_DEFINE(u_int8_t, [uint8_t], [Define a type for 8-bit unsigned
364 AC_CHECK_TYPE([u_int16_t], [], [
366 AC_DEFINE(u_int16_t, [uint16_t], [Define a type for 16-bit unsigned
369 AC_CHECK_TYPE([u_int32_t], [], [
371 AC_DEFINE(u_int32_t, [uint32_t], [Define a type for 32-bit unsigned
374 AC_CHECK_TYPE([u_int64_t], [], [
376 AC_DEFINE(u_int64_t, [uint64_t], [Define a type for 64-bit unsigned
380 # see if ifaddrs.h is available
381 AC_CHECK_HEADERS(ifaddrs.h)
383 # figure out what IPv4 interface code to use
384 AC_CHECK_HEADERS(linux/types.h) # needed for linux/filter.h on old systems
386 AC_CHECK_HEADER(linux/filter.h, DO_LPF=1, ,
388 #ifdef HAVE_LINUX_TYPES_H
389 #include <linux/types.h>
394 AC_DEFINE([HAVE_LPF], [1],
395 [Define to 1 to use the Linux Packet Filter interface code.])
397 AC_CHECK_HEADER(sys/dlpi.h, DO_DLPI=1)
398 if test -n "$DO_DLPI"
400 AC_DEFINE([HAVE_DLPI], [1],
401 [Define to 1 to use DLPI interface code.])
403 AC_CHECK_HEADER(net/bpf.h, DO_BPF=1)
406 AC_DEFINE([HAVE_BPF], [1],
407 [Define to 1 to use the
408 Berkeley Packet Filter interface code.])
413 # SIOCGLIFCONF uses some transport structures. Trick is not all platforms
414 # use the same structures. We like to use 'struct lifconf' and 'struct
415 # lifreq', but we'll use these other structures if they're present. HPUX
416 # does not define 'struct lifnum', but does use SIOCGLIFNUM - they use an
419 AC_MSG_CHECKING([for struct lifnum])
421 [ #include <sys/types.h>
422 #include <sys/socket.h>
428 AC_DEFINE([ISC_PLATFORM_HAVELIFNUM], [1],
429 [Define to 1 if the system has 'struct lifnum'.])],
432 AC_MSG_CHECKING([for struct if_laddrconf])
434 [ #include <sys/types.h>
437 [ struct if_laddrconf a;
440 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRCONF], [1],
441 [Define to 1 if the system has 'struct if_laddrconf'.])],
444 AC_MSG_CHECKING([for struct if_laddrreq])
446 [#include <sys/types.h>
449 [ struct if_laddrreq a;
452 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRREQ], [1],
453 [Define to 1 if the system has 'struct if_laddrreq'.])],
456 # Look for optional headers.
457 AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
459 # Solaris needs some libraries for functions
460 AC_SEARCH_LIBS(socket, [socket])
461 AC_SEARCH_LIBS(inet_ntoa, [nsl])
463 AC_SEARCH_LIBS(inet_aton, [socket nsl], ,
464 AC_DEFINE([NEED_INET_ATON], [1],
465 [Define to 1 if the inet_aton() function is missing.]))
467 # Check for a standalone regex library.
468 AC_SEARCH_LIBS(regcomp, [regex])
470 # For HP/UX we need -lipv6 for if_nametoindex, perhaps others.
471 AC_SEARCH_LIBS(if_nametoindex, [ipv6])
473 # check for /dev/random (declares HAVE_DEV_RANDOM)
474 AC_CHECK_FILE(/dev/random,
475 AC_DEFINE([HAVE_DEV_RANDOM], [1],
476 [Define to 1 if you have the /dev/random file.]))
478 # see if there is a "sa_len" field in our interface information structure
479 AC_CHECK_MEMBER(struct sockaddr.sa_len,
480 AC_DEFINE([HAVE_SA_LEN], [],
481 [Define to 1 if the sockaddr structure has a length field.]),
483 [#include <sys/socket.h>])
485 # figure out pointer size
486 AC_CHECK_SIZEOF(struct iaddr *, , [
487 #include "includes/inet.h"
491 # Solaris does not have the msg_control or msg_controlen members in
492 # in the msghdr structure unless you define:
494 # _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, and __EXTENSIONS__
496 # See the "standards" man page for details.
498 # We check for the msg_control member, and if it is not found, we check
499 # again with the appropriate defines added to the CFLAGS. (In order to
500 # do this we have to remove the check from the cache, which is what the
502 AC_CHECK_MEMBER(struct msghdr.msg_control,,
503 [CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
504 CFLAGS="$CFLAGS -D__EXTENSIONS__"
505 unset ac_cv_member_struct_msghdr_msg_control
506 AC_CHECK_MEMBER(struct msghdr.msg_control,,
507 [AC_MSG_ERROR([Missing msg_control member in
508 msg_control structure.])],
510 #include <sys/types.h>
511 #include <sys/socket.h>
515 #include <sys/types.h>
516 #include <sys/socket.h>
521 AC_HELP_STRING([--with-libbind=PATH],
522 [bind includes and libraries are in PATH
523 (default is ./bind)]),
524 use_libbind="$withval", use_libbind="no")
525 case "$use_libbind" in
527 libbind="\${top_srcdir}/bind"
530 libbind="\${top_srcdir}/bind"
533 libbind="$use_libbind"
539 AC_HELP_STRING([--with-ldap],
540 [enable OpenLDAP support in dhcpd (default is no)]),
544 # OpenLDAP with SSL support.
545 AC_ARG_WITH(ldapcrypto,
546 AC_HELP_STRING([--with-ldapcrypto],
547 [enable OpenLDAP crypto support in dhcpd (default is no)]),
548 [ldapcrypto=$withval],
551 # OpenLDAP support is disabled by default, if enabled then SSL support is an
552 # extra optional that is also disabled by default. Enabling LDAP SSL support
553 # implies enabling LDAP support.
554 if test x$ldap = xyes || test x$ldapcrypto = xyes ; then
555 AC_SEARCH_LIBS(ldap_initialize, [ldap], ,
556 AC_MSG_FAILURE([*** Cannot find ldap_initialize with -lldap - do you need to install an OpenLDAP2 Devel package?]))
557 AC_SEARCH_LIBS(ber_pvt_opt_on, [lber], ,
558 AC_MSG_FAILURE([*** Cannot find ber_pvt_opt_on with -llber - do you need to install an OpenLDAP2 Devel package?]))
560 if test x$ldapcrypto = xyes ; then
561 AC_SUBST(LDAP_CFLAGS, ["-DLDAP_CONFIGURATION -DLDAP_USE_SSL"])
563 AC_SUBST(LDAP_CFLAGS, ["-DLDAP_CONFIGURATION"])
567 # Append selected warning levels to CFLAGS before substitution (but after
568 # AC_TRY_COMPILE & etc).
569 CFLAGS="$CFLAGS $STD_CWARNINGS"
571 # Try to add the bind include directory
572 CFLAGS="$CFLAGS -I$libbind/include"
574 AC_C_FLEXIBLE_ARRAY_MEMBER
580 common/tests/Makefile