]> git.proxmox.com Git - mirror_frr.git/blame - configure.ac
build: chop down complicated CFLAGS logic
[mirror_frr.git] / configure.ac
CommitLineData
7ea487bc 1##
e8f2984c 2## Configure template file for Quagga.
7ea487bc 3## autoconf will generate configure script.
4##
5## Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
e8f2984c 6## Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st>
7ea487bc 7##
9bc6875a 8AC_PREREQ(2.60)
7ea487bc 9
73ea75da 10AC_INIT(Quagga, 0.99.24+cl3u5, [https://bugzilla.quagga.net])
80db5ac1
DL
11CONFIG_ARGS="$*"
12AC_SUBST(CONFIG_ARGS)
fa1253d0 13AC_CONFIG_SRCDIR(lib/zebra.h)
62c9f504 14AC_CONFIG_MACRO_DIR([m4])
dfb9a545 15
16dnl -----------------------------------
17dnl Get hostname and other information.
18dnl -----------------------------------
19AC_CANONICAL_BUILD()
20AC_CANONICAL_HOST()
21AC_CANONICAL_TARGET()
22
f77cba1b
AS
23# Disable portability warnings -- our automake code (in particular
24# common.am) uses some constructs specific to gmake.
25AM_INIT_AUTOMAKE([1.6 -Wno-portability])
50cfc0d2 26m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
e54583ea 27AM_SILENT_RULES([yes])
303bb005 28AC_CONFIG_HEADERS(config.h)
7ea487bc 29
0be793e6 30AC_PATH_PROG(PERL, perl)
03ecfb67 31
d6b72f7a 32dnl default is to match previous behavior
c4f0efe6 33exampledir=${sysconfdir}
d6b72f7a 34AC_ARG_ENABLE([exampledir],
23925784 35 AS_HELP_STRING([--enable-exampledir],
d6b72f7a 36 [specify alternate directory for examples]),
37 exampledir="$enableval",)
c4f0efe6 38dnl XXX add --exampledir to autoconf standard directory list somehow
d6b72f7a 39AC_SUBST(exampledir)
40
cbd04084 41dnl default is to match previous behavior
42pkgsrcrcdir=""
43pkgsrcdir=""
44AC_ARG_ENABLE([pkgsrcrcdir],
23925784 45 AS_HELP_STRING([--enable-pkgsrcrcdir],
cbd04084 46 [specify directory for rc.d scripts]),
47 pkgsrcrcdir="$enableval"; pkgsrcdir="pkgsrc",)
48dnl XXX add --pkgsrcrcdir to autoconf standard directory list somehow
49AC_SUBST(pkgsrcdir)
50AC_SUBST(pkgsrcrcdir)
51
3f9c7369 52AC_ARG_ENABLE(tcmalloc,
428cd73f 53 AS_HELP_STRING([--enable-tcmalloc], [Turn on tcmalloc]),
3f9c7369
DS
54[case "${enableval}" in
55 yes) tcmalloc_enabled=true
56LIBS="$LIBS -ltcmalloc_minimal"
57 ;;
58 no) tcmalloc_enabled=false ;;
59 *) AC_MSG_ERROR(bad value ${enableval} for --enable-tcmalloc) ;;
60esac],[tcmalloc_enabled=false])
61
62
1969e4b9 63dnl --------------------
64dnl Check CC and friends
65dnl --------------------
a89b1641
DL
66dnl note orig_cflags is also used further down
67orig_cflags="$CFLAGS"
46bc0e43 68AC_LANG([C])
7ea487bc 69AC_PROG_CC
1969e4b9 70AC_PROG_CPP
46bc0e43 71AM_PROG_CC_C_O
a89b1641
DL
72dnl remove autoconf default "-g -O2"
73CFLAGS="$orig_cflags"
1769aff8 74AC_PROG_CC_C99
553bdfe3 75
a89b1641
DL
76AC_PROG_EGREP
77
553bdfe3
GT
78dnl autoconf 2.59 appears not to support AC_PROG_SED
79dnl AC_PROG_SED
80AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
1969e4b9 81
fa482834
PJ
82dnl pdflatex and latexmk are needed to build HACKING.pdf
83AC_CHECK_PROG([PDFLATEX],[pdflatex],[pdflatex],[/bin/false])
84AC_CHECK_PROG([LATEXMK],[latexmk],[latexmk],[/bin/false])
85if test "x$PDFLATEX" = "x/bin/false" -o "x$LATEXMK" = "x/bin/false"; then
86 AC_MSG_WARN([Will not be able to make PDF versions of TeX documents])
87else
88 HAVE_LATEX=true
89fi
90AM_CONDITIONAL([HAVE_LATEX], [test "x$HAVE_LATEX" = "xtrue"])
91
a89b1641
DL
92dnl try and enable CFLAGS that are useful for Quagga
93dnl - specifically, options to control warnings
1969e4b9 94
988225dd
DL
95AC_USE_SYSTEM_EXTENSIONS()
96AC_DEFUN([AC_C_FLAG], [{
97 AC_LANG_PUSH(C)
98 ac_c_flag_save="$CFLAGS"
99 CFLAGS="$CFLAGS $1"
100 AC_MSG_CHECKING([[whether $CC supports $1]])
101 AC_COMPILE_IFELSE(
102 [AC_LANG_PROGRAM([[]])],
103 [
104 AC_MSG_RESULT([yes])
105 m4_if([$3], [], [], [
106 CFLAGS="$ac_c_flag_save"
107 $3
108 ])
109 ], [
110 CFLAGS="$ac_c_flag_save"
111 AC_MSG_RESULT([no])
112 $2
113 ])
114 AC_LANG_POP(C)
115 }])
116
a89b1641
DL
117dnl ICC won't bail on unknown options without -diag-error 10006
118dnl need to do this first so we get useful results for the other options
119AC_C_FLAG([-diag-error 10006])
120
121dnl if the user specified any CFLAGS, we don't add "-g -Os/-O2" here
122if test "z$orig_cflags" = "z"; then
123 AC_C_FLAG([-g])
124 AC_C_FLAG([-Os], [
125 AC_C_FLAG([-O2])
126 ])
127fi
128
129dnl always want these CFLAGS
130AC_C_FLAG([-fno-omit-frame-pointer])
131AC_C_FLAG([-Wall])
132AC_C_FLAG([-Wextra])
133AC_C_FLAG([-Wmissing-prototypes])
134AC_C_FLAG([-Wmissing-declarations])
135AC_C_FLAG([-Wpointer-arith])
136AC_C_FLAG([-Wbad-function-cast])
137AC_C_FLAG([-Wwrite-strings])
138if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then
139 AC_C_FLAG([-Wcast-qual])
140 AC_C_FLAG([-Wstrict-prototypes])
141 AC_C_FLAG([-Wmissing-noreturn])
142 AC_C_FLAG([-Wmissing-format-attribute])
143 AC_C_FLAG([-Wunreachable-code])
144 AC_C_FLAG([-Wpacked])
145 AC_C_FLAG([-Wpadded])
6a4b8832 146else
a89b1641 147 AC_C_FLAG([-Wno-unused-result])
1969e4b9 148fi
a89b1641
DL
149AC_C_FLAG([-Wno-unused-parameter])
150AC_C_FLAG([-Wno-missing-field-initializers])
151
152dnl ICC emits a broken warning for const char *x = a ? "b" : "c";
153dnl for some reason the string consts get 'promoted' to char *,
154dnl triggering a const to non-const conversion warning.
155AC_C_FLAG([-diag-disable 3179])
1969e4b9 156
aa9584c1
DS
157if test x"${enable_werror}" = x"yes" ; then
158 WERROR="-Werror"
159fi
160AC_SUBST(WERROR)
161
2e83e8e9
DL
162dnl need link on this one, not compile
163AC_LANG_PUSH(C)
164ac_ld_flag_save="$LDFLAGS"
165LDFLAGS="$LDFLAGS -rdynamic"
166AC_MSG_CHECKING([[whether linker supports -rdynamic]])
167AC_LINK_IFELSE(
168 [AC_LANG_PROGRAM([[]])],
169 [AC_MSG_RESULT([yes])],
170 [
171 LDFLAGS="$ac_ld_flag_save"
172 AC_MSG_RESULT([no])
173 ])
174AC_LANG_POP(C)
175
7ea487bc 176dnl --------------
177dnl Check programs
178dnl --------------
7ea487bc 179AC_PROG_INSTALL
6f0e3f6e 180AC_PROG_LN_S
7ea487bc 181AC_PROG_MAKE_SET
182AC_CHECK_TOOL(AR, ar)
7ea487bc 183
105b8239
PJ
184dnl ---------------------------
185dnl We, perhaps unfortunately,
186dnl depend on GNU Make specific
187dnl constructs.
188dnl Give the user a warning if
189dnl not GNU Make.
190dnl ---------------------------
191AC_CACHE_CHECK([if ${MAKE-make} is GNU make], [quagga_cv_gnu_make],
192 [quagga_cv_gnu_make=no
193 if ${MAKE-make} --version 2>/dev/null | \
194 grep '^GNU Make ' >/dev/null ; then
195 quagga_cv_gnu_make=yes;
196 fi
197 ]
198)
199
d46d2a24
PJ
200dnl -----------------
201dnl System extensions
202dnl -----------------
d46d2a24 203AC_GNU_SOURCE
7ea487bc 204
87efd646 205dnl -------
206dnl libtool
207dnl -------
95bb8305 208LT_INIT
87efd646 209
7ea487bc 210dnl ----------------------
211dnl Packages configuration
212dnl ----------------------
1080c13f
JN
213AC_ARG_WITH(pkg-extra-version,
214 AS_HELP_STRING([--with-pkg-extra-version=VER], [add extra version field, for packagers/distributions]),
215 [EXTRAVERSION=$withval],)
0be793e6
DL
216AC_ARG_WITH(pkg-git-version,
217 AS_HELP_STRING([--with-pkg-git-version], [add git information to MOTD and build version string]),
a16dcf7c 218 [ test "x$withval" != "xno" && with_pkg_git_version="yes" ])
7ea487bc 219AC_ARG_ENABLE(vtysh,
23925784 220 AS_HELP_STRING([--disable-vtysh], [do not build integrated vty shell for Quagga]))
cbcd9bfc 221AC_ARG_ENABLE(doc,
23925784 222 AS_HELP_STRING([--disable-doc], [do not build docs]))
7ea487bc 223AC_ARG_ENABLE(zebra,
23925784 224 AS_HELP_STRING([--disable-zebra], [do not build zebra daemon]))
7ea487bc 225AC_ARG_ENABLE(bgpd,
23925784 226 AS_HELP_STRING([--disable-bgpd], [do not build bgpd]))
7ea487bc 227AC_ARG_ENABLE(ripd,
23925784 228 AS_HELP_STRING([--disable-ripd], [do not build ripd]))
7ea487bc 229AC_ARG_ENABLE(ripngd,
23925784 230 AS_HELP_STRING([--disable-ripngd], [do not build ripngd]))
7ea487bc 231AC_ARG_ENABLE(ospfd,
23925784 232 AS_HELP_STRING([--disable-ospfd], [do not build ospfd]))
7ea487bc 233AC_ARG_ENABLE(ospf6d,
23925784 234 AS_HELP_STRING([--disable-ospf6d], [do not build ospf6d]))
eac6e3f0
RW
235AC_ARG_ENABLE(ldpd,
236 AS_HELP_STRING([--enable-ldpd], [build ldpd]))
d0199430 237AC_ARG_ENABLE(watchquagga,
23925784 238 AS_HELP_STRING([--disable-watchquagga], [do not build watchquagga]))
9e867fe6 239AC_ARG_ENABLE(isisd,
c3a9461e 240 AS_HELP_STRING([--disable-isisd], [do not build isisd]))
12e41d03 241AC_ARG_ENABLE(pimd,
23925784 242 AS_HELP_STRING([--disable-pimd], [do not build pimd]))
7ea487bc 243AC_ARG_ENABLE(bgp-announce,
23925784 244 AS_HELP_STRING([--disable-bgp-announce,], [turn off BGP route announcement]))
65efcfce 245AC_ARG_ENABLE(bgp-vnc,
f95f2ad9 246 AS_HELP_STRING([--disable-bgp-vnc],[turn off BGP VNC support]))
65efcfce
LB
247AC_ARG_WITH(rfp-path,
248 AS_HELP_STRING([--with-rfp-path[=DIR]],[path to replaced stub RFP used with BGP VNC]))
7ea487bc 249AC_ARG_ENABLE(snmp,
23925784 250 AS_HELP_STRING([--enable-snmp=ARG], [enable SNMP support (smux or agentx)]))
7ea487bc 251AC_ARG_WITH(libpam,
23925784 252 AS_HELP_STRING([--with-libpam], [use libpam for PAM support in vtysh]))
71c0fb50 253AC_ARG_ENABLE(tcp-zebra,
23925784 254 AS_HELP_STRING([--enable-tcp-zebra], [enable TCP/IP socket connection between zebra and protocol daemon]))
1ef74ef7 255AC_ARG_ENABLE(ospfapi,
23925784 256 AS_HELP_STRING([--disable-ospfapi], [do not build OSPFAPI to access the OSPF LSA Database]))
1ef74ef7 257AC_ARG_ENABLE(ospfclient,
23925784
DL
258 AS_HELP_STRING([--disable-ospfclient], [do not build OSPFAPI client for OSPFAPI,
259 (this is the default if --disable-ospfapi is set)]))
7ea487bc 260AC_ARG_ENABLE(multipath,
23925784 261 AS_HELP_STRING([--enable-multipath=ARG], [enable multipath function, ARG must be digit]))
fe86b484 262AC_ARG_ENABLE(user,
23925784 263 AS_HELP_STRING([--enable-user=USER], [user to run Quagga suite as (default quagga)]))
fe86b484 264AC_ARG_ENABLE(group,
23925784 265 AS_HELP_STRING([--enable-group=GROUP], [group to run Quagga suite as (default quagga)]))
edd7c245 266AC_ARG_ENABLE(vty_group,
23925784 267 AS_HELP_STRING([--enable-vty-group=ARG], [set vty sockets to have specified group as owner]))
aa593d5e 268AC_ARG_ENABLE(configfile_mask,
23925784 269 AS_HELP_STRING([--enable-configfile-mask=ARG], [set mask for config files]))
aa593d5e 270AC_ARG_ENABLE(logfile_mask,
23925784 271 AS_HELP_STRING([--enable-logfile-mask=ARG], [set mask for log files]))
5fd1f747 272AC_ARG_ENABLE(shell_access,
23925784 273 AS_HELP_STRING([--enable-shell-access], [Allow users to access shell/telnet/ssh]))
71c0fb50 274AC_ARG_ENABLE(rtadv,
23925784 275 AS_HELP_STRING([--disable-rtadv], [disable IPV6 router advertisement feature]))
ca776988 276AC_ARG_ENABLE(irdp,
23925784 277 AS_HELP_STRING([--enable-irdp], [enable IRDP server support in zebra]))
41d3fc96 278AC_ARG_ENABLE(capabilities,
23925784 279 AS_HELP_STRING([--disable-capabilities], [disable using POSIX capabilities]))
47f6aef0 280AC_ARG_ENABLE(rusage,
23925784 281 AS_HELP_STRING([--disable-rusage], [disable using getrusage]))
6b6942f9 282AC_ARG_ENABLE(gcc_ultra_verbose,
23925784 283 AS_HELP_STRING([--enable-gcc-ultra-verbose], [enable ultra verbose GCC warnings]))
3453a712 284AC_ARG_ENABLE(linux24_tcp_md5,
23925784 285 AS_HELP_STRING([--enable-linux24-tcp-md5], [enable support for old, Linux-2.4 RFC2385 patch]))
8c99b4c1 286AC_ARG_ENABLE(backtrace,
23925784 287 AS_HELP_STRING([--disable-backtrace,], [disable crash backtraces (default autodetect)]))
924b9229 288AC_ARG_ENABLE(time-check,
23925784 289 AS_HELP_STRING([--disable-time-check], [disable slow thread warning messages]))
25f45887 290AC_ARG_ENABLE(pcreposix,
23925784 291 AS_HELP_STRING([--enable-pcreposix], [enable using PCRE Posix libs for regex functions]))
5adc2528 292AC_ARG_ENABLE(fpm,
23925784 293 AS_HELP_STRING([--enable-fpm], [enable Forwarding Plane Manager support]))
ddd82ff6 294AC_ARG_ENABLE(systemd,
23925784 295 AS_HELP_STRING([--enable-systemd], [enable Systemd support]))
0a95a0d0 296AC_ARG_ENABLE(poll,
23925784 297 AS_HELP_STRING([--enable-poll], [enable usage of Poll instead of select]))
aa9584c1
DS
298AC_ARG_ENABLE(werror,
299 AS_HELP_STRING([--enable-werror], [enable -Werror (recommended for developers only)]))
000cf1fb 300AC_ARG_ENABLE(cumulus,
23925784 301 AS_HELP_STRING([--enable-cumulus], [enable Cumulus Switch Special Extensions]))
76981cd3
DS
302AC_ARG_ENABLE(rr-semantics,
303 AS_HELP_STRING([--disable-rr-semantics], [disable the v6 Route Replace semantics]))
dad253b4
AS
304AC_ARG_ENABLE([protobuf],
305 AS_HELP_STRING([--enable-protobuf], [Enable experimental protobuf support]))
6b6942f9 306
112072ac
DS
307AC_CHECK_HEADERS(json-c/json.h)
308AC_CHECK_LIB(json-c, json_object_get, LIBS="$LIBS -ljson-c")
309if test $ac_cv_lib_json_c_json_object_get = no; then
10b8ab26
DS
310 AC_CHECK_LIB(json, json_object_get, LIBS="$LIBS -ljson")
311 if test $ac_cv_lib_json_json_object_get = no; then
312 AC_MSG_ERROR([lib json is needed to compile])
313 fi
c2f4c19c
DS
314fi
315
3b8282a8
AS
316AC_ARG_ENABLE([dev_build],
317 AS_HELP_STRING([--enable-dev-build], [build for development]))
318
924b9229 319if test x"${enable_time_check}" != x"no" ; then
320 if test x"${enable_time_check}" = x"yes" -o x"${enable_time_check}" = x ; then
321 AC_DEFINE(CONSUMED_TIME_CHECK,5000000,Consumed Time Check)
322 else
323 AC_DEFINE_UNQUOTED(CONSUMED_TIME_CHECK,$enable_time_check,Consumed Time Check)
324 fi
325fi
326
37219958
DS
327case "${enable_systemd}" in
328 "no") ;;
329 "yes")
330 AC_CHECK_LIB(systemd, sd_notify, LIBS="$LIBS -lsystemd")
331 if test $ac_cv_lib_systemd_sd_notify = no; then
332 AC_MSG_ERROR([enable systemd has been specified but systemd development env not found on your system])
63e30864
DS
333 else
334 AC_DEFINE(HAVE_SYSTEMD,,Compile systemd support in)
37219958
DS
335 fi
336 ;;
337 "*") ;;
338esac
ddd82ff6 339
76981cd3
DS
340if test "${enable_rr_semantics}" != "no" ; then
341 AC_DEFINE(HAVE_V6_RR_SEMANTICS,, Compile in v6 Route Replacement Semantics)
342fi
343
0a95a0d0
DS
344if test "${enable_poll}" = "yes" ; then
345 AC_DEFINE(HAVE_POLL,,Compile systemd support in)
346fi
347
be0dba35
RW
348dnl ----------
349dnl MPLS check
350dnl ----------
be0dba35 351AC_MSG_CHECKING(whether this OS has MPLS stack)
fe6c7157
RW
352case "$host" in
353 *-linux*)
354 MPLS_METHOD="zebra_mpls_netlink.o"
355 AC_MSG_RESULT(Linux MPLS)
356 ;;
357 *-openbsd*)
358 MPLS_METHOD="zebra_mpls_openbsd.o"
359 AC_MSG_RESULT(OpenBSD MPLS)
360 ;;
361 *)
362 MPLS_METHOD="zebra_mpls_null.o"
363 AC_MSG_RESULT(Unsupported kernel)
364 ;;
365esac
be0dba35
RW
366AC_SUBST(MPLS_METHOD)
367
000cf1fb
DS
368if test "${enable_cumulus}" = "yes" ; then
369 AC_DEFINE(HAVE_CUMULUS,,Compile Special Cumulus Code in)
370fi
371
576b6b5d
DS
372if test "${enable_shell_access}" = "yes"; then
373 AC_DEFINE(HAVE_SHELL_ACCESS,,Allow user to use ssh/telnet/bash)
374fi
375
5adc2528
AS
376if test "${enable_fpm}" = "yes"; then
377 AC_DEFINE(HAVE_FPM,,Forwarding Plane Manager support)
378fi
379
3b8282a8
AS
380if test "x${enable_dev_build}" = "xyes"; then
381 AC_DEFINE(DEV_BUILD,,Build for development)
382fi
383AM_CONDITIONAL([DEV_BUILD], [test "x$enable_dev_build" = "xyes"])
384
dad253b4
AS
385#
386# Logic for protobuf support.
387#
388if test "$enable_protobuf" = "yes"; then
389 have_protobuf=yes
390
391 # Check for protoc-c
392 AC_CHECK_PROG([PROTOC_C], [protoc-c], [protoc-c], [/bin/false])
393 if test "x$PROTOC_C" = "x/bin/false"; then
394 have_protobuf=no
395 else
396 found_protobuf_c=no
397 PKG_CHECK_MODULES([PROTOBUF_C], libprotobuf-c >= 0.14,
398 [found_protobuf_c=yes],
399 [AC_MSG_RESULT([pkg-config did not find libprotobuf-c])])
400
401 if test "x$found_protobuf_c" = "xyes"; then
402 LDFLAGS="$LDFLAGS $PROTOBUF_C_LIBS"
403 CFLAGS="$CFLAGS $PROTOBUF_C_CFLAGS"
404 else
405 AC_CHECK_HEADER([google/protobuf-c/protobuf-c.h], [],
406 [have_protobuf=no; AC_MSG_RESULT([Couldn't find google/protobuf-c.h])])
407 fi
408 fi
409fi
410
411# Fail if the user explicity enabled protobuf support and we couldn't
412# find the compiler or libraries.
413if test "x$have_protobuf" = "xno" && test "x$enable_protobuf" = "xyes"; then
414 AC_MSG_ERROR([Protobuf enabled explicitly but can't find libraries/tools])
415fi
416
417if test "x$have_protobuf" = "xyes"; then
418 AC_DEFINE(HAVE_PROTOBUF,, protobuf)
419fi
420
421AM_CONDITIONAL([HAVE_PROTOBUF], [test "x$have_protobuf" = "xyes"])
422
423#
424# End of logic for protobuf support.
425#
426
7ea487bc 427if test "${enable_tcp_zebra}" = "yes"; then
428 AC_DEFINE(HAVE_TCP_ZEBRA,,Use TCP for zebra communication)
429fi
430
3453a712
PJ
431if test "${enable_linux24_tcp_md5}" = "yes"; then
432 AC_DEFINE(HAVE_TCP_MD5_LINUX24,,Old Linux 2.4 TCP MD5 Signature Patch)
433fi
434
d2a0ccc6 435AC_MSG_CHECKING(if zebra should be configurable to send Route Advertisements)
436if test "${enable_rtadv}" != "no"; then
71c0fb50 437 AC_MSG_RESULT(yes)
d2a0ccc6 438 AC_DEFINE(HAVE_RTADV,,Enable IPv6 Routing Advertisement support)
2487bea1 439else
440 AC_MSG_RESULT(no)
71c0fb50 441fi
7ea487bc 442
ca776988 443if test "${enable_irdp}" = "yes"; then
444 AC_DEFINE(HAVE_IRDP,, IRDP )
445fi
446
0b02a1b4
JAG
447if test x"${enable_user}" = x"no"; then
448 enable_user=""
449else
450 if test x"${enable_user}" = x"yes" || test x"${enable_user}" = x""; then
451 enable_user="quagga"
452 fi
453 AC_DEFINE_UNQUOTED(QUAGGA_USER, "${enable_user}", Quagga User)
edd7c245 454fi
edd7c245 455
0b02a1b4
JAG
456if test x"${enable_group}" = x"no"; then
457 enable_group=""
458else
459 if test x"${enable_group}" = x"yes" || test x"${enable_group}" = x""; then
460 enable_group="quagga"
461 fi
462 AC_DEFINE_UNQUOTED(QUAGGA_GROUP, "${enable_group}", Quagga Group)
edd7c245 463fi
edd7c245 464
465if test x"${enable_vty_group}" = x"yes" ; then
8d4aee5d 466 AC_MSG_ERROR([--enable-vty-group requires a group as argument, not yes])
79cb2169 467elif test x"${enable_vty_group}" != x""; then
8d4aee5d 468 if test x"${enable_vty_group}" != x"no"; then
edd7c245 469 AC_DEFINE_UNQUOTED(VTY_GROUP, "${enable_vty_group}", VTY Sockets Group)
470 fi
471fi
26275b05 472AC_SUBST([enable_user])
473AC_SUBST([enable_group])
474AC_SUBST([enable_vty_group])
edd7c245 475
aa593d5e 476enable_configfile_mask=${enable_configfile_mask:-0600}
477AC_DEFINE_UNQUOTED(CONFIGFILE_MASK, ${enable_configfile_mask}, Mask for config files)
478
479enable_logfile_mask=${enable_logfile_mask:-0600}
480AC_DEFINE_UNQUOTED(LOGFILE_MASK, ${enable_logfile_mask}, Mask for log files)
481
7a6da5ba 482MPATH_NUM=1
7ea487bc 483
484case "${enable_multipath}" in
7c5d2b76 485 0)
7a6da5ba 486 MPATH_NUM=64
7c5d2b76 487 ;;
90fb3e13 488 [[1-9]|[1-9][0-9]|[1-9][0-9][0-9]])
7a6da5ba 489 MPATH_NUM="${enable_multipath}"
7ea487bc 490 ;;
491 "")
492 ;;
493 *)
6f0e3f6e 494 AC_MSG_FAILURE([Please specify digit to enable multipath ARG])
7ea487bc 495 ;;
496esac
497
7a6da5ba 498AC_DEFINE_UNQUOTED(MULTIPATH_NUM, $MPATH_NUM, Maximum number of paths for a route)
7ea487bc 499
1080c13f
JN
500dnl -----------------------------------
501dnl Add extra version string to package
502dnl name, string and version fields.
503dnl -----------------------------------
504if test "x${EXTRAVERSION}" != "x" ; then
0be793e6
DL
505 VERSION="${VERSION}${EXTRAVERSION}"
506 PACKAGE_VERSION="${PACKAGE_VERSION}${EXTRAVERSION}"
507 PACKAGE_STRING="${PACKAGE_STRING}${EXTRAVERSION}"
1080c13f
JN
508fi
509
a16dcf7c
DL
510if test "x$with_pkg_git_version" = "xyes"; then
511 if test -d "${srcdir}/.git"; then
512 AC_DEFINE(GIT_VERSION, [1], [include git version info])
513 else with_pkg_git_version="no"
514 AC_MSG_WARN([--with-pkg-git-version given, but this is not a git checkout])
515 fi
516fi
517AM_CONDITIONAL([GIT_VERSION], [test "x$with_pkg_git_version" = "xyes"])
0be793e6 518
6f0e3f6e
PJ
519dnl ------------------------------------
520dnl Check C keywords and standard types
521dnl ------------------------------------
522AC_C_CONST
523AC_C_INLINE
524AC_C_RESTRICT
525AC_C_VOLATILE
dc7a2bf1 526AC_HEADER_STDC
6f0e3f6e
PJ
527AC_HEADER_TIME
528AC_HEADER_SYS_WAIT
63a13864 529AC_HEADER_STDBOOL
6f0e3f6e
PJ
530dnl AC_TYPE_PID_T
531AC_TYPE_UID_T
532AC_TYPE_MODE_T
533AC_TYPE_SIZE_T
6f0e3f6e 534AC_STRUCT_TM
dc7a2bf1 535
6f0e3f6e
PJ
536dnl -------------------------
537dnl Check other header files.
538dnl -------------------------
539AC_CHECK_HEADERS([stropts.h sys/ksym.h sys/times.h sys/select.h \
540 sys/types.h linux/version.h netdb.h asm/types.h \
16ffb26f 541 sys/cdefs.h sys/param.h limits.h signal.h \
6511cab2 542 sys/socket.h netinet/in.h time.h sys/time.h])
6f0e3f6e
PJ
543
544dnl Utility macro to avoid retyping includes all the time
545m4_define([QUAGGA_INCLUDES],
546[#ifdef SUNOS_5
547#define _XPG4_2
548#define __EXTENSIONS__
549#endif
550#include <stdio.h>
551#if STDC_HEADERS
552# include <stdlib.h>
553# include <stddef.h>
554#else
555# if HAVE_STDLIB_H
556# include <stdlib.h>
557# endif
558#endif
559#if HAVE_SYS_TYPES_H
560# include <sys/types.h>
561#endif
562/* sys/conf.h depends on param.h on FBSD at least */
563#if HAVE_SYS_PARAM_H
564# include <sys/param.h>
565#endif
566/* Required for MAXSIG */
567#if HAVE_SIGNAL_H
568# include <signal.h>
569#endif
570#if HAVE_SYS_SOCKET_H
571# include <sys/socket.h>
572#endif
ea057677
HT
573#ifdef __APPLE__
574# define __APPLE_USE_RFC_3542
575#endif
6f0e3f6e
PJ
576#if HAVE_NETINET_IN_H
577# include <netinet/in.h>
578#endif
6511cab2
PJ
579#ifdef TIME_WITH_SYS_TIME
580# include <sys/time.h>
581# include <time.h>
582#else
583# ifdef HAVE_SYS_TIME_H
584# include <sys/time.h>
585# else
586# include <time.h>
587# endif
588#endif /* TIME_WITH_SYS_TIME */
6f0e3f6e
PJ
589])dnl
590
2b43bf23
DO
591dnl HAVE_NET_IF_H must be discovered by the time the longer AC_CHECK_HEADERS
592dnl round below execution begins, otherwise it doesn't properly detect
593dnl HAVE_NETINET6_IN6_VAR_H, HAVE_NET_IF_VAR_H and HAVE_STRUCT_IN6_ALIASREQ
594dnl on FreeBSD (BZ#408).
595
596AC_CHECK_HEADERS([net/if.h], [], [], QUAGGA_INCLUDES)
597
598m4_define([QUAGGA_INCLUDES],
599QUAGGA_INCLUDES
600[#if HAVE_NET_IF_H
601# include <net/if.h>
602#endif
603])dnl
604
605dnl Same applies for HAVE_NET_IF_VAR_H, which HAVE_NETINET6_ND6_H and
606dnl HAVE_NETINET_IN_VAR_H depend upon. But if_var.h depends on if.h, hence
607dnl an additional round for it.
608
609AC_CHECK_HEADERS([net/if_var.h], [], [], QUAGGA_INCLUDES)
610
611m4_define([QUAGGA_INCLUDES],
612QUAGGA_INCLUDES
613[#if HAVE_NET_IF_VAR_H
614# include <net/if_var.h>
615#endif
616])dnl
617
618AC_CHECK_HEADERS([sys/un.h netinet/in_systm.h netinet/in_var.h \
619 net/if_dl.h net/netopt.h net/route.h \
11770e10 620 inet/nd.h arpa/inet.h netinet/ip_icmp.h \
6f0e3f6e
PJ
621 fcntl.h stddef.h sys/ioctl.h syslog.h wchar.h wctype.h \
622 sys/sysctl.h sys/sockio.h kvm.h sys/conf.h],
623 [], [], QUAGGA_INCLUDES)
624
625AC_CHECK_HEADERS([ucontext.h], [], [],
626[#ifndef __USE_GNU
627#define __USE_GNU
628#endif /* __USE_GNU */
629QUAGGA_INCLUDES
630])
631
bccbd141
JT
632m4_define([UCONTEXT_INCLUDES],
633[#include <ucontext.h>])dnl
634
635AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.uc_regs],
636 [], [], [UCONTEXT_INCLUDES])
637AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.regs],
638 [AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.regs.nip],
639 [], [], [UCONTEXT_INCLUDES])],
640 [], [UCONTEXT_INCLUDES])
641AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.gregs],
642 [], [], [UCONTEXT_INCLUDES])
643
6f0e3f6e
PJ
644m4_define([QUAGGA_INCLUDES],
645QUAGGA_INCLUDES
2b43bf23 646[#if HAVE_SYS_UN_H
6f0e3f6e
PJ
647# include <sys/un.h>
648#endif
649#if HAVE_NETINET_IN_SYSTM_H
650# include <netinet/in_systm.h>
651#endif
652#if HAVE_NETINET_IN_VAR_H
653# include <netinet/in_var.h>
654#endif
655#if HAVE_NET_IF_DL_H
656# include <net/if_dl.h>
657#endif
6f0e3f6e
PJ
658#if HAVE_NET_NETOPT_H
659# include <net/netopt.h>
660#endif
661#if HAVE_NET_ROUTE_H
662# include <net/route.h>
663#endif
664#if HAVE_INET_ND_H
665# include <inet/nd.h>
666#endif
667#if HAVE_ARPA_INET_H
668# include <arpa/inet.h>
669#endif
11770e10
PJ
670/* Required for IDRP */
671#if HAVE_NETINET_IP_ICMP_H
672# include <netinet/ip_icmp.h>
673#endif
6f0e3f6e 674])dnl
dc7a2bf1 675
fa3232e1 676dnl V6 headers are checked below, after we check for v6
7ea487bc 677
7ea487bc 678dnl Some systems (Solaris 2.x) require libnsl (Network Services Library)
679case "$host" in
afd8a129 680 [*-sunos5.[6-7]*] | [*-solaris2.[6-7]*])
7ea487bc 681 opsys=sol2-6
afd8a129 682 AC_DEFINE(SUNOS_56, 1, SunOS 5.6 to 5.7)
19877dd2 683 AC_DEFINE(SUNOS_5, 1, SunOS 5)
7ea487bc 684 AC_CHECK_LIB(xnet, main)
685 CURSES=-lcurses
a77d2023 686 SOLARIS="solaris"
7ea487bc 687 ;;
1b73de8b 688 [*-sunos5.[8-9]] \
689 | [*-sunos5.1[0-9]] \
690 | [*-sunos5.1[0-9].[0-9]] \
691 | [*-solaris2.[8-9]] \
692 | [*-solaris2.1[0-9]] \
693 | [*-solaris2.1[0-9].[0-9]])
afd8a129 694 opsys=sol8
fb66b29c
PJ
695 AC_DEFINE(SUNOS_59, 1, [SunOS 5.8 up])
696 AC_DEFINE(SUNOS_5, 1, [SunOS 5])
19877dd2 697 AC_CHECK_LIB(socket, main)
698 AC_CHECK_LIB(nsl, main)
1b73de8b 699 AC_CHECK_LIB(umem, main)
fb66b29c
PJ
700 AC_CHECK_FUNCS([printstack],
701 [AC_DEFINE([HAVE_PRINTSTACK],1,[Solaris printstack])
702 AC_DEFINE([HAVE_STACK_TRACE],1,[Stack symbols decode functionality])
703 ])
19877dd2 704 CURSES=-lcurses
a77d2023 705 SOLARIS="solaris"
19877dd2 706 ;;
7ea487bc 707 *-sunos5* | *-solaris2*)
19877dd2 708 AC_DEFINE(SUNOS_5,,SunOS 5, Unknown SunOS)
7ea487bc 709 AC_CHECK_LIB(socket, main)
710 AC_CHECK_LIB(nsl, main)
711 CURSES=-lcurses
a77d2023 712 SOLARIS="solaris"
7ea487bc 713 ;;
c45eb839 714 *-linux*)
7ea487bc 715 opsys=gnu-linux
716 AC_DEFINE(GNU_LINUX,,GNU Linux)
717 ;;
7ea487bc 718 *-openbsd*)
719 opsys=openbsd
720 AC_DEFINE(OPEN_BSD,,OpenBSD)
721 ;;
7ea487bc 722esac
723
62c9f504
PJ
724AC_SYS_LARGEFILE
725
7ea487bc 726dnl ---------------------
727dnl Integrated VTY option
728dnl ---------------------
729case "${enable_vtysh}" in
f0646db0
DS
730 "no") VTYSH="";;
731 *) VTYSH="vtysh";
7ea487bc 732 AC_DEFINE(VTYSH,,VTY shell)
fc9d0745 733dnl Vtysh uses libreadline, which looks for termcap functions at
6f0e3f6e 734dnl configure time. We follow readlines search order.
fc9d0745 735dnl The required procedures are in libtermcap on NetBSD, in
736dnl [TODO] on Linux, and in [TODO] on Solaris.
c0689394 737 AC_CHECK_LIB(termcap, tputs, LIBREADLINE="$LIBREADLINE -ltermcap",
a969459c 738 [AC_CHECK_LIB(tinfo, tputs, LIBREADLINE="$LIBREADLINE -ltinfo",
739 [AC_CHECK_LIB(curses, tputs, LIBREADLINE="$LIBREADLINE -lcurses",
740 [AC_CHECK_LIB(ncurses, tputs,
741 LIBREADLINE="$LIBREADLINE -lncurses")]
742 )]
743 )]
744 )
4c2f8e95 745 AC_CHECK_LIB(readline, main, LIBREADLINE="-lreadline $LIBREADLINE",,
a969459c 746 "$LIBREADLINE")
7ea487bc 747 if test $ac_cv_lib_readline_main = no; then
fc9d0745 748 AC_MSG_ERROR([vtysh needs libreadline but was not found and usable on your system.])
7ea487bc 749 fi
750 AC_CHECK_HEADER(readline/history.h)
751 if test $ac_cv_header_readline_history_h = no;then
752 AC_MSG_ERROR([readline is too old to have readline/history.h, please update to the latest readline library.])
753 fi
a969459c 754 AC_CHECK_LIB(readline, rl_completion_matches,
755 LIBREADLINE="$LIBREADLINE",, "$LIBREADLINE")
3d3de8c4 756 if test $ac_cv_lib_readline_rl_completion_matches = no; then
757 AC_DEFINE(rl_completion_matches,completion_matches,Old readline)
758 fi
759 ;;
7ea487bc 760esac
c0689394 761AC_SUBST(LIBREADLINE)
f027d331 762AM_CONDITIONAL(VTYSH, test "x$VTYSH" = "xvtysh")
7ea487bc 763
764dnl ----------
765dnl PAM module
6159928d
DO
766dnl
767dnl Quagga detects the PAM library it is built against by checking for a
768dnl functional pam_misc.h (Linux-PAM) or openpam.h (OpenPAM) header. pam_misc.h
769dnl is known to #include pam_appl.h, the standard header of a PAM library, and
770dnl openpam.h doesn't do that, although depends on the header too. Hence a
771dnl little assistance to AC_CHECK_HEADER is necessary for the proper detection
772dnl of OpenPAM.
7ea487bc 773dnl ----------
24cd435b 774if test "$with_libpam" = "yes"; then
6f0e3f6e
PJ
775 AC_CHECK_HEADER([security/pam_misc.h],
776 [AC_DEFINE(HAVE_PAM_MISC_H,,Have pam_misc.h)
777 AC_DEFINE(PAM_CONV_FUNC,misc_conv,Have misc_conv)
778 pam_conv_func="misc_conv"
779 ],
780 [], QUAGGA_INCLUDES)
781 AC_CHECK_HEADER([security/openpam.h],
782 [AC_DEFINE(HAVE_OPENPAM_H,,Have openpam.h)
783 AC_DEFINE(PAM_CONV_FUNC,openpam_ttyconv,Have openpam_ttyconv)
784 pam_conv_func="openpam_ttyconv"
785 ],
6159928d 786 [], QUAGGA_INCLUDES[#include <security/pam_appl.h>])
24cd435b 787 if test -z "$ac_cv_header_security_pam_misc_h$ac_cv_header_security_openpam_h" ; then
788 AC_MSG_WARN([*** pam support will not be built ***])
789 with_libpam="no"
790 fi
791fi
792
7ea487bc 793if test "$with_libpam" = "yes"; then
6f0e3f6e 794dnl took this test from proftpds configure.in and suited to our needs
7ea487bc 795dnl -------------------------------------------------------------------------
796dnl
797dnl This next check looks funky due to a linker problem with some versions
798dnl of the PAM library. Prior to 0.72 release, the Linux PAM shared library
799dnl omitted requiring libdl linking information. PAM-0.72 or better ships
800dnl with RedHat 6.2 and Debian 2.2 or better.
801AC_CHECK_LIB(pam, pam_start,
24cd435b 802 [AC_CHECK_LIB(pam, $pam_conv_func,
7ea487bc 803 [AC_DEFINE(USE_PAM,,Use PAM for authentication)
804 LIBPAM="-lpam"],
805 [AC_DEFINE(USE_PAM,,Use PAM for authentication)
806 LIBPAM="-lpam -lpam_misc"]
807 )
808 ],
809
810 [AC_CHECK_LIB(pam, pam_end,
24cd435b 811 [AC_CHECK_LIB(pam, $pam_conv_func,
a159ed93 812 [AC_DEFINE(USE_PAM,,Use PAM for authentication)
7ea487bc 813 LIBPAM="-lpam -ldl"],
a159ed93 814 [AC_DEFINE(USE_PAM,,Use PAM for authentication)
7ea487bc 815 LIBPAM="-lpam -ldl -lpam_misc"]
816 )
817 ],AC_MSG_WARN([*** pam support will not be built ***]),
818 [-ldl])
819 ]
820)
821fi
822AC_SUBST(LIBPAM)
823
824dnl -------------------------------
825dnl Endian-ness check
826dnl -------------------------------
827AC_WORDS_BIGENDIAN
828
829dnl -------------------------------
830dnl check the size in byte of the C
831dnl -------------------------------
832dnl AC_CHECK_SIZEOF(char)
833dnl AC_CHECK_SIZEOF(int)
834dnl AC_CHECK_SIZEOF(short)
835dnl AC_CHECK_SIZEOF(long)
836
837dnl ----------------------------
838dnl check existance of functions
839dnl ----------------------------
6f0e3f6e
PJ
840AC_FUNC_CHOWN
841AC_FUNC_FNMATCH
842AC_FUNC_FORK
6f0e3f6e
PJ
843AC_FUNC_MEMCMP
844AC_FUNC_MKTIME
845AC_FUNC_STRFTIME
6f0e3f6e
PJ
846AC_FUNC_STAT
847AC_FUNC_SELECT_ARGTYPES
848AC_FUNC_STRFTIME
d46d2a24
PJ
849dnl Avoid AC_FUNC_STRNLEN because it pulls in AC_SYSTEM_EXTENSIONS which
850dnl can lead to strange side effects. So we just check for strnlen
851dnl directly, see below.
2b5cb411 852dnl AC_FUNC_STRNLENdnl
6f0e3f6e
PJ
853AC_FUNC_VPRINTF
854
855dnl -------------------------------
856dnl bgpd needs pow() and hence libm
857dnl -------------------------------
858TMPLIBS="$LIBS"
859AC_CHECK_HEADER([math.h],
860 [AC_CHECK_LIB([m], [pow],
861 [LIBM="-lm"
862 LIBS="$LIBS $LIBM"
863 AC_DEFINE(HAVE_LIBM,, Have libm)
864 AC_CHECK_FUNCS(pow,[],[LIBM=""])
865 ])
866])
867if test x"$LIBM" = x ; then
868 AC_MSG_WARN([Unable to find working pow function - bgpd may not link])
869fi
870LIBS="$TMPLIBS"
871AC_SUBST(LIBM)
872
873dnl ---------------
874dnl other functions
875dnl ---------------
876AC_CHECK_FUNCS([dup2 ftruncate getcwd gethostbyname getpagesize gettimeofday \
d46d2a24 877 inet_ntoa inet_aton strnlen \
6f0e3f6e
PJ
878 memchr memmove memset select socket \
879 strcasecmp strchr strcspn strdup strerror \
880 strncasecmp strndup strrchr strspn strstr \
881 strtol strtoul strlcat strlcpy \
882 daemon snprintf vsnprintf \
883 if_nametoindex if_indextoname getifaddrs \
eac6e3f0 884 uname fcntl getgrouplist pledge])
6f0e3f6e 885
13460c44
FL
886AC_CHECK_HEADER([asm-generic/unistd.h],
887 [AC_CHECK_DECL(__NR_setns,
888 AC_DEFINE(HAVE_NETNS,, Have netns),,
889 QUAGGA_INCLUDES [#include <asm-generic/unistd.h>
890 ])
428cd73f 891 AC_CHECK_FUNCS(setns)]
13460c44
FL
892 )
893
7ea487bc 894dnl ------------------------------------
895dnl Determine routing get and set method
896dnl ------------------------------------
897AC_MSG_CHECKING(zebra between kernel interface method)
898if test x"$opsys" = x"gnu-linux"; then
35c4bf71
DL
899 AC_MSG_RESULT(netlink)
900 RT_METHOD=rt_netlink.o
1fdc9eae 901 KERNEL_METHOD=kernel_netlink.o
35c4bf71
DL
902 AC_DEFINE(HAVE_NETLINK,,netlink)
903 netlink=yes
904 AC_CHECK_DECLS([IFLA_INFO_SLAVE_KIND], [], [], [#include <linux/if_link.h>])
865730ab 905else
19877dd2 906 AC_MSG_RESULT(Route socket)
907 KERNEL_METHOD="kernel_socket.o"
908 RT_METHOD="rt_socket.o"
7ea487bc 909fi
910AC_SUBST(RT_METHOD)
911AC_SUBST(KERNEL_METHOD)
5adc2528 912AM_CONDITIONAL([HAVE_NETLINK], [test "x$netlink" = "xyes"])
7ea487bc 913
238497fc
PJ
914dnl --------------------------
915dnl Determine IS-IS I/O method
916dnl --------------------------
745bf05f
DL
917AC_DEFINE(ISIS_METHOD_PFPACKET, 1, [ constant value for isis method pfpacket ])
918AC_DEFINE(ISIS_METHOD_DLPI, 2, [ constant value for isis method dlpi ])
919AC_DEFINE(ISIS_METHOD_BPF, 3, [ constant value for isis method bpf ])
238497fc
PJ
920AC_CHECK_HEADER(net/bpf.h)
921AC_CHECK_HEADER(sys/dlpi.h)
922AC_MSG_CHECKING(zebra IS-IS I/O method)
923if test x"$opsys" = x"gnu-linux"; then
924 AC_MSG_RESULT(pfpacket)
745bf05f 925 ISIS_METHOD_MACRO="ISIS_METHOD_PFPACKET"
238497fc
PJ
926elif test x"$opsys" = x"sol2-6" -o x"$opsys" = x"sol8"; then
927 AC_MSG_RESULT(DLPI)
745bf05f 928 ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
238497fc
PJ
929else
930 if test $ac_cv_header_net_bpf_h = no; then
931 if test $ac_cv_header_sys_dlpi_h = no; then
932 AC_MSG_RESULT(none)
933 AC_MSG_WARN([*** IS-IS support will not be built ***])
934 ISISD=""
935 else
936 AC_MSG_RESULT(DLPI)
937 fi
745bf05f 938 ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
238497fc
PJ
939 else
940 AC_MSG_RESULT(BPF)
745bf05f 941 ISIS_METHOD_MACRO="ISIS_METHOD_BPF"
238497fc
PJ
942 fi
943fi
745bf05f 944AC_DEFINE_UNQUOTED(ISIS_METHOD, $ISIS_METHOD_MACRO, [ selected method for isis, == one of the constants ])
238497fc 945
b99760ab 946dnl ------------------------------------
947dnl check for broken CMSG_FIRSTHDR macro
948dnl ------------------------------------
6c20046f 949AC_MSG_CHECKING(for broken CMSG_FIRSTHDR)
5b087528 950AC_RUN_IFELSE([AC_LANG_SOURCE([[
b99760ab 951#ifdef SUNOS_5
952#define _XPG4_2
953#define __EXTENSIONS__
954#endif
6f0e3f6e
PJ
955#ifdef HAVE_STDLIB_H
956# include <stdlib.h>
957#endif
958#ifdef HAVE_SYS_TYPES_H
b99760ab 959#include <sys/types.h>
6f0e3f6e
PJ
960#endif
961#ifdef HAVE_SYS_SOCKET_H
b99760ab 962#include <sys/socket.h>
6f0e3f6e 963#endif
b99760ab 964
965main()
966{
967 struct msghdr msg;
968 char buf[4];
969
970 msg.msg_control = buf;
971 msg.msg_controllen = 0;
972
973 if (CMSG_FIRSTHDR(&msg) != NULL)
974 exit(0);
975 exit (1);
5b087528 976}]])],[AC_MSG_RESULT(yes - using workaround) AC_DEFINE(HAVE_BROKEN_CMSG_FIRSTHDR,,Broken CMSG_FIRSTHDR)],
d33e8d7b 977[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
b99760ab 978
7ea487bc 979dnl ------------------------------
980dnl check kernel route read method
981dnl ------------------------------
5589ffa7
JJ
982AC_CACHE_CHECK([route read method], [quagga_cv_rtread_method],
983[if test "x$netlink" = xyes; then
984 quagga_cv_rtread_method="netlink"
7ea487bc 985else
35c4bf71 986for quagga_cv_rtread_method in /dev/ip /dev/null;
7ea487bc 987do
5589ffa7 988 test x`ls $quagga_cv_rtread_method 2>/dev/null` = x"$quagga_cv_rtread_method" && break
7ea487bc 989done
5589ffa7 990case $quagga_cv_rtread_method in
9c30ab6b 991 "/dev/ip")
992 case "$host" in
5589ffa7
JJ
993 *-freebsd*) quagga_cv_rtread_method="sysctl";;
994 *) quagga_cv_rtread_method="getmsg";;
9c30ab6b 995 esac;;
5589ffa7
JJ
996 *)
997 quagga_cv_rtread_method="sysctl";;
7ea487bc 998esac
999fi])
5589ffa7 1000RTREAD_METHOD=rtread_${quagga_cv_rtread_method}.o
7ea487bc 1001AC_SUBST(RTREAD_METHOD)
1002
1003dnl -----------------------------
1004dnl check interface lookup method
1005dnl -----------------------------
19877dd2 1006IOCTL_METHOD=ioctl.o
7ea487bc 1007AC_MSG_CHECKING(interface looking up method)
1008if test "$netlink" = yes; then
1009 AC_MSG_RESULT(netlink)
1010 IF_METHOD=if_netlink.o
19877dd2 1011elif test "$opsys" = "sol2-6";then
1012 AC_MSG_RESULT(Solaris GIF)
1013 IF_METHOD=if_ioctl.o
afd8a129 1014elif test "$opsys" = "sol8";then
19877dd2 1015 AC_MSG_RESULT(Solaris GLIF)
1016 IF_METHOD=if_ioctl_solaris.o
1017 IOCTL_METHOD=ioctl_solaris.o
19877dd2 1018elif test "$opsys" = "openbsd";then
1019 AC_MSG_RESULT(openbsd)
1020 IF_METHOD=if_ioctl.o
1021elif grep NET_RT_IFLIST /usr/include/sys/socket.h >/dev/null 2>&1; then
1022 AC_MSG_RESULT(sysctl)
7ea487bc 1023 IF_METHOD=if_sysctl.o
1024 AC_DEFINE(HAVE_NET_RT_IFLIST,,NET_RT_IFLIST)
19877dd2 1025else
7ea487bc 1026 AC_MSG_RESULT(ioctl)
1027 IF_METHOD=if_ioctl.o
7ea487bc 1028fi
1029AC_SUBST(IF_METHOD)
19877dd2 1030AC_SUBST(IOCTL_METHOD)
7ea487bc 1031
42c98199 1032dnl ---------------------------------------------------------------
1033dnl figure out how to specify an interface in multicast sockets API
1034dnl ---------------------------------------------------------------
6f0e3f6e 1035AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], QUAGGA_INCLUDES)
42c98199 1036
b3f2bf7c
RW
1037AC_CHECK_HEADERS([linux/mroute.h], [], [],[
1038 #ifdef HAVE_SYS_SOCKET_H
1039 # include <sys/socket.h>
1040 #endif
1041 #ifdef HAVE_NETINET_IN_H
1042 # include <netinet/in.h>
1043 #endif
1044 #define _LINUX_IN_H /* For Linux <= 2.6.25 */
1045 #include <linux/types.h>
1046])
1047
1048m4_define([QUAGGA_INCLUDES],
1049QUAGGA_INCLUDES
1050[#if HAVE_LINUX_MROUTE_H
1051# include <linux/mroute.h>
1052#endif
1053])dnl
1054
1055AC_CHECK_HEADERS([netinet/ip_mroute.h], [], [],[
1056 #ifdef HAVE_SYS_SOCKET_H
1057 # include <sys/socket.h>
1058 #endif
1059 #ifdef HAVE_SYS_TYPES_H
1060 # include <sys/types.h>
1061 #endif
1062 #ifdef HAVE_NETINET_IN_H
1063 # include <netinet/in.h>
1064 #endif
1065 #ifdef HAVE_NET_ROUTE_H
1066 # include <net/route.h>
1067 #endif
1068])
1069
1070m4_define([QUAGGA_INCLUDES],
1071QUAGGA_INCLUDES
1072[#if HAVE_NETINET_IP_MROUTE_H
1073# include <netinet/ip_mroute.h>
1074#endif
1075])dnl
1076
42c98199 1077AC_MSG_CHECKING([for BSD struct ip_mreq hack])
1078AC_TRY_COMPILE([#ifdef HAVE_SYS_PARAM_H
1079#include <sys/param.h>
373ba5cd 1080#endif],[#if (defined(__FreeBSD__) && ((__FreeBSD_version >= 500022 && __FreeBSD_version < 700000) || (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) || (defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 106010000) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__DragonFly__) || defined(__sun)
42c98199 1081 return (0);
1082#else
1083 #error No support for BSD struct ip_mreq hack detected
1084#endif],[AC_MSG_RESULT(yes)
1085AC_DEFINE(HAVE_BSD_STRUCT_IP_MREQ_HACK,,[Can pass ifindex in struct ip_mreq])],
1086AC_MSG_RESULT(no))
1087
10d04cdb
DT
1088AC_MSG_CHECKING([for RFC3678 protocol-independed API])
1089AC_TRY_COMPILE([
1090#include <sys/types.h>
1091#include <netinet/in.h>
1092], [struct group_req gr; int sock; setsockopt(sock, IPPROTO_IP, MCAST_JOIN_GROUP, (void*)&gr, sizeof(gr));
1093], [AC_MSG_RESULT(yes)
1094AC_DEFINE(HAVE_RFC3678,1,[Have RFC3678 protocol-independed API])],
1095AC_MSG_RESULT(no))
1096
c543a173
AS
1097dnl ---------------------------------------------------------------
1098dnl figure out how to check link-state
1099dnl ---------------------------------------------------------------
6418bedf
AS
1100AC_CHECK_HEADER([net/if.h],
1101 [AC_CHECK_HEADER( [net/if_media.h],
1102 [m4_define([LINK_DETECT_INCLUDES],
1103 QUAGGA_INCLUDES
1104 [#include <net/if_media.h>
1105 ])
1106 AC_CHECK_MEMBERS( [struct ifmediareq.ifm_status],
1107 AC_DEFINE(HAVE_BSD_LINK_DETECT,,[BSD link-detect]),
1108 [], LINK_DETECT_INCLUDES)],
1109 [],
1110 QUAGGA_INCLUDES)],
1111 [], QUAGGA_INCLUDES )
c543a173 1112
9234b382
DV
1113dnl ---------------------------------------------------------------
1114dnl Additional, newer way to check link-state using ifi_link_state.
1115dnl Not available in all BSD's when ifmediareq available
1116dnl ---------------------------------------------------------------
1117AC_CHECK_HEADER([net/if.h],
1118 AC_CHECK_MEMBERS([struct if_data.ifi_link_state],
1119 AC_DEFINE(HAVE_BSD_IFI_LINK_STATE,,[BSD ifi_link_state available]),
1120 [], QUAGGA_INCLUDES),
1121 ,)
1122
0df7c91f
PJ
1123dnl ------------------------
1124dnl TCP_MD5SIG socket option
1125dnl ------------------------
1126
1127AC_CHECK_HEADER([netinet/tcp.h],
1128 [m4_define([MD5_INCLUDES],
1129 QUAGGA_INCLUDES
1130 [#include <netinet/tcp.h>
1131 ])
1132 AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)],
1133 [],
1134 QUAGGA_INCLUDES)
1135if test $ac_cv_have_decl_TCP_MD5SIG = no; then
1136 AC_CHECK_HEADER([linux/tcp.h],
1137 [m4_define([MD5_INCLUDES],
1138 QUAGGA_INCLUDES
1139 [#include <linux/tcp.h>
1140 ])
1141 AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)])
1142fi
1143
7ea487bc 1144dnl -----------------------------
1145dnl check ipforward detect method
1146dnl -----------------------------
5589ffa7 1147AC_CACHE_CHECK([ipforward method], [quagga_cv_ipforward_method],
ca9f342c
DL
1148[if test x$cross_compiling = xyes; then
1149 if test x"$opsys" = x"gnu-linux"; then
1150 quagga_cv_ipforward_method=/proc/net/snmp
1151 else
1152 quagga_cv_ipforward_method=/dev/ip
1153 fi
1154else
1155 for quagga_cv_ipforward_method in /proc/net/snmp /dev/ip /dev/null;
1156 do
1157 test x`ls $quagga_cv_ipforward_method 2>/dev/null` = x"$quagga_cv_ipforward_method" && break
1158 done
1159fi
5589ffa7
JJ
1160case $quagga_cv_ipforward_method in
1161 "/proc/net/snmp") quagga_cv_ipforward_method="proc";;
7ea487bc 1162 "/dev/ip")
1163 case "$host" in
5589ffa7
JJ
1164 *-freebsd*) quagga_cv_ipforward_method="sysctl";;
1165 *) quagga_cv_ipforward_method="solaris";;
7ea487bc 1166 esac;;
5589ffa7 1167 *) quagga_cv_ipforward_method="sysctl";;
7ea487bc 1168esac])
5589ffa7 1169IPFORWARD=ipforward_${quagga_cv_ipforward_method}.o
7ea487bc 1170AC_SUBST(IPFORWARD)
1171
1172AC_CHECK_FUNCS(getaddrinfo, [have_getaddrinfo=yes], [have_getaddrinfo=no])
1173
60060acc
RW
1174dnl ----------------------------------------------------------------------------
1175dnl figure out if domainname is available in the utsname struct (GNU extension).
1176dnl ----------------------------------------------------------------------------
1177AC_CHECK_MEMBERS([struct utsname.domainname], [], [], [#include <sys/utsname.h>])
1178
7ea487bc 1179dnl ----------
1180dnl IPv6 check
1181dnl ----------
1182AC_MSG_CHECKING(whether does this OS have IPv6 stack)
7ea487bc 1183dnl ---------
1184dnl KAME IPv6
1185dnl ---------
1cbb5dfc 1186 if grep WIDE /usr/include/netinet6/in6.h >/dev/null 2>&1; then
a159ed93 1187 AC_DEFINE(KAME,1,KAME IPv6)
a159ed93 1188 AC_MSG_RESULT(KAME)
19877dd2 1189dnl ------------------------------------
1190dnl Solaris 9, 10 and potentially higher
1191dnl ------------------------------------
afd8a129 1192 elif test x"$opsys" = x"sol8"; then
19877dd2 1193 AC_DEFINE(SOLARIS_IPV6, 1, Solaris IPv6)
19877dd2 1194 AC_MSG_RESULT(Solaris IPv6)
7ea487bc 1195dnl ----------
1196dnl Linux IPv6
1197dnl ----------
42bb3dfd 1198 elif test x"$opsys" = x"gnu-linux"; then
3ef0b877 1199 AC_DEFINE(LINUX_IPV6,1,Linux IPv6 stack)
d8dc5257
DS
1200 dnl Linux has a compilation problem with mixing
1201 dnl netinet/in.h and linux/in6.h they are not
1202 dnl compatible. There has been discussion on
1203 dnl how to fix it but no real progress on implementation
1204 dnl when they fix it, remove this
1205 AC_DEFINE(IPV6_MINHOPCOUNT, 73, Linux ipv6 Min Hop Count)
42bb3dfd
DL
1206 AC_MSG_RESULT(Linux IPv6)
1207 else
80ec006d 1208 AC_MSG_ERROR([Failed to detect IPv6 stack])
a159ed93 1209 fi
7ea487bc 1210
80ec006d
DL
1211dnl this is unconditial, for compatibility
1212AC_DEFINE(HAVE_IPV6,1,IPv6)
7ea487bc 1213
fa3232e1 1214dnl ------------------
1215dnl IPv6 header checks
1216dnl ------------------
fa3232e1 1217AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h netinet/icmp6.h \
6f0e3f6e
PJ
1218 netinet6/in6_var.h netinet6/nd6.h], [], [],
1219 QUAGGA_INCLUDES)
fa3232e1 1220
6f0e3f6e
PJ
1221m4_define([QUAGGA_INCLUDES],dnl
1222QUAGGA_INCLUDES
1223[#if HAVE_NETINET6_IN6_H
1224#include <netinet6/in6.h>
1225#endif
1226#if HAVE_NETINET_IN6_VAR_H
1227#include <netinet/in6_var.h>
1228#endif
1229#if HAVE_NETINET_ICMP6_H
1230# include <netinet/icmp6.h>
1231#endif
1232#if HAVE_NETINET6_IN6_VAR_H
1233# include <netinet6/in6_var.h>
1234#endif
1235#if HAVE_NETINET6_ND6_H
fbf24544 1236# include <netinet6/nd6.h>
6f0e3f6e
PJ
1237#endif
1238])dnl
1239
cbcd9bfc
JT
1240dnl disable doc check
1241if test "${enable_doc}" = "no";then
1242 DOC=""
1243else
1244 DOC="doc"
1245fi
1246
7ea487bc 1247dnl --------------------
1248dnl Daemon disable check
1249dnl --------------------
1250if test "${enable_zebra}" = "no";then
1251 ZEBRA=""
1252else
1253 ZEBRA="zebra"
1254fi
f027d331 1255AM_CONDITIONAL(ZEBRA, test "x$ZEBRA" = "xzebra")
7ea487bc 1256
1257if test "${enable_bgpd}" = "no";then
1258 BGPD=""
1259else
1260 BGPD="bgpd"
1261fi
f027d331 1262AM_CONDITIONAL(BGPD, test "x$BGPD" = "xbgpd")
7ea487bc 1263
1264if test "${enable_ripd}" = "no";then
1265 RIPD=""
1266else
1267 RIPD="ripd"
1268fi
f027d331 1269AM_CONDITIONAL(RIPD, test "x$RIPD" = "xripd")
7ea487bc 1270
1271if test "${enable_ospfd}" = "no";then
1272 OSPFD=""
1273else
1274 OSPFD="ospfd"
1275fi
f027d331 1276AM_CONDITIONAL(OSPFD, test "x$OSPFD" = "xospfd")
7ea487bc 1277
eac6e3f0
RW
1278if test "${enable_ldpd}" = "yes";then
1279 LDPD="ldpd"
87ab4aec 1280 AC_DEFINE(HAVE_LDPD, 1, ldpd)
eac6e3f0
RW
1281else
1282 LDPD=""
1283fi
1284AM_CONDITIONAL(LDPD, test "x$LDPD" = "xldpd")
1285
d0199430 1286if test "${enable_watchquagga}" = "no";then
1287 WATCHQUAGGA=""
1288else
1289 WATCHQUAGGA="watchquagga"
1290fi
f027d331 1291AM_CONDITIONAL(WATCHQUAGGA, test "x$WATCHQUAGGA" = "xwatchquagga")
d0199430 1292
1ef74ef7 1293OSPFCLIENT=""
cd66cd4c 1294if test "${enable_ospfapi}" != "no";then
9a569848 1295 AC_DEFINE(SUPPORT_OSPF_API,,OSPFAPI)
1ef74ef7 1296
cd66cd4c 1297 if test "${enable_ospfclient}" != "no";then
1ef74ef7 1298 OSPFCLIENT="ospfclient"
1ef74ef7 1299 fi
7ea487bc 1300fi
cd66cd4c 1301
f027d331 1302AM_CONDITIONAL(OSPFCLIENT, test "x$OSPFCLIENT" = "xospfclient")
7ea487bc 1303
1304case "${enable_ripngd}" in
7ea487bc 1305 "no" ) RIPNGD="";;
80ec006d 1306 * ) RIPNGD="ripngd";;
7ea487bc 1307esac
f027d331 1308AM_CONDITIONAL(RIPNGD, test "x$RIPNGD" = "xripngd")
7ea487bc 1309
1310case "${enable_ospf6d}" in
7ea487bc 1311 "no" ) OSPF6D="";;
80ec006d 1312 * ) OSPF6D="ospf6d";;
7ea487bc 1313esac
f027d331 1314AM_CONDITIONAL(OSPF6D, test "x$OSPF6D" = "xospf6d")
7ea487bc 1315
9e867fe6 1316case "${enable_isisd}" in
9e867fe6 1317 "no" ) ISISD="";;
c3a9461e 1318 * ) ISISD="isisd";;
9e867fe6 1319esac
f027d331 1320AM_CONDITIONAL(ISISD, test "x$ISISD" = "xisisd")
9e867fe6 1321
12e41d03 1322case "${enable_pimd}" in
12e41d03 1323 "no" ) PIMD="";;
f0646db0 1324 * ) PIMD="pimd";;
12e41d03
DL
1325esac
1326AM_CONDITIONAL(PIMD, test "x$PIMD" = "xpimd")
1327
7ea487bc 1328if test "${enable_bgp_announce}" = "no";then
750e8146
PJ
1329 AC_DEFINE(DISABLE_BGP_ANNOUNCE,1,Disable BGP installation to zebra)
1330else
1331 AC_DEFINE(DISABLE_BGP_ANNOUNCE,0,Disable BGP installation to zebra)
7ea487bc 1332fi
1333
65efcfce
LB
1334if test "${with_rfp_path}" = "yes" || test x"${with_rfp_path}" = x""; then
1335 with_rfp_path="bgpd/rfp-example"
1336fi
1337if test "${with_rfp_path}" != "no"; then
1338 VNC_RFP_PATH="${with_rfp_path}"
1339 AC_SUBST(VNC_RFP_PATH)
1340fi
1341
f95f2ad9 1342if test "${enable_bgp_vnc}" != "no";then
65efcfce
LB
1343 AC_DEFINE(ENABLE_BGP_VNC,1,Enable BGP VNC support)
1344 RFPTEST="${with_rfp_path}/rfptest"
1345 LIBRFP="${with_rfp_path}/librfp"
1346 RFPINC="${with_rfp_path}/librfp"
1347else
1348 RFPTEST=
1349 LIBRFP=
1350 RFPINC="bgpd/rfp-example/librfp"
1351fi
1352# set
f95f2ad9 1353AM_CONDITIONAL([ENABLE_BGP_VNC], [test x${enable_bgp_vnc} != xno])
65efcfce 1354
cbcd9bfc 1355AC_SUBST(DOC)
7ea487bc 1356AC_SUBST(ZEBRA)
65efcfce
LB
1357AC_SUBST(RFPTEST)
1358AC_SUBST(LIBRFP)
1359AC_SUBST(RFPINC)
7ea487bc 1360AC_SUBST(BGPD)
1361AC_SUBST(RIPD)
1362AC_SUBST(RIPNGD)
1363AC_SUBST(OSPFD)
1364AC_SUBST(OSPF6D)
eac6e3f0 1365AC_SUBST(LDPD)
d0199430 1366AC_SUBST(WATCHQUAGGA)
9e867fe6 1367AC_SUBST(ISISD)
12e41d03 1368AC_SUBST(PIMD)
97cee877 1369AC_SUBST(SOLARIS)
7ea487bc 1370AC_SUBST(VTYSH)
7ea487bc 1371AC_SUBST(CURSES)
1372AC_SUBST(OSPFCLIENT)
1ef74ef7 1373AC_SUBST(OSPFAPI)
7ea487bc 1374AC_CHECK_LIB(c, inet_ntop, [AC_DEFINE(HAVE_INET_NTOP,,inet_ntop)])
1375AC_CHECK_LIB(c, inet_pton, [AC_DEFINE(HAVE_INET_PTON,,inet_pton)])
1376AC_CHECK_LIB(crypt, crypt)
1377AC_CHECK_LIB(resolv, res_init)
7ea487bc 1378
25f45887
JJ
1379dnl ---------------------------
1380dnl check system has PCRE regexp
1381dnl ---------------------------
1382if test "x$enable_pcreposix" = "xyes"; then
1383 AC_CHECK_LIB(pcreposix, pcreposix_regexec, ,[enable_pcreposix=no
1384 AC_MSG_WARN([*** falling back to other regex library ***]) ])
1385fi
1386
1387if test "x$enable_pcreposix" != "xyes"; then
7ea487bc 1388dnl ---------------------------
1389dnl check system has GNU regexp
1390dnl ---------------------------
25f45887 1391AC_MSG_CHECKING(whether system has GNU regex)
7ea487bc 1392AC_CHECK_LIB(c, regexec,
1393[AC_DEFINE(HAVE_GNU_REGEX,,GNU regexp library)
1394 LIB_REGEX=""],
1395[LIB_REGEX="regex.o"])
25f45887
JJ
1396fi
1397AC_SUBST(HAVE_LIBPCREPOSIX)
7ea487bc 1398AC_SUBST(LIB_REGEX)
1399
1400dnl ------------------
b1fc9acb 1401dnl check Net-SNMP library
7ea487bc 1402dnl ------------------
d6be5fb9 1403if test "${enable_snmp}" != ""; then
08d7f653
VB
1404 AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], [no])
1405 if test x"$NETSNMP_CONFIG" = x"no"; then
1406 AC_MSG_ERROR([--enable-snmp given but unable to find net-snmp-config])
1407 fi
1408 LIBS="$LIBS `${NETSNMP_CONFIG} --agent-libs`"
1409 CFLAGS="`${NETSNMP_CONFIG} --base-cflags` $CFLAGS"
1410 AC_MSG_CHECKING([whether we can link to Net-SNMP])
1411 AC_LINK_IFELSE([AC_LANG_PROGRAM([
1412int main(void);
1413],
1414[
1415{
1416 return 0;
1417}
1418])],[AC_MSG_RESULT(yes)],[
1419 AC_MSG_RESULT(no)
1420 AC_MSG_ERROR([--enable-snmp given but not usable])])
1421 AC_DEFINE(HAVE_SNMP,,SNMP)
d6be5fb9
VB
1422 case "${enable_snmp}" in
1423 yes)
1424 SNMP_METHOD=agentx
1425 ;;
1426 smux|agentx)
1427 SNMP_METHOD="${enable_snmp}"
1428 ;;
1429 *)
1430 AC_MSG_ERROR([--enable-snmp given with an unknown method (${enable_snmp}). Use smux or agentx])
1431 ;;
1432 esac
1433 AH_TEMPLATE([SNMP_SMUX], [Use SNMP SMUX to interface with snmpd])
1434 AH_TEMPLATE([SNMP_AGENTX], [Use SNMP AgentX to interface with snmpd])
1435 AC_DEFINE_UNQUOTED(AS_TR_CPP(SNMP_${SNMP_METHOD}),,SNMP method to interface with snmpd)
6cf9df08 1436fi
1437
7ea487bc 1438dnl ---------------------------
6f0e3f6e 1439dnl sockaddr and netinet checks
7ea487bc 1440dnl ---------------------------
6f0e3f6e
PJ
1441AC_CHECK_TYPES([struct sockaddr, struct sockaddr_in,
1442 struct sockaddr_in6, struct sockaddr_un, struct sockaddr_dl,
12e41d03
DL
1443 socklen_t, struct vifctl, struct mfcctl, struct sioc_sg_req,
1444 vifi_t, struct sioc_vif_req, struct igmpmsg,
6f0e3f6e
PJ
1445 struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq,
1446 struct nd_opt_adv_interval, struct rt_addrinfo,
11770e10 1447 struct nd_opt_homeagent_info, struct nd_opt_adv_interval],
6f0e3f6e
PJ
1448 [], [], QUAGGA_INCLUDES)
1449
1450AC_CHECK_MEMBERS([struct sockaddr.sa_len,
1451 struct sockaddr_in.sin_len, struct sockaddr_un.sun_len,
1452 struct sockaddr_in6.sin6_scope_id,
ca3ccd87 1453 struct sockaddr_dl.sdl_len,
6f0e3f6e
PJ
1454 struct if6_aliasreq.ifra_lifetime,
1455 struct nd_opt_adv_interval.nd_opt_ai_type],
1456 [], [], QUAGGA_INCLUDES)
29c4c9bd 1457
6f0e3f6e 1458dnl ---------------------------
11770e10 1459dnl IRDP/pktinfo/icmphdr checks
6f0e3f6e
PJ
1460dnl ---------------------------
1461AC_CHECK_TYPES([struct in_pktinfo],
11770e10
PJ
1462 [AC_CHECK_TYPES([struct icmphdr],
1463 [if test "${enable_irdp}" != "no"; then
1464 AC_DEFINE(HAVE_IRDP,, IRDP)
1465 fi],
1466 [if test "${enable_irdp}" = "yes"; then
1467 AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
1468 fi], [QUAGGA_INCLUDES])],
6f0e3f6e
PJ
1469 [if test "${enable_irdp}" = "yes"; then
1470 AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
1471 fi], [QUAGGA_INCLUDES])
29c4c9bd 1472
12e41d03
DL
1473dnl -----------------------
1474dnl checking for IP_PKTINFO
1475dnl -----------------------
1476AC_MSG_CHECKING(for IP_PKTINFO)
1477AC_TRY_COMPILE([#include <netdb.h>], [
1478 int opt = IP_PKTINFO;
1479], [
1480 AC_MSG_RESULT(yes)
1481 AC_DEFINE(HAVE_IP_PKTINFO, 1, [Have IP_PKTINFO])
1482], [
1483 AC_MSG_RESULT(no)
1484])
1485
1486dnl ---------------------------
1487dnl checking for IP_RECVDSTADDR
1488dnl ---------------------------
1489AC_MSG_CHECKING(for IP_RECVDSTADDR)
1490AC_TRY_COMPILE([#include <netinet/in.h>], [
1491 int opt = IP_RECVDSTADDR;
1492], [
1493 AC_MSG_RESULT(yes)
1494 AC_DEFINE(HAVE_IP_RECVDSTADDR, 1, [Have IP_RECVDSTADDR])
1495], [
1496 AC_MSG_RESULT(no)
1497])
1498
1499dnl ----------------------
1500dnl checking for IP_RECVIF
1501dnl ----------------------
1502AC_MSG_CHECKING(for IP_RECVIF)
1503AC_TRY_COMPILE([#include <netinet/in.h>], [
1504 int opt = IP_RECVIF;
1505], [
1506 AC_MSG_RESULT(yes)
1507 AC_DEFINE(HAVE_IP_RECVIF, 1, [Have IP_RECVIF])
1508], [
1509 AC_MSG_RESULT(no)
1510])
1511
eac6e3f0
RW
1512dnl ----------------------
1513dnl checking for SO_BINDANY
1514dnl ----------------------
1515AC_MSG_CHECKING(for SO_BINDANY)
1516AC_TRY_COMPILE([#include <sys/socket.h>], [
1517 int opt = SO_BINDANY;
1518], [
1519 AC_MSG_RESULT(yes)
1520 AC_DEFINE(HAVE_SO_BINDANY, 1, [Have SO_BINDANY])
1521], [
1522 AC_MSG_RESULT(no)
1523])
1524
1525dnl ----------------------
1526dnl checking for IP_FREEBIND
1527dnl ----------------------
1528AC_MSG_CHECKING(for IP_FREEBIND)
1529AC_TRY_COMPILE([#include <netinet/in.h>], [
1530 int opt = IP_FREEBIND;
1531], [
1532 AC_MSG_RESULT(yes)
1533 AC_DEFINE(HAVE_IP_FREEBIND, 1, [Have IP_FREEBIND])
1534], [
1535 AC_MSG_RESULT(no)
1536])
1537
7ea487bc 1538dnl --------------------------------------
1539dnl checking for getrusage struct and call
1540dnl --------------------------------------
47f6aef0
SH
1541if test "${enable_rusage}" != "no"; then
1542 AC_MSG_CHECKING(whether getrusage is available)
1543 AC_TRY_COMPILE([#include <sys/resource.h>],[struct rusage ac_x; getrusage (RUSAGE_SELF, &ac_x);],
1544 [AC_MSG_RESULT(yes)
1545 AC_DEFINE(HAVE_RUSAGE,,rusage)],
1546 AC_MSG_RESULT(no))
1547fi
7ea487bc 1548
c4376c9d
SH
1549dnl --------------------------------------
1550dnl checking for clock_time monotonic struct and call
1551dnl --------------------------------------
6511cab2
PJ
1552AC_CHECK_DECL(CLOCK_MONOTONIC,
1553 [AC_CHECK_LIB(rt, clock_gettime, [LIBS="$LIBS -lrt"])
9964fcfc 1554 AC_DEFINE(HAVE_CLOCK_MONOTONIC,, Have monotonic clock)
6511cab2 1555], [AC_MSG_RESULT(no)], [QUAGGA_INCLUDES])
c4376c9d 1556
edd7c245 1557dnl -------------------
1558dnl capabilities checks
1559dnl -------------------
41d3fc96 1560if test "${enable_capabilities}" != "no"; then
1561 AC_MSG_CHECKING(whether prctl PR_SET_KEEPCAPS is available)
1562 AC_TRY_COMPILE([#include <sys/prctl.h>],[prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);],
1563 [AC_MSG_RESULT(yes)
1564 AC_DEFINE(HAVE_PR_SET_KEEPCAPS,,prctl)
1565 quagga_ac_keepcaps="yes"],
1566 AC_MSG_RESULT(no)
edd7c245 1567 )
41d3fc96 1568 if test x"${quagga_ac_keepcaps}" = x"yes"; then
1569 AC_CHECK_HEADERS(sys/capability.h)
1570 fi
1571 if test x"${ac_cv_header_sys_capability_h}" = x"yes"; then
1572 AC_CHECK_LIB(cap, cap_init,
1573 [AC_DEFINE(HAVE_LCAPS,1,Capabilities)
1574 LIBCAP="-lcap"
ceacedba 1575 quagga_ac_lcaps="yes"]
41d3fc96 1576 )
ceacedba 1577 else
1578 AC_CHECK_HEADERS(priv.h,
1579 [AC_MSG_CHECKING(Solaris style privileges are available)
1580 AC_TRY_COMPILE([#include <priv.h>],[getpflags(PRIV_AWARE);],
1581 [AC_MSG_RESULT(yes)
1582 AC_DEFINE(HAVE_SOLARIS_CAPABILITIES,1,getpflags)
1583 quagga_ac_scaps="yes"],
1584 AC_MSG_RESULT(no)
1585 )
1586 ]
1587 )
1588 fi
1589 if test x"${quagga_ac_scaps}" = x"yes" \
1590 -o x"${quagga_ac_lcaps}" = x"yes"; then
1591 AC_DEFINE(HAVE_CAPABILITIES,1,capabilities)
41d3fc96 1592 fi
edd7c245 1593fi
1594AC_SUBST(LIBCAP)
1595
fb2d1502 1596dnl ---------------------------
1597dnl check for glibc 'backtrace'
1598dnl ---------------------------
8c99b4c1
DL
1599if test x"${enable_backtrace}" != x"no" ; then
1600 backtrace_ok=no
1601 AC_CHECK_HEADER([execinfo.h], [
1602 AC_SEARCH_LIBS([backtrace], [execinfo], [
1603 AC_DEFINE(HAVE_GLIBC_BACKTRACE,,[Glibc backtrace])
1604 AC_DEFINE(HAVE_STACK_TRACE,,[Stack symbol decoding])
1605 backtrace_ok=yes
1606 ],, [-lm])
eda3529e 1607 ])
8c99b4c1
DL
1608
1609 if test x"${enable_backtrace}" = x"yes" -a x"${backtrace_ok}" = x"no"; then
1610 dnl user explicitly requested backtrace but we failed to find support
1611 AC_MSG_FAILURE([failed to find backtrace support])
1612 fi
1613fi
fb2d1502 1614
41be32bf
PJ
1615dnl -----------------------------------------
1616dnl check for malloc mallinfo struct and call
1617dnl this must try and link using LIBS, in
1618dnl order to check no alternative allocator
1619dnl has been specified, which might not provide
1620dnl mallinfo, e.g. such as Umem on Solaris.
1621dnl -----------------------------------------
6f0e3f6e 1622AC_CHECK_HEADER([malloc.h],
41be32bf
PJ
1623 [AC_MSG_CHECKING(whether mallinfo is available)
1624 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
1625 [[struct mallinfo ac_x; ac_x = mallinfo ();]])],
1626 [AC_MSG_RESULT(yes)
1627 AC_DEFINE(HAVE_MALLINFO,,mallinfo)],
1628 AC_MSG_RESULT(no)
1629 )
6f0e3f6e 1630 ], [], QUAGGA_INCLUDES)
41be32bf 1631
408ad943 1632dnl ----------
1633dnl configure date
1634dnl ----------
1635CONFDATE=`date '+%Y%m%d'`
1636AC_SUBST(CONFDATE)
1637
f281ab97
DL
1638dnl -------
1639dnl DejaGNU
1640dnl -------
1641if test x"$DEJAGNU" = x
1642then
1643 DEJAGNU="\$(top_srcdir)/tests/global-conf.exp"
1644fi
1645RUNTESTDEFAULTFLAGS="-x --tool \$\$tool"
1646
1647AC_SUBST(DEJAGNU)
1648AC_SUBST(RUNTESTDEFAULTFLAGS)
1649
7ea487bc 1650dnl ------------------------------
a159ed93 1651dnl set paths for state directory
23bd12c3 1652dnl ------------------------------
e84999d9 1653AC_MSG_CHECKING(directory to use for state file)
23bd12c3 1654if test "${prefix}" = "NONE"; then
e8f2984c 1655 quagga_statedir_prefix="";
23bd12c3 1656else
e8f2984c 1657 quagga_statedir_prefix=${prefix}
23bd12c3 1658fi
1659if test "${localstatedir}" = '${prefix}/var'; then
e84999d9 1660 for QUAGGA_STATE_DIR in ${quagga_statedir_prefix}/var/run dnl
e8f2984c 1661 ${quagga_statedir_prefix}/var/adm dnl
1662 ${quagga_statedir_prefix}/etc dnl
a159ed93 1663 /var/run dnl
1664 /var/adm dnl
1665 /etc dnl
1666 /dev/null;
23bd12c3 1667 do
e8f2984c 1668 test -d $QUAGGA_STATE_DIR && break
23bd12c3 1669 done
e84999d9 1670 quagga_statedir=$QUAGGA_STATE_DIR
23bd12c3 1671else
e8f2984c 1672 quagga_statedir=${localstatedir}
a159ed93 1673fi
e8f2984c 1674if test $quagga_statedir = "/dev/null"; then
a159ed93 1675 AC_MSG_ERROR('STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!')
1676fi
e84999d9
JJ
1677AC_MSG_RESULT(${quagga_statedir})
1678AC_SUBST(quagga_statedir)
a159ed93 1679
e8f2984c 1680AC_DEFINE_UNQUOTED(PATH_ZEBRA_PID, "$quagga_statedir/zebra.pid",zebra PID)
1681AC_DEFINE_UNQUOTED(PATH_RIPD_PID, "$quagga_statedir/ripd.pid",ripd PID)
1682AC_DEFINE_UNQUOTED(PATH_RIPNGD_PID, "$quagga_statedir/ripngd.pid",ripngd PID)
1683AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$quagga_statedir/bgpd.pid",bgpd PID)
1684AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$quagga_statedir/ospfd.pid",ospfd PID)
1685AC_DEFINE_UNQUOTED(PATH_OSPF6D_PID, "$quagga_statedir/ospf6d.pid",ospf6d PID)
eac6e3f0
RW
1686AC_DEFINE_UNQUOTED(PATH_LDPD_PID, "$quagga_statedir/ldpd.pid",ldpd PID)
1687AC_DEFINE_UNQUOTED(LDPD_SOCKET, "$quagga_statedir/ldpd.sock",ldpd control socket)
9e867fe6 1688AC_DEFINE_UNQUOTED(PATH_ISISD_PID, "$quagga_statedir/isisd.pid",isisd PID)
12e41d03 1689AC_DEFINE_UNQUOTED(PATH_PIMD_PID, "$quagga_statedir/pimd.pid",pimd PID)
d0199430 1690AC_DEFINE_UNQUOTED(PATH_WATCHQUAGGA_PID, "$quagga_statedir/watchquagga.pid",watchquagga PID)
e8f2984c 1691AC_DEFINE_UNQUOTED(ZEBRA_SERV_PATH, "$quagga_statedir/zserv.api",zebra api socket)
1692AC_DEFINE_UNQUOTED(ZEBRA_VTYSH_PATH, "$quagga_statedir/zebra.vty",zebra vty socket)
1693AC_DEFINE_UNQUOTED(RIP_VTYSH_PATH, "$quagga_statedir/ripd.vty",rip vty socket)
1694AC_DEFINE_UNQUOTED(RIPNG_VTYSH_PATH, "$quagga_statedir/ripngd.vty",ripng vty socket)
1695AC_DEFINE_UNQUOTED(BGP_VTYSH_PATH, "$quagga_statedir/bgpd.vty",bgpd vty socket)
1696AC_DEFINE_UNQUOTED(OSPF_VTYSH_PATH, "$quagga_statedir/ospfd.vty",ospfd vty socket)
1697AC_DEFINE_UNQUOTED(OSPF6_VTYSH_PATH, "$quagga_statedir/ospf6d.vty",ospf6d vty socket)
eac6e3f0 1698AC_DEFINE_UNQUOTED(LDP_VTYSH_PATH, "$quagga_statedir/ldpd.vty",ldpd vty socket)
9e867fe6 1699AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$quagga_statedir/isisd.vty",isisd vty socket)
12e41d03 1700AC_DEFINE_UNQUOTED(PIM_VTYSH_PATH, "$quagga_statedir/pimd.vty",pimd vty socket)
4a96e944 1701AC_DEFINE_UNQUOTED(WATCHQUAGGA_VTYSH_PATH, "$quagga_statedir/watchquagga.vty",watchquagga vty socket)
515210bd 1702AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$quagga_statedir",daemon vty directory)
7ea487bc 1703
95c4aff2
DL
1704dnl autoconf does this, but it does it too late...
1705test "x$prefix" = xNONE && prefix=$ac_default_prefix
1706test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
1707
1708dnl get the full path, recursing through variables...
1709vtysh_bin="$bindir/vtysh"
1710for I in 1 2 3 4 5 6 7 8 9 10; do
1711 eval vtysh_bin="\"$vtysh_bin\""
1712done
1713AC_DEFINE_UNQUOTED(VTYSH_BIN_PATH, "$vtysh_bin",path to vtysh binary)
1714
1eb8ef25 1715dnl -------------------------------
1716dnl Quagga sources should always be
1717dnl current wrt interfaces. Dont
1718dnl allow deprecated interfaces to
1719dnl be exposed.
1720dnl -------------------------------
1721AC_DEFINE(QUAGGA_NO_DEPRECATED_INTERFACES, 1, Hide deprecated interfaces)
1722
7ea487bc 1723dnl ---------------------------
1724dnl Check htonl works correctly
1725dnl ---------------------------
1726AC_MSG_CHECKING(for working htonl)
6f0e3f6e
PJ
1727AC_CACHE_VAL(ac_cv_htonl_works,
1728 [AC_LINK_IFELSE([AC_LANG_PROGRAM([QUAGGA_INCLUDES],[htonl (0);])],
1729 [ac_cv_htonl_works=yes], [ac_cv_htonl_works=no])
1730 ]
1731)
7ea487bc 1732AC_MSG_RESULT($ac_cv_htonl_works)
1733
dad253b4 1734AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile
d0199430 1735 ripngd/Makefile bgpd/Makefile ospfd/Makefile watchquagga/Makefile
eac6e3f0 1736 ospf6d/Makefile ldpd/Makefile isisd/Makefile vtysh/Makefile
f281ab97 1737 doc/Makefile ospfclient/Makefile tests/Makefile m4/Makefile
12e41d03 1738 pimd/Makefile
5bb7e4d1 1739 tests/bgpd.tests/Makefile
c69905b6 1740 tests/libzebra.tests/Makefile
f281ab97 1741 redhat/Makefile
1018422a
DS
1742 tools/Makefile
1743 cumulus/Makefile
69f1fc22 1744 pkgsrc/Makefile
93c7bed1 1745 fpm/Makefile
670bbf19 1746 redhat/quagga.spec
b7a97f82 1747 lib/version.h
14c17fd8 1748 doc/defines.texi
cbd04084 1749 pkgsrc/bgpd.sh pkgsrc/ospf6d.sh pkgsrc/ospfd.sh
f31293af 1750 pkgsrc/ripd.sh pkgsrc/ripngd.sh pkgsrc/zebra.sh])
65efcfce 1751
f95f2ad9 1752if test "${enable_bgp_vnc}" != "no"; then
65efcfce
LB
1753 if test "${with_rfp_path}" = "bgpd/rfp-example" ; then
1754 AC_CONFIG_FILES([bgpd/rfp-example/rfptest/Makefile bgpd/rfp-example/librfp/Makefile])
1755 else
1756 AC_CONFIG_FILES([${with_rfp_path}/rfptest/Makefile ${with_rfp_path}/librfp/Makefile])
1757 fi
1758fi
1759
26275b05 1760AC_CONFIG_FILES([solaris/Makefile])
1761
670bbf19 1762AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl])
65efcfce 1763
48577196 1764## Hack, but working solution to avoid rebuilding of quagga.info.
1765## It's already in CVS until texinfo 4.7 is more common.
14c17fd8 1766AC_OUTPUT
7ea487bc 1767
1768echo "
c89f6494 1769Quagga configuration
1770--------------------
1771quagga version : ${PACKAGE_VERSION}
1080c13f 1772host operating system : ${host_os}
7ea487bc 1773source code location : ${srcdir}
1774compiler : ${CC}
1775compiler flags : ${CFLAGS}
6f0e3f6e 1776make : ${MAKE-make}
6f0e3f6e 1777linker flags : ${LDFLAGS} ${LIBS} ${LIBCAP} ${LIBREADLINE} ${LIBM}
e8f2984c 1778state file directory : ${quagga_statedir}
dc7a2bf1 1779config file directory : `eval echo \`echo ${sysconfdir}\``
d6b72f7a 1780example directory : `eval echo \`echo ${exampledir}\``
8d4aee5d 1781user to run as : ${enable_user}
1782group to run as : ${enable_group}
1783group for vty sockets : ${enable_vty_group}
aa593d5e 1784config file mask : ${enable_configfile_mask}
1785log file mask : ${enable_logfile_mask}
dad253b4 1786zebra protobuf enabled : ${have_protobuf:-no}
dc7a2bf1 1787
1788The above user and group must have read/write access to the state file
105b8239
PJ
1789directory and to the config files in the config file directory."
1790
1791if test x"$quagga_cv_gnu_make" = x"no"; then echo "
1792Warning: The ${MAKE-make} programme detected, either in your path or
1793via the MAKE variable, is not GNU Make. GNU make may be installed as
1794gmake on some systems. and is required to complete a build of Quagga
1795" > /dev/stderr
1796fi