bgpd: tighten bounds checking in RR ORF msg reader
[jleu-quagga.git] / configure.ac
blobe7c99b0db31b7ea450a4126c30c11273df858d89
1 ##
2 ## Configure template file for Quagga.
3 ## autoconf will generate configure script.
4 ##
5 ##  Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
6 ##  Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st>
7 ##
8 ## $Id$
9 AC_PREREQ(2.53)
11 AC_INIT(Quagga, 0.99.16, [http://bugzilla.quagga.net])
12 AC_CONFIG_SRCDIR(lib/zebra.h)
13 AC_CONFIG_MACRO_DIR([m4])
15 dnl -----------------------------------
16 dnl Get hostname and other information.
17 dnl -----------------------------------
18 AC_CANONICAL_BUILD()
19 AC_CANONICAL_HOST()
20 AC_CANONICAL_TARGET()
22 AM_INIT_AUTOMAKE(1.6)
23 AM_CONFIG_HEADER(config.h)
25 AC_CHECK_PROG([GAWK],[gawk],[gawk],[not-in-PATH])
26 if test "x$GAWK" = "xnot-in-PATH" ; then
27         AC_MSG_ERROR([GNU awk is required for lib/memtype.h made by memtypes.awk.
28 BSD awk complains: awk: gensub doesn't support backreferences (subst "\1") ])
30 AC_ARG_VAR([GAWK],[GNU AWK])
32 dnl default is to match previous behavior
33 exampledir=${sysconfdir}
34 AC_ARG_ENABLE([exampledir],
35           AC_HELP_STRING([--enable-exampledir],
36                          [specify alternate directory for examples]),
37                          exampledir="$enableval",)
38 dnl XXX add --exampledir to autoconf standard directory list somehow
39 AC_SUBST(exampledir)
41 dnl default is to match previous behavior
42 pkgsrcrcdir=""
43 pkgsrcdir=""
44 AC_ARG_ENABLE([pkgsrcrcdir],
45           AC_HELP_STRING([--enable-pkgsrcrcdir],
46                          [specify directory for rc.d scripts]),
47                          pkgsrcrcdir="$enableval"; pkgsrcdir="pkgsrc",)
48 dnl XXX add --pkgsrcrcdir to autoconf standard directory list somehow
49 AC_SUBST(pkgsrcdir)
50 AC_SUBST(pkgsrcrcdir)
52 dnl ------------
53 dnl Check CFLAGS
54 dnl ------------
55 AC_ARG_WITH(cflags,
56 [  --with-cflags           Set CFLAGS for use in compilation.])
57 if test "x$with_cflags" != "x" ; then
58   CFLAGS="$with_cflags" ; cflags_specified=yes ;
59 elif test -n "$CFLAGS" ; then
60   cflags_specified=yes ;
63 dnl --------------------
64 dnl Check CC and friends
65 dnl --------------------
66 AC_LANG([C])
67 AC_PROG_CC
68 AC_PROG_CPP
69 AM_PROG_CC_C_O
70 AC_PROG_EGREP
72 dnl autoconf 2.59 appears not to support AC_PROG_SED
73 dnl AC_PROG_SED
74 AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
76 dnl ------------------------------------------------------------------
77 dnl Intel compiler check. Although Intel tries really hard to make icc
78 dnl look like gcc, there are some differences. It's very verbose with
79 dnl -Wall and it doesn't support the individual -W options.
80 dnl ------------------------------------------------------------------
81 if test "x${GCC}" = "xyes" ; then
82   COMPILER="GCC"
83   AC_MSG_CHECKING([whether we are using the Intel compiler])
84   AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
85       [AC_MSG_RESULT([no])],
86       [COMPILER="ICC"
87        AC_MSG_RESULT([yes])]
88   )
89 else
90   AC_MSG_CHECKING([whether we are using SunPro compiler])
91   AC_EGREP_CPP([^__SUNPRO_C.*0x5(7|8|9)], ["__SUNPRO_C" __SUNPRO_C],
92       [AC_MSG_RESULT([no])],
93       [COMPILER="SUNPRO"
94        AC_MSG_RESULT([yes])]
95   )
98 dnl ---------------------------------------------
99 dnl If CLFAGS doesn\'t exist set default value
100 dnl AC_PROG_CC will have set minimal default
101 dnl already, eg "-O2 -g" for gcc, "-g" for others
102 dnl (Wall is gcc specific... have to make sure
103 dnl  gcc is being used before setting it)
105 dnl Intel icc 8.0 also sets __GNUC__, 
106 dnl but doesn't support all these fancy -W options.
107 dnl Intel compiler warnings we ignore:
108 dnl 279: controlling expression is constant.
109 dnl 869: parameter "xxx" was never referenced - to avoid massive warnings
110 dnl      about "self", "vty", "argc" and "argv" never referenced in DEFUN
111 dnl      macro.
112 dnl 981: operands are evaluated in unspecified order.
114 dnl Sun Studio 10 / SunPro 5.7 is also supported,
115 dnl so lets set some sane CFLAGS for it.
116 dnl ---------------------------------------------
118 AC_MSG_CHECKING([whether to set a default CFLAGS])
119 if test "x${cflags_specified}" = "x" ; then
120   case ${COMPILER} in
121     "ICC")
122         CFLAGS="-Os -g -Wall -wd 279,869,981"
123         AC_MSG_RESULT([Intel default])
124         ;;
125     "GCC")
126         CFLAGS="-Os -fno-omit-frame-pointer -g -std=gnu99 -Wall"
127         CFLAGS="${CFLAGS} -Wsign-compare -Wpointer-arith"
128         CFLAGS="${CFLAGS} -Wbad-function-cast -Wwrite-strings"
129         CFLAGS="${CFLAGS} -Wmissing-prototypes -Wmissing-declarations"
130         CFLAGS="${CFLAGS} -Wchar-subscripts -Wcast-qual"
131         # TODO: conditionally addd -Wpacked if handled
132         AC_MSG_RESULT([gcc default])
133         ;;
134     "SUNPRO")
135         CFLAGS="-xO4 -v -g -xspace -xcode=pic32 -xstrconst -xc99"
136         AC_MSG_RESULT([SunPro default])
137         ;;
138     *)
139         AC_MSG_RESULT([unknown compiler])
140         ;;
141   esac
142 else
143   AC_MSG_RESULT([CFLAGS supplied by user])
146 dnl --------------
147 dnl Check programs
148 dnl --------------
149 AC_PROG_INSTALL
150 AC_PROG_LN_S
151 AC_PROG_MAKE_SET
152 AC_CHECK_TOOL(AR, ar)
154 dnl ---------------------------
155 dnl We, perhaps unfortunately,
156 dnl depend on GNU Make specific
157 dnl constructs.
158 dnl Give the user a warning if
159 dnl not GNU Make.
160 dnl ---------------------------
161 AC_CACHE_CHECK([if ${MAKE-make} is GNU make], [quagga_cv_gnu_make],
162         [quagga_cv_gnu_make=no
163          if ${MAKE-make} --version 2>/dev/null | \
164                 grep '^GNU Make ' >/dev/null ; then
165                 quagga_cv_gnu_make=yes;
166          fi
167         ]
170 dnl -----------------
171 dnl System extensions
172 dnl -----------------
173 AC_GNU_SOURCE
175 dnl -------
176 dnl libtool
177 dnl -------
178 AC_PROG_LIBTOOL
180 dnl ----------------------
181 dnl Packages configuration
182 dnl ----------------------
183 AC_ARG_ENABLE(vtysh,
184 [  --enable-vtysh          include integrated vty shell for Quagga])
185 AC_ARG_ENABLE(ipv6,
186 [  --disable-ipv6          turn off IPv6 related features and daemons])
187 AC_ARG_ENABLE(doc,
188 [  --disable-doc           do not build docs])
189 AC_ARG_ENABLE(zebra,
190 [  --disable-zebra         do not build zebra daemon])
191 AC_ARG_ENABLE(bgpd,
192 [  --disable-bgpd          do not build bgpd])
193 AC_ARG_ENABLE(ripd,
194 [  --disable-ripd          do not build ripd])
195 AC_ARG_ENABLE(ripngd,
196 [  --disable-ripngd        do not build ripngd])
197 AC_ARG_ENABLE(ospfd,
198 [  --disable-ospfd         do not build ospfd])
199 AC_ARG_ENABLE(ospf6d,
200 [  --disable-ospf6d        do not build ospf6d])
201 AC_ARG_ENABLE(watchquagga,
202 [  --disable-watchquagga   do not build watchquagga])
203 AC_ARG_ENABLE(isisd,
204 [  --enable-isisd          build isisd])
205 AC_ARG_ENABLE(solaris,
206 [  --enable-solaris          build solaris])
207 AC_ARG_ENABLE(bgp-announce,
208 [  --disable-bgp-announce, turn off BGP route announcement])
209 AC_ARG_ENABLE(netlink,
210 [  --enable-netlink        force to use Linux netlink interface])
211 AC_ARG_ENABLE(broken-aliases,
212 [  --enable-broken-aliases enable aliases as distinct interfaces for Linux 2.2.X])
213 AC_ARG_WITH(crypto,
214 [  --without-crypto        do not use libcrypto in SNMP])
215 AC_ARG_ENABLE(snmp,
216 [  --enable-snmp           enable SNMP support])
217 AC_ARG_WITH(libpam,
218 [  --with-libpam           use libpam for PAM support in vtysh])
219 AC_ARG_ENABLE(tcp-zebra,
220 [  --enable-tcp-zebra      enable TCP/IP socket connection between zebra and protocol daemon])
221 AC_ARG_ENABLE(opaque-lsa,
222 [  --enable-opaque-lsa     enable OSPF Opaque-LSA with OSPFAPI support (RFC2370)])
223 AC_ARG_ENABLE(ospfapi,
224 [  --disable-ospfapi       do not build OSPFAPI to access the OSPF LSA Database, 
225                           (this is the default if --enable-opaque-lsa is not set)])
226 AC_ARG_ENABLE(ospfclient,
227 [  --disable-ospfclient    do not build OSPFAPI client for OSPFAPI, 
228                           (this is the default if --disable-ospfapi is set)])
229 AC_ARG_ENABLE(ospf-te,
230 [  --enable-ospf-te        enable Traffic Engineering Extension to OSPF])
231 AC_ARG_ENABLE(multipath,
232 [  --enable-multipath=ARG  enable multipath function, ARG must be digit])
233 AC_ARG_ENABLE(user,
234   AC_HELP_STRING([--enable-user=user], [user to run Quagga suite as (default quagga)]))
235 AC_ARG_ENABLE(group,
236   AC_HELP_STRING([--enable-group=group], [group to run Quagga suite as (default quagga)]))
237 AC_ARG_ENABLE(vty_group,
238 [  --enable-vty-group=ARG  set vty sockets to have specified group as owner])
239 AC_ARG_ENABLE(configfile_mask,
240 [  --enable-configfile-mask=ARG  set mask for config files])
241 AC_ARG_ENABLE(logfile_mask,
242 [  --enable-logfile-mask=ARG     set mask for log files])
244 AC_ARG_ENABLE(rtadv,
245 [  --disable-rtadv               disable IPV6 router advertisement feature])
246 AC_ARG_ENABLE(irdp,
247 [  --enable-irdp                 enable IRDP server support in zebra])
248 AC_ARG_ENABLE(isis_topology,
249 [  --enable-isis-topology        enable IS-IS topology generator])
250 AC_ARG_ENABLE(capabilities,
251 [  --disable-capabilities        disable using POSIX capabilities])
252 AC_ARG_ENABLE(gcc_ultra_verbose,
253 [  --enable-gcc-ultra-verbose    enable ultra verbose GCC warnings])
254 AC_ARG_ENABLE(linux24_tcp_md5,
255 [  --enable-linux24-tcp-md5  enable support for old, Linux-2.4 RFC2385 patch])
256 AC_ARG_ENABLE(gcc-rdynamic,
257 [  --enable-gcc-rdynamic   enable gcc linking with -rdynamic for better backtraces])
258 AC_ARG_ENABLE(time-check,
259 [  --disable-time-check          disable slow thread warning messages])
260 AC_ARG_ENABLE(pcreposix,
261 [  --enable-pcreposix          enable using PCRE Posix libs for regex functions])
263 if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then
264   CFLAGS="${CFLAGS} -W -Wcast-qual -Wstrict-prototypes"
265   CFLAGS="${CFLAGS} -Wmissing-declarations -Wmissing-noreturn"
266   CFLAGS="${CFLAGS} -Wmissing-format-attribute -Wunreachable-code"
267   CFLAGS="${CFLAGS} -Wpacked -Wpadded"
270 if test x"${enable_gcc_rdynamic}" = x"yes" ; then
271   LDFLAGS="${LDFLAGS} -rdynamic"
274 if test x"${enable_time_check}" != x"no" ; then
275   if test x"${enable_time_check}" = x"yes" -o x"${enable_time_check}" = x ; then
276     AC_DEFINE(CONSUMED_TIME_CHECK,5000000,Consumed Time Check)
277   else
278     AC_DEFINE_UNQUOTED(CONSUMED_TIME_CHECK,$enable_time_check,Consumed Time Check)
279   fi
282 if test "${enable_broken_aliases}" = "yes"; then
283   if test "${enable_netlink}" = "yes"
284   then
285     AC_MSG_FAILURE([Sorry you can not use netlink with broken aliases])
286   fi
287   AC_DEFINE(HAVE_BROKEN_ALIASES,,Broken Alias)
288   enable_netlink=no
291 if test "${enable_tcp_zebra}" = "yes"; then
292   AC_DEFINE(HAVE_TCP_ZEBRA,,Use TCP for zebra communication)
295 if test "${enable_opaque_lsa}" = "yes"; then
296   AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA)
299 if test "${enable_ospf_te}" = "yes"; then
300   AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA)
301   AC_DEFINE(HAVE_OSPF_TE,,OSPF TE)
304 if test "${enable_linux24_tcp_md5}" = "yes"; then
305   AC_DEFINE(HAVE_TCP_MD5_LINUX24,,Old Linux 2.4 TCP MD5 Signature Patch)
308 AC_MSG_CHECKING(if zebra should be configurable to send Route Advertisements)
309 if test "${enable_rtadv}" != "no"; then
310   AC_MSG_RESULT(yes)
311   AC_DEFINE(HAVE_RTADV,,Enable IPv6 Routing Advertisement support)
312 else
313   AC_MSG_RESULT(no)
316 if test "${enable_irdp}" = "yes"; then
317   AC_DEFINE(HAVE_IRDP,, IRDP )
320 if test "${enable_isisd}" = "yes" && test "${enable_isis_topology}" = yes; then
321   AC_DEFINE(TOPOLOGY_GENERATE,,Enable IS-IS topology generator code)
322   ISIS_TOPOLOGY_INCLUDES="-I./topology"
323   ISIS_TOPOLOGY_DIR="topology"
324   ISIS_TOPOLOGY_LIB="./topology/libtopology.a"
327 AC_SUBST(ISIS_TOPOLOGY_INCLUDES)
328 AC_SUBST(ISIS_TOPOLOGY_DIR)
329 AC_SUBST(ISIS_TOPOLOGY_LIB)
331 if test "${enable_user}" = "yes" || test x"${enable_user}" = x""; then
332   enable_user="quagga"
333 elif test "${enable_user}" = "no"; then
334   enable_user="root"
337 if test "${enable_group}" = "yes" || test x"${enable_group}" = x""; then
338   enable_group="quagga"
339 elif test "${enable_group}" = "no"; then
340   enable_group="root"
343 if test x"${enable_vty_group}" = x"yes" ; then
344   AC_MSG_ERROR([--enable-vty-group requires a group as argument, not yes])
345 elif test x"${enable_vty_group}" != x""; then
346   if test x"${enable_vty_group}" != x"no"; then
347     AC_DEFINE_UNQUOTED(VTY_GROUP, "${enable_vty_group}", VTY Sockets Group)
348   fi
350 AC_SUBST([enable_user])
351 AC_SUBST([enable_group])
352 AC_SUBST([enable_vty_group])
353 AC_DEFINE_UNQUOTED(QUAGGA_USER, "${enable_user}", Quagga User)
354 AC_DEFINE_UNQUOTED(QUAGGA_GROUP, "${enable_group}", Quagga Group)
356 enable_configfile_mask=${enable_configfile_mask:-0600}
357 AC_DEFINE_UNQUOTED(CONFIGFILE_MASK, ${enable_configfile_mask}, Mask for config files)
359 enable_logfile_mask=${enable_logfile_mask:-0600}
360 AC_DEFINE_UNQUOTED(LOGFILE_MASK, ${enable_logfile_mask}, Mask for log files)
362 MULTIPATH_NUM=1
364 case "${enable_multipath}" in
365   [[0-9]|[1-9][0-9]])
366     MULTIPATH_NUM="${enable_multipath}"
367     ;;
368   "")
369     ;;
370   *)           
371     AC_MSG_FAILURE([Please specify digit to enable multipath ARG])
372     ;;
373 esac
375 AC_SUBST(MULTIPATH_NUM)
377 dnl ------------------------------------
378 dnl Check C keywords and standard  types
379 dnl ------------------------------------
380 AC_C_CONST
381 AC_C_INLINE
382 AC_C_RESTRICT
383 AC_C_VOLATILE
384 AC_HEADER_STDC
385 AC_HEADER_TIME
386 AC_HEADER_SYS_WAIT
387 dnl AC_TYPE_PID_T
388 AC_TYPE_UID_T
389 AC_TYPE_MODE_T
390 AC_TYPE_SIZE_T
391 AC_TYPE_SIGNAL
392 AC_STRUCT_TM
394 dnl -------------------------
395 dnl Check other header files.
396 dnl -------------------------
397 AC_CHECK_HEADERS([stropts.h sys/ksym.h sys/times.h sys/select.h \
398         sys/types.h linux/version.h netdb.h asm/types.h \
399         sys/param.h limits.h signal.h libutil.h \
400         sys/socket.h netinet/in.h time.h sys/time.h])
402 dnl Utility macro to avoid retyping includes all the time
403 m4_define([QUAGGA_INCLUDES],
404 [#ifdef SUNOS_5
405 #define _XPG4_2
406 #define __EXTENSIONS__
407 #endif
408 #include <stdio.h>
409 #if STDC_HEADERS
410 # include <stdlib.h>
411 # include <stddef.h>
412 #else
413 # if HAVE_STDLIB_H
414 #  include <stdlib.h>
415 # endif
416 #endif
417 #if HAVE_SYS_TYPES_H
418 # include <sys/types.h>
419 #endif
420 /* sys/conf.h depends on param.h on FBSD at least */
421 #if HAVE_SYS_PARAM_H
422 # include <sys/param.h>
423 #endif
424 /* Required for MAXSIG */
425 #if HAVE_SIGNAL_H
426 # include <signal.h>
427 #endif
428 #if HAVE_SYS_SOCKET_H
429 # include <sys/socket.h>
430 #endif
431 #if HAVE_NETINET_IN_H
432 # include <netinet/in.h>
433 #endif
434 #ifdef TIME_WITH_SYS_TIME
435 # include <sys/time.h>
436 # include <time.h>
437 #else
438 # ifdef HAVE_SYS_TIME_H
439 #  include <sys/time.h>
440 # else
441 #  include <time.h>
442 # endif
443 #endif /* TIME_WITH_SYS_TIME */
444 ])dnl
446 AC_CHECK_HEADERS([sys/un.h net/if.h netinet/in_systm.h netinet/in_var.h \
447         net/if_dl.h net/if_var.h net/netopt.h net/route.h \
448         inet/nd.h arpa/inet.h netinet/ip_icmp.h \
449         fcntl.h stddef.h sys/ioctl.h syslog.h wchar.h wctype.h \
450         sys/sysctl.h sys/sockio.h kvm.h sys/conf.h],
451         [], [], QUAGGA_INCLUDES)
453 AC_CHECK_HEADERS([ucontext.h], [], [],
454 [#ifndef __USE_GNU
455 #define __USE_GNU
456 #endif /* __USE_GNU */
457 QUAGGA_INCLUDES
460 m4_define([QUAGGA_INCLUDES],
461 QUAGGA_INCLUDES
462 [#if HAVE_NET_IF_H
463 # include <net/if.h>
464 #endif
465 #if HAVE_SYS_UN_H
466 # include <sys/un.h>
467 #endif
468 #if HAVE_NETINET_IN_SYSTM_H
469 # include <netinet/in_systm.h>
470 #endif
471 #if HAVE_NETINET_IN_VAR_H
472 # include <netinet/in_var.h>
473 #endif
474 #if HAVE_NET_IF_DL_H
475 # include <net/if_dl.h>
476 #endif
477 #if HAVE_NET_IF_VAR_H
478 # include <net/if_var.h>
479 #endif
480 #if HAVE_NET_NETOPT_H
481 # include <net/netopt.h>
482 #endif
483 #if HAVE_NET_ROUTE_H
484 # include <net/route.h>
485 #endif
486 #if HAVE_INET_ND_H
487 # include <inet/nd.h>
488 #endif
489 #if HAVE_ARPA_INET_H
490 # include <arpa/inet.h>
491 #endif
492 /* Required for IDRP */
493 #if HAVE_NETINET_IP_ICMP_H
494 # include <netinet/ip_icmp.h>
495 #endif
496 ])dnl
498 dnl V6 headers are checked below, after we check for v6
500 dnl Some systems (Solaris 2.x) require libnsl (Network Services Library)
501 case "$host" in
502   [*-sunos5.[6-7]*] | [*-solaris2.[6-7]*])
503       opsys=sol2-6
504       AC_DEFINE(SUNOS_56, 1, SunOS 5.6 to 5.7)
505       AC_DEFINE(SUNOS_5, 1, SunOS 5)
506       AC_CHECK_LIB(xnet, main)
507       CURSES=-lcurses
508   ;;
509   [*-sunos5.[8-9]] \
510   | [*-sunos5.1[0-9]] \
511   | [*-sunos5.1[0-9].[0-9]] \
512   | [*-solaris2.[8-9]] \
513   | [*-solaris2.1[0-9]] \
514   | [*-solaris2.1[0-9].[0-9]])
515       opsys=sol8
516       AC_DEFINE(SUNOS_59, 1, [SunOS 5.8 up])
517       AC_DEFINE(SUNOS_5, 1, [SunOS 5])
518       AC_CHECK_LIB(socket, main)
519       AC_CHECK_LIB(nsl, main)
520       AC_CHECK_LIB(umem, main)
521       AC_CHECK_FUNCS([printstack],
522         [AC_DEFINE([HAVE_PRINTSTACK],1,[Solaris printstack])
523          AC_DEFINE([HAVE_STACK_TRACE],1,[Stack symbols decode functionality])
524         ])
525       CURSES=-lcurses
526   ;;
527   *-sunos5* | *-solaris2*)
528       AC_DEFINE(SUNOS_5,,SunOS 5, Unknown SunOS)
529       AC_CHECK_LIB(socket, main)
530       AC_CHECK_LIB(nsl, main)
531       CURSES=-lcurses
532   ;;
533   *-linux*)
534       opsys=gnu-linux
535       AC_DEFINE(GNU_LINUX,,GNU Linux)
536   ;;
537   *-nec-sysv4*)
538       AC_CHECK_LIB(nsl, gethostbyname)
539       AC_CHECK_LIB(socket, socket)
540   ;;
541   *-openbsd*)
542       opsys=openbsd
543       AC_DEFINE(OPEN_BSD,,OpenBSD)
544   ;;
545   *-bsdi*)
546       opsys=bsdi
547       OTHER_METHOD="mtu_kvm.o"
548       AC_CHECK_LIB(kvm, main)
549   ;;
550   *-irix6.5)
551       opsys=irix
552       AC_DEFINE(IRIX_65,,IRIX 6.5)
553   ;;
554 esac
556 AC_SYS_LARGEFILE
558 dnl ---------------------
559 dnl Integrated VTY option
560 dnl ---------------------
561 case "${enable_vtysh}" in
562   "yes") VTYSH="vtysh";
563          AC_DEFINE(VTYSH,,VTY shell)
564          AC_PATH_PROG(PERL, perl)
565 dnl      Vtysh uses libreadline, which looks for termcap functions at
566 dnl      configure time.  We follow readlines search order.
567 dnl      The required procedures are in libtermcap on NetBSD, in
568 dnl      [TODO] on Linux, and in [TODO] on Solaris.
569          AC_CHECK_LIB(termcap, tputs, LIBREADLINE="$LIBREADLINE -ltermcap",
570            [AC_CHECK_LIB(tinfo, tputs, LIBREADLINE="$LIBREADLINE -ltinfo",
571              [AC_CHECK_LIB(curses, tputs, LIBREADLINE="$LIBREADLINE -lcurses",
572                [AC_CHECK_LIB(ncurses, tputs, 
573                              LIBREADLINE="$LIBREADLINE -lncurses")]
574               )]
575             )]
576           )
577          AC_CHECK_LIB(readline, main, LIBREADLINE="$LIBREADLINE -lreadline",,
578                       "$LIBREADLINE")
579          if test $ac_cv_lib_readline_main = no; then
580            AC_MSG_ERROR([vtysh needs libreadline but was not found and usable on your system.])
581          fi
582          AC_CHECK_HEADER(readline/history.h)
583          if test $ac_cv_header_readline_history_h = no;then
584            AC_MSG_ERROR([readline is too old to have readline/history.h, please update to the latest readline library.])
585          fi
586          AC_CHECK_LIB(readline, rl_completion_matches, 
587                       LIBREADLINE="$LIBREADLINE",, "$LIBREADLINE")
588          if test $ac_cv_lib_readline_rl_completion_matches = no; then
589            AC_DEFINE(rl_completion_matches,completion_matches,Old readline)
590          fi
591          ;;
592   "no" ) VTYSH="";;
593   *    ) ;;
594 esac
595 AC_SUBST(LIBREADLINE)
597 dnl ----------
598 dnl PAM module
599 dnl ----------
600 if test "$with_libpam" = "yes"; then
601   AC_CHECK_HEADER([security/pam_misc.h],
602     [AC_DEFINE(HAVE_PAM_MISC_H,,Have pam_misc.h)
603      AC_DEFINE(PAM_CONV_FUNC,misc_conv,Have misc_conv)
604      pam_conv_func="misc_conv"
605     ],
606     [], QUAGGA_INCLUDES)
607   AC_CHECK_HEADER([security/openpam.h],
608     [AC_DEFINE(HAVE_OPENPAM_H,,Have openpam.h)
609      AC_DEFINE(PAM_CONV_FUNC,openpam_ttyconv,Have openpam_ttyconv)
610      pam_conv_func="openpam_ttyconv"
611     ],
612     [], QUAGGA_INCLUDES)
613   if test -z "$ac_cv_header_security_pam_misc_h$ac_cv_header_security_openpam_h" ; then
614     AC_MSG_WARN([*** pam support will not be built ***])
615     with_libpam="no"
616   fi
619 if test "$with_libpam" = "yes"; then
620 dnl took this test from proftpds configure.in and suited to our needs
621 dnl -------------------------------------------------------------------------
623 dnl This next check looks funky due to a linker problem with some versions
624 dnl of the PAM library.  Prior to 0.72 release, the Linux PAM shared library
625 dnl omitted requiring libdl linking information. PAM-0.72 or better ships
626 dnl with RedHat 6.2 and Debian 2.2 or better.
627 AC_CHECK_LIB(pam, pam_start,
628   [AC_CHECK_LIB(pam, $pam_conv_func,
629     [AC_DEFINE(USE_PAM,,Use PAM for authentication)
630      LIBPAM="-lpam"],
631     [AC_DEFINE(USE_PAM,,Use PAM for authentication)
632      LIBPAM="-lpam -lpam_misc"]
633     )
634   ],
636   [AC_CHECK_LIB(pam, pam_end,
637     [AC_CHECK_LIB(pam, $pam_conv_func,
638       [AC_DEFINE(USE_PAM,,Use PAM for authentication)
639        LIBPAM="-lpam -ldl"],
640       [AC_DEFINE(USE_PAM,,Use PAM for authentication)
641        LIBPAM="-lpam -ldl -lpam_misc"]
642      )
643   ],AC_MSG_WARN([*** pam support will not be built ***]),
644   [-ldl])
645   ]
648 AC_SUBST(LIBPAM)
650 dnl -------------------------------
651 dnl Endian-ness check
652 dnl -------------------------------
653 AC_WORDS_BIGENDIAN
655 dnl -------------------------------
656 dnl check the size in byte of the C
657 dnl -------------------------------
658 dnl AC_CHECK_SIZEOF(char)
659 dnl AC_CHECK_SIZEOF(int)
660 dnl AC_CHECK_SIZEOF(short)
661 dnl AC_CHECK_SIZEOF(long)
663 dnl ----------------------------
664 dnl check existance of functions
665 dnl ----------------------------
666 AC_FUNC_CHOWN
667 AC_FUNC_FNMATCH
668 AC_FUNC_FORK
669 AC_FUNC_MALLOC
670 AC_FUNC_MEMCMP
671 AC_FUNC_MKTIME
672 AC_FUNC_STRFTIME
673 AC_FUNC_REALLOC
674 AC_FUNC_STAT
675 AC_FUNC_SELECT_ARGTYPES
676 AC_FUNC_STRFTIME
677 dnl Avoid AC_FUNC_STRNLEN because it pulls in AC_SYSTEM_EXTENSIONS which
678 dnl can lead to strange side effects.  So we just check for strnlen
679 dnl directly, see below.
680 dnl AC_FUNC_STRNLENdnl
681 AC_FUNC_VPRINTF
683 dnl -------------------------------
684 dnl bgpd needs pow() and hence libm
685 dnl -------------------------------
686 TMPLIBS="$LIBS"
687 AC_CHECK_HEADER([math.h],
688   [AC_CHECK_LIB([m], [pow],
689     [LIBM="-lm"
690      LIBS="$LIBS $LIBM"
691      AC_DEFINE(HAVE_LIBM,, Have libm)
692      AC_CHECK_FUNCS(pow,[],[LIBM=""])
693     ])
695 if test x"$LIBM" = x ; then
696   AC_MSG_WARN([Unable to find working pow function - bgpd may not link])
698 LIBS="$TMPLIBS"
699 AC_SUBST(LIBM)
701 dnl ---------------
702 dnl other functions
703 dnl ---------------
704 AC_CHECK_FUNCS([dup2 ftruncate getcwd gethostbyname getpagesize gettimeofday \
705         inet_ntoa inet_aton strnlen \
706         memchr memmove memset select socket \
707         strcasecmp strchr strcspn strdup strerror \
708         strncasecmp strndup strrchr strspn strstr \
709         strtol strtoul strlcat strlcpy \
710         daemon snprintf vsnprintf \
711         if_nametoindex if_indextoname getifaddrs \
712         uname fcntl])
714 AC_CHECK_FUNCS(setproctitle, ,
715   [AC_CHECK_LIB(util, setproctitle, 
716      [LIBS="$LIBS -lutil"
717       AC_DEFINE(HAVE_SETPROCTITLE,, Have setproctitle)
718      ]
719    )
720   ]
723 dnl ------------------------------------
724 dnl Determine routing get and set method
725 dnl ------------------------------------
726 AC_MSG_CHECKING(zebra between kernel interface method)
727 if test x"$opsys" = x"gnu-linux"; then
728   if test "${enable_netlink}" = "yes";then
729     AC_MSG_RESULT(netlink)
730     RT_METHOD=rt_netlink.o
731     AC_DEFINE(HAVE_NETLINK,,netlink)
732     netlink=yes
733   elif test "${enable_netlink}" = "no"; then
734     AC_MSG_RESULT(ioctl)
735     RT_METHOD=rt_ioctl.o
736     netlink=no
737   else
738     AC_MSG_RESULT(netlink)
739     RT_METHOD=rt_netlink.o
740     AC_DEFINE(HAVE_NETLINK,,netlink)
741     netlink=yes
742   fi
743 elif test x"$opsys" = x"sol2-6";then
744   AC_MSG_RESULT(Route socket)
745   KERNEL_METHOD="kernel_socket.o"
746   RT_METHOD="rt_socket.o"
747 elif test x"$opsys" = x"sol8";then
748   AC_MSG_RESULT(Route socket)
749   KERNEL_METHOD="kernel_socket.o"
750   RT_METHOD="rt_socket.o"
751 elif test "$opsys" = "irix" ; then
752   AC_MSG_RESULT(Route socket)
753   KERNEL_METHOD="kernel_socket.o"
754   RT_METHOD="rt_socket.o"
755 else
756   AC_TRY_RUN([#include <errno.h>
757 #include <sys/types.h>
758 #include <sys/socket.h>
760 main ()
762   int ac_sock;
764   ac_sock = socket (AF_ROUTE, SOCK_RAW, 0);
765   if (ac_sock < 0 && errno == EINVAL)
766     exit (1);
767   exit (0);
769   [KERNEL_METHOD=kernel_socket.o
770    RT_METHOD=rt_socket.o
771    AC_MSG_RESULT(socket)],
772   [RT_METHOD=rt_ioctl.o
773    AC_MSG_RESULT(ioctl)],
774   [KERNEL_METHOD=kernel_socket.o
775    RT_METHOD=rt_socket.o
776    AC_MSG_RESULT(socket)])
778 AC_SUBST(RT_METHOD)
779 AC_SUBST(KERNEL_METHOD)
780 AC_SUBST(OTHER_METHOD)
782 dnl --------------------------
783 dnl Determine IS-IS I/O method
784 dnl --------------------------
785 AC_DEFINE(ISIS_METHOD_PFPACKET, 1, [ constant value for isis method pfpacket ])
786 AC_DEFINE(ISIS_METHOD_DLPI,     2, [ constant value for isis method dlpi ])
787 AC_DEFINE(ISIS_METHOD_BPF,      3, [ constant value for isis method bpf ])
788 AC_CHECK_HEADER(net/bpf.h)
789 AC_CHECK_HEADER(sys/dlpi.h)
790 AC_MSG_CHECKING(zebra IS-IS I/O method)
791 if test x"$opsys" = x"gnu-linux"; then
792   AC_MSG_RESULT(pfpacket)
793   ISIS_METHOD_MACRO="ISIS_METHOD_PFPACKET"
794 elif test x"$opsys" = x"sol2-6" -o x"$opsys" = x"sol8"; then
795   AC_MSG_RESULT(DLPI)
796   ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
797 else
798   if test $ac_cv_header_net_bpf_h = no; then
799     if test $ac_cv_header_sys_dlpi_h = no; then
800       AC_MSG_RESULT(none)
801       AC_MSG_WARN([*** IS-IS support will not be built ***])
802       ISISD=""
803     else
804       AC_MSG_RESULT(DLPI)
805     fi
806     ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
807   else
808     AC_MSG_RESULT(BPF)
809     ISIS_METHOD_MACRO="ISIS_METHOD_BPF"
810   fi
812 AC_DEFINE_UNQUOTED(ISIS_METHOD, $ISIS_METHOD_MACRO, [ selected method for isis, == one of the constants ])
814 dnl ------------------------------------
815 dnl check for broken CMSG_FIRSTHDR macro
816 dnl ------------------------------------
817 AC_MSG_CHECKING(for broken CMSG_FIRSTHDR)
818 AC_RUN_IFELSE([AC_LANG_SOURCE([[
819 #ifdef SUNOS_5
820 #define _XPG4_2
821 #define __EXTENSIONS__
822 #endif
823 #ifdef HAVE_STDLIB_H
824 # include <stdlib.h>
825 #endif
826 #ifdef HAVE_SYS_TYPES_H
827 #include <sys/types.h>
828 #endif
829 #ifdef HAVE_SYS_SOCKET_H
830 #include <sys/socket.h>
831 #endif
833 main()
835   struct msghdr msg;
836   char buf[4];
838   msg.msg_control = buf;
839   msg.msg_controllen = 0;
841   if (CMSG_FIRSTHDR(&msg) != NULL)
842     exit(0);
843   exit (1);
844 }]])],[AC_MSG_RESULT(yes - using workaround) AC_DEFINE(HAVE_BROKEN_CMSG_FIRSTHDR,,Broken CMSG_FIRSTHDR)],
845 [AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
847 dnl ------------------------------
848 dnl check kernel route read method
849 dnl ------------------------------
850 AC_CACHE_CHECK([route read method], [quagga_cv_rtread_method],
851 [if test "x$netlink" = xyes; then
852   quagga_cv_rtread_method="netlink"
853 else
854 for quagga_cv_rtread_method in /proc/net/route /dev/ip /dev/null;
856   test x`ls $quagga_cv_rtread_method 2>/dev/null` = x"$quagga_cv_rtread_method" && break
857 done
858 case $quagga_cv_rtread_method in
859   "/proc/net/route") quagga_cv_rtread_method="proc";;
860   "/dev/ip")
861                      case "$host" in
862                        *-freebsd*)    quagga_cv_rtread_method="sysctl";;
863                        *)             quagga_cv_rtread_method="getmsg";;
864                      esac;;
865         *)
866                      quagga_cv_rtread_method="sysctl";;
867 esac
868 fi])
869 RTREAD_METHOD=rtread_${quagga_cv_rtread_method}.o
870 AC_SUBST(RTREAD_METHOD)
872 dnl -----------------------------
873 dnl check interface lookup method
874 dnl -----------------------------
875 IOCTL_METHOD=ioctl.o
876 AC_MSG_CHECKING(interface looking up method)
877 if test "$netlink" = yes; then
878   AC_MSG_RESULT(netlink)
879   IF_METHOD=if_netlink.o
880 elif test "$opsys" = "sol2-6";then
881   AC_MSG_RESULT(Solaris GIF)
882   IF_METHOD=if_ioctl.o
883 elif test "$opsys" = "sol8";then
884   AC_MSG_RESULT(Solaris GLIF)
885   IF_METHOD=if_ioctl_solaris.o
886   IOCTL_METHOD=ioctl_solaris.o
887 elif test "$opsys" = "irix" ; then
888   AC_MSG_RESULT(IRIX)
889   IF_METHOD=if_ioctl.o
890 elif test "$opsys" = "openbsd";then
891   AC_MSG_RESULT(openbsd)
892   IF_METHOD=if_ioctl.o
893 elif grep NET_RT_IFLIST /usr/include/sys/socket.h >/dev/null 2>&1; then
894   AC_MSG_RESULT(sysctl)
895     IF_METHOD=if_sysctl.o
896     AC_DEFINE(HAVE_NET_RT_IFLIST,,NET_RT_IFLIST)
897 else
898     AC_MSG_RESULT(ioctl)
899     IF_METHOD=if_ioctl.o
901 AC_SUBST(IF_METHOD)
902 AC_SUBST(IOCTL_METHOD)
904 dnl ---------------------------------------------------------------
905 dnl figure out how to specify an interface in multicast sockets API
906 dnl ---------------------------------------------------------------
907 AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], QUAGGA_INCLUDES)
909 AC_MSG_CHECKING([for BSD struct ip_mreq hack])
910 AC_TRY_COMPILE([#ifdef HAVE_SYS_PARAM_H
911 #include <sys/param.h>
912 #endif],[#if (defined(__FreeBSD__) && ((__FreeBSD_version >= 500022 && __FreeBSD_version < 700000) || (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) || (defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 106010000)
913   return (0);
914 #else
915   #error No support for BSD struct ip_mreq hack detected
916 #endif],[AC_MSG_RESULT(yes)
917 AC_DEFINE(HAVE_BSD_STRUCT_IP_MREQ_HACK,,[Can pass ifindex in struct ip_mreq])],
918 AC_MSG_RESULT(no))
920 dnl ---------------------------------------------------------------
921 dnl figure out how to check link-state
922 dnl ---------------------------------------------------------------
923 AC_CHECK_HEADER([net/if.h],
924   [AC_CHECK_HEADER( [net/if_media.h],
925     [m4_define([LINK_DETECT_INCLUDES],
926       QUAGGA_INCLUDES
927       [#include <net/if_media.h>
928     ])
929     AC_CHECK_MEMBERS( [struct ifmediareq.ifm_status],
930       AC_DEFINE(HAVE_BSD_LINK_DETECT,,[BSD link-detect]),
931       [], LINK_DETECT_INCLUDES)], 
932     [],
933     QUAGGA_INCLUDES)], 
934   [], QUAGGA_INCLUDES )
936 dnl ------------------------
937 dnl TCP_MD5SIG socket option
938 dnl ------------------------
940 AC_CHECK_HEADER([netinet/tcp.h], 
941    [m4_define([MD5_INCLUDES],
942       QUAGGA_INCLUDES
943       [#include <netinet/tcp.h>
944     ])
945     AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)],
946    [],
947    QUAGGA_INCLUDES)
948 if test $ac_cv_have_decl_TCP_MD5SIG = no; then
949   AC_CHECK_HEADER([linux/tcp.h],
950        [m4_define([MD5_INCLUDES],
951           QUAGGA_INCLUDES
952           [#include <linux/tcp.h>
953         ])
954        AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)])
957 dnl -----------------------
958 dnl check proc file system.
959 dnl -----------------------
960 if test "$netlink" != yes; then
961   if test -r /proc/net/dev; then
962     AC_DEFINE(HAVE_PROC_NET_DEV,,/proc/net/dev)
963     IF_PROC=if_proc.o
964   fi
965   if test -r /proc/net/if_inet6; then
966     AC_DEFINE(HAVE_PROC_NET_IF_INET6,,/proc/net/if_inet6)
967     IF_PROC=if_proc.o
968   fi
970 AC_SUBST(IF_PROC)
972 dnl -----------------------------
973 dnl check ipforward detect method
974 dnl -----------------------------
975 AC_CACHE_CHECK([ipforward method], [quagga_cv_ipforward_method],
976 [for quagga_cv_ipforward_method in /proc/net/snmp /dev/ip /dev/null;
978   test x`ls $quagga_cv_ipforward_method 2>/dev/null` = x"$quagga_cv_ipforward_method" && break
979 done
980 case $quagga_cv_ipforward_method in
981   "/proc/net/snmp")  quagga_cv_ipforward_method="proc";;
982   "/dev/ip")         
983                      case "$host" in
984                        *-nec-sysv4*)  quagga_cv_ipforward_method="ews";;
985                        *-freebsd*)    quagga_cv_ipforward_method="sysctl";;
986                        *)             quagga_cv_ipforward_method="solaris";;
987                      esac;;
988   *)                 quagga_cv_ipforward_method="sysctl";;
989 esac])
990 IPFORWARD=ipforward_${quagga_cv_ipforward_method}.o
991 AC_SUBST(IPFORWARD)
993 AC_CHECK_FUNCS(getaddrinfo, [have_getaddrinfo=yes], [have_getaddrinfo=no])
995 dnl ----------
996 dnl IPv6 check
997 dnl ----------
998 AC_MSG_CHECKING(whether does this OS have IPv6 stack)
999 if test "${enable_ipv6}" = "no"; then
1000   AC_MSG_RESULT(disabled)
1001 else
1002 dnl ----------
1003 dnl INRIA IPv6
1004 dnl ----------
1005   if grep IPV6_INRIA_VERSION /usr/include/netinet/in.h >/dev/null 2>&1; then
1006     zebra_cv_ipv6=yes
1007     AC_DEFINE(HAVE_IPV6,1,INRIA IPv6)
1008     AC_DEFINE(INRIA_IPV6,1,INRIA IPv6)
1009     RIPNGD="ripngd"
1010     OSPF6D="ospf6d"
1011     LIB_IPV6=""
1012     AC_MSG_RESULT(INRIA IPv6)
1013 dnl ---------
1014 dnl KAME IPv6
1015 dnl ---------
1016   elif grep WIDE /usr/include/netinet6/in6.h >/dev/null 2>&1; then
1017     zebra_cv_ipv6=yes
1018     AC_DEFINE(HAVE_IPV6,1,KAME IPv6)
1019     AC_DEFINE(KAME,1,KAME IPv6)
1020     RIPNGD="ripngd"
1021     OSPF6D="ospf6d"
1022     if test -d /usr/local/v6/lib -a -f /usr/local/v6/lib/libinet6.a; then
1023       LIB_IPV6="-L/usr/local/v6/lib -linet6"
1024     fi
1025     AC_MSG_RESULT(KAME)
1026 dnl -------------------------
1027 dnl MUSICA IPv6
1028 dnl  default host check
1029 dnl  It is not used by Kheops
1030 dnl -------------------------
1031   elif grep MUSICA /usr/include6/netinet6/in6.h >/dev/null 2>&1; then
1032     zebra_cv_ipv6=yes
1033     AC_DEFINE(HAVE_IPV6,1,Musicia IPv6)
1034     AC_DEFINE(MUSICA,1,Musica IPv6 stack)
1035     AC_DEFINE(KAME,1,KAME IPv6 stack)
1036     RIPNGD="ripngd"
1037     OSPF6D="ospf6d"
1038     if test -d /usr/local/v6/lib -a -f /usr/local/v6/lib/libinet6.a; then
1039       LIB_IPV6="-L/usr/local/v6/lib -linet6"
1040     fi
1041     AC_MSG_RESULT(MUSICA)
1042 dnl ---------
1043 dnl NRL check
1044 dnl ---------
1045   elif grep NRL /usr/include/netinet6/in6.h >/dev/null 2>&1; then
1046     zebra_cv_ipv6=yes
1047     AC_DEFINE(HAVE_IPV6,1,NRL IPv6)
1048     AC_DEFINE(NRL,1,NRL)
1049     RIPNGD="ripngd"
1050     OSPF6D="ospf6d"
1051     if test x"$opsys" = x"bsdi";then
1052       AC_DEFINE(BSDI_NRL,,BSDI)
1053       AC_MSG_RESULT(BSDI_NRL)
1054     else
1055       AC_MSG_RESULT(NRL)
1056     fi
1057 dnl ------------------------------------
1058 dnl Solaris 9, 10 and potentially higher
1059 dnl ------------------------------------
1060   elif test x"$opsys" = x"sol8"; then
1061     zebra_cv_ipv6=yes;
1062     AC_DEFINE(HAVE_IPV6, 1, IPv6)
1063     AC_DEFINE(SOLARIS_IPV6, 1, Solaris IPv6)
1064     RIPNGD="ripngd"
1065     OSPF6D="ospf6d"
1066     AC_MSG_RESULT(Solaris IPv6)
1067 dnl ----------
1068 dnl Linux IPv6
1069 dnl ----------
1070   elif test "${enable_ipv6}" = "yes"; then
1071     AC_EGREP_CPP(yes, [
1072       #include <linux/version.h>
1073       /* 2.1.128 or later */
1074       #if LINUX_VERSION_CODE >= 0x020180
1075       yes
1076       #endif],
1077       [zebra_cv_ipv6=yes
1078        zebra_cv_linux_ipv6=yes
1079        AC_MSG_RESULT(Linux IPv6)])
1080   else
1081     if test x`ls /proc/net/ipv6_route 2>/dev/null` = x"/proc/net/ipv6_route"
1082      then
1083       zebra_cv_ipv6=yes
1084       zebra_cv_linux_ipv6=yes
1085       AC_MSG_RESULT(Linux IPv6)
1086     fi
1087   fi
1089   if test "$zebra_cv_linux_ipv6" = "yes";then
1090     AC_MSG_CHECKING(whether libc has IPv6 support)
1091     AC_TRY_LINK([#include <netinet/in.h>
1092     ],[ int a; a = (int) in6addr_any.s6_addr[0]; if (a != 12345) return a; ],
1093     [AC_MSG_RESULT(yes)
1094       zebra_cv_ipv6=yes
1095       zebra_cv_linux_ipv6=yes],
1096     [AC_MSG_RESULT(no)
1097       zebra_cv_ipv6=no
1098       zebra_cv_linux_ipv6=no])
1099   fi
1101   if test "$zebra_cv_linux_ipv6" = "yes";then
1102     AC_MSG_CHECKING(for GNU libc >= 2.1)
1103     AC_DEFINE(HAVE_IPV6,1,Linux IPv6)
1104     AC_EGREP_CPP(yes, [
1105 #include <features.h>
1106 #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
1107   yes
1108 #endif], 
1109       [glibc=yes
1110        AC_DEFINE(LINUX_IPV6,1,Linux IPv6 stack)
1111        AC_MSG_RESULT(yes)], 
1112       AC_MSG_RESULT(no)
1113     )
1114     RIPNGD="ripngd"
1115     OSPF6D="ospf6d"
1116     if test "$glibc" != "yes"; then
1117       INCLUDES="-I/usr/inet6/include"
1118       if test x`ls /usr/inet6/lib/libinet6.a 2>/dev/null` != x;then
1119          LIB_IPV6="-L/usr/inet6/lib -linet6"
1120       fi
1121     fi
1122   fi
1124 dnl -----------------------
1125 dnl Set IPv6 related values
1126 dnl -----------------------
1127   LIBS="$LIB_IPV6 $LIBS"
1128   AC_SUBST(LIB_IPV6)
1130   if test x"$RIPNGD" = x""; then
1131     AC_MSG_RESULT(IPv4 only)
1132   fi
1135 dnl ------------------
1136 dnl IPv6 header checks
1137 dnl ------------------
1138 if test "x${zebra_cv_ipv6}" = "xyes"; then
1139 AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h netinet/icmp6.h \
1140         netinet6/in6_var.h netinet6/nd6.h], [], [],
1141         QUAGGA_INCLUDES)
1144 m4_define([QUAGGA_INCLUDES],dnl
1145 QUAGGA_INCLUDES
1146 [#if HAVE_NETINET6_IN6_H
1147 #include <netinet6/in6.h>
1148 #endif
1149 #if HAVE_NETINET_IN6_VAR_H
1150 #include <netinet/in6_var.h>
1151 #endif
1152 #if HAVE_NETINET_ICMP6_H
1153 # include <netinet/icmp6.h>
1154 #endif
1155 #if HAVE_NETINET6_IN6_VAR_H
1156 # include <netinet6/in6_var.h>
1157 #endif
1158 #if HAVE_NETINET6_ND6_H
1159 # include <netinet6/nd6.h>
1160 #endif
1161 ])dnl
1163 dnl disable doc check
1164 if test "${enable_doc}" = "no";then
1165   DOC=""
1166 else
1167   DOC="doc"
1170 dnl --------------------
1171 dnl Daemon disable check
1172 dnl --------------------
1173 if test "${enable_zebra}" = "no";then
1174   ZEBRA=""
1175 else
1176   ZEBRA="zebra"
1179 if test "${enable_bgpd}" = "no";then
1180   BGPD=""
1181 else
1182   BGPD="bgpd"
1185 if test "${enable_ripd}" = "no";then
1186   RIPD=""
1187 else
1188   RIPD="ripd"
1191 if test "${enable_ospfd}" = "no";then
1192   OSPFD=""
1193 else
1194   OSPFD="ospfd"
1197 if test "${enable_watchquagga}" = "no";then
1198   WATCHQUAGGA=""
1199 else
1200   WATCHQUAGGA="watchquagga"
1203 OSPFCLIENT=""
1204 if test "${enable_opaque_lsa}" = "yes"; then
1205   if test "${enable_ospfapi}" != "no";then
1206     AC_DEFINE(SUPPORT_OSPF_API,,OSPFAPI)
1208     if test "${enable_ospfclient}" != "no";then
1209       OSPFCLIENT="ospfclient"
1210     fi
1211   fi
1215 case "${enable_ripngd}" in
1216   "yes") RIPNGD="ripngd";;
1217   "no" ) RIPNGD="";;
1218   *    ) ;;
1219 esac
1221 case "${enable_ospf6d}" in
1222   "yes") OSPF6D="ospf6d";;
1223   "no" ) OSPF6D="";;
1224   *    ) ;;
1225 esac
1227 case "${enable_isisd}" in
1228   "yes") ISISD="isisd";;
1229   "no" ) ISISD="";;
1230   *    ) ;;
1231 esac
1233 # XXX Perhaps auto-enable on Solaris, but that's messy for cross builds.
1234 case "${enable_solaris}" in
1235   "yes") SOLARIS="solaris";;
1236   "no" ) SOLARIS="";;
1237   *    ) ;;
1238 esac
1240 if test "${enable_bgp_announce}" = "no";then
1241   AC_DEFINE(DISABLE_BGP_ANNOUNCE,1,Disable BGP installation to zebra)
1242 else
1243   AC_DEFINE(DISABLE_BGP_ANNOUNCE,0,Disable BGP installation to zebra)
1246 AC_SUBST(DOC)
1247 AC_SUBST(ZEBRA)
1248 AC_SUBST(BGPD)
1249 AC_SUBST(RIPD)
1250 AC_SUBST(RIPNGD)
1251 AC_SUBST(OSPFD)
1252 AC_SUBST(OSPF6D)
1253 AC_SUBST(WATCHQUAGGA)
1254 AC_SUBST(ISISD)
1255 AC_SUBST(SOLARIS)
1256 AC_SUBST(VTYSH)
1257 AC_SUBST(INCLUDES)
1258 AC_SUBST(CURSES)
1259 AC_SUBST(OSPFCLIENT)
1260 AC_SUBST(OSPFAPI)
1261 AC_CHECK_LIB(c, inet_ntop, [AC_DEFINE(HAVE_INET_NTOP,,inet_ntop)])
1262 AC_CHECK_LIB(c, inet_pton, [AC_DEFINE(HAVE_INET_PTON,,inet_pton)])
1263 AC_CHECK_LIB(crypt, crypt)
1264 AC_CHECK_LIB(resolv, res_init)
1266 dnl ---------------------------------------------------
1267 dnl BSD/OS 4.1 define inet_XtoY function as __inet_XtoY
1268 dnl ---------------------------------------------------
1269 AC_CHECK_FUNC(__inet_ntop, AC_DEFINE(HAVE_INET_NTOP,,__inet_ntop))
1270 AC_CHECK_FUNC(__inet_pton, AC_DEFINE(HAVE_INET_PTON,,__inet_pton))
1271 AC_CHECK_FUNC(__inet_aton, AC_DEFINE(HAVE_INET_ATON,,__inet_aton))
1273 dnl ---------------------------
1274 dnl check system has PCRE regexp
1275 dnl ---------------------------
1276 if test "x$enable_pcreposix" = "xyes"; then
1277   AC_CHECK_LIB(pcreposix, pcreposix_regexec, ,[enable_pcreposix=no
1278   AC_MSG_WARN([*** falling back to other regex library ***]) ])
1281 if test "x$enable_pcreposix" != "xyes"; then
1282 dnl ---------------------------
1283 dnl check system has GNU regexp
1284 dnl ---------------------------
1285 AC_MSG_CHECKING(whether system has GNU regex)
1286 AC_CHECK_LIB(c, regexec,
1287 [AC_DEFINE(HAVE_GNU_REGEX,,GNU regexp library)
1288  LIB_REGEX=""],
1289 [LIB_REGEX="regex.o"])
1291 AC_SUBST(HAVE_LIBPCREPOSIX)
1292 AC_SUBST(LIB_REGEX)
1294 dnl ------------------
1295 dnl check Net-SNMP library
1296 dnl ------------------
1297 if test "${enable_snmp}" = "yes"; then
1298     if test "$with_crypto" != "no"; then
1299         LIBS="${LIBS} -lcrypto";
1300     fi
1301     AC_CHECK_LIB(netsnmp, asn_parse_int,
1302         [AC_DEFINE(HAVE_NETSNMP,,Net SNMP) 
1303          AC_DEFINE(HAVE_SNMP,,SNMP)
1304          LIBS="${LIBS} -lnetsnmp"],
1305         [AC_MSG_ERROR([--enable-snmp given, but cannot find support for SNMP])])
1307     AC_CHECK_HEADER([net-snmp/net-snmp-config.h],
1308         [],
1309         [AC_MSG_ERROR([--enable-snmp given, but cannot find net-snmp-config.h])],
1310         QUAGGA_INCLUDES)
1311     AC_SUBST(SNMP_INCLUDES)
1314 dnl ---------------------------
1315 dnl sockaddr and netinet checks
1316 dnl ---------------------------
1317 AC_CHECK_TYPES([struct sockaddr, struct sockaddr_in,
1318         struct sockaddr_in6, struct sockaddr_un, struct sockaddr_dl,
1319         socklen_t,
1320         struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq,
1321         struct nd_opt_adv_interval, struct rt_addrinfo,
1322         struct nd_opt_homeagent_info, struct nd_opt_adv_interval],
1323         [], [], QUAGGA_INCLUDES)
1325 AC_CHECK_MEMBERS([struct sockaddr.sa_len,
1326         struct sockaddr_in.sin_len, struct sockaddr_un.sun_len,
1327         struct sockaddr_in6.sin6_scope_id,
1328         struct if6_aliasreq.ifra_lifetime,
1329         struct nd_opt_adv_interval.nd_opt_ai_type],
1330         [], [], QUAGGA_INCLUDES)
1332 dnl ---------------------------
1333 dnl IRDP/pktinfo/icmphdr checks
1334 dnl ---------------------------
1335 AC_CHECK_TYPES([struct in_pktinfo], 
1336  [AC_CHECK_TYPES([struct icmphdr],
1337    [if test "${enable_irdp}" != "no"; then
1338       AC_DEFINE(HAVE_IRDP,, IRDP)
1339     fi],
1340    [if test "${enable_irdp}" = "yes"; then
1341       AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
1342     fi], [QUAGGA_INCLUDES])],
1343  [if test "${enable_irdp}" = "yes"; then
1344     AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
1345   fi], [QUAGGA_INCLUDES])
1347 dnl --------------------------------------
1348 dnl checking for getrusage struct and call
1349 dnl --------------------------------------
1350 AC_MSG_CHECKING(whether getrusage is available)
1351 AC_TRY_COMPILE([#include <sys/resource.h>
1352 ],[struct rusage ac_x; getrusage (RUSAGE_SELF, &ac_x);],
1353 [AC_MSG_RESULT(yes)
1354  AC_DEFINE(HAVE_RUSAGE,,rusage)],
1355  AC_MSG_RESULT(no))
1357 dnl --------------------------------------
1358 dnl checking for clock_time monotonic struct and call
1359 dnl --------------------------------------
1360 AC_CHECK_DECL(CLOCK_MONOTONIC,
1361         [AC_CHECK_LIB(rt, clock_gettime, [LIBS="$LIBS -lrt"])
1362          AC_DEFINE(HAVE_CLOCK_MONOTONIC,, Have monotonic clock)
1363 ], [AC_MSG_RESULT(no)], [QUAGGA_INCLUDES])
1365 dnl -------------------
1366 dnl capabilities checks
1367 dnl -------------------
1368 if test "${enable_capabilities}" != "no"; then
1369   AC_MSG_CHECKING(whether prctl PR_SET_KEEPCAPS is available)
1370   AC_TRY_COMPILE([#include <sys/prctl.h>],[prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);],
1371     [AC_MSG_RESULT(yes)
1372      AC_DEFINE(HAVE_PR_SET_KEEPCAPS,,prctl)
1373      quagga_ac_keepcaps="yes"],
1374      AC_MSG_RESULT(no)
1375   )
1376   if test x"${quagga_ac_keepcaps}" = x"yes"; then
1377     AC_CHECK_HEADERS(sys/capability.h)
1378   fi
1379   if test x"${ac_cv_header_sys_capability_h}" = x"yes"; then
1380     AC_CHECK_LIB(cap, cap_init, 
1381       [AC_DEFINE(HAVE_LCAPS,1,Capabilities)
1382        LIBCAP="-lcap"
1383        quagga_ac_lcaps="yes"]
1384     )
1385   else
1386     AC_CHECK_HEADERS(priv.h,
1387      [AC_MSG_CHECKING(Solaris style privileges are available)
1388       AC_TRY_COMPILE([#include <priv.h>],[getpflags(PRIV_AWARE);],
1389           [AC_MSG_RESULT(yes)
1390            AC_DEFINE(HAVE_SOLARIS_CAPABILITIES,1,getpflags)
1391            quagga_ac_scaps="yes"],
1392            AC_MSG_RESULT(no)
1393       )
1394      ]
1395    )
1396   fi
1397   if test x"${quagga_ac_scaps}" = x"yes" \
1398        -o x"${quagga_ac_lcaps}" = x"yes"; then
1399     AC_DEFINE(HAVE_CAPABILITIES,1,capabilities)
1400   fi
1402 AC_SUBST(LIBCAP)
1404 dnl ---------------------------
1405 dnl check for glibc 'backtrace'
1406 dnl --------------------------- 
1407 if test "${glibc}" = "yes"; then
1408    AC_CHECK_HEADER([execinfo.h],
1409     [AC_CHECK_FUNC([backtrace],
1410         [AC_DEFINE(HAVE_GLIBC_BACKTRACE,,[Glibc backtrace])
1411          AC_DEFINE(HAVE_STACK_TRACE,,[Stack symbol decoding])
1412         ])
1413     ])
1416 dnl -----------------------------------------
1417 dnl check for malloc mallinfo struct and call
1418 dnl this must try and link using LIBS, in
1419 dnl order to check no alternative allocator
1420 dnl has been specified, which might not provide
1421 dnl mallinfo, e.g. such as Umem on Solaris.
1422 dnl -----------------------------------------
1423 AC_CHECK_HEADER([malloc.h],
1424  [AC_MSG_CHECKING(whether mallinfo is available)
1425   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
1426                         [[struct mallinfo ac_x; ac_x = mallinfo ();]])],
1427       [AC_MSG_RESULT(yes)
1428        AC_DEFINE(HAVE_MALLINFO,,mallinfo)],
1429        AC_MSG_RESULT(no)
1430   )
1431  ], [], QUAGGA_INCLUDES)
1433 dnl ----------
1434 dnl configure date
1435 dnl ----------
1436 CONFDATE=`date '+%Y%m%d'`
1437 AC_SUBST(CONFDATE)
1439 dnl Conditionally enable PIE support for GNU toolchains.
1440 AC_ARG_ENABLE(pie, AS_HELP_STRING([--disable-pie], [Do not build tools as a Position Independent Executables]))
1441 if test "$enable_pie" != "no"; then
1442   AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [
1443     save_CFLAGS=$CFLAGS
1444     save_LDFLAGS=$LDFLAGS
1445     CFLAGS="$CFLAGS -fPIE"
1446     LDFLAGS="$LDFLAGS -pie"
1447     AC_LINK_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
1448       [ap_cv_cc_pie=yes], [ap_cv_cc_pie=no]
1449     )
1450     CFLAGS=$save_CFLAGS
1451     LDFLAGS=$save_LDFLAGS
1452   ])
1453   if test "$ap_cv_cc_pie" = "yes"; then
1454     PICFLAGS="-fPIE"
1455     PILDFLAGS="-pie"
1456   fi
1459 AC_SUBST(PICFLAGS)
1460 AC_SUBST(PILDFLAGS)
1462 dnl ------------------------------
1463 dnl set paths for state directory
1464 dnl ------------------------------
1465 AC_MSG_CHECKING(directory to use for state file)
1466 if test "${prefix}" = "NONE"; then
1467   quagga_statedir_prefix="";
1468 else
1469   quagga_statedir_prefix=${prefix}
1471 if test "${localstatedir}" = '${prefix}/var'; then
1472   for QUAGGA_STATE_DIR in ${quagga_statedir_prefix}/var/run dnl
1473                         ${quagga_statedir_prefix}/var/adm dnl
1474                         ${quagga_statedir_prefix}/etc dnl
1475                         /var/run        dnl
1476                         /var/adm        dnl
1477                         /etc            dnl
1478                         /dev/null;
1479   do
1480     test -d $QUAGGA_STATE_DIR && break
1481   done
1482   quagga_statedir=$QUAGGA_STATE_DIR
1483 else
1484   quagga_statedir=${localstatedir}
1486 if test $quagga_statedir = "/dev/null"; then
1487     AC_MSG_ERROR('STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!')
1489 AC_MSG_RESULT(${quagga_statedir})
1490 AC_SUBST(quagga_statedir)
1492 AC_DEFINE_UNQUOTED(PATH_ZEBRA_PID, "$quagga_statedir/zebra.pid",zebra PID)
1493 AC_DEFINE_UNQUOTED(PATH_RIPD_PID, "$quagga_statedir/ripd.pid",ripd PID)
1494 AC_DEFINE_UNQUOTED(PATH_RIPNGD_PID, "$quagga_statedir/ripngd.pid",ripngd PID)
1495 AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$quagga_statedir/bgpd.pid",bgpd PID)
1496 AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$quagga_statedir/ospfd.pid",ospfd PID)
1497 AC_DEFINE_UNQUOTED(PATH_OSPF6D_PID, "$quagga_statedir/ospf6d.pid",ospf6d PID)
1498 AC_DEFINE_UNQUOTED(PATH_ISISD_PID, "$quagga_statedir/isisd.pid",isisd PID)
1499 AC_DEFINE_UNQUOTED(PATH_WATCHQUAGGA_PID, "$quagga_statedir/watchquagga.pid",watchquagga PID)
1500 AC_DEFINE_UNQUOTED(ZEBRA_SERV_PATH, "$quagga_statedir/zserv.api",zebra api socket)
1501 AC_DEFINE_UNQUOTED(ZEBRA_VTYSH_PATH, "$quagga_statedir/zebra.vty",zebra vty socket)
1502 AC_DEFINE_UNQUOTED(RIP_VTYSH_PATH, "$quagga_statedir/ripd.vty",rip vty socket)
1503 AC_DEFINE_UNQUOTED(RIPNG_VTYSH_PATH, "$quagga_statedir/ripngd.vty",ripng vty socket)
1504 AC_DEFINE_UNQUOTED(BGP_VTYSH_PATH, "$quagga_statedir/bgpd.vty",bgpd vty socket)
1505 AC_DEFINE_UNQUOTED(OSPF_VTYSH_PATH, "$quagga_statedir/ospfd.vty",ospfd vty socket)
1506 AC_DEFINE_UNQUOTED(OSPF6_VTYSH_PATH, "$quagga_statedir/ospf6d.vty",ospf6d vty socket)
1507 AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$quagga_statedir/isisd.vty",isisd vty socket)
1508 AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$quagga_statedir",daemon vty directory)
1510 dnl -------------------------------
1511 dnl Quagga sources should always be 
1512 dnl current wrt interfaces. Dont
1513 dnl allow deprecated interfaces to
1514 dnl be exposed.
1515 dnl -------------------------------
1516 AC_DEFINE(QUAGGA_NO_DEPRECATED_INTERFACES, 1, Hide deprecated interfaces)
1518 dnl ---------------------------
1519 dnl Check htonl works correctly
1520 dnl ---------------------------
1521 AC_MSG_CHECKING(for working htonl)
1522 AC_CACHE_VAL(ac_cv_htonl_works,
1523  [AC_LINK_IFELSE([AC_LANG_PROGRAM([QUAGGA_INCLUDES],[htonl (0);])],
1524                 [ac_cv_htonl_works=yes], [ac_cv_htonl_works=no])
1527 AC_MSG_RESULT($ac_cv_htonl_works)
1529 AC_CONFIG_FILES([Makefile lib/Makefile zebra/Makefile ripd/Makefile 
1530           ripngd/Makefile bgpd/Makefile ospfd/Makefile watchquagga/Makefile
1531           ospf6d/Makefile isisd/Makefile vtysh/Makefile doc/Makefile 
1532           ospfclient/Makefile tests/Makefile m4/Makefile redhat/Makefile
1533           pkgsrc/Makefile
1534           redhat/quagga.spec 
1535           lib/version.h
1536           doc/defines.texi
1537           isisd/topology/Makefile
1538           pkgsrc/bgpd.sh pkgsrc/ospf6d.sh pkgsrc/ospfd.sh
1539           pkgsrc/ripd.sh pkgsrc/ripngd.sh pkgsrc/zebra.sh])
1540 AC_CONFIG_FILES([solaris/Makefile])
1542 AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl])
1543 ## Hack, but working solution to avoid rebuilding of quagga.info.
1544 ## It's already in CVS until texinfo 4.7 is more common.
1545 AC_OUTPUT
1547 echo "
1548 Quagga configuration
1549 --------------------
1550 quagga version          : ${PACKAGE_VERSION}
1551 host operating system  : ${host_os}
1552 source code location    : ${srcdir}
1553 compiler                : ${CC}
1554 compiler flags          : ${CFLAGS}
1555 make                    : ${MAKE-make}
1556 includes                : ${INCLUDES} ${SNMP_INCLUDES}
1557 linker flags            : ${LDFLAGS} ${LIBS} ${LIBCAP} ${LIBREADLINE} ${LIBM}
1558 state file directory    : ${quagga_statedir}
1559 config file directory   : `eval echo \`echo ${sysconfdir}\``
1560 example directory       : `eval echo \`echo ${exampledir}\``
1561 user to run as          : ${enable_user}
1562 group to run as         : ${enable_group}
1563 group for vty sockets   : ${enable_vty_group}
1564 config file mask        : ${enable_configfile_mask}
1565 log file mask           : ${enable_logfile_mask}
1567 The above user and group must have read/write access to the state file
1568 directory and to the config files in the config file directory."
1570 if test x"$quagga_cv_gnu_make" = x"no"; then echo "
1571 Warning: The ${MAKE-make} programme detected, either in your path or
1572 via the MAKE variable, is not GNU Make. GNU make may be installed as
1573 gmake on some systems. and is required to complete a build of Quagga
1574 " > /dev/stderr