]> git.ipfire.org Git - thirdparty/dhcp.git/blame - configure.ac
Remove infinite loop in token_print_indent_concat().
[thirdparty/dhcp.git] / configure.ac
CommitLineData
05ae2d15 1AC_INIT([DHCP], [4.2.0], [dhcp-users@isc.org])
fe5b0fdd
DH
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
06eb8bab
SK
7# We want to turn on warnings if we are using gcc and the user did
8# not specify CFLAGS. The autoconf check for the C compiler sets the
9# CFLAGS if gcc is used, so we will save it before we run that check.
10SAVE_CFLAGS="$CFLAGS"
11
12# Now find our C compiler.
fe5b0fdd 13AC_PROG_CC
06eb8bab 14
159c89d7
EH
15# Suppress warnings about --datarootdir
16AC_DEFUN([AC_DATAROOTDIR_CHECKED])
17
06eb8bab
SK
18# If we have gcc, and AC_PROG_CC changed the flags, then we know the
19# user did not specify any flags. Add warnings in this case.
20if test "$GCC" = "yes"; then
21 if test "$CFLAGS" != "$SAVE_CFLAGS"; then
eaf7eb17 22 STD_CWARNINGS="$STD_CWARNINGS -Wall -Werror -fno-strict-aliasing"
06eb8bab
SK
23 fi
24fi
25
ae566556
SR
26# POSIX doesn't include the IPv6 Advanced Socket API and glibc hides
27# parts of the IPv6 Advanced Socket API as a result. This is stupid
28# as it breaks how the two halves (Basic and Advanced) of the IPv6
29# Socket API were designed to be used but we have to live with it.
30# Use this to define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
31AC_USE_SYSTEM_EXTENSIONS
32
fe5b0fdd
DH
33AC_PROG_RANLIB
34AC_CONFIG_HEADERS([includes/config.h])
35
36# we sometimes need to know byte order for building packets
37AC_C_BIGENDIAN(AC_SUBST(byte_order, BIG_ENDIAN),
38 AC_SUBST(byte_order, LITTLE_ENDIAN))
39AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
40 [Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs)
41 or LITTLE_ENDIAN for LSB (Intel CPUs).])
42
66cebfcb
DH
43# Optional compile-time DEBUGging.
44AC_ARG_ENABLE(debug,
45 AC_HELP_STRING([--enable-debug],
46 [create a debug-only version of the software (default is no).]))
47# This is very much off by default.
48if test "$enable_debug" = "yes" ; then
49 AC_DEFINE([DEBUG], [1],
50 [Define to compile debug-only DHCP software.])
51 # Just override CFLAGS to totally to remove optimization.
52 CFLAGS="-g"
53fi
54# XXX: there are actually quite a lot more DEBUG_ features we could enable,
55# but I don't want to pollute the --help space.
56#
57#/* #define DEBUG_TOKENS */
58#/* #define DEBUG_PACKET */
59#/* #define DEBUG_EXPRESSIONS */
60#/* #define DEBUG_FIND_LEASE */
61#/* #define DEBUG_EXPRESSION_PARSE */
62#/* #define DEBUG_CLASS_MATCHING */
63#/* #define DEBUG_MEMORY_LEAKAGE */
64#/* #define DEBUG_MALLOC_POOL */
65#/* #define DEBUG_LEASE_STATE_TRANSITIONS */
66#/* #define DEBUG_RC_HISTORY */
67#/* #define DEBUG_RC_HISTORY_EXHAUSTIVELY */
68#/* #define RC_HISTORY_MAX 10240 */
69#/* #define POINTER_DEBUG */
70#/* #define DEBUG_FAILOVER_MESSAGES */
71#/* #define DEBUG_FAILOVER_TIMING */
72#/* #define DEBUG_DUMP_ALL_LEASES */
73
74# Failover optional compile-time feature.
75AC_ARG_ENABLE(failover,
76 AC_HELP_STRING([--enable-failover],
77 [enable support for failover (default is yes)]))
78# Failover is on by default, so define if it is not explicitly disabled.
79if test "$enable_failover" != "no"; then
80 AC_DEFINE([FAILOVER_PROTOCOL], [1],
81 [Define to include Failover Protocol support.])
82fi
83
84# execute() support.
85AC_ARG_ENABLE(execute,
86 AC_HELP_STRING([--enable-execute],
87 [enable support for execute() in config (default is yes)]))
88# execute() is on by default, so define if it is not explicitly disabled.
89if test "$enable_execute" != "no" ; then
90 AC_DEFINE([ENABLE_EXECUTE], [1],
91 [Define to include execute() config language support.])
92fi
93
94# Server tracing support.
95AC_ARG_ENABLE(tracing,
96 AC_HELP_STRING([--enable-tracing],
97 [enable support for server activity tracing (default is yes)]))
98# tracing is on by default, so define if it is not explicitly disabled.
99if test "$enable_tracing" != "no" ; then
100 AC_DEFINE([TRACING], [1],
101 [Define to include server activity tracing support.])
102fi
103
fbcee149
DH
104# Delayed-ack feature support (experimental).
105AC_ARG_ENABLE(delayed_ack,
106 AC_HELP_STRING([--enable-delayed-ack],
107 [queues multiple DHCPACK replies (default is no)]))
108if test "$enable_delayed_ack" = "yes"; then
109 AC_DEFINE([DELAYED_ACK], [1],
110 [Define to queue multiple DHCPACK replies per fsync.])
111fi
112
66cebfcb 113# DHCPv6 optional compile-time feature.
fe5b0fdd
DH
114AC_ARG_ENABLE(dhcpv6,
115 AC_HELP_STRING([--enable-dhcpv6],
d00d373a 116 [enable support for DHCPv6 (default is yes)]))
66cebfcb 117# DHCPv6 is on by default, so define if it is not explicitly disabled.
d00d373a 118if test "$enable_dhcpv6" != "no"; then
fe5b0fdd 119 AC_DEFINE([DHCPv6], [1],
d00d373a
SK
120 [Define to 1 to include DHCPv6 support.])
121fi
fe5b0fdd 122
63971a83
DH
123# PARANOIA is off by default (until we can test it with all features)
124AC_ARG_ENABLE(paranoia,
125 AC_HELP_STRING([--enable-paranoia],
126 [enable support for chroot/setuid (default is no)]))
127AC_ARG_ENABLE(early_chroot,
26ef247f 128 AC_HELP_STRING([--enable-early-chroot],
63971a83
DH
129 [enable chrooting prior to configuration (default is no)]))
130# If someone enables early chroot, but does not enable paranoia, do so for
131# them.
132if test "$enable_paranoia" != "yes" && \
133 test "$enable_early_chroot" = "yes" ; then
134 enable_paranoia="yes"
135fi
136
137if test "$enable_paranoia" = "yes" ; then
138 AC_DEFINE([PARANOIA], [1],
139 [Define to any value to include Ari's PARANOIA patch.])
140fi
141if test "$enable_early_chroot" = "yes" ; then
142 AC_DEFINE([EARLY_CHROOT], [1],
143 [Define to any value to chroot() prior to loading config.])
144fi
145
f8b3c6f4
DH
146###
147### Path fun. Older versions of DHCP were installed in /usr/sbin, so we
148### need to look there and potentially overwrite by default (but not if
149### the user configures an alternate value). LOCALSTATEDIR is totally
150### braindead. No one uses /usr/local/var/db/ nor /usr/local/var/run, and
151### they would be insane for suggesting it. We need to look in /var/for
152### 'db' and 'state/dhcp' for db files, and /var/run for pid files by
153### default.
154###
155AC_PREFIX_PROGRAM(dhcpd)
156
157# XXX - isn't there SOME WAY to default autoconf to /var instead of
158# /usr/local/var/no/one/has/this/please/stop/trying?
159case "$localstatedir" in
160 '${prefix}/var')
161 localstatedir=/var
162 ;;
163esac
164
fe5b0fdd
DH
165# Allow specification of alternate state files
166AC_ARG_WITH(srv-lease-file,
167 AC_HELP_STRING([--with-srv-lease-file=PATH],
168 [File for dhcpd leases
169 (default is LOCALSTATEDIR/db/dhcpd.leases)]),
170 AC_DEFINE_UNQUOTED([_PATH_DHCPD_DB], ["$withval"],
171 [File for dhcpd leases.]))
f8b3c6f4
DH
172
173echo -n "checking for dhcpd.leases location..."
174if [[ "x$with_srv_lease_file" = "x" ]] ; then
175 if [[ -d "${localstatedir}/db" ]] ; then
176 with_srv_lease_file="${localstatedir}/db/dhcpd.leases"
177 elif [[ -d "${localstatedir}/state" ]] ; then
178 if [[ -d "${localstatedir}/state/dhcp" ]] ; then
179 with_srv_lease_file="${localstatedir}/state/dhcp/dhcpd.leases"
180 else
181 with_srv_lease_file="${localstatedir}/state/dhcpd.leases"
182 fi
183 elif [[ -d "${localstatedir}/lib" ]] ; then
184 if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
185 with_srv_lease_file="${localstatedir}/lib/dhcp/dhcpd.leases"
186 else
187 with_srv_lease_file="${localstatedir}/lib/dhcpd.leases"
188 fi
189 elif [[ -d "${localstatedir}/etc" ]] ; then
190 with_srv_lease_file="${localstatedir}/etc/dhcpd.leases"
191 else
192 with_srv_lease_file="/etc/dhcpd.leases"
193 fi
194fi
195echo "$with_srv_lease_file"
196
8dea7ba7
FD
197AC_ARG_WITH(srv6-lease-file,
198 AC_HELP_STRING([--with-srv6-lease-file=PATH],
199 [File for dhcpd6 leases
200 (default is LOCALSTATEDIR/db/dhcpd6.leases)]),
201 AC_DEFINE_UNQUOTED([_PATH_DHCPD6_DB], ["$withval"],
202 [File for dhcpd6 leases.]))
203
204echo -n "checking for dhcpd6.leases location..."
205if [[ "x$with_srv6_lease_file" = "x" ]] ; then
206 if [[ -d "${localstatedir}/db" ]] ; then
207 with_srv6_lease_file="${localstatedir}/db/dhcpd6.leases"
208 elif [[ -d "${localstatedir}/state" ]] ; then
209 if [[ -d "${localstatedir}/state/dhcp" ]] ; then
210 with_srv6_lease_file="${localstatedir}/state/dhcp/dhcpd6.leases"
211 else
212 with_srv6_lease_file="${localstatedir}/state/dhcpd6.leases"
213 fi
214 elif [[ -d "${localstatedir}/lib" ]] ; then
215 if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
216 with_srv6_lease_file="${localstatedir}/lib/dhcp/dhcpd6.leases"
217 else
218 with_srv6_lease_file="${localstatedir}/lib/dhcpd6.leases"
219 fi
220 elif [[ -d "${localstatedir}/etc" ]] ; then
221 with_srv6_lease_file="${localstatedir}/etc/dhcpd6.leases"
222 else
223 with_srv6_lease_file="/etc/dhcpd6.leases"
224 fi
225fi
226echo "$with_srv6_lease_file"
227
fe5b0fdd
DH
228AC_ARG_WITH(cli-lease-file,
229 AC_HELP_STRING([--with-cli-lease-file=PATH],
230 [File for dhclient leases
231 (default is LOCALSTATEDIR/db/dhclient.leases)]),
232 AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_DB], ["$withval"],
233 [File for dhclient leases.]))
f8b3c6f4
DH
234
235echo -n "checking for dhclient.leases location..."
236if [[ "x$with_cli_lease_file" = "x" ]] ; then
237 if [[ -d "${localstatedir}/db" ]] ; then
238 with_cli_lease_file="${localstatedir}/db/dhclient.leases"
239 elif [[ -d "${localstatedir}/state" ]] ; then
240 if [[ -d "${localstatedir}/state/dhcp" ]] ; then
241 with_cli_lease_file="${localstatedir}/state/dhcp/dhclient.leases"
242 else
243 with_cli_lease_file="${localstatedir}/state/dhclient.leases"
244 fi
245 elif [[ -d "${localstatedir}/lib" ]] ; then
246 if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
247 with_cli_lease_file="${localstatedir}/lib/dhcp/dhclient.leases"
248 else
249 with_cli_lease_file="${localstatedir}/lib/dhclient.leases"
250 fi
251 elif [[ -d "${localstatedir}/etc" ]] ; then
252 with_cli_lease_file="${localstatedir}/etc/dhclient.leases"
253 else
254 with_cli_lease_file="/etc/dhclient.leases"
255 fi
256fi
257echo "$with_cli_lease_file"
258
8dea7ba7
FD
259AC_ARG_WITH(cli6-lease-file,
260 AC_HELP_STRING([--with-cli6-lease-file=PATH],
261 [File for dhclient6 leases
262 (default is LOCALSTATEDIR/db/dhclient6.leases)]),
263 AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_DB], ["$withval"],
264 [File for dhclient6 leases.]))
265
266echo -n "checking for dhclient6.leases location..."
267if [[ "x$with_cli6_lease_file" = "x" ]] ; then
268 if [[ -d "${localstatedir}/db" ]] ; then
269 with_cli6_lease_file="${localstatedir}/db/dhclient6.leases"
270 elif [[ -d "${localstatedir}/state" ]] ; then
271 if [[ -d "${localstatedir}/state/dhcp" ]] ; then
272 with_cli6_lease_file="${localstatedir}/state/dhcp/dhclient6.leases"
273 else
274 with_cli6_lease_file="${localstatedir}/state/dhclient6.leases"
275 fi
276 elif [[ -d "${localstatedir}/lib" ]] ; then
277 if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
278 with_cli6_lease_file="${localstatedir}/lib/dhcp/dhclient6.leases"
279 else
280 with_cli6_lease_file="${localstatedir}/lib/dhclient6.leases"
281 fi
282 elif [[ -d "${localstatedir}/etc" ]] ; then
283 with_cli6_lease_file="${localstatedir}/etc/dhclient6.leases"
284 else
285 with_cli6_lease_file="/etc/dhclient6.leases"
286 fi
287fi
288echo "$with_cli6_lease_file"
289
fe5b0fdd
DH
290AC_ARG_WITH(srv-pid-file,
291 AC_HELP_STRING([--with-srv-pid-file=PATH],
292 [File for dhcpd process information
293 (default is LOCALSTATEDIR/run/dhcpd.pid)]),
294 AC_DEFINE_UNQUOTED([_PATH_DHCPD_PID], ["$withval"],
295 [File for dhcpd process information.]))
8dea7ba7
FD
296AC_ARG_WITH(srv6-pid-file,
297 AC_HELP_STRING([--with-srv6-pid-file=PATH],
298 [File for dhcpd6 process information
299 (default is LOCALSTATEDIR/run/dhcpd6.pid)]),
300 AC_DEFINE_UNQUOTED([_PATH_DHCPD6_PID], ["$withval"],
301 [File for dhcpd6 process information.]))
fe5b0fdd
DH
302AC_ARG_WITH(cli-pid-file,
303 AC_HELP_STRING([--with-cli-pid-file=PATH],
304 [File for dhclient process information
305 (default is LOCALSTATEDIR/run/dhclient.pid)]),
8dea7ba7 306 AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_PID], ["$withval"],
fe5b0fdd 307 [File for dhclient process information.]))
8dea7ba7
FD
308AC_ARG_WITH(cli6-pid-file,
309 AC_HELP_STRING([--with-cli6-pid-file=PATH],
310 [File for dhclient6 process information
311 (default is LOCALSTATEDIR/run/dhclient6.pid)]),
312 AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_PID], ["$withval"],
313 [File for dhclient6 process information.]))
fe5b0fdd
DH
314AC_ARG_WITH(relay-pid-file,
315 AC_HELP_STRING([--with-relay-pid-file=PATH],
316 [File for dhcrelay process information
317 (default is LOCALSTATEDIR/run/dhcrelay.pid)]),
318 AC_DEFINE_UNQUOTED([_PATH_DHCRELAY_PID], ["$withval"],
319 [File for dhcrelay process information.]))
320
b8c0eda0
MA
321# see if ifaddrs.h is available
322AC_CHECK_HEADERS(ifaddrs.h)
323
fe5b0fdd 324# figure out what IPv4 interface code to use
f125dc8b
SK
325AC_CHECK_HEADERS(linux/types.h) # needed for linux/filter.h on old systems
326
327AC_CHECK_HEADER(linux/filter.h, DO_LPF=1, ,
328[
329#ifdef HAVE_LINUX_TYPES_H
330#include <linux/types.h>
331#endif
332])
333if test -n "$DO_LPF"
334then
fe5b0fdd 335 AC_DEFINE([USE_LPF], [1],
f125dc8b
SK
336 [Define to 1 to use the Linux Packet Filter interface code.])
337else
338 AC_CHECK_HEADER(sys/dlpi.h, DO_DLPI=1)
339 if test -n "$DO_DLPI"
340 then
341 AC_DEFINE([USE_DLPI], [1],
342 [Define to 1 to use DLPI interface code.])
343 else
344 AC_CHECK_HEADER(net/bpf.h, DO_BPF=1)
345 if test -n "$DO_BPF"
346 then
347 AC_DEFINE([USE_BPF], [""],
348 [Define to 1 to use the
349 Berkeley Packet Filter interface code.])
350 fi
351 fi
352
353fi
fe5b0fdd 354
8da06bb1
DH
355# SIOCGLIFCONF uses some transport structures. Trick is not all platforms
356# use the same structures. We like to use 'struct lifconf' and 'struct
357# lifreq', but we'll use these other structures if they're present. HPUX
358# does not define 'struct lifnum', but does use SIOCGLIFNUM - they use an
359# int value.
360#
361AC_MSG_CHECKING([for struct lifnum])
362AC_TRY_COMPILE(
363[ #include <sys/types.h>
cff9b78f 364 #include <sys/socket.h>
8da06bb1
DH
365 #include <net/if.h>
366],
367[ struct lifnum a;
368],
369 [AC_MSG_RESULT(yes)
370 AC_DEFINE([ISC_PLATFORM_HAVELIFNUM], [1],
371 [Define to 1 if the system has 'struct lifnum'.])],
372 [AC_MSG_RESULT(no)])
373
374AC_MSG_CHECKING([for struct if_laddrconf])
375AC_TRY_COMPILE(
376[ #include <sys/types.h>
377 #include <net/if6.h>
378],
379[ struct if_laddrconf a;
380],
381 [AC_MSG_RESULT(yes)
382 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRCONF], [1],
383 [Define to 1 if the system has 'struct if_laddrconf'.])],
384 [AC_MSG_RESULT(no)])
385
386AC_MSG_CHECKING([for struct if_laddrreq])
387AC_TRY_LINK(
388[#include <sys/types.h>
389 #include <net/if6.h>
390],
391[ struct if_laddrreq a;
392],
393 [AC_MSG_RESULT(yes)
394 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRREQ], [1],
395 [Define to 1 if the system has 'struct if_laddrreq'.])],
396 [AC_MSG_RESULT(no)])
397
6dd7efa2 398# Look for optional headers.
cff9b78f 399AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
6dd7efa2 400
fe5b0fdd
DH
401# find an MD5 library
402AC_SEARCH_LIBS(MD5_Init, [crypto])
403AC_SEARCH_LIBS(MD5Init, [crypto])
404
405# Solaris needs some libraries for functions
406AC_SEARCH_LIBS(socket, [socket])
407AC_SEARCH_LIBS(inet_ntoa, [nsl])
408
409AC_SEARCH_LIBS(inet_aton, [socket nsl], ,
410 AC_DEFINE([NEED_INET_ATON], [1],
411 [Define to 1 if the inet_aton() function is missing.]))
412
dd328225
DH
413# Check for a standalone regex library.
414AC_SEARCH_LIBS(regcomp, [regex])
415
2394b26b
DH
416# For HP/UX we need -lipv6 for if_nametoindex, perhaps others.
417AC_SEARCH_LIBS(if_nametoindex, [ipv6])
418
fe5b0fdd
DH
419# check for /dev/random (declares HAVE_DEV_RANDOM)
420AC_CHECK_FILE(/dev/random,
421 AC_DEFINE([HAVE_DEV_RANDOM], [1],
422 [Define to 1 if you have the /dev/random file.]))
423
424# see if there is a "sa_len" field in our interface information structure
425AC_CHECK_MEMBER(struct sockaddr.sa_len,
426 AC_DEFINE([HAVE_SA_LEN], [],
427 [Define to 1 if the sockaddr structure has a length field.]),
428 ,
429 [#include <sys/socket.h>])
430
76c944da
SK
431# figure out pointer size
432AC_CHECK_SIZEOF(struct iaddr *, , [
433#include "includes/inet.h"
434#include <stdio.h>
435])
436
847e7000
SK
437# Solaris does not have the msg_control or msg_controlen members in
438# in the msghdr structure unless you define:
439#
440# _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, and __EXTENSIONS__
441#
442# See the "standards" man page for details.
443#
444# We check for the msg_control member, and if it is not found, we check
445# again with the appropriate defines added to the CFLAGS. (In order to
446# do this we have to remove the check from the cache, which is what the
447# "unset" is for.)
448AC_CHECK_MEMBER(struct msghdr.msg_control,,
449 [CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
450 CFLAGS="$CFLAGS -D__EXTENSIONS__"
451 unset ac_cv_member_struct_msghdr_msg_control
452 AC_CHECK_MEMBER(struct msghdr.msg_control,,
453 [AC_MSG_ERROR([Missing msg_control member in
454 msg_control structure.])],
06eb8bab
SK
455 [
456#include <sys/types.h>
457#include <sys/socket.h>
458 ])
459 ],
460 [
461#include <sys/types.h>
462#include <sys/socket.h>
463 ])
847e7000 464
eaf7eb17
DH
465# Append selected warning levels to CFLAGS before substitution (but after
466# AC_TRY_COMPILE & etc).
467CFLAGS="$CFLAGS $STD_CWARNINGS"
468
6ecda39c 469AC_OUTPUT([
fe5b0fdd
DH
470 Makefile
471 client/Makefile
472 common/Makefile
6e999c3c 473 common/tests/Makefile
fe5b0fdd
DH
474 dhcpctl/Makefile
475 dst/Makefile
476 includes/Makefile
477 minires/Makefile
478 omapip/Makefile
479 relay/Makefile
480 server/Makefile
6e999c3c 481 tests/Makefile
6ecda39c 482])
fe5b0fdd 483