Merge branch 'Teaman-ND' into Teaman-RT
[tomato.git] / release / src / router / zebra / configure.ac
blob55ffef5e085ba34a60d2a4969b60e47a16ea6513
1 ##
2 ## Configure template file for Zebra.
3 ## autoconf will generate configure script.
4 ##
5 ##  Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
6 ##
7 AC_PREREQ(2.53)
9 AC_INIT(lib/zebra.h)
10 AM_INIT_AUTOMAKE(zebra, 0.95)
11 AM_CONFIG_HEADER(config.h)
13 dnl -----------------------------------
14 dnl Get hostname and other information.
15 dnl -----------------------------------
16 AC_CANONICAL_HOST
18 dnl ------------
19 dnl Check CFLAGS
20 dnl ------------
21 AC_ARG_WITH(cflags,
22 [  --with-cflags           Set CFLAGS for use in compilation.])
23 if test "x$with_cflags" != "x" ; then
24   CFLAGS="$with_cflags" ; cflags_specified=yes ;
25 elif test -n "$CFLAGS" ; then
26   cflags_specified=yes ;
29 dnl ------------
30 dnl Check LINKBASE
31 dnl ------------
32 AC_ARG_WITH(linkbase,
33 [  --with-linkbase         Set local library base for use in compilation.])
34 if test "x$with_linkbase" != "x" ; then
35   linkbase_specified=yes ;
38 dnl --------
39 dnl Check CC
40 dnl --------
41 AC_PROG_CC
43 dnl -----------------------------------------
44 dnl If CLFAGS doesn\'t exist set default value
45 dnl -----------------------------------------
46 if test "x$cflags_specified" = "x" ; then
47   CFLAGS="$CFLAGS -Wall"
50 dnl -----------------------------------------
51 dnl If linkbase specified expand it
52 dnl -----------------------------------------
53 if test "$linkbase_specified" = "yes" ; then
54   CFLAGS="$CFLAGS -I${with_linkbase}/include" ;
55   LIBS="$LIBS -L${with_linkbase}/lib" ;
58 dnl --------------
59 dnl Check programs
60 dnl --------------
61 AC_PROG_CPP
62 AC_PROG_INSTALL
63 AC_PROG_MAKE_SET
64 AC_CHECK_TOOL(AR, ar)
65 AC_CHECK_TOOL(RANLIB, ranlib, :)
67 dnl ---------
68 dnl AIX check
69 dnl ---------
70 AC_AIX
72 dnl ----------------------
73 dnl Packages configuration
74 dnl ----------------------
75 AC_ARG_ENABLE(vtysh,
76 [  --enable-vtysh,       Make integrated VTY version of zebra])
77 AC_ARG_ENABLE(ipv6,
78 [  --disable-ipv6          turn off IPv6 related features and daemons])
79 AC_ARG_ENABLE(zebra,
80 [  --disable-zebra         do not build zebra daemon])
81 AC_ARG_ENABLE(bgpd,
82 [  --disable-bgpd          do not build bgpd])
83 AC_ARG_ENABLE(ripd,
84 [  --disable-ripd          do not build ripd])
85 AC_ARG_ENABLE(ripngd,
86 [  --disable-ripngd        do not build ripngd])
87 AC_ARG_ENABLE(ospfd,
88 [  --disable-ospfd         do not build ospfd])
89 AC_ARG_ENABLE(ospf6d,
90 [  --disable-ospf6d        do not build ospf6d])
91 AC_ARG_ENABLE(irdp,
92 [  --enable-irdp           enable IRDP server support in zebra])
93 AC_ARG_ENABLE(bgp-announce,
94 [  --disable-bgp-announce, turn off BGP route announcement])
95 AC_ARG_ENABLE(netlink,
96 [  --enable-netlink        force to use Linux netlink interface])
97 AC_ARG_ENABLE(broken-aliases,
98 [  --enable-broken-aliases enable aliases as distinct interfaces for Linux 2.2.X])
99 AC_ARG_ENABLE(snmp,
100 [  --enable-snmp           enable SNMP support])
101 AC_ARG_WITH(libpam,
102 [  --with-libpam           use libpam for PAM support in vtysh])
103 AC_ARG_ENABLE(tcpsock,
104 [  --enable-tcp-zebra      enable TCP/IP socket connection between zebra and protocol daemon])
105 dnl Temporary option until OSPF NSSA implementation complete
106 AC_ARG_ENABLE(nssa,
107 [  --enable-nssa           enable OSPF NSSA option])
108 AC_ARG_ENABLE(opaque-lsa,
109 [  --enable-opaque-lsa     enable OSPF Opaque-LSA support (RFC2370)])
110 AC_ARG_ENABLE(ospf-te,
111 [  --enable-ospf-te        enable Traffic Engineering Extension to OSPF])
112 AC_ARG_ENABLE(multipath,
113 [  --enable-multipath=ARG  enable multipath function, ARG must be digit])
114 AC_ARG_ENABLE(tcp-signature,
115 [  --enable-tcp-signature  enable TCP MD5 Signature Option (RFC2385) (for Linux and OpenBSD)])
117 if test "${enable_broken_aliases}" = "yes"; then
118   if test "${enable_netlink}" = "yes"
119   then
120     echo "Sorry, you can't use netlink with broken aliases"
121     exit 1
122   fi
123   AC_DEFINE(HAVE_BROKEN_ALIASES,,Broken Alias)
124   enable_netlink=no
127 if test "${enable_tcp_zebra}" = "yes"; then
128   AC_DEFINE(HAVE_TCP_ZEBRA,,Use TCP for zebra communication)
131 if test "${enable_nssa}" = "yes"; then
132   AC_DEFINE(HAVE_NSSA,,OSPF NSSA)
135 if test "${enable_irdp}" = "yes"; then
136   AC_DEFINE(HAVE_IRDP,, IRDP )
139 if test "${enable_opaque_lsa}" = "yes"; then
140   AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA)
143 if test "${enable_ospf_te}" = "yes"; then
144   AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA)
145   AC_DEFINE(HAVE_OSPF_TE,,OSPF TE)
148 changequote(, )dnl
150 MULTIPATH_NUM=1
152 case "${enable_multipath}" in
153   [0-9]|[1-9][0-9])
154     MULTIPATH_NUM="${enable_multipath}"
155     ;;
156   "")
157     ;;
158   *)           
159     echo "Please specify digit to --enable-multipath ARG."
160     exit 1
161     ;;
162 esac
164 changequote([, ])dnl
166 AC_SUBST(MULTIPATH_NUM)
168 dnl -------------------
169 dnl Check header files.
170 dnl -------------------
171 AC_STDC_HEADERS
172 AC_CHECK_HEADERS(string.h stropts.h sys/conf.h sys/ksym.h sys/time.h sys/times.h sys/select.h sys/sysctl.h sys/sockio.h sys/types.h net/if_dl.h net/if_var.h linux/version.h kvm.h netdb.h netinet/in.h net/netopt.h netinet/in_var.h netinet/in6_var.h netinet/in6.h inet/nd.h asm/types.h netinet/icmp6.h netinet6/nd6.h libutil.h)
174 dnl check some types
175 AC_C_CONST
176 dnl AC_TYPE_PID_T
177 AC_TYPE_SIGNAL
179 dnl Some systems (Solaris 2.x) require libnsl (Network Services Library)
180 case "$host" in
181   *-sunos5.6* | *-solaris2.6*)
182       opsys=sol2-6
183       AC_DEFINE(SUNOS_5,,SunOS 5)
184       AC_CHECK_LIB(xnet, main)
185       CURSES=-lcurses
186   ;;
187   *-sunos5* | *-solaris2*)
188       AC_DEFINE(SUNOS_5,,SunOS 5)
189       AC_CHECK_LIB(socket, main)
190       AC_CHECK_LIB(nsl, main)
191       CURSES=-lcurses
192   ;;
193   *-linux-*)
194       opsys=gnu-linux
195       AC_DEFINE(GNU_LINUX,,GNU Linux)
196   ;;
197   *-nec-sysv4*)
198       AC_CHECK_LIB(nsl, gethostbyname)
199       AC_CHECK_LIB(socket, socket)
200   ;;
201   *-freebsd3.2)
202       AC_DEFINE(FREEBSD_32,,FreeBSD 3.2)
203   ;;
204   *-openbsd*)
205       opsys=openbsd
206       AC_DEFINE(OPEN_BSD,,OpenBSD)
207   ;;
208   *-bsdi*)
209       opsys=bsdi
210       OTHER_METHOD="mtu_kvm.o"
211       AC_CHECK_LIB(kvm, main)
212   ;;
213 esac
215 dnl ---------------------
216 dnl Integrated VTY option
217 dnl ---------------------
218 case "${enable_vtysh}" in
219   "yes")
220     VTYSH="vtysh";
221     AC_DEFINE(VTYSH,,VTY shell)
222     AC_CHECK_LIB(tinfo, tputs, , AC_CHECK_LIB(ncurses, tputs, ,
223                  AC_CHECK_LIB(termcap, tputs)))
224     AC_CHECK_LIB(readline, main)
225     if test $ac_cv_lib_readline_main = no; then
226       AC_MSG_ERROR([vtysh needs libreadline but was not found on your system.])
227     fi
228     AC_CHECK_HEADER(readline/history.h)
229     if test $ac_cv_header_readline_history_h = no;then
230       AC_MSG_ERROR([readline is too old to have readline/history.h, please update to the latest readline library.])
231     fi
232     ;;
233   "no")
234     VTYSH=""
235     ;;
236   *)
237     ;;
238 esac
240 dnl ----------
241 dnl PAM module
242 dnl ----------
243 if test "$with_libpam" = "yes"; then
244 dnl took this test from proftpd's configure.in and suited to our needs
245 dnl -------------------------------------------------------------------------
247 dnl This next check looks funky due to a linker problem with some versions
248 dnl of the PAM library.  Prior to 0.72 release, the Linux PAM shared library
249 dnl omitted requiring libdl linking information. PAM-0.72 or better ships
250 dnl with RedHat 6.2 and Debian 2.2 or better.
251 AC_CHECK_LIB(pam, pam_start,
252   [AC_CHECK_LIB(pam, misc_conv,
253     [AC_DEFINE(USE_PAM,,Use PAM for authentication)
254      LIBPAM="-lpam"],
255     [AC_DEFINE(USE_PAM,,Use PAM for authentication)
256      LIBPAM="-lpam -lpam_misc"]
257     )
258   ],
260   [AC_CHECK_LIB(pam, pam_end,
261     [AC_CHECK_LIB(pam, misc_conv,
262       [AC_DEFINE(USE_PAM)
263        LIBPAM="-lpam -ldl"],
264       [AC_DEFINE(USE_PAM)
265        LIBPAM="-lpam -ldl -lpam_misc"]
266      )
267   ],AC_MSG_WARN([*** pam support will not be built ***]),
268   [-ldl])
269   ]
272 AC_SUBST(LIBPAM)
274 dnl -------------------------------
275 dnl Endian-ness check
276 dnl -------------------------------
277 AC_WORDS_BIGENDIAN
279 dnl -------------------------------
280 dnl check the size in byte of the C
281 dnl -------------------------------
282 dnl AC_CHECK_SIZEOF(char)
283 dnl AC_CHECK_SIZEOF(int)
284 dnl AC_CHECK_SIZEOF(short)
285 dnl AC_CHECK_SIZEOF(long)
287 dnl ----------------------------
288 dnl check existance of functions
289 dnl ----------------------------
290 AC_CHECK_FUNCS(bcopy bzero strerror inet_aton daemon snprintf vsnprintf strlcat strlcpy if_nametoindex if_indextoname getifaddrs)
291 AC_CHECK_FUNCS(setproctitle, ,[AC_CHECK_LIB(util, setproctitle, [LIBS="$LIBS -lutil"; AC_DEFINE(HAVE_SETPROCTITLE)])])
293 dnl ------------------------------------
294 dnl Determine routing get and set method
295 dnl ------------------------------------
296 AC_MSG_CHECKING(zebra between kernel interface method)
297 if test x"$opsys" = x"gnu-linux"; then
298   if test "${enable_netlink}" = "yes";then
299     AC_MSG_RESULT(netlink)
300     RT_METHOD=rt_netlink.o
301     AC_DEFINE(HAVE_NETLINK,,netlink)
302     netlink=yes
303   elif test "${enable_netlink}" = "no"; then
304     AC_MSG_RESULT(ioctl)
305     RT_METHOD=rt_ioctl.o
306     netlink=no
307   else
308     AC_MSG_RESULT(netlink)
309     RT_METHOD=rt_netlink.o
310     AC_DEFINE(HAVE_NETLINK,,netlink)
311     netlink=yes
312   fi
313 else
314   if test "$opsys" = "sol2-6";then
315     AC_MSG_RESULT(solaris)
316     KERNEL_METHOD="kernel_socket.o"
317     RT_METHOD="rt_socket.o"
318   else
319     AC_TRY_RUN([#include <errno.h>
320 #include <sys/types.h>
321 #include <sys/socket.h>
323 main ()
325   int ac_sock;
327   ac_sock = socket (AF_ROUTE, SOCK_RAW, 0);
328   if (ac_sock < 0 && errno == EINVAL)
329     exit (1);
330   exit (0);
332   [KERNEL_METHOD=kernel_socket.o
333    RT_METHOD=rt_socket.o
334    AC_MSG_RESULT(socket)],
335   [RT_METHOD=rt_ioctl.o
336    AC_MSG_RESULT(ioctl)],
337   [KERNEL_METHOD=kernel_socket.o
338    RT_METHOD=rt_socket.o
339    AC_MSG_RESULT(socket)])
340   fi
342 AC_SUBST(RT_METHOD)
343 AC_SUBST(KERNEL_METHOD)
344 AC_SUBST(OTHER_METHOD)
346 dnl ------------------------------
347 dnl check kernel route read method
348 dnl ------------------------------
349 AC_CACHE_CHECK(route read method check, zebra_rtread,
350 [if test "$netlink" = yes; then
351   RTREAD_METHOD="rtread_netlink.o"
352   zebra_rtread="netlink"
353 else
354 for zebra_rtread in /proc/net/route /dev/ip /dev/null;
356   test x`ls $zebra_rtread 2>/dev/null` = x"$zebra_rtread" && break
357 done
358 case $zebra_rtread in
359   "/proc/net/route") RTREAD_METHOD="rtread_proc.o"
360                      zebra_rtread="proc";;
361   "/dev/ip")         RTREAD_METHOD="rtread_getmsg.o"
362                      zebra_rtread="getmsg";;
363   *)                 RTREAD_METHOD="rtread_sysctl.o"
364                      zebra_rtread="sysctl";;
365 esac
366 fi])
367 AC_SUBST(RTREAD_METHOD)
369 dnl -----------------------------
370 dnl check interface lookup method
371 dnl -----------------------------
372 AC_MSG_CHECKING(interface looking up method)
373 if test "$netlink" = yes; then
374   AC_MSG_RESULT(netlink)
375   IF_METHOD=if_netlink.o
376 else
377   if test "$opsys" = "sol2-6";then
378     AC_MSG_RESULT(solaris)
379     IF_METHOD=if_ioctl.o
380   elif test "$opsys" = "openbsd";then
381     AC_MSG_RESULT(openbsd)
382     IF_METHOD=if_ioctl.o
383   elif grep NET_RT_IFLIST /usr/include/sys/socket.h >/dev/null 2>&1; then
384     AC_MSG_RESULT(sysctl)
385     IF_METHOD=if_sysctl.o
386     AC_DEFINE(HAVE_NET_RT_IFLIST,,NET_RT_IFLIST)
387   else
388     AC_MSG_RESULT(ioctl)
389     IF_METHOD=if_ioctl.o
390   fi
392 AC_SUBST(IF_METHOD)
394 dnl -----------------------
395 dnl check proc file system.
396 dnl -----------------------
397 if test -r /proc/net/dev; then
398   AC_DEFINE(HAVE_PROC_NET_DEV,,/proc/net/dev)
399   IF_PROC=if_proc.o
402 if test -r /proc/net/if_inet6; then
403   AC_DEFINE(HAVE_PROC_NET_IF_INET6,,/proc/net/if_inet6)
404   IF_PROC=if_proc.o
406 AC_SUBST(IF_PROC)
408 dnl -----------------------------
409 dnl check ipforward detect method
410 dnl -----------------------------
411 AC_CACHE_CHECK(ipforward method check, zebra_ipforward_path,
412 [for zebra_ipforward_path in /proc/net/snmp /dev/ip /dev/null;
414   test x`ls $zebra_ipforward_path 2>/dev/null` = x"$zebra_ipforward_path" && break
415 done
416 case $zebra_ipforward_path in
417   "/proc/net/snmp")  IPFORWARD=ipforward_proc.o
418                      zebra_ipforward_path="proc";;
419   "/dev/ip")         
420                      case "$host" in
421                        *-linux-*)     IPFORWARD=ipforward_proc.o
422                                       zebra_ipforward_path="proc";;
423                        *-nec-sysv4*)  IPFORWARD=ipforward_ews.o
424                                       zebra_ipforward_path="ews";;
425                        *)             IPFORWARD=ipforward_solaris.o
426                                       zebra_ipforward_path="solaris";;
427                      esac;;
428   *)                 IPFORWARD=ipforward_sysctl.o
429                      zebra_ipforward_path="sysctl";;
430 esac])
431 AC_SUBST(IPFORWARD)
433 AC_CHECK_FUNCS(getaddrinfo, [have_getaddrinfo=yes], [have_getaddrinfo=no])
435 dnl ----------
436 dnl IPv6 check
437 dnl ----------
438 AC_MSG_CHECKING(whether does this OS have IPv6 stack)
439 if test "${enable_ipv6}" = "no"; then
440   AC_MSG_RESULT(disabled)
441 else
442 dnl ----------
443 dnl INRIA IPv6
444 dnl ----------
445 if grep IPV6_INRIA_VERSION /usr/include/netinet/in.h >/dev/null 2>&1; then
446    zebra_cv_ipv6=yes
447    AC_DEFINE(HAVE_IPV6,,IPv6)
448    AC_DEFINE(INRIA_IPV6,,Inria IPv6)
449    RIPNGD="ripngd"
450    OSPF6D="ospf6d"
451    LIB_IPV6=""
452    AC_MSG_RESULT(INRIA IPv6)
454 dnl ---------
455 dnl KAME IPv6
456 dnl ---------
457 if grep WIDE /usr/include/netinet6/in6.h >/dev/null 2>&1; then
458    zebra_cv_ipv6=yes
459    AC_DEFINE(HAVE_IPV6,,IPv6)
460    AC_DEFINE(KAME,,KAME IPv6)
461    RIPNGD="ripngd"
462    OSPF6D="ospf6d"
463    if test -d /usr/local/v6/lib -a -f /usr/local/v6/lib/libinet6.a; then
464       LIB_IPV6="-L/usr/local/v6/lib -linet6"
465    fi
466    AC_MSG_RESULT(KAME)
468 dnl ---------
469 dnl NRL check
470 dnl ---------
471 if grep NRL /usr/include/netinet6/in6.h >/dev/null 2>&1; then
472    zebra_cv_ipv6=yes
473    AC_DEFINE(HAVE_IPV6,,IPv6)
474    AC_DEFINE(NRL,,NRL)
475    RIPNGD="ripngd"
476    OSPF6D="ospf6d"
477    if test x"$opsys" = x"bsdi";then
478       AC_DEFINE(BSDI_NRL,,BSDI)
479       AC_MSG_RESULT(BSDI_NRL)
480    else
481       AC_MSG_RESULT(NRL)
482    fi
485 dnl ----------
486 dnl Linux IPv6
487 dnl ----------
488 if test "${enable_ipv6}" = "yes"; then
489    AC_EGREP_CPP(yes, [
490    #include <linux/version.h>
491    /* 2.1.128 or later */
492    #if LINUX_VERSION_CODE >= 0x020180
493    yes
494    #endif],
495    [zebra_cv_ipv6=yes; zebra_cv_linux_ipv6=yes;AC_MSG_RESULT(Linux IPv6)])
496 else
497    if test x`ls /proc/net/ipv6_route 2>/dev/null` = x"/proc/net/ipv6_route"
498    then
499       zebra_cv_ipv6=yes
500       zebra_cv_linux_ipv6=yes
501       AC_MSG_RESULT(Linux IPv6)
502    fi
505 if test "$zebra_cv_linux_ipv6" = "yes";then
506    AC_DEFINE(HAVE_IPV6)
507    AC_MSG_CHECKING(for GNU libc 2.1)
508    AC_EGREP_CPP(yes, [
509 #include <features.h>
510 #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
511   yes
512 #endif], [glibc=yes; AC_MSG_RESULT(yes)], AC_MSG_RESULT(no))
513    AC_DEFINE(LINUX_IPV6,,Linux IPv6)   
514    RIPNGD="ripngd"
515    OSPF6D="ospf6d"
516    if test "$glibc" != "yes"; then
517       INCLUDES="-I/usr/inet6/include"
518       if test x`ls /usr/inet6/lib/libinet6.a 2>/dev/null` != x;then
519          LIB_IPV6="-L/usr/inet6/lib -linet6"
520       fi
521    fi
524 dnl -----------------------
525 dnl Set IPv6 related values
526 dnl -----------------------
527 LIBS="$LIB_IPV6 $LIBS"
528 AC_SUBST(LIB_IPV6)
530 if test x"$RIPNGD" = x""; then
531   AC_MSG_RESULT(IPv4 only)
535 dnl ----------------------------
536 dnl Check TCP Signature support.
537 dnl ----------------------------
538 if test "${enable_tcp_signature}" = "yes"; then
539   AC_DEFINE(HAVE_TCP_SIGNATURE,,TCP Signature Option)
540   case "$host" in
541     *-linux-*)
542         AC_DEFINE(HAVE_LINUX_TCP_SIGNATURE,,Linux TCP Signature Option)
543     ;;
544     *-openbsd*)
545         AC_DEFINE(HAVE_OPENBSD_TCP_SIGNATURE,,OpenBSD TCP Signature Option)
546     ;;
547     *)
548         echo "Sorry, your OS don't support TCP signature."
549         exit 1
550     ;;
551   esac
554 dnl --------------------
555 dnl Daemon disable check
556 dnl --------------------
557 if test "${enable_zebra}" = "no";then
558   ZEBRA=""
559 else
560   ZEBRA="zebra"
563 if test "${enable_bgpd}" = "no";then
564   BGPD=""
565 else
566   BGPD="bgpd"
569 if test "${enable_ripd}" = "no";then
570   RIPD=""
571 else
572   RIPD="ripd"
575 if test "${enable_ospfd}" = "no";then
576   OSPFD=""
577 else
578   OSPFD="ospfd"
581 case "${enable_ripngd}" in
582   "yes") RIPNGD="ripngd";;
583   "no" ) RIPNGD="";;
584   *    ) ;;
585 esac
587 case "${enable_ospf6d}" in
588   "yes") OSPF6D="ospf6d";;
589   "no" ) OSPF6D="";;
590   *    ) ;;
591 esac
593 if test "${enable_bgp_announce}" = "no";then
594   AC_DEFINE(DISABLE_BGP_ANNOUNCE,,Disable BGP installation to zebra)
597 AC_SUBST(ZEBRA)
598 AC_SUBST(BGPD)
599 AC_SUBST(RIPD)
600 AC_SUBST(RIPNGD)
601 AC_SUBST(OSPFD)
602 AC_SUBST(OSPF6D)
603 AC_SUBST(VTYSH)
604 AC_SUBST(INCLUDES)
605 AC_SUBST(CURSES)
606 AC_CHECK_LIB(c, inet_ntop, [AC_DEFINE(HAVE_INET_NTOP,,inet_ntop)])
607 AC_CHECK_LIB(c, inet_pton, [AC_DEFINE(HAVE_INET_PTON,,inet_pton)])
608 AC_CHECK_LIB(crypt, crypt)
609 AC_CHECK_LIB(resolv, res_init)
610 AC_CHECK_LIB(m, main)
612 dnl ---------------------------------------------------
613 dnl BSD/OS 4.1 define inet_XtoY function as __inet_XtoY
614 dnl ---------------------------------------------------
615 AC_CHECK_FUNC(__inet_ntop, AC_DEFINE(HAVE_INET_NTOP))
616 AC_CHECK_FUNC(__inet_pton, AC_DEFINE(HAVE_INET_PTON))
617 AC_CHECK_FUNC(__inet_aton, AC_DEFINE(HAVE_INET_ATON))
619 dnl ---------------------------
620 dnl check system has GNU regexp
621 dnl ---------------------------
622 dnl AC_MSG_CHECKING(whether system has GNU regex)
623 AC_CHECK_LIB(c, regexec,
624 [AC_DEFINE(HAVE_GNU_REGEX,,GNU regexp library)
625  LIB_REGEX=""],
626 [LIB_REGEX="regex.o"])
627 AC_SUBST(LIB_REGEX)
629 dnl ------------------
630 dnl check SNMP library
631 dnl ------------------
632 if test "${enable_snmp}" = "yes"; then
633   saved_libs="${LIBS}"
634   LIBS=""
636   unset link_dir link_dirs
637   test "${linkbase_specified}" = "yes" && link_dirs=${with_linkbase}
638   link_dirs="$link_dirs /usr/local"
639   for link_dir in '' ${link_dirs}; do
640     test "x${link_dir}" != "x" && link_dir="-L${link_dir}/lib"
641     LIBS=${link_dir}
643     AC_MSG_NOTICE(try linking with LIBS: $LIBS)
644     unset ac_cv_lib_netsnmp_asn_parse_int
645     AC_CHECK_LIB(netsnmp, asn_parse_int,
646       [HAVE_SNMP=yes; ac_snmp_lib="$LIBS -lnetsnmp"])
647     test "${HAVE_SNMP}" = "yes" && break
649     unset ac_cv_lib_snmp_asn_parse_int
650     AC_CHECK_LIB(snmp, asn_parse_int,
651       [HAVE_SNMP=yes; ac_snmp_lib="$LIBS -lsnmp"])
652     test "${HAVE_SNMP}" = "yes" && break
654     AC_CHECK_LIB(crypto, main, [NEED_CRYPTO=yes])
655     test "${NEED_CRYPTO}" != "yes" && continue
656     LIBS="$LIBS -lcrypto"
658     AC_MSG_NOTICE(try linking with LIBS: $LIBS)
659     unset ac_cv_lib_netsnmp_asn_parse_int
660     AC_CHECK_LIB(netsnmp, asn_parse_int,
661       [HAVE_SNMP=yes; ac_snmp_lib="$LIBS -lnetsnmp"],, -lcrypto)
662     test "${HAVE_SNMP}" = "yes" && break
664     unset ac_cv_lib_snmp_asn_parse_int
665     AC_CHECK_LIB(snmp, asn_parse_int,
666       [HAVE_SNMP=yes; ac_snmp_lib="$LIBS -lsnmp"],, -lcrypto)
667     test "${HAVE_SNMP}" = "yes" && break
668   done
669   if test "${HAVE_SNMP}" = ""; then
670     AC_MSG_ERROR(cannot find valid snmp library)
671   fi
672   LIBS="${saved_libs} $ac_snmp_lib"
674   AC_MSG_CHECKING(for snmp library header)
675   unset link_dir link_dirs ac_snmp ac_snmps ac_snmp_dir ac_snmp_dirs
676   link_dirs="/usr/include";
677   if test "${linkbase_specified}" = "yes"; then
678     link_dirs="${link_dirs} ${with_linkbase}/include"
679   fi
680   link_dirs="${link_dirs} /usr/local/include"
681   ac_snmp_dirs="net-snmp net-snmp/library ucd-snmp"
683   for link_dir in '' ${link_dirs}; do
684     test -z $link_dir && continue
685     for ac_snmp_dir in '' ${ac_snmp_dirs}; do
686       test -z $ac_snmp_dir && continue
687       ac_snmps="${ac_snmps} ${link_dir}/${ac_snmp_dir}/asn1.h"
688     done
689   done
690   ac_snmps="${ac_snmps}"
692   for ac_snmp in '' ${ac_snmps}; do
693     test -z ${ac_snmp} && continue
694     test -f ${ac_snmp} && break
695   done
696   ac_snmp_header=`echo ${ac_snmp} | sed -e 's/\/asn1.h//'`
697   ac_snmp_header="-I${ac_snmp_header}"
699   case ${ac_snmp} in
700     /usr/local/include/net-snmp/*)
701                 AC_DEFINE(HAVE_SNMP,,SNMP)
702                 AC_DEFINE(HAVE_NETSNMP,,NET-SNMP)
703                 CFLAGS="${CFLAGS} -I/usr/local/include"
704                 ;;
705     */net-snmp/*)
706                 AC_DEFINE(HAVE_SNMP,,SNMP)
707                 AC_DEFINE(HAVE_NETSNMP,,NET-SNMP)
708                 ;;
709     /usr/local/include/ucd-snmp/*) 
710                 AC_DEFINE(HAVE_SNMP,,SNMP)
711                 CFLAGS="${CFLAGS} -I/usr/local/include"
712                 ;;
713     */ucd-snmp/*)
714                 AC_DEFINE(HAVE_SNMP,,SNMP)
715                 ;;
716   esac
717   AC_MSG_RESULT($ac_snmp_header)
718   CFLAGS="${CFLAGS} ${ac_snmp_header}"
721 dnl ----------------------------
722 dnl check sa_len of sockaddr
723 dnl ----------------------------
724 AC_MSG_CHECKING(whether struct sockaddr has a sa_len field)
725 AC_TRY_COMPILE([#include <sys/types.h>
726 #include <sys/socket.h>
727 ],[static struct sockaddr ac_i;int ac_j = sizeof (ac_i.sa_len);],
728 [AC_MSG_RESULT(yes)
729  AC_DEFINE(HAVE_SA_LEN,,sa_len)],
730  AC_MSG_RESULT(no))
732 dnl ----------------------------
733 dnl check sin_len of sockaddr_in
734 dnl ----------------------------
735 AC_MSG_CHECKING(whether struct sockaddr_in has a sin_len field)
736 AC_TRY_COMPILE([#include <sys/types.h>
737 #include <netinet/in.h>
738 ],[static struct sockaddr_in ac_i;int ac_j = sizeof (ac_i.sin_len);],
739 [AC_MSG_RESULT(yes)
740  AC_DEFINE(HAVE_SIN_LEN,,sin_len)],
741  AC_MSG_RESULT(no))
743 dnl ----------------------------
744 dnl check sun_len of sockaddr_un
745 dnl ----------------------------
746 AC_MSG_CHECKING(whether struct sockaddr_un has a sun_len field)
747 AC_TRY_COMPILE([#include <sys/types.h>
748 #include <sys/un.h>
749 ],[static struct sockaddr_un ac_i;int ac_j = sizeof (ac_i.sun_len);],
750 [AC_MSG_RESULT(yes)
751  AC_DEFINE(HAVE_SUN_LEN,,sun_len)],
752  AC_MSG_RESULT(no))
754 dnl -----------------------------------
755 dnl check sin6_scope_id of sockaddr_in6
756 dnl -----------------------------------
757 if test "$zebra_cv_ipv6" = yes; then
758   AC_MSG_CHECKING(whether struct sockaddr_in6 has a sin6_scope_id field)
759   AC_TRY_COMPILE([#include <sys/types.h>
760 #include <netinet/in.h>
761 ],[static struct sockaddr_in6 ac_i;int ac_j = sizeof (ac_i.sin6_scope_id);],
762 [AC_MSG_RESULT(yes)
763  AC_DEFINE(HAVE_SIN6_SCOPE_ID,,scope id)],
764  AC_MSG_RESULT(no))
767 dnl -----------------------------------
768 dnl check in6addr_loopback global variable
769 dnl -----------------------------------
770 if test "$zebra_cv_ipv6" = yes; then
771   AC_MSG_CHECKING(whether in6addr_loopback is usable)
772   AC_TRY_COMPILE([#include <sys/types.h>
773 #include <netinet/in.h>
774 ],[static struct in6_addr ac_i; ac_i = in6addr_loopback;],
775 [AC_MSG_RESULT(yes)
776  AC_DEFINE(HAVE_IN6ADDR_GLOBAL,,in6addr global variables e.g. in6addr_loopback)],
777  AC_MSG_RESULT(no))
780 dnl ----------------------------
781 dnl check socklen_t exist or not
782 dnl ----------------------------
783 AC_MSG_CHECKING(whther socklen_t is defined)
784 AC_TRY_COMPILE([#include <sys/types.h>
785 #include <sys/socket.h>
786 #include <netinet/in.h>
787 ],[socklen_t ac_x;],
788 [AC_MSG_RESULT(yes)
789  AC_DEFINE(HAVE_SOCKLEN_T,,socklen_t)],
790  AC_MSG_RESULT(no))
792 dnl ------------------------
793 dnl check struct sockaddr_dl
794 dnl ------------------------
795 AC_MSG_CHECKING(whether struct sockaddr_dl exist)
796 AC_EGREP_HEADER(sockaddr_dl,
797 net/if_dl.h,
798 [AC_MSG_RESULT(yes)
799  AC_DEFINE(HAVE_SOCKADDR_DL,,sockaddr_dl)],
800  AC_MSG_RESULT(no))
802 dnl --------------------------
803 dnl check structure ifaliasreq
804 dnl --------------------------
805 AC_MSG_CHECKING(whether struct ifaliasreq exist)
806 AC_EGREP_HEADER(ifaliasreq,
807 net/if.h,
808 [AC_MSG_RESULT(yes)
809  AC_DEFINE(HAVE_IFALIASREQ,,ifaliasreq)],
810  AC_MSG_RESULT(no))
812 dnl ----------------------------
813 dnl check structure in6_aliasreq
814 dnl ----------------------------
815 AC_MSG_CHECKING(whether struct if6_aliasreq exist)
816 AC_EGREP_HEADER(in6_aliasreq,
817 netinet6/in6_var.h,
818 [AC_MSG_RESULT(yes)
819  AC_DEFINE(HAVE_IN6_ALIASREQ,,in6_aliasreq)],
820  AC_MSG_RESULT(no))
822 dnl ---------------------------
823 dnl check structure rt_addrinfo
824 dnl ---------------------------
825 AC_MSG_CHECKING(whether struct rt_addrinfo exist)
826 AC_EGREP_HEADER(rt_addrinfo,
827 net/route.h,
828 [AC_MSG_RESULT(yes)
829  AC_DEFINE(HAVE_RT_ADDRINFO,,rt_addrinfo)],
830  AC_MSG_RESULT(no))
832 dnl --------------------------
833 dnl check structure in_pktinfo
834 dnl --------------------------
835 AC_MSG_CHECKING(whether struct in_pktinfo exist)
836 AC_TRY_COMPILE([#include <netinet/in.h>
837 ],[struct in_pktinfo ac_x;],
838 [AC_MSG_RESULT(yes)
839  AC_DEFINE(HAVE_INPKTINFO,,in_pktinfo)],
840  AC_MSG_RESULT(no))
842 dnl --------------------------------------
843 dnl checking for getrusage struct and call
844 dnl --------------------------------------
845 AC_MSG_CHECKING(whether getrusage is available)
846 AC_TRY_COMPILE([#include <sys/resource.h>
847 ],[struct rusage ac_x; getrusage (RUSAGE_SELF, &ac_x);],
848 [AC_MSG_RESULT(yes)
849  AC_DEFINE(HAVE_RUSAGE,,rusage)],
850  AC_MSG_RESULT(no))
852 dnl -------------
853 dnl check version
854 dnl -------------
855 file="${srcdir}/lib/version.h"
856 VERSION=`sed -ne 's/^#.*ZEBRA_VERSION.*\"\([^\"]*\)\"$/\1/p' $file`
857 AC_SUBST(VERSION)
859 dnl ------------------------------
860 dnl set paths for process id files
861 dnl ------------------------------
862 AC_CACHE_CHECK(pid file directory,ac_piddir,
863 [for ZEBRA_PID_DIR in /var/run  dnl
864                    /var/adm     dnl
865                    /etc         dnl
866                    /dev/null;
868   test -d $ZEBRA_PID_DIR && break
869 done
870 ac_piddir=$ZEBRA_PID_DIR
871 if test $ZEBRA_PID_DIR = "/dev/null"; then
872   echo "PID DIRECTORY NOT FOUND!"
873 fi])
874 AC_DEFINE_UNQUOTED(PATH_ZEBRA_PID, "$ac_piddir/zebra.pid",zebra PID)
875 AC_DEFINE_UNQUOTED(PATH_RIPD_PID, "$ac_piddir/ripd.pid",ripd PID)
876 AC_DEFINE_UNQUOTED(PATH_RIPNGD_PID, "$ac_piddir/ripngd.pid",ripngd PID)
877 AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$ac_piddir/bgpd.pid",bgpd PID)
878 AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$ac_piddir/ospfd.pid",ospfd PID)
879 AC_DEFINE_UNQUOTED(PATH_OSPF6D_PID, "$ac_piddir/ospf6d.pid",ospf6d PID)
882 dnl ---------------------------
883 dnl Check htonl works correctly
884 dnl ---------------------------
885 AC_MSG_CHECKING(for working htonl)
886 AC_CACHE_VAL(ac_cv_htonl_works, [
887 AC_TRY_LINK([#ifdef HAVE_SYS_TYPES_H
888 #include <sys/types.h>
889 #endif
890 #ifdef HAVE_NETDB_H
891 #include <netdb.h>
892 #endif
893 #ifdef HAVE_NETINET_IN_H
894 #include <netinet/in.h>
895 #endif],
896 [htonl (0);],
897 ac_cv_htonl_works=yes,
898 ac_cv_htonl_works=no)])
899 AC_MSG_RESULT($ac_cv_htonl_works)
901 AC_OUTPUT(Makefile lib/Makefile zebra/Makefile ripd/Makefile ripngd/Makefile bgpd/Makefile ospfd/Makefile ospf6d/Makefile vtysh/Makefile doc/Makefile)
903 echo "
904 zebra configuration
905 -------------------
906 zebra version           : ${VERSION}
907 host operationg system  : ${host_os}
908 source code location    : ${srcdir}
909 compiler                : ${CC}
910 compiler flags          : ${CFLAGS}
911 link libraries          : ${LIBS}
912 directory for pid files : ${ac_piddir}