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