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