configure.ac 29.9 KB
Newer Older
1
AC_INIT([DHCP],[4.3.4],[dhcp-users@isc.org])
2
3
4
5
6

# we specify "foreign" to avoid having to have the GNU mandated files,
# like AUTHORS, COPYING, and such
AM_INIT_AUTOMAKE([foreign])

7
8
9
10
11
# we specify AM_MAINTAINER_MODE to avoid problems with rebuilding
# the configure and makefiles.  Without it users doing things that
# change the timestamps on the code, like checking it into a cvs
# tree, could trigger a rebuild of the infrastructure files which
# might fail if they don't have the correct tools.
12
AM_MAINTAINER_MODE
13

14
15
AC_CANONICAL_HOST

16
# We want to turn on warnings if we are using gcc and the user did
17
18
19
20
21
# 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.
22
AC_PROG_CC
23

24
25
26
# Suppress warnings about --datarootdir
AC_DEFUN([AC_DATAROOTDIR_CHECKED])

27
28
29
30
# 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
31
		STD_CWARNINGS="$STD_CWARNINGS -Wall -Werror -fno-strict-aliasing"
32
33
34
	fi
fi

35
36
# We can have some flags to pass to bind configure
BINDCONFIG=
37
38
39
if test "$cross_compiling" = "yes"; then
	BINDCONFIG="--host=$host"
fi
40
AC_SUBST(BINDCONFIG)
41
AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = "yes")
42

43
44
45
46
47
48
49
# 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

50
AC_PROG_RANLIB
51
52
53
54

AC_PATH_PROG(AR, ar)
AC_SUBST(AR)

55
56
57
58
59
60
if test "X$AR" = "X"; then
	AC_MSG_ERROR([
ar program not found.  Please fix your PATH to include the directory in
which ar resides, or set AR in the environment with the full path to ar.])
fi

61
62
63
AC_CONFIG_HEADERS([includes/config.h])

# we sometimes need to know byte order for building packets
64
AC_C_BIGENDIAN(AC_SUBST(byte_order, BIG_ENDIAN),
65
	       AC_SUBST(byte_order, LITTLE_ENDIAN))
66
AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
67
68
69
		   [Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs)
		    or LITTLE_ENDIAN for LSB (Intel CPUs).])

70
71
# Optional compile-time DEBUGging.
AC_ARG_ENABLE(debug,
Shawn Routhier's avatar
Shawn Routhier committed
72
	AS_HELP_STRING([--enable-debug],[create a debug-only version of the software (default is no).]),
73
74
75
76
77
78
79
80
81
82
  [case "${enableval}" in
    yes) enable_debug=yes
        AC_DEFINE([DEBUG], [1],
            [Define to compile debug-only DHCP software.])
        # Just override CFLAGS totally to remove optimization.
        CFLAGS="-g";;
    no)  enable_debug=no ;;
    *)   AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
  esac],[enable_debug=no])

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# 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,
Shawn Routhier's avatar
Shawn Routhier committed
105
	AS_HELP_STRING([--enable-failover],[enable support for failover (default is yes)]))
106
107
# Failover is on by default, so define if it is not explicitly disabled.
if test "$enable_failover" != "no"; then
108
    enable_failover="yes"
109
110
111
112
113
114
	AC_DEFINE([FAILOVER_PROTOCOL], [1],
		  [Define to include Failover Protocol support.])
fi

# execute() support.
AC_ARG_ENABLE(execute,
Shawn Routhier's avatar
Shawn Routhier committed
115
	AS_HELP_STRING([--enable-execute],[enable support for execute() in config (default is yes)]))
116
117
# execute() is on by default, so define if it is not explicitly disabled.
if test "$enable_execute" != "no" ; then
118
    enable_execute="yes"
119
120
121
122
123
124
	AC_DEFINE([ENABLE_EXECUTE], [1],
		  [Define to include execute() config language support.])
fi

# Server tracing support.
AC_ARG_ENABLE(tracing,
Shawn Routhier's avatar
Shawn Routhier committed
125
	AS_HELP_STRING([--enable-tracing],[enable support for server activity tracing (default is yes)]))
126
127
128
129
130
131
# 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

132
133
# Delayed-ack feature support (experimental).
AC_ARG_ENABLE(delayed_ack,
Shawn Routhier's avatar
Shawn Routhier committed
134
	AS_HELP_STRING([--enable-delayed-ack],[queues multiple DHCPACK replies (default is no)]))
135
136
137
if test "$enable_delayed_ack" = "yes"; then
	AC_DEFINE([DELAYED_ACK], [1],
		  [Define to queue multiple DHCPACK replies per fsync.])
138
139
else
    enable_delayed_ack="no"
140
141
fi

142
# DHCPv6 optional compile-time feature.
143
AC_ARG_ENABLE(dhcpv6,
Shawn Routhier's avatar
Shawn Routhier committed
144
	AS_HELP_STRING([--enable-dhcpv6],[enable support for DHCPv6 (default is yes)]))
145
# DHCPv6 is on by default, so define if it is not explicitly disabled.
Shane Kerr's avatar
Shane Kerr committed
146
if test "$enable_dhcpv6" != "no"; then
147
    enable_dhcpv6="yes"
148
	AC_DEFINE([DHCPv6], [1],
Shane Kerr's avatar
Shane Kerr committed
149
150
		  [Define to 1 to include DHCPv6 support.])
fi
151

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# DHCPv4o6 optional compile-time feature.
AC_ARG_ENABLE(dhcpv4o6,
	AS_HELP_STRING([--enable-dhcpv4o6],[enable support for DHCPv4-over-DHCPv6 (default is no)]))
# DHCPv4o6 is off by default, so define if it is explicitly enabled.
if test "$enable_dhcpv4o6" = "yes"; then
	# DHCPv4o6 requires DHCPv6
	if test "$enable_dhcpv6" = "no"; then
		AC_MSG_ERROR([dhcpv4o6 requires dhcpv6])
	fi
	# DHCPv4o6 is not yet compatible with delayed-ack
	if test "$enable_delayed_ack" = "yes"; then
		AC_MSG_ERROR([dhcpv4o6 is not compatible with delayed-ack])
	fi
	AC_DEFINE([DHCP4o6], [1], 
		  [Define to 1 to include DHCPv4 over DHCPv6 support.])
fi

169
170
# PARANOIA is off by default (until we can test it with all features)
AC_ARG_ENABLE(paranoia,
Shawn Routhier's avatar
Shawn Routhier committed
171
	AS_HELP_STRING([--enable-paranoia],[enable support for chroot/setuid (default is no)]))
172
AC_ARG_ENABLE(early_chroot,
Shawn Routhier's avatar
Shawn Routhier committed
173
	AS_HELP_STRING([--enable-early-chroot],[enable chrooting prior to configuration (default is no)]))
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# 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

190
AC_ARG_ENABLE(ipv4_pktinfo,
Shawn Routhier's avatar
Shawn Routhier committed
191
	AS_HELP_STRING([--enable-ipv4-pktinfo],[enable use of pktinfo on IPv4 sockets (default is no)]))
192
193
194
195
196
197

if test "$enable_ipv4_pktinfo" = "yes"; then
	AC_DEFINE([USE_V4_PKTINFO], [1],
		[Define to 1 to enable IPv4 packet info support.])
fi

198
AC_ARG_ENABLE(use_sockets,
Shawn Routhier's avatar
Shawn Routhier committed
199
	AS_HELP_STRING([--enable-use-sockets],[use the standard BSD socket API (default is no)]))
200
201
202
203
204
205

if test "$enable_use_sockets" = "yes"; then
	AC_DEFINE([USE_SOCKETS], [1],
		[Define to 1 to use the standard BSD socket API.])
fi

Shawn Routhier's avatar
Shawn Routhier committed
206
207
208
# Try to hnadle incorrect byte order for secs field
# This is off by default
AC_ARG_ENABLE(secs_byteorder,
Shawn Routhier's avatar
Shawn Routhier committed
209
	AS_HELP_STRING([--enable-secs-byteorder],[Correct bad byteorders in the secs field (default is no).]))
Shawn Routhier's avatar
Shawn Routhier committed
210
211
212
213
214
215

if test "$enable_secs_byteorder" = "yes" ; then
	AC_DEFINE([SECS_BYTEORDER], [1],
		[Define to correct bad byteorders in secs field.])
fi

216
217
218
219
220
221
222
223
224
225
# Include the PID in the log messages.  This is useful when there may
# be multiple instances of a program.
# This is off by default
AC_ARG_ENABLE(log_pid,
	AS_HELP_STRING([--enable-log-pid],[Include PIDs in syslog messages (default is no).]))
if test "$enable_log_pid" = "yes" ; then
	AC_DEFINE([USE_LOG_PID], [1],
		[Define to include PIDs in syslog messages.])
fi

226
227
228
229
230
231
232
# Allow for binary search when inserting v4 leases into queues
AC_ARG_ENABLE(binary_leases,
	AS_HELP_STRING([--enable-binary-leases],[enable support for binary insertion of leases (default is no)]))
# binary_leases is off by default.
if test "$enable_binary_leases" = "yes"; then
	AC_DEFINE([BINARY_LEASES], [1],
		  [Define to support binary insertion of leases into queues.])
233
234
else
    enable_binary_leases="no"
235
236
fi

237
238
# Testing section

Francis Dupont's avatar
Francis Dupont committed
239
DISTCHECK_ATF_CONFIGURE_FLAG=
240
241
atf_path="no"
AC_ARG_WITH([atf],
242
    AS_HELP_STRING([--with-atf=PATH],[specify location where atf was installed (or "bind")]),
243
    [atf_path="$withval"])
244
245
AM_CONDITIONAL(BIND_ATF, test "$atf_path" = "bind")
if test "$atf_path" = "bind" ; then
Francis Dupont's avatar
Francis Dupont committed
246
    DISTCHECK_ATF_CONFIGURE_FLAG="--with-atf=bind"
247
248
249
250
    atf_pcp="bind"
    atf_path="\${top_srcdir}/bind/atf"
    ATF_CFLAGS="-I$atf_path/include -DUNIT_TEST"
    ATF_LDFLAGS="-L$atf_path/lib -latf-c"
251
    ATF_BIN=`cd $srcdir; pwd`/bind/atf/bin
252
253
254
255
256
    AC_SUBST(ATF_CFLAGS)
    AC_SUBST(ATF_LDFLAGS)
    AC_SUBST(ATF_BIN)
    BINDCONFIG="$BINDCONFIG --with-atf"
elif test "$atf_path" != "no" ; then
Francis Dupont's avatar
Francis Dupont committed
257
    DISTCHECK_ATF_CONFIGURE_FLAG="--with-atf=$atf_path"
258
259
260
261
262
    # Config path for pkg-config
    atf_pcp=""
    if test "$atf_path" != "yes" ; then
        if test -f $atf_path/lib/pkgconfig/atf-c.pc ; then
            atf_pcp=$atf_path/lib/pkgconfig
Shawn Routhier's avatar
Shawn Routhier committed
263
264
        elif test -f $atf_path/lib64/pkgconfig/atf-c.pc ; then
            atf_pcp=$atf_path/lib64/pkgconfig
265
266
267
268
269
270
271
272
        fi
    else
        # Not specified, try some common paths
        atf_dirs="/usr /usr/local /usr/pkg /opt /opt/local"
        for d in $atf_dirs
        do
            if test -f $d/lib/pkgconfig/atf-c.pc ; then
                atf_pcp=$d/lib/pkgconfig
273
                atf_path=$d
Shawn Routhier's avatar
Shawn Routhier committed
274
275
            elif test -f $d/lib64/pkgconfig/atf-c.pc ; then
                atf_pcp=$d/lib64/pkgconfig
276
                atf_path=$d
277
278
279
            fi
        done
    fi
280

281
282
283
    if test "$atf_pcp" = "" ; then
        AC_MSG_ERROR([Unable to find atf files in location specified])
    else
284
285
286
287
        AC_CHECK_PROG([pkgcfg_found],[pkg-config],[pkg-config],[])
        if test "$pkgcfg_found" = ""; then
            AC_MSG_ERROR([Could not locate ATF, pkg-config not installed])
        fi
288
289
        ATF_CFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --cflags atf-c` -DUNIT_TEST"
        ATF_LDFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --libs atf-c`"
290
291
292
293
294
295
296
297
298
299
300
        if  test -f $atf_pcp/atf-sh.pc ; then
                ATF_BIN="`PKG_CONFIG_PATH=$atf_pcp pkg-config --variable=exec_prefix atf-sh`/bin"
        else
                # older versions don't have atf-sh, try usual place
                ATF_BIN=$atf_path/bin
        fi

        if test ! -x $ATF_BIN/atf-run  -o  ! -x $ATF_BIN/atf-report ; then
            AC_MSG_WARN([atf-run,atf-report not found, assuming they are in your path])
        fi

301
302
        AC_SUBST(ATF_CFLAGS)
        AC_SUBST(ATF_LDFLAGS)
303
        AC_SUBST(ATF_BIN)
304
    fi
305
fi
306
307

AM_CONDITIONAL(HAVE_ATF, test "$atf_pcp" != "")
308
AM_COND_IF([HAVE_ATF], [AC_DEFINE([HAVE_ATF], [1], [ATF framework specified?])])
Francis Dupont's avatar
Francis Dupont committed
309
AC_SUBST(DISTCHECK_ATF_CONFIGURE_FLAG)
310

311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
###
### 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

330
331
# Allow specification of alternate state files
AC_ARG_WITH(srv-lease-file,
332
	AS_HELP_STRING([--with-srv-lease-file=PATH],[File for dhcpd leases
333
334
335
		        (default is LOCALSTATEDIR/db/dhcpd.leases)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD_DB], ["$withval"],
			   [File for dhcpd leases.]))
336

337
AC_MSG_CHECKING([for dhcpd.leases location])
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
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
359
AC_MSG_RESULT($with_srv_lease_file)
360

Francis Dupont's avatar
Francis Dupont committed
361
AC_ARG_WITH(srv6-lease-file,
362
	AS_HELP_STRING([--with-srv6-lease-file=PATH],[File for dhcpd6 leases
Francis Dupont's avatar
Francis Dupont committed
363
364
365
366
		        (default is LOCALSTATEDIR/db/dhcpd6.leases)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD6_DB], ["$withval"],
			   [File for dhcpd6 leases.]))

367
AC_MSG_CHECKING([for dhcpd6.leases location])
Francis Dupont's avatar
Francis Dupont committed
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
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
389
AC_MSG_RESULT($with_srv6_lease_file)
Francis Dupont's avatar
Francis Dupont committed
390

391
AC_ARG_WITH(cli-lease-file,
392
	AS_HELP_STRING([--with-cli-lease-file=PATH],[File for dhclient leases
393
394
395
		        (default is LOCALSTATEDIR/db/dhclient.leases)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_DB], ["$withval"],
			   [File for dhclient leases.]))
396

397
AC_MSG_CHECKING([for dhclient.leases location])
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
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
419
AC_MSG_RESULT($with_cli_lease_file)
420

Francis Dupont's avatar
Francis Dupont committed
421
AC_ARG_WITH(cli6-lease-file,
422
	AS_HELP_STRING([--with-cli6-lease-file=PATH],[File for dhclient6 leases
Francis Dupont's avatar
Francis Dupont committed
423
424
425
426
		        (default is LOCALSTATEDIR/db/dhclient6.leases)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_DB], ["$withval"],
			   [File for dhclient6 leases.]))

427
AC_MSG_CHECKING([for dhclient6.leases location])
Francis Dupont's avatar
Francis Dupont committed
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
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
449
AC_MSG_RESULT($with_cli6_lease_file)
Francis Dupont's avatar
Francis Dupont committed
450

451
AC_ARG_WITH(srv-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
452
	AS_HELP_STRING([--with-srv-pid-file=PATH],[File for dhcpd process information
453
454
455
		        (default is LOCALSTATEDIR/run/dhcpd.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD_PID], ["$withval"],
			   [File for dhcpd process information.]))
Francis Dupont's avatar
Francis Dupont committed
456
AC_ARG_WITH(srv6-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
457
	AS_HELP_STRING([--with-srv6-pid-file=PATH],[File for dhcpd6 process information
Francis Dupont's avatar
Francis Dupont committed
458
459
460
		        (default is LOCALSTATEDIR/run/dhcpd6.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD6_PID], ["$withval"],
			   [File for dhcpd6 process information.]))
461
AC_ARG_WITH(cli-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
462
	AS_HELP_STRING([--with-cli-pid-file=PATH],[File for dhclient process information
463
		        (default is LOCALSTATEDIR/run/dhclient.pid)]),
Francis Dupont's avatar
Francis Dupont committed
464
	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_PID], ["$withval"],
465
			   [File for dhclient process information.]))
Francis Dupont's avatar
Francis Dupont committed
466
AC_ARG_WITH(cli6-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
467
	AS_HELP_STRING([--with-cli6-pid-file=PATH],[File for dhclient6 process information
Francis Dupont's avatar
Francis Dupont committed
468
469
470
		        (default is LOCALSTATEDIR/run/dhclient6.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_PID], ["$withval"],
			   [File for dhclient6 process information.]))
471
AC_ARG_WITH(relay-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
472
	AS_HELP_STRING([--with-relay-pid-file=PATH],[File for dhcrelay process information
473
474
475
		        (default is LOCALSTATEDIR/run/dhcrelay.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCRELAY_PID], ["$withval"],
			   [File for dhcrelay process information.]))
476
AC_ARG_WITH(relay6-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
477
	AS_HELP_STRING([--with-relay6-pid-file=PATH],[File for dhcrelay6 process information
478
479
480
		        (default is LOCALSTATEDIR/run/dhcrelay6.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCRELAY6_PID], ["$withval"],
			   [File for dhcrelay6 process information.]))
481

482
483
484
485
# Check basic types.
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
486
AC_TYPE_INT64_T
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503

# 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.])
])
504
505
506
507
508
AC_CHECK_TYPE([u_int64_t], [], [
  AC_TYPE_UINT64_T
  AC_DEFINE(u_int64_t, [uint64_t], [Define a type for 64-bit unsigned
				    integers.])
])
509

Mark Andrews's avatar
Mark Andrews committed
510
511
512
# see if ifaddrs.h is available
AC_CHECK_HEADERS(ifaddrs.h)

513
# figure out what IPv4 interface code to use
514
515
516
517
518
519
520
521
522
523
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
524
	AC_DEFINE([HAVE_LPF], [1],
525
526
527
528
529
		  [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
530
		AC_DEFINE([HAVE_DLPI], [1],
531
532
533
534
535
			  [Define to 1 to use DLPI interface code.])
	else
		AC_CHECK_HEADER(net/bpf.h, DO_BPF=1)
		if test -n "$DO_BPF"
		then
536
			AC_DEFINE([HAVE_BPF], [1],
537
				   [Define to 1 to use the
538
539
540
541
				   Berkeley Packet Filter interface code.])
		fi
	fi
fi
542

543
544
545
546
547
548
549
# 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])
Shawn Routhier's avatar
Shawn Routhier committed
550
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
Shane Kerr's avatar
Shane Kerr committed
551
  #include <sys/socket.h>
552
  #include <net/if.h>
Shawn Routhier's avatar
Shawn Routhier committed
553
554
]], [[ struct lifnum a;
]])],[AC_MSG_RESULT(yes)
555
	 AC_DEFINE([ISC_PLATFORM_HAVELIFNUM], [1],
Shawn Routhier's avatar
Shawn Routhier committed
556
		   [Define to 1 if the system has 'struct lifnum'.])],[AC_MSG_RESULT(no)])
557
558

AC_MSG_CHECKING([for struct if_laddrconf])
Shawn Routhier's avatar
Shawn Routhier committed
559
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
560
  #include <net/if6.h>
Shawn Routhier's avatar
Shawn Routhier committed
561
562
]], [[ struct if_laddrconf a;
]])],[AC_MSG_RESULT(yes)
563
	 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRCONF], [1],
Shawn Routhier's avatar
Shawn Routhier committed
564
		   [Define to 1 if the system has 'struct if_laddrconf'.])],[AC_MSG_RESULT(no)])
565
566

AC_MSG_CHECKING([for struct if_laddrreq])
Shawn Routhier's avatar
Shawn Routhier committed
567
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
568
 #include <net/if6.h>
Shawn Routhier's avatar
Shawn Routhier committed
569
570
]], [[ struct if_laddrreq a;
]])],[AC_MSG_RESULT(yes)
571
	 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRREQ], [1],
Shawn Routhier's avatar
Shawn Routhier committed
572
		   [Define to 1 if the system has 'struct if_laddrreq'.])],[AC_MSG_RESULT(no)])
573

574
575
576
577
#
# check for GCC noreturn attribute
#
AC_MSG_CHECKING(for GCC noreturn attribute)
Shawn Routhier's avatar
Shawn Routhier committed
578
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[void foo() __attribute__((noreturn));]])],[AC_MSG_RESULT(yes)
579
	 AC_DEFINE([ISC_DHCP_NORETURN], [__attribute__((noreturn))],
Shawn Routhier's avatar
Shawn Routhier committed
580
		   [Define to the string for a noreturn attribute.])],[AC_MSG_RESULT(no)
581
582
583
	 AC_DEFINE([ISC_DHCP_NORETURN], [],
		   [Define to the string for a noreturn attribute.])])

584
# Look for optional headers.
Shane Kerr's avatar
Shane Kerr committed
585
AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
586

587
588
589
590
# Solaris needs some libraries for functions
AC_SEARCH_LIBS(socket, [socket])
AC_SEARCH_LIBS(inet_ntoa, [nsl])

591
592
AC_SEARCH_LIBS(inet_aton, [socket nsl], ,
	AC_DEFINE([NEED_INET_ATON], [1],
593
594
		  [Define to 1 if the inet_aton() function is missing.]))

595
596
597
# Check for a standalone regex library.
AC_SEARCH_LIBS(regcomp, [regex])

598
599
AC_CHECK_FUNCS(strlcat)

600
601
602
# For HP/UX we need -lipv6 for if_nametoindex, perhaps others.
AC_SEARCH_LIBS(if_nametoindex, [ipv6])

603
# check for /dev/random (declares HAVE_DEV_RANDOM)
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
AC_MSG_CHECKING(for random device)
AC_ARG_WITH(randomdev,
	AS_HELP_STRING([--with-randomdev=PATH],[Path for random device
		       (default is /dev/random)]),
	use_randomdev="$withval", use_randomdev="unspec")
if test "$use_randomdev" = "unspec"; then
	if test "$cross_compiling" = "yes"; then
		AC_MSG_RESULT(unspecified)
		AC_MSG_ERROR([ need --with-randomdev=PATH or --with-randomdev=no])
	fi
	use_randomdev="/dev/random"
elif test "$use_randomdev" = "yes"; then
	use_randomdev="/dev/random"
fi
if test "$use_randomdev" = "no"; then
	AC_MSG_RESULT(disabled)
	BINDCONFIG="$BINDCONFIG --with-randomdev=no"
else
	if test "$cross_compiling" = "yes"; then
		AC_MSG_RESULT($use_randomdev (unchecked))
	else
		AC_MSG_RESULT($use_randomdev)
		AC_CHECK_FILE($use_randomdev,
		    AC_DEFINE([HAVE_DEV_RANDOM], [1], 
			[Define to 1 if you have the /dev/random or other configured file.]),
		    AC_MSG_ERROR(cannot find $use_randomdev))
	fi
	BINDCONFIG="$BINDCONFIG --with-randomdev=$use_randomdev"
fi
633

634
635
636
637
638
BINDIOMUX="--disable-kqueue --disable-epoll --disable-devpoll"
# check kqueue/epoll/devpoll alternative to select
AC_ARG_ENABLE(kqueue,
	AS_HELP_STRING([--enable-kqueue],[use BSD kqueue (default is no)]),
	want_kqueue="$enableval", want_kqueue="no")
Francis Dupont's avatar
Francis Dupont committed
639
if test "$want_kqueue" = "yes"; then
640
641
642
643
644
	BINDIOMUX="--enable-kqueue"
fi
AC_ARG_ENABLE(epoll,
	AS_HELP_STRING([--enable-epoll],[use Linux epoll (default is no)]),
	want_epoll="$enableval", want_epoll="no")
Francis Dupont's avatar
Francis Dupont committed
645
if test "$want_epoll" = "yes"; then
646
647
648
649
650
	BINDIOMUX="--enable-epoll"
fi
AC_ARG_ENABLE(devpoll,
	AS_HELP_STRING([--enable-devpoll],[use /dev/poll (default is no)]),
	want_devpoll="$enableval", want_devpoll="no")
Francis Dupont's avatar
Francis Dupont committed
651
if test "$want_devpoll" = "yes"; then
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
	BINDIOMUX="--enable-devpoll"
fi
AC_SUBST(BINDIOMUX)

# general extra bind configure arguments
AC_ARG_WITH(bind-extra-config,
	AS_HELP_STRING([--with-bind-extra-config],[configure bind librairies
		       with some extra options (default is none)]),
	use_xbindconfig="$withval", use_xbindconfig="")
case "$use_xbindconfig" in
yes|no|'')
	;;
*)
	BINDCONFIG="$BINDCONFIG $use_xbindconfig"
	;;
esac

669
670
# see if there is a "sa_len" field in our interface information structure
AC_CHECK_MEMBER(struct sockaddr.sa_len,
671
	AC_DEFINE([HAVE_SA_LEN], [],
672
673
674
675
		  [Define to 1 if the sockaddr structure has a length field.]),
	,
	[#include <sys/socket.h>])

Shane Kerr's avatar
Shane Kerr committed
676
# figure out pointer size
Francis Dupont's avatar
Francis Dupont committed
677
678
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$srcdir"
Shane Kerr's avatar
Shane Kerr committed
679
680
681
682
AC_CHECK_SIZEOF(struct iaddr *, , [
#include "includes/inet.h"
#include <stdio.h>
])
Francis Dupont's avatar
Francis Dupont committed
683
CFLAGS="$SAVE_CFLAGS"
Shane Kerr's avatar
Shane Kerr committed
684

685
# Solaris does not have the msg_control or msg_controlen members
Shane Kerr's avatar
Shane Kerr committed
686
687
688
# in the msghdr structure unless you define:
#
#   _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, and __EXTENSIONS__
689
#
Shane Kerr's avatar
Shane Kerr committed
690
# See the "standards" man page for details.
691
#
Shane Kerr's avatar
Shane Kerr committed
692
693
694
695
696
697
698
699
700
# 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,,
701
	 	[AC_MSG_ERROR([Missing msg_control member in
Shane Kerr's avatar
Shane Kerr committed
702
			       msg_control structure.])],
703
704
705
706
707
708
709
710
711
		[
#include <sys/types.h>
#include <sys/socket.h>
		])
	],
	[
#include <sys/types.h>
#include <sys/socket.h>
	])
Shane Kerr's avatar
Shane Kerr committed
712

713
714
715
716
AC_CHECK_MEMBER(struct tpacket_auxdata.tp_vlan_tci,
    [AC_DEFINE([VLAN_TCI_PRESENT], [1], [tpacket_auxdata.tp_vlan_tci present])]
    ,, [#include <linux/if_packet.h>])

Francis Dupont's avatar
Francis Dupont committed
717
BINDDIR=
718
BINDSRCDIR=
719
AC_ARG_WITH(libbind,
720
	AS_HELP_STRING([--with-libbind=PATH],[bind includes and libraries are in PATH
721
722
		        (default is ./bind)]),
	use_libbind="$withval", use_libbind="no")
723
case "$use_libbind" in
724
yes)
Francis Dupont's avatar
Francis Dupont committed
725
	BINDDIR="\${top_srcdir}/bind"
726
	BINDSRCDIR="\${top_srcdir}/bind"
727
728
	;;
no)
Francis Dupont's avatar
Francis Dupont committed
729
	BINDDIR="\${top_srcdir}/bind"
730
	BINDSRCDIR="\${top_srcdir}/bind"
731
732
	;;
*)
Francis Dupont's avatar
Francis Dupont committed
733
	BINDDIR="$use_libbind"
734
	if test ! -d "$srcdir/bind"; then
Francis Dupont's avatar
Francis Dupont committed
735
		# no bind directory, create it with a fake Makefile.in
736
737
		# (AC_CONFIG_FILES and top Makefile refer to it so
		# it must exits)
738
		mkdir $srcdir/bind
739
		cat > $srcdir/bind/Makefile.in << EOF
Francis Dupont's avatar
Francis Dupont committed
740
741
742
743
744
# placeholder
all check clean distclean distdir install uninstall:

EOF
	fi
745
746
	;;
esac
Francis Dupont's avatar
Francis Dupont committed
747
AC_SUBST(BINDDIR)
748
AC_SUBST(BINDSRCDIR)
749

750
751
# OpenLDAP support.
AC_ARG_WITH(ldap,
Shawn Routhier's avatar
Shawn Routhier committed
752
    AS_HELP_STRING([--with-ldap],[enable OpenLDAP support in dhcpd (default is no)]),
753
754
755
756
757
    [ldap=$withval],
    [ldap=no])

# OpenLDAP with SSL support.
AC_ARG_WITH(ldapcrypto,
Shawn Routhier's avatar
Shawn Routhier committed
758
    AS_HELP_STRING([--with-ldapcrypto],[enable OpenLDAP crypto support in dhcpd (default is no)]),
759
760
761
    [ldapcrypto=$withval],
    [ldapcrypto=no])

762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
# Gssapi to allow LDAP to authenticate with a keytab
AC_ARG_WITH(ldap-gssapi,
    AC_HELP_STRING([--with-ldap-gssapi],
                   [enable krb5/gssapi authentication for OpenLDAP in dhcpd (default is no)]),
    [ldap_gssapi=$withval],
    [ldap_gssapi=no])


# LDAP CASA auth support.
AC_ARG_WITH(ldapcasa,
    AC_HELP_STRING([--with-ldapcasa],
                   [enable LDAP CASA auth support in dhcpd (default is no)]),
    [ldapcasa=$withval],
    [ldapcasa=no])

777
778
# OpenLDAP support is disabled by default, if enabled then SSL support is an
# extra optional that is also disabled by default.  Enabling LDAP SSL support
779
780
781
782
783
# implies enabling LDAP support. Similarly, KRB5 support implies LDAP support,
# but doesn't include SSL. The two are not dependant.
if test x$ldap = xyes || test x$ldapcrypto = xyes || test x$ldap_gssapi = xyes; then
    saved_LIBS="$LIBS"
    LIBS=""
784
785
    AC_SEARCH_LIBS(ldap_initialize, [ldap], ,
		   AC_MSG_FAILURE([*** Cannot find ldap_initialize with -lldap - do you need to install an OpenLDAP2 Devel package?]))
Shawn Routhier's avatar
Shawn Routhier committed
786
787
    AC_SEARCH_LIBS(ber_pvt_opt_on, [lber], ,
		   AC_MSG_FAILURE([*** Cannot find ber_pvt_opt_on with -llber - do you need to install an OpenLDAP2 Devel package?]))
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
    if test x$ldap_gssapi = xyes ; then
    AC_SEARCH_LIBS(krb5_init_context, [krb5], ,
          AC_MSG_FAILURE([*** Cannot find krb5_init_context with -lkrb5 - do you need to install a Kerberos Devel package?]))
    fi

    # Create LDAP_LIBS which we specify them explicitly rather than lumping them in with LIBS
    AC_SUBST(LDAP_LIBS, [$LIBS])
    LIBS="$saved_LIBS"


    AC_CHECK_HEADERS([ldap.h])
    AC_CHECK_FUNCS([inet_pton inet_ntop])


    LDAP_CFLAGS="-DLDAP_CONFIGURATION"

    if test x$ldapcasa = xyes ; then
    AC_CHECK_HEADERS([micasa_mgmd.h],[
           LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_CASA_AUTH"
    ], AC_MSG_FAILURE([*** Cannot find micasa_mgmd.h for ldap casa auth support]))
    fi
809
810

    if test x$ldapcrypto = xyes ; then
811
    LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_USE_SSL"
812
    fi
813
814
815
816
817
818

    if test x$ldap_gssapi = xyes; then
    LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_USE_GSSAPI"
    fi

    AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
819
820
fi

821
# Append selected warning levels to CFLAGS before substitution (but after
Shawn Routhier's avatar
Shawn Routhier committed
822
# AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
823
824
CFLAGS="$CFLAGS $STD_CWARNINGS"

825
826
# Try to add the bind and dhcp include directories
CFLAGS="$CFLAGS -I\$(top_srcdir)/includes -I$BINDDIR/include"
827

828
829
case "$host" in
*-darwin*)
830
831
832
833
834
835
836
    CFLAGS="$CFLAGS -D__APPLE_USE_RFC_3542";;
*-solaris*)
    # As of Solaris 11, ethernet dev files are in /dev/net
    AC_CHECK_FILE(/dev/net,
		    [AC_DEFINE([USE_DEV_NET], [1],
			[Define to 1 if ethernet devices are in /dev/net])])
    ;;
837
838
esac

839
840
AC_C_FLEXIBLE_ARRAY_MEMBER

Shawn Routhier's avatar
Shawn Routhier committed
841
AC_CONFIG_FILES([
842
  Makefile
843
  $srcdir/bind/Makefile
844
  client/Makefile
845
  client/tests/Makefile
846
  common/Makefile
Shane Kerr's avatar
Shane Kerr committed
847
  common/tests/Makefile
848
849
850
851
852
  dhcpctl/Makefile
  includes/Makefile
  omapip/Makefile
  relay/Makefile
  server/Makefile
Shane Kerr's avatar
Shane Kerr committed
853
  tests/Makefile
854
  tests/unittest.sh
855
  server/tests/Makefile
856
  doc/devel/doxyfile
857
])
Shawn Routhier's avatar
Shawn Routhier committed
858
AC_OUTPUT
859

860
861
862
863
864
865
866
867
if test "$enable_dhcpv4o6" = "yes"; then
	DHCP_VERSIONS="DHCPv4, DHCPv6 and DHCPv4-over-DHCPv6"
elif test "$enable_dhcpv6" != "no"; then
	DHCP_VERSIONS="DHCPv4 and DHCPv6"
else
	DHCP_VERSIONS="DHCPv4"
fi

868
869
870
871
872
873
(cd $srcdir
    sh util/bindvar.sh
    if test $? -ne 0; then
        AC_MSG_ERROR([*** util/bindvar.sh failed])
    fi
)
874
875
876
if test $? -ne 0; then
    exit $?
fi
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892

cat > config.report << END

     ISC DHCP source configure results:
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Package:
  Name:          $PACKAGE_NAME
  Version:       $PACKAGE_VERSION

C Compiler:      $CC

Flags:
  DEFS:          $DEFS
  CFLAGS:        $CFLAGS

893
894
DHCP versions:   $DHCP_VERSIONS

895
896
897
898
Features:
  debug:         $enable_debug
  failover:      $enable_failover
  execute:       $enable_execute
899
  binary-leases: $enable_binary_leases
900
901
  dhcpv6:        $enable_dhcpv6
  delayed-ack:   $enable_delayed_ack
902
903

Developer:
904
  ATF unittests : $atf_path
905
906
907
908

END
# TODO: Add Perl system tests

909
if test "$atf_path" != "no"
910
911
912
then
echo "ATF_CFLAGS  : $ATF_CFLAGS" >> config.report
echo "ATF_LDFLAGS : $ATF_LDFLAGS" >> config.report
913
echo "ATF_BIN : $ATF_BIN" >> config.report
914
915
916
917
918
919
920
921
echo
fi

cat config.report

echo
echo Now you can type "make" to build ISC DHCP
echo