configure.ac 34.7 KB
Newer Older
1
AC_INIT([DHCP],[4.4.1],[dhcp-users@isc.org])
2

3

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

8 9 10 11 12
# 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.
13
AM_MAINTAINER_MODE
14

15 16
AC_CANONICAL_HOST

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

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

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

36 37
# We can have some flags to pass to bind configure
BINDCONFIG=
38 39 40
if test "$cross_compiling" = "yes"; then
	BINDCONFIG="--host=$host"
fi
Francis Dupont's avatar
Francis Dupont committed
41 42 43 44 45 46 47 48 49 50 51 52 53
# Pass CFLAGS and co. $ac_configure_args looks like "'arg1' 'arg2' ..."
# and as there can be a space inside an argument some magic is required.
# This sets $1 ... $N to my_configure_args, arg1 ... argN
eval "set my_configure_args $ac_configure_args"
# remove my_configure_args, i.e., the guard against empty $ac_configure_args
shift
# iterate on arguments and copying 'arg' when it begins by an upper case
for a
do
	case $a in
		[[A-Z]]*) BINDCONFIG="$BINDCONFIG '$a'" ;;
	esac
done
54 55
AC_SUBST(BINDCONFIG)

56 57 58 59 60 61 62
# 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

63
AC_PROG_RANLIB
64 65 66 67

AC_PATH_PROG(AR, ar)
AC_SUBST(AR)

68 69 70 71 72 73
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

74 75 76
AC_CONFIG_HEADERS([includes/config.h])

# we sometimes need to know byte order for building packets
77
AC_C_BIGENDIAN(AC_SUBST(byte_order, BIG_ENDIAN),
78
	       AC_SUBST(byte_order, LITTLE_ENDIAN))
79
AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
80 81 82
		   [Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs)
		    or LITTLE_ENDIAN for LSB (Intel CPUs).])

83 84
# Optional compile-time DEBUGging.
AC_ARG_ENABLE(debug,
Shawn Routhier's avatar
Shawn Routhier committed
85
	AS_HELP_STRING([--enable-debug],[create a debug-only version of the software (default is no).]),
86 87 88 89 90 91 92 93 94 95
  [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])

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
# 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
118
	AS_HELP_STRING([--enable-failover],[enable support for failover (default is yes)]))
119 120
# Failover is on by default, so define if it is not explicitly disabled.
if test "$enable_failover" != "no"; then
121
    enable_failover="yes"
122 123 124 125 126 127
	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
128
	AS_HELP_STRING([--enable-execute],[enable support for execute() in config (default is yes)]))
129 130
# execute() is on by default, so define if it is not explicitly disabled.
if test "$enable_execute" != "no" ; then
131
    enable_execute="yes"
132 133 134 135 136 137
	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
138
	AS_HELP_STRING([--enable-tracing],[enable support for server activity tracing (default is yes)]))
139 140 141 142 143 144
# 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

145
# Delayed-ack feature support.
146
AC_ARG_ENABLE(delayed_ack,
147 148 149
	AS_HELP_STRING([--enable-delayed-ack],[queues multiple DHCPACK replies (default is yes)]))
if test "$enable_delayed_ack" != "no"; then
    enable_delayed_ack="yes"
150 151 152 153
	AC_DEFINE([DELAYED_ACK], [1],
		  [Define to queue multiple DHCPACK replies per fsync.])
fi

154
# DHCPv6 optional compile-time feature.
155
AC_ARG_ENABLE(dhcpv6,
Shawn Routhier's avatar
Shawn Routhier committed
156
	AS_HELP_STRING([--enable-dhcpv6],[enable support for DHCPv6 (default is yes)]))
157
# DHCPv6 is on by default, so define if it is not explicitly disabled.
Shane Kerr's avatar
Shane Kerr committed
158
if test "$enable_dhcpv6" != "no"; then
159
    enable_dhcpv6="yes"
160
	AC_DEFINE([DHCPv6], [1],
Shane Kerr's avatar
Shane Kerr committed
161 162
		  [Define to 1 to include DHCPv6 support.])
fi
163

164 165 166 167 168 169 170 171 172 173 174
# 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
	AC_DEFINE([DHCP4o6], [1], 
		  [Define to 1 to include DHCPv4 over DHCPv6 support.])
175 176 177
else
    # so we can report below
    enable_dhcpv4o6="no"
178 179
fi

Francis Dupont's avatar
Francis Dupont committed
180 181 182 183 184 185 186
# Relay port (draft-ietf-dhc-relay-port-10.txt) optional compile-time feature.
AC_ARG_ENABLE(relay-port,
	AS_HELP_STRING([--enable-relay-port],[enable support for relay port (default is no)]))
# Relay port is off by default (for now)
if test "$enable_relay_port" = "yes"; then
	AC_DEFINE([RELAY_PORT], [1],
		  [Define to 1 to include relay port support.])
187
else
188
	# so we can report below
Francis Dupont's avatar
Francis Dupont committed
189
	enable_relay_port="no"
Francis Dupont's avatar
Francis Dupont committed
190 191
fi

192 193
# PARANOIA is off by default (until we can test it with all features)
AC_ARG_ENABLE(paranoia,
Shawn Routhier's avatar
Shawn Routhier committed
194
	AS_HELP_STRING([--enable-paranoia],[enable support for chroot/setuid (default is no)]))
195
AC_ARG_ENABLE(early_chroot,
Shawn Routhier's avatar
Shawn Routhier committed
196
	AS_HELP_STRING([--enable-early-chroot],[enable chrooting prior to configuration (default is no)]))
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
# 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

213
AC_ARG_ENABLE(ipv4_pktinfo,
Shawn Routhier's avatar
Shawn Routhier committed
214
	AS_HELP_STRING([--enable-ipv4-pktinfo],[enable use of pktinfo on IPv4 sockets (default is no)]))
215 216 217 218 219 220

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

221
AC_ARG_ENABLE(use_sockets,
Shawn Routhier's avatar
Shawn Routhier committed
222
	AS_HELP_STRING([--enable-use-sockets],[use the standard BSD socket API (default is no)]))
223 224 225 226 227 228

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

229 230 231 232 233 234 235 236 237 238
# 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

239 240 241 242 243 244 245
# 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.])
246 247
else
    enable_binary_leases="no"
248 249
fi

250 251
# Testing section

Francis Dupont's avatar
Francis Dupont committed
252
DISTCHECK_ATF_CONFIGURE_FLAG=
253 254
atf_path="no"
AC_ARG_WITH([atf],
255
    AS_HELP_STRING([--with-atf=PATH],[specify location where atf was installed (or "bind")]),
256
    [atf_path="$withval"])
257 258
AM_CONDITIONAL(BIND_ATF, test "$atf_path" = "bind")
if test "$atf_path" = "bind" ; then
Francis Dupont's avatar
Francis Dupont committed
259
    DISTCHECK_ATF_CONFIGURE_FLAG="--with-atf=bind"
260 261 262 263
    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"
264
    ATF_BIN=`cd $srcdir; pwd`/bind/atf/bin
265 266 267 268 269
    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
270
    DISTCHECK_ATF_CONFIGURE_FLAG="--with-atf=$atf_path"
271 272 273 274 275
    # 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
276 277
        elif test -f $atf_path/lib64/pkgconfig/atf-c.pc ; then
            atf_pcp=$atf_path/lib64/pkgconfig
278 279 280 281 282 283 284 285
        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
286
                atf_path=$d
Shawn Routhier's avatar
Shawn Routhier committed
287 288
            elif test -f $d/lib64/pkgconfig/atf-c.pc ; then
                atf_pcp=$d/lib64/pkgconfig
289
                atf_path=$d
290 291 292
            fi
        done
    fi
293

294 295 296
    if test "$atf_pcp" = "" ; then
        AC_MSG_ERROR([Unable to find atf files in location specified])
    else
297 298 299 300
        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
301 302
        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`"
303 304 305 306 307 308 309
        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

Francis Dupont's avatar
Francis Dupont committed
310
        UNITTESTS=tests
311

312 313
        AC_SUBST(ATF_CFLAGS)
        AC_SUBST(ATF_LDFLAGS)
314
        AC_SUBST(ATF_BIN)
Francis Dupont's avatar
Francis Dupont committed
315
        AC_SUBST(UNITTESTS)
316
    fi
317
fi
318 319

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

323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
###
### 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

342 343 344 345 346 347 348
# Default server configuration file.
AC_ARG_WITH(srv-conf-file,
	AS_HELP_STRING([--with-srv-conf-file=PATH],[Default file containing dhcpd configuration
		        (default is typically /etc/dhcpd.conf)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD_CONF], ["$withval"],
			   [Default file containing dhcpd configuration.]))

349 350
# Allow specification of alternate state files
AC_ARG_WITH(srv-lease-file,
351
	AS_HELP_STRING([--with-srv-lease-file=PATH],[File for dhcpd leases
352 353 354
		        (default is LOCALSTATEDIR/db/dhcpd.leases)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD_DB], ["$withval"],
			   [File for dhcpd leases.]))
355

356
AC_MSG_CHECKING([for dhcpd.leases location])
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
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
378
AC_MSG_RESULT($with_srv_lease_file)
379

380
AC_ARG_WITH(srv6-lease-file,
381
	AS_HELP_STRING([--with-srv6-lease-file=PATH],[File for dhcpd6 leases
382 383 384 385
		        (default is LOCALSTATEDIR/db/dhcpd6.leases)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD6_DB], ["$withval"],
			   [File for dhcpd6 leases.]))

386
AC_MSG_CHECKING([for dhcpd6.leases location])
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
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
408
AC_MSG_RESULT($with_srv6_lease_file)
409

410
AC_ARG_WITH(cli-lease-file,
411
	AS_HELP_STRING([--with-cli-lease-file=PATH],[File for dhclient leases
412 413 414
		        (default is LOCALSTATEDIR/db/dhclient.leases)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_DB], ["$withval"],
			   [File for dhclient leases.]))
415

416
AC_MSG_CHECKING([for dhclient.leases location])
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
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
438
AC_MSG_RESULT($with_cli_lease_file)
439

440
AC_ARG_WITH(cli6-lease-file,
441
	AS_HELP_STRING([--with-cli6-lease-file=PATH],[File for dhclient6 leases
442 443 444 445
		        (default is LOCALSTATEDIR/db/dhclient6.leases)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_DB], ["$withval"],
			   [File for dhclient6 leases.]))

446
AC_MSG_CHECKING([for dhclient6.leases location])
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
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
468
AC_MSG_RESULT($with_cli6_lease_file)
469

470
AC_ARG_WITH(srv-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
471
	AS_HELP_STRING([--with-srv-pid-file=PATH],[File for dhcpd process information
472 473 474
		        (default is LOCALSTATEDIR/run/dhcpd.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD_PID], ["$withval"],
			   [File for dhcpd process information.]))
475
AC_ARG_WITH(srv6-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
476
	AS_HELP_STRING([--with-srv6-pid-file=PATH],[File for dhcpd6 process information
477 478 479
		        (default is LOCALSTATEDIR/run/dhcpd6.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCPD6_PID], ["$withval"],
			   [File for dhcpd6 process information.]))
480
AC_ARG_WITH(cli-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
481
	AS_HELP_STRING([--with-cli-pid-file=PATH],[File for dhclient process information
482
		        (default is LOCALSTATEDIR/run/dhclient.pid)]),
483
	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_PID], ["$withval"],
484
			   [File for dhclient process information.]))
485
AC_ARG_WITH(cli6-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
486
	AS_HELP_STRING([--with-cli6-pid-file=PATH],[File for dhclient6 process information
487 488 489
		        (default is LOCALSTATEDIR/run/dhclient6.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_PID], ["$withval"],
			   [File for dhclient6 process information.]))
490
AC_ARG_WITH(relay-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
491
	AS_HELP_STRING([--with-relay-pid-file=PATH],[File for dhcrelay process information
492 493 494
		        (default is LOCALSTATEDIR/run/dhcrelay.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCRELAY_PID], ["$withval"],
			   [File for dhcrelay process information.]))
495
AC_ARG_WITH(relay6-pid-file,
Shawn Routhier's avatar
Shawn Routhier committed
496
	AS_HELP_STRING([--with-relay6-pid-file=PATH],[File for dhcrelay6 process information
497 498 499
		        (default is LOCALSTATEDIR/run/dhcrelay6.pid)]),
	AC_DEFINE_UNQUOTED([_PATH_DHCRELAY6_PID], ["$withval"],
			   [File for dhcrelay6 process information.]))
500

501 502 503 504
# Check basic types.
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
505
AC_TYPE_INT64_T
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522

# 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.])
])
523 524 525 526 527
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.])
])
528

Mark Andrews's avatar
Mark Andrews committed
529 530 531
# see if ifaddrs.h is available
AC_CHECK_HEADERS(ifaddrs.h)

532
# figure out what IPv4 interface code to use
533 534
AC_CHECK_HEADERS(linux/types.h)  # needed for linux/filter.h on old systems

Francis Dupont's avatar
Francis Dupont committed
535
relay_port_supported="no"
536 537 538 539 540 541 542 543
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
544
	AC_DEFINE([HAVE_LPF], [1],
545
		  [Define to 1 to use the Linux Packet Filter interface code.])
Francis Dupont's avatar
Francis Dupont committed
546
	relay_port_supported="yes"
547 548 549 550
else
	AC_CHECK_HEADER(sys/dlpi.h, DO_DLPI=1)
	if test -n "$DO_DLPI"
	then
551
		AC_DEFINE([HAVE_DLPI], [1],
552 553 554 555 556
			  [Define to 1 to use DLPI interface code.])
	else
		AC_CHECK_HEADER(net/bpf.h, DO_BPF=1)
		if test -n "$DO_BPF"
		then
557
			AC_DEFINE([HAVE_BPF], [1],
558
				   [Define to 1 to use the
559
				   Berkeley Packet Filter interface code.])
Francis Dupont's avatar
Francis Dupont committed
560
			relay_port_supported="yes"
561 562 563
		fi
	fi
fi
564

Francis Dupont's avatar
Francis Dupont committed
565 566 567 568 569 570
if test "$enable_relay_port" = "yes"; then
	if test "$relay_port_supported" != "yes"; then
		AC_MSG_ERROR([--enable-relay-port requires BPF or LPF])
	fi
fi

571 572 573 574 575 576 577
# 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
578
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
Shane Kerr's avatar
Shane Kerr committed
579
  #include <sys/socket.h>
580
  #include <net/if.h>
Shawn Routhier's avatar
Shawn Routhier committed
581 582
]], [[ struct lifnum a;
]])],[AC_MSG_RESULT(yes)
583
	 AC_DEFINE([ISC_PLATFORM_HAVELIFNUM], [1],
Shawn Routhier's avatar
Shawn Routhier committed
584
		   [Define to 1 if the system has 'struct lifnum'.])],[AC_MSG_RESULT(no)])
585 586

AC_MSG_CHECKING([for struct if_laddrconf])
Shawn Routhier's avatar
Shawn Routhier committed
587
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
588
  #include <net/if6.h>
Shawn Routhier's avatar
Shawn Routhier committed
589 590
]], [[ struct if_laddrconf a;
]])],[AC_MSG_RESULT(yes)
591
	 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRCONF], [1],
Shawn Routhier's avatar
Shawn Routhier committed
592
		   [Define to 1 if the system has 'struct if_laddrconf'.])],[AC_MSG_RESULT(no)])
593 594

AC_MSG_CHECKING([for struct if_laddrreq])
Shawn Routhier's avatar
Shawn Routhier committed
595
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
596
 #include <net/if6.h>
Shawn Routhier's avatar
Shawn Routhier committed
597 598
]], [[ struct if_laddrreq a;
]])],[AC_MSG_RESULT(yes)
599
	 AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRREQ], [1],
Shawn Routhier's avatar
Shawn Routhier committed
600
		   [Define to 1 if the system has 'struct if_laddrreq'.])],[AC_MSG_RESULT(no)])
601

602 603 604 605
#
# check for GCC noreturn attribute
#
AC_MSG_CHECKING(for GCC noreturn attribute)
Shawn Routhier's avatar
Shawn Routhier committed
606
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[void foo() __attribute__((noreturn));]])],[AC_MSG_RESULT(yes)
607
	 AC_DEFINE([ISC_DHCP_NORETURN], [__attribute__((noreturn))],
Shawn Routhier's avatar
Shawn Routhier committed
608
		   [Define to the string for a noreturn attribute.])],[AC_MSG_RESULT(no)
609 610 611
	 AC_DEFINE([ISC_DHCP_NORETURN], [],
		   [Define to the string for a noreturn attribute.])])

612
# Look for optional headers.
Shane Kerr's avatar
Shane Kerr committed
613
AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
614

615 616 617 618
# Solaris needs some libraries for functions
AC_SEARCH_LIBS(socket, [socket])
AC_SEARCH_LIBS(inet_ntoa, [nsl])

619 620
AC_SEARCH_LIBS(inet_aton, [socket nsl], ,
	AC_DEFINE([NEED_INET_ATON], [1],
621 622
		  [Define to 1 if the inet_aton() function is missing.]))

623 624 625
# Check for a standalone regex library.
AC_SEARCH_LIBS(regcomp, [regex])

626 627
AC_CHECK_FUNCS(strlcat)

628 629 630
# For HP/UX we need -lipv6 for if_nametoindex, perhaps others.
AC_SEARCH_LIBS(if_nametoindex, [ipv6])

631 632 633 634 635 636 637 638 639 640
# For some Solaris nanosleep is found by BIND in librt
have_nanosleep="no"
AC_CHECK_FUNC(nanosleep, have_nanosleep="yes")
if test "$have_nanosleep" = "no"; then
	AC_CHECK_LIB(rt, nanosleep, have_nanosleep="rt")
fi
if test "$have_nanosleep" = "rt"; then
	LIBS="-lrt $LIBS"
fi

641
# check for /dev/random (declares HAVE_DEV_RANDOM)
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
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
671

Francis Dupont's avatar
Francis Dupont committed
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
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")
if test "$want_kqueue" = "yes"; then
	BINDIOMUX="--enable-kqueue"
	AC_MSG_WARN([--enable-kqueue is not supported: it may lead to issues such as server looping])
fi
AC_ARG_ENABLE(epoll,
	AS_HELP_STRING([--enable-epoll],[use Linux epoll (default is no)]),
	want_epoll="$enableval", want_epoll="no")
if test "$want_epoll" = "yes"; then
	BINDIOMUX="--enable-epoll"
	AC_MSG_WARN([--enable-epoll is not supported: it may lead to issues such as server looping])
fi
AC_ARG_ENABLE(devpoll,
	AS_HELP_STRING([--enable-devpoll],[use /dev/poll (default is no)]),
	want_devpoll="$enableval", want_devpoll="no")
if test "$want_devpoll" = "yes"; then
	BINDIOMUX="--enable-devpoll"
	AC_MSG_WARN([--enable-devpoll is not supported: it may lead to issues such as server looping])
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"
	AC_MSG_WARN([Most options to bind configure are not supported when used by ISC DHCP])
	;;
esac

711 712
# see if there is a "sa_len" field in our interface information structure
AC_CHECK_MEMBER(struct sockaddr.sa_len,
713
	AC_DEFINE([HAVE_SA_LEN], [],
714 715 716 717
		  [Define to 1 if the sockaddr structure has a length field.]),
	,
	[#include <sys/socket.h>])

718
# figure out pointer size
Francis Dupont's avatar
Francis Dupont committed
719 720
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$srcdir"
721 722 723 724
AC_CHECK_SIZEOF(struct iaddr *, , [
#include "includes/inet.h"
#include <stdio.h>
])
Francis Dupont's avatar
Francis Dupont committed
725
CFLAGS="$SAVE_CFLAGS"
726

727
# Solaris does not have the msg_control or msg_controlen members
Shane Kerr's avatar
Shane Kerr committed
728 729 730
# in the msghdr structure unless you define:
#
#   _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, and __EXTENSIONS__
731
#
Shane Kerr's avatar
Shane Kerr committed
732
# See the "standards" man page for details.
733
#
Shane Kerr's avatar
Shane Kerr committed
734 735 736 737 738 739 740 741 742
# 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,,
743
	 	[AC_MSG_ERROR([Missing msg_control member in
Shane Kerr's avatar
Shane Kerr committed
744
			       msg_control structure.])],
745 746 747 748 749 750 751 752 753
		[
#include <sys/types.h>
#include <sys/socket.h>
		])
	],
	[
#include <sys/types.h>
#include <sys/socket.h>
	])
Shane Kerr's avatar
Shane Kerr committed
754

755 756 757 758
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
759 760
# bind/Makefile.in is not from automake so we need 2 variables for bind dir
BINDSUBDIR=
Francis Dupont's avatar
Francis Dupont committed
761
BINDDIR=
762
BINDSRCDIR=
Francis Dupont's avatar
Francis Dupont committed
763 764 765 766
BINDLIBIRSDIR=
BINDLIBDNSDIR=
BINDLIBISCCFGDIR=
BINDLIBISCDIR=
767
DISTCHECK_LIBBIND_CONFIGURE_FLAG=
768
AC_ARG_WITH(libbind,
Francis Dupont's avatar
Francis Dupont committed
769
	AS_HELP_STRING([--with-libbind=PATH],[bind includes and libraries are in PATH]),
770
	use_libbind="$withval", use_libbind="no")
771
case "$use_libbind" in
772
yes)
Francis Dupont's avatar
Francis Dupont committed
773
	AC_MSG_ERROR([PATH is required in --with-libbind=PATH])
774 775
	;;
no)
Francis Dupont's avatar
Francis Dupont committed
776
	BINDSUBDIR="\${top_srcdir}/bind"
Francis Dupont's avatar
Francis Dupont committed
777
	my_abs_srcdir=`cd $srcdir && pwd`
Francis Dupont's avatar
Francis Dupont committed
778
	BINDDIR="${my_abs_srcdir}/bind"
Francis Dupont's avatar
Francis Dupont committed
779 780 781 782
	if test ! -d "$srcdir/bind"; then
		AC_MSG_ERROR([Where to find or build bind includes and libraries must be specified])
	fi
	if test -d "$srcdir/bind/bind9"; then
Francis Dupont's avatar
Francis Dupont committed
783
		BINDSRCDIR="${my_abs_srcdir}/bind/bind9"
Francis Dupont's avatar
Francis Dupont committed
784 785 786 787 788 789
	else
		if test ! -f "$srcdir/bind/version.tmp"; then
			AC_MSG_ERROR([Cannot find $srcdir/bind/version.tmp])
		fi
		. "$srcdir/bind/version.tmp"
		bindversion=${MAJORVER}.${MINORVER}.${PATCHVER}${RELEASETYPE}${RELEASEVER}
Francis Dupont's avatar
Francis Dupont committed
790
		BINDSRCDIR="${my_abs_srcdir}/bind/bind-$bindversion"
Francis Dupont's avatar
Francis Dupont committed
791 792
	fi
	AC_CONFIG_FILES([$srcdir/bind/Makefile])
Francis Dupont's avatar
Francis Dupont committed
793

Francis Dupont's avatar
Francis Dupont committed
794 795 796 797
	BINDLIBIRSDIR="$BINDSRCDIR/lib/irs"
	BINDLIBDNSDIR="$BINDSRCDIR/lib/dns"
	BINDLIBISCCFGDIR="$BINDSRCDIR/lib/isccfg"
	BINDLIBISCDIR="$BINDSRCDIR/lib/isc"
798 799
	;;
*)
Francis Dupont's avatar
Francis Dupont committed
800 801 802
	if test ! -d "$use_libbind"; then
		AC_MSG_ERROR([Cannot find bind directory at $use_libbind])
	fi
803 804 805
	if test ! -d "$use_libbind/include" -o \
	        ! -f "$use_libbind/include/isc/buffer.h"
	then
Francis Dupont's avatar
Francis Dupont committed
806
		AC_MSG_ERROR([Cannot find bind includes at $use_libbind/include])
Francis Dupont's avatar
Francis Dupont committed
807
	fi
808 809 810 811
	if test	! -d "$use_libbind/lib" -o \
	        \( ! -f "$use_libbind/lib/libisc.a" -a \
		   ! -f	"$use_libbind/lib/libisc.la" \)
	then
Francis Dupont's avatar
Francis Dupont committed
812 813 814
		AC_MSG_ERROR([Cannot find bind libraries at $use_libbind/lib])
	fi
	BINDDIR="$use_libbind"
Francis Dupont's avatar
Francis Dupont committed
815 816 817 818
	BINDLIBIRSDIR="$BINDDIR/lib"
	BINDLIBDNSDIR="$BINDDIR/lib"
	BINDLIBISCCFGDIR="$BINDDIR/lib"
	BINDLIBISCDIR="$BINDDIR/lib"	
819
	DISTCHECK_LIBBIND_CONFIGURE_FLAG="--with-libbind=$use_libbind"
820 821
	;;
esac
Francis Dupont's avatar
Francis Dupont committed
822
AC_SUBST(BINDSUBDIR)
Francis Dupont's avatar
Francis Dupont committed
823
AC_SUBST(BINDDIR)
824
AC_SUBST(BINDSRCDIR)
Francis Dupont's avatar
Francis Dupont committed
825 826 827 828
AC_SUBST(BINDLIBIRSDIR)
AC_SUBST(BINDLIBDNSDIR)
AC_SUBST(BINDLIBISCCFGDIR)
AC_SUBST(BINDLIBISCDIR)
829 830
AC_SUBST(DISTCHECK_LIBBIND_CONFIGURE_FLAG)
AM_CONDITIONAL(HAVE_BINDDIR, test "$use_libbind" = "no")
831

832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
#
# GNU libtool support
#
case "$build_os" in
	sunos*)
		# Just set the maximum command line length for sunos
		# as it otherwise takes a exceptionally long time to
		# work it out. Required for libtool.

		lt_cv_sys_max_cmd_len=4096
		;;
esac

want_libtool="no"

BINDLT=
848
DISTCHECK_LIBTOOL_CONFIGURE_FLAG=
849
AC_ARG_ENABLE(libtool,
850 851
	AS_HELP_STRING([--enable-libtool],
[use GNU libtool for dynamic shared libraries (default is no).]),
852
	want_libtool="$enableval")
853

854 855 856 857 858 859 860 861 862 863 864 865 866
if test "$use_libbind" != "no"; then
	if test "$want_libtool" = "yes" -a \
	        ! -f "$use_libbind/lib/libisc.la"
	then
		AC_MSG_ERROR([Cannot find dynamic libraries at $use_libbind/lib])
	fi
	if test "$want_libtool" = "no" -a \
	        ! -f "$use_libbind/lib/libisc.a"
	then
		AC_MSG_ERROR([Cannot find static libraries at $use_libbind/lib])
	fi
fi

867

868 869
if test "$want_libtool" = "yes"; then
	AC_MSG_WARN([legacy configure is used but libtool is enabled. Trying to recover...])
870
	# expand $ac_configure_args
871 872
	eval "set my_configure_args $ac_configure_args"
	shift
873
	cd $srcdir; exec ./config+lt "$@"
874 875
	AC_MSG_ERROR([Recovering failed])
fi
876 877

DHLIBS=LIBRARIES
878
A=a
879 880

AC_SUBST(DHLIBS)
881 882
AC_SUBST(A)
AC_SUBST(BINDLT)
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
AC_SUBST(DISTCHECK_LIBTOOL_CONFIGURE_FLAG)

# quoting in Makefile.am.in
Q=@
AC_SUBST(Q)

# install bind includes and libraries

want_install_bind="no"
if test "$want_libtool" = "yes"; then
	want_install_bind="yes"
fi
if test "$use_libbind" != "no"; then
	want_install_bind="no"
fi
Francis Dupont's avatar
Francis Dupont committed
898
AC_ARG_ENABLE(bind_install,
899 900
	AS_HELP_STRING([--enable-bind-install],
[install bind includes and libraries (default is no).]),
901 902 903 904 905 906 907
	want_install_bind="$enableval")
if test "$want_install_bind" = "yes"; then
        if test "$use_libbind" != "no"; then
		AC_MSG_WARN([--enable-bind-install does nothing when --with-libbind is set])
	fi
elif test "$want_libtool" = "yes" -a "$use_libbind" = "no"; then
	AC_MSG_WARN([embedded dynamic bind libraries must be installed])
Francis Dupont's avatar
Francis Dupont committed
908
fi
909
AM_CONDITIONAL(INSTALL_BIND, test "$want_install_bind" = "yes")
Francis Dupont's avatar
Francis Dupont committed
910

911 912
# OpenLDAP support.
AC_ARG_WITH(ldap,
Shawn Routhier's avatar
Shawn Routhier committed
913
    AS_HELP_STRING([--with-ldap],[enable OpenLDAP support in dhcpd (default is no)]),
914 915 916 917 918
    [ldap=$withval],
    [ldap=no])

# OpenLDAP with SSL support.
AC_ARG_WITH(ldapcrypto,
Shawn Routhier's avatar
Shawn Routhier committed
919
    AS_HELP_STRING([--with-ldapcrypto],[enable OpenLDAP crypto support in dhcpd (default is no)]),
920 921 922
    [ldapcrypto=$withval],
    [ldapcrypto=no])

923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
# 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])

938 939
# 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
940 941 942 943 944
# 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=""
945 946
    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
947 948
    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?]))
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969
    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
970 971

    if test x$ldapcrypto = xyes ; then
972
    LDAP_CFLAGS="$LDAP_CFLAGS -DLDAP_USE_SSL"
973
    fi
974 975 976 977 978 979

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

    AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
980 981
fi

982
# Append selected warning levels to CFLAGS before substitution (but after
Shawn Routhier's avatar
Shawn Routhier committed
983
# AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
984 985
CFLAGS="$CFLAGS $STD_CWARNINGS"

986 987
# Try to add the bind and dhcp include directories
CFLAGS="$CFLAGS -I\$(top_srcdir)/includes -I$BINDDIR/include"
988

989 990
case "$host" in
*-darwin*)
991 992 993 994 995 996 997
    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])])
    ;;
998 999
esac

1000 1001
AC_C_FLEXIBLE_ARRAY_MEMBER

Shawn Routhier's avatar
Shawn Routhier committed
1002
AC_CONFIG_FILES([
1003 1004
  Makefile
  client/Makefile
1005
  client/tests/Makefile
1006
  common/Makefile.am
1007
  common/Makefile
Shane Kerr's avatar
Shane Kerr committed
1008
  common/tests/Makefile
1009
  dhcpctl/Makefile.am
1010 1011
  dhcpctl/Makefile
  includes/Makefile
1012
  omapip/Makefile.am
1013 1014 1015
  omapip/Makefile
  relay/Makefile
  server/Makefile
1016
  tests/Makefile.am
Shane Kerr's avatar
Shane Kerr committed
1017
  tests/Makefile
1018
  tests/unittest.sh
1019
  server/tests/Makefile
1020
  doc/devel/doxyfile
1021
])
Shawn Routhier's avatar
Shawn Routhier committed
1022
AC_OUTPUT
1023

1024

1025 1026 1027 1028 1029 1030 1031 1032
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

1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
cat > config.report << END

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

Package:
  Name:          $PACKAGE_NAME
  Version:       $PACKAGE_VERSION

C Compiler:      $CC

Flags:
  DEFS:          $DEFS
  CFLAGS:        $CFLAGS

1048 1049
DHCP versions:   $DHCP_VERSIONS

1050 1051 1052 1053
Features:
  debug:         $enable_debug
  failover:      $enable_failover
  execute:       $enable_execute
1054
  binary-leases: $enable_binary_leases
1055 1056
  dhcpv6:        $enable_dhcpv6
  delayed-ack:   $enable_delayed_ack
1057
  dhcpv4o6:      $enable_dhcpv4o6
Francis Dupont's avatar
Francis Dupont committed
1058
  relay-port:    $enable_relay_port
1059 1060

Developer:
1061
  ATF unittests : $atf_path
1062 1063 1064 1065

END
# TODO: Add Perl system tests

1066
if test "$atf_path" != "no"
1067 1068 1069
then
echo "ATF_CFLAGS  : $ATF_CFLAGS" >> config.report
echo "ATF_LDFLAGS : $ATF_LDFLAGS" >> config.report
1070
echo "ATF_BIN : $ATF_BIN" >> config.report
1071 1072 1073 1074 1075 1076 1077 1078
echo
fi

cat config.report

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