]> git.proxmox.com Git - mirror_frr.git/blobdiff - configure.ac
delete CVS keywords
[mirror_frr.git] / configure.ac
index 4f5956e08c4e20250c7b1b6e96c9292e57ddd72a..899108d9f4ecb97651a7d285816b3cecb4e373ac 100755 (executable)
@@ -5,11 +5,11 @@
 ##  Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
 ##  Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st>
 ##
-## $Id$
 AC_PREREQ(2.53)
 
-AC_INIT(Quagga, 0.99.5, [http://bugzilla.quagga.net])
+AC_INIT(Quagga, 0.99.19, [https://bugzilla.quagga.net])
 AC_CONFIG_SRCDIR(lib/zebra.h)
+AC_CONFIG_MACRO_DIR([m4])
 
 dnl -----------------------------------
 dnl Get hostname and other information.
@@ -21,8 +21,11 @@ AC_CANONICAL_TARGET()
 AM_INIT_AUTOMAKE(1.6)
 AM_CONFIG_HEADER(config.h)
 
-dnl we need gawk for memtypes.awk
-AC_CHECK_PROG([GAWK],[gawk],[gawk],[/bin/false])
+AC_CHECK_PROG([GAWK],[gawk],[gawk],[not-in-PATH])
+if test "x$GAWK" = "xnot-in-PATH" ; then
+       AC_MSG_ERROR([GNU awk is required for lib/memtype.h made by memtypes.awk.
+BSD awk complains: awk: gensub doesn't support backreferences (subst "\1") ])
+fi
 AC_ARG_VAR([GAWK],[GNU AWK])
 
 dnl default is to match previous behavior
@@ -59,10 +62,16 @@ fi
 dnl --------------------
 dnl Check CC and friends
 dnl --------------------
+AC_LANG([C])
 AC_PROG_CC
 AC_PROG_CPP
+AM_PROG_CC_C_O
 AC_PROG_EGREP
 
+dnl autoconf 2.59 appears not to support AC_PROG_SED
+dnl AC_PROG_SED
+AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
+
 dnl ------------------------------------------------------------------
 dnl Intel compiler check. Although Intel tries really hard to make icc
 dnl look like gcc, there are some differences. It's very verbose with
@@ -113,7 +122,7 @@ if test "x${cflags_specified}" = "x" ; then
         AC_MSG_RESULT([Intel default])
         ;;
     "GCC")
-       CFLAGS="-Os -fno-omit-frame-pointer -g -std=c99 -Wall"
+       CFLAGS="-Os -fno-omit-frame-pointer -g -std=gnu99 -Wall"
        CFLAGS="${CFLAGS} -Wsign-compare -Wpointer-arith"
        CFLAGS="${CFLAGS} -Wbad-function-cast -Wwrite-strings"
        CFLAGS="${CFLAGS} -Wmissing-prototypes -Wmissing-declarations"
@@ -137,9 +146,9 @@ dnl --------------
 dnl Check programs
 dnl --------------
 AC_PROG_INSTALL
+AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AC_CHECK_TOOL(AR, ar)
-AC_CHECK_TOOL(RANLIB, ranlib, :)
 
 dnl ---------------------------
 dnl We, perhaps unfortunately,
@@ -157,10 +166,10 @@ AC_CACHE_CHECK([if ${MAKE-make} is GNU make], [quagga_cv_gnu_make],
        ]
 )
 
-dnl ---------
-dnl AIX check
-dnl ---------
-AC_AIX
+dnl -----------------
+dnl System extensions
+dnl -----------------
+AC_GNU_SOURCE
 
 dnl -------
 dnl libtool
@@ -174,6 +183,8 @@ AC_ARG_ENABLE(vtysh,
 [  --enable-vtysh          include integrated vty shell for Quagga])
 AC_ARG_ENABLE(ipv6,
 [  --disable-ipv6          turn off IPv6 related features and daemons])
+AC_ARG_ENABLE(doc,
+[  --disable-doc           do not build docs])
 AC_ARG_ENABLE(zebra,
 [  --disable-zebra         do not build zebra daemon])
 AC_ARG_ENABLE(bgpd,
@@ -190,12 +201,16 @@ AC_ARG_ENABLE(watchquagga,
 [  --disable-watchquagga   do not build watchquagga])
 AC_ARG_ENABLE(isisd,
 [  --enable-isisd          build isisd])
+AC_ARG_ENABLE(solaris,
+[  --enable-solaris          build solaris])
 AC_ARG_ENABLE(bgp-announce,
 [  --disable-bgp-announce, turn off BGP route announcement])
 AC_ARG_ENABLE(netlink,
 [  --enable-netlink        force to use Linux netlink interface])
 AC_ARG_ENABLE(broken-aliases,
 [  --enable-broken-aliases enable aliases as distinct interfaces for Linux 2.2.X])
+AC_ARG_WITH(crypto,
+[  --without-crypto        do not use libcrypto in SNMP])
 AC_ARG_ENABLE(snmp,
 [  --enable-snmp           enable SNMP support])
 AC_ARG_WITH(libpam,
@@ -203,21 +218,20 @@ AC_ARG_WITH(libpam,
 AC_ARG_ENABLE(tcp-zebra,
 [  --enable-tcp-zebra      enable TCP/IP socket connection between zebra and protocol daemon])
 AC_ARG_ENABLE(opaque-lsa,
-[  --enable-opaque-lsa     enable OSPF Opaque-LSA with OSPFAPI support (RFC2370)])
+  AC_HELP_STRING([--disable-opaque-lsa],[do not build OSPF Opaque-LSA with OSPFAPI support (RFC2370)]))
 AC_ARG_ENABLE(ospfapi,
-[  --disable-ospfapi       do not build OSPFAPI to access the OSPF LSA Database, 
-                          (this is the default if --enable-opaque-lsa is not set)])
+[  --disable-ospfapi       do not build OSPFAPI to access the OSPF LSA Database])
 AC_ARG_ENABLE(ospfclient,
 [  --disable-ospfclient    do not build OSPFAPI client for OSPFAPI, 
                           (this is the default if --disable-ospfapi is set)])
 AC_ARG_ENABLE(ospf-te,
-[  --enable-ospf-te        enable Traffic Engineering Extension to OSPF])
+  AC_HELP_STRING([--disable-ospf-te],[disable Traffic Engineering Extension to OSPF]))
 AC_ARG_ENABLE(multipath,
 [  --enable-multipath=ARG  enable multipath function, ARG must be digit])
-AC_ARG_ENABLE(quagga_user,
-[  --enable-user=ARG       user to run Quagga suite as (default quagga)])
-AC_ARG_ENABLE(quagga_group,
-[  --enable-group=ARG      group to run Quagga suite as (default quagga)])
+AC_ARG_ENABLE(user,
+  AC_HELP_STRING([--enable-user=user], [user to run Quagga suite as (default quagga)]))
+AC_ARG_ENABLE(group,
+  AC_HELP_STRING([--enable-group=group], [group to run Quagga suite as (default quagga)]))
 AC_ARG_ENABLE(vty_group,
 [  --enable-vty-group=ARG  set vty sockets to have specified group as owner])
 AC_ARG_ENABLE(configfile_mask,
@@ -235,10 +249,14 @@ AC_ARG_ENABLE(capabilities,
 [  --disable-capabilities        disable using POSIX capabilities])
 AC_ARG_ENABLE(gcc_ultra_verbose,
 [  --enable-gcc-ultra-verbose    enable ultra verbose GCC warnings])
+AC_ARG_ENABLE(linux24_tcp_md5,
+[  --enable-linux24-tcp-md5  enable support for old, Linux-2.4 RFC2385 patch])
 AC_ARG_ENABLE(gcc-rdynamic,
 [  --enable-gcc-rdynamic   enable gcc linking with -rdynamic for better backtraces])
 AC_ARG_ENABLE(time-check,
 [  --disable-time-check          disable slow thread warning messages])
+AC_ARG_ENABLE(pcreposix,
+[  --enable-pcreposix          enable using PCRE Posix libs for regex functions])
 
 if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then
   CFLAGS="${CFLAGS} -W -Wcast-qual -Wstrict-prototypes"
@@ -262,8 +280,7 @@ fi
 if test "${enable_broken_aliases}" = "yes"; then
   if test "${enable_netlink}" = "yes"
   then
-    echo "Sorry, you can't use netlink with broken aliases"
-    exit 1
+    AC_MSG_FAILURE([Sorry you can not use netlink with broken aliases])
   fi
   AC_DEFINE(HAVE_BROKEN_ALIASES,,Broken Alias)
   enable_netlink=no
@@ -273,15 +290,19 @@ if test "${enable_tcp_zebra}" = "yes"; then
   AC_DEFINE(HAVE_TCP_ZEBRA,,Use TCP for zebra communication)
 fi
 
-if test "${enable_opaque_lsa}" = "yes"; then
+if test "${enable_opaque_lsa}" != "no"; then
   AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA)
 fi
 
-if test "${enable_ospf_te}" = "yes"; then
+if test "${enable_ospf_te}" != "no"; then
   AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA)
   AC_DEFINE(HAVE_OSPF_TE,,OSPF TE)
 fi
 
+if test "${enable_linux24_tcp_md5}" = "yes"; then
+  AC_DEFINE(HAVE_TCP_MD5_LINUX24,,Old Linux 2.4 TCP MD5 Signature Patch)
+fi
+
 AC_MSG_CHECKING(if zebra should be configurable to send Route Advertisements)
 if test "${enable_rtadv}" != "no"; then
   AC_MSG_RESULT(yes)
@@ -336,45 +357,164 @@ AC_DEFINE_UNQUOTED(CONFIGFILE_MASK, ${enable_configfile_mask}, Mask for config f
 enable_logfile_mask=${enable_logfile_mask:-0600}
 AC_DEFINE_UNQUOTED(LOGFILE_MASK, ${enable_logfile_mask}, Mask for log files)
 
-changequote(, )dnl
-
 MULTIPATH_NUM=1
 
 case "${enable_multipath}" in
-  [0-9]|[1-9][0-9])
+  [[0-9]|[1-9][0-9]])
     MULTIPATH_NUM="${enable_multipath}"
     ;;
   "")
     ;;
   *)           
-    echo "Please specify digit to --enable-multipath ARG."
-    exit 1
+    AC_MSG_FAILURE([Please specify digit to enable multipath ARG])
     ;;
 esac
 
-changequote([, ])dnl
-
 AC_SUBST(MULTIPATH_NUM)
 
-dnl -------------------
-dnl Check header files.
-dnl -------------------
+dnl ------------------------------------
+dnl Check C keywords and standard  types
+dnl ------------------------------------
+AC_C_CONST
+AC_C_INLINE
+AC_C_RESTRICT
+AC_C_VOLATILE
 AC_HEADER_STDC
-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 linux/version.h kvm.h netdb.h asm/types.h \
-                 sys/param.h libutil.h limits.h stdint.h])
+AC_HEADER_TIME
+AC_HEADER_SYS_WAIT
+dnl AC_TYPE_PID_T
+AC_TYPE_UID_T
+AC_TYPE_MODE_T
+AC_TYPE_SIZE_T
+AC_TYPE_SIGNAL
+AC_STRUCT_TM
+
+dnl -------------------------
+dnl Check other header files.
+dnl -------------------------
+AC_CHECK_HEADERS([stropts.h sys/ksym.h sys/times.h sys/select.h \
+       sys/types.h linux/version.h netdb.h asm/types.h \
+       sys/param.h limits.h signal.h \
+       sys/socket.h netinet/in.h time.h sys/time.h])
+
+dnl Utility macro to avoid retyping includes all the time
+m4_define([QUAGGA_INCLUDES],
+[#ifdef SUNOS_5
+#define _XPG4_2
+#define __EXTENSIONS__
+#endif
+#include <stdio.h>
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+/* sys/conf.h depends on param.h on FBSD at least */
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+/* Required for MAXSIG */
+#if HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif /* TIME_WITH_SYS_TIME */
+])dnl
+
+dnl HAVE_NET_IF_H must be discovered by the time the longer AC_CHECK_HEADERS
+dnl round below execution begins, otherwise it doesn't properly detect
+dnl HAVE_NETINET6_IN6_VAR_H, HAVE_NET_IF_VAR_H and HAVE_STRUCT_IN6_ALIASREQ
+dnl on FreeBSD (BZ#408).
+
+AC_CHECK_HEADERS([net/if.h], [], [], QUAGGA_INCLUDES)
+
+m4_define([QUAGGA_INCLUDES],
+QUAGGA_INCLUDES
+[#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+])dnl
 
-AC_CHECK_HEADERS([sys/socket.h netinet/in_systm.h netinet/in.h \
-                net/if_dl.h net/netopt.h inet/nd.h net/route.h \
-                net/if.h net/if_var.h netinet/in_var.h])
+dnl Same applies for HAVE_NET_IF_VAR_H, which HAVE_NETINET6_ND6_H and
+dnl HAVE_NETINET_IN_VAR_H depend upon. But if_var.h depends on if.h, hence
+dnl an additional round for it.
 
-dnl V6 headers are checked below, after we check for v6
+AC_CHECK_HEADERS([net/if_var.h], [], [], QUAGGA_INCLUDES)
 
-dnl check some types
-AC_C_CONST
-dnl AC_TYPE_PID_T
-AC_TYPE_SIGNAL
+m4_define([QUAGGA_INCLUDES],
+QUAGGA_INCLUDES
+[#if HAVE_NET_IF_VAR_H
+# include <net/if_var.h>
+#endif
+])dnl
+
+AC_CHECK_HEADERS([sys/un.h netinet/in_systm.h netinet/in_var.h \
+       net/if_dl.h net/netopt.h net/route.h \
+       inet/nd.h arpa/inet.h netinet/ip_icmp.h \
+       fcntl.h stddef.h sys/ioctl.h syslog.h wchar.h wctype.h \
+       sys/sysctl.h sys/sockio.h kvm.h sys/conf.h],
+       [], [], QUAGGA_INCLUDES)
+
+AC_CHECK_HEADERS([ucontext.h], [], [],
+[#ifndef __USE_GNU
+#define __USE_GNU
+#endif /* __USE_GNU */
+QUAGGA_INCLUDES
+])
+
+m4_define([QUAGGA_INCLUDES],
+QUAGGA_INCLUDES
+[#if HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_VAR_H
+# include <netinet/in_var.h>
+#endif
+#if HAVE_NET_IF_DL_H
+# include <net/if_dl.h>
+#endif
+#if HAVE_NET_NETOPT_H
+# include <net/netopt.h>
+#endif
+#if HAVE_NET_ROUTE_H
+# include <net/route.h>
+#endif
+#if HAVE_INET_ND_H
+# include <inet/nd.h>
+#endif
+#if HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+/* Required for IDRP */
+#if HAVE_NETINET_IP_ICMP_H
+# include <netinet/ip_icmp.h>
+#endif
+])dnl
+
+dnl V6 headers are checked below, after we check for v6
 
 dnl Some systems (Solaris 2.x) require libnsl (Network Services Library)
 case "$host" in
@@ -432,6 +572,8 @@ case "$host" in
   ;;
 esac
 
+AC_SYS_LARGEFILE
+
 dnl ---------------------
 dnl Integrated VTY option
 dnl ---------------------
@@ -440,7 +582,7 @@ case "${enable_vtysh}" in
          AC_DEFINE(VTYSH,,VTY shell)
         AC_PATH_PROG(PERL, perl)
 dnl     Vtysh uses libreadline, which looks for termcap functions at
-dnl     configure time.  We follow readline's search order.
+dnl     configure time.  We follow readlines search order.
 dnl     The required procedures are in libtermcap on NetBSD, in
 dnl     [TODO] on Linux, and in [TODO] on Solaris.
         AC_CHECK_LIB(termcap, tputs, LIBREADLINE="$LIBREADLINE -ltermcap",
@@ -473,20 +615,27 @@ AC_SUBST(LIBREADLINE)
 
 dnl ----------
 dnl PAM module
+dnl
+dnl Quagga detects the PAM library it is built against by checking for a
+dnl functional pam_misc.h (Linux-PAM) or openpam.h (OpenPAM) header. pam_misc.h
+dnl is known to #include pam_appl.h, the standard header of a PAM library, and
+dnl openpam.h doesn't do that, although depends on the header too. Hence a
+dnl little assistance to AC_CHECK_HEADER is necessary for the proper detection
+dnl of OpenPAM.
 dnl ----------
 if test "$with_libpam" = "yes"; then
-  AC_CHECK_HEADER(security/pam_misc.h)
-  if test "$ac_cv_header_security_pam_misc_h" = yes; then
-    AC_DEFINE(HAVE_PAM_MISC_H,,Have pam_misc.h)
-    AC_DEFINE(PAM_CONV_FUNC,misc_conv,Have misc_conv)
-    pam_conv_func="misc_conv"
-  fi
-  AC_CHECK_HEADER(security/openpam.h)
-  if test "$ac_cv_header_security_openpam_h" = yes; then
-    AC_DEFINE(HAVE_OPENPAM_H,,Have openpam.h)
-    AC_DEFINE(PAM_CONV_FUNC,openpam_ttyconv,Have openpam_ttyconv)
-    pam_conv_func="openpam_ttyconv"
-  fi
+  AC_CHECK_HEADER([security/pam_misc.h],
+    [AC_DEFINE(HAVE_PAM_MISC_H,,Have pam_misc.h)
+     AC_DEFINE(PAM_CONV_FUNC,misc_conv,Have misc_conv)
+     pam_conv_func="misc_conv"
+    ],
+    [], QUAGGA_INCLUDES)
+  AC_CHECK_HEADER([security/openpam.h],
+    [AC_DEFINE(HAVE_OPENPAM_H,,Have openpam.h)
+     AC_DEFINE(PAM_CONV_FUNC,openpam_ttyconv,Have openpam_ttyconv)
+     pam_conv_func="openpam_ttyconv"
+    ],
+    [], QUAGGA_INCLUDES[#include <security/pam_appl.h>])
   if test -z "$ac_cv_header_security_pam_misc_h$ac_cv_header_security_openpam_h" ; then
     AC_MSG_WARN([*** pam support will not be built ***])
     with_libpam="no"
@@ -494,7 +643,7 @@ if test "$with_libpam" = "yes"; then
 fi
 
 if test "$with_libpam" = "yes"; then
-dnl took this test from proftpd's configure.in and suited to our needs
+dnl took this test from proftpds configure.in and suited to our needs
 dnl -------------------------------------------------------------------------
 dnl
 dnl This next check looks funky due to a linker problem with some versions
@@ -540,9 +689,54 @@ dnl AC_CHECK_SIZEOF(long)
 dnl ----------------------------
 dnl check existance of functions
 dnl ----------------------------
-AC_CHECK_FUNCS(memset memcpy strerror inet_aton daemon snprintf vsnprintf \
-               strlcat strlcpy if_nametoindex if_indextoname getifaddrs \
-              fcntl strnlen strndup)
+AC_FUNC_CHOWN
+AC_FUNC_FNMATCH
+AC_FUNC_FORK
+AC_FUNC_MALLOC
+AC_FUNC_MEMCMP
+AC_FUNC_MKTIME
+AC_FUNC_STRFTIME
+AC_FUNC_REALLOC
+AC_FUNC_STAT
+AC_FUNC_SELECT_ARGTYPES
+AC_FUNC_STRFTIME
+dnl Avoid AC_FUNC_STRNLEN because it pulls in AC_SYSTEM_EXTENSIONS which
+dnl can lead to strange side effects.  So we just check for strnlen
+dnl directly, see below.
+dnl AC_FUNC_STRNLENdnl
+AC_FUNC_VPRINTF
+
+dnl -------------------------------
+dnl bgpd needs pow() and hence libm
+dnl -------------------------------
+TMPLIBS="$LIBS"
+AC_CHECK_HEADER([math.h],
+  [AC_CHECK_LIB([m], [pow],
+    [LIBM="-lm"
+     LIBS="$LIBS $LIBM"
+     AC_DEFINE(HAVE_LIBM,, Have libm)
+     AC_CHECK_FUNCS(pow,[],[LIBM=""])
+    ])
+])
+if test x"$LIBM" = x ; then
+  AC_MSG_WARN([Unable to find working pow function - bgpd may not link])
+fi
+LIBS="$TMPLIBS"
+AC_SUBST(LIBM)
+
+dnl ---------------
+dnl other functions
+dnl ---------------
+AC_CHECK_FUNCS([dup2 ftruncate getcwd gethostbyname getpagesize gettimeofday \
+       inet_ntoa inet_aton strnlen \
+       memchr memmove memset select socket \
+       strcasecmp strchr strcspn strdup strerror \
+       strncasecmp strndup strrchr strspn strstr \
+       strtol strtoul strlcat strlcpy \
+       daemon snprintf vsnprintf \
+       if_nametoindex if_indextoname getifaddrs \
+       uname fcntl])
+
 AC_CHECK_FUNCS(setproctitle, ,
   [AC_CHECK_LIB(util, setproctitle, 
      [LIBS="$LIBS -lutil"
@@ -611,6 +805,38 @@ AC_SUBST(RT_METHOD)
 AC_SUBST(KERNEL_METHOD)
 AC_SUBST(OTHER_METHOD)
 
+dnl --------------------------
+dnl Determine IS-IS I/O method
+dnl --------------------------
+AC_DEFINE(ISIS_METHOD_PFPACKET,        1, [ constant value for isis method pfpacket ])
+AC_DEFINE(ISIS_METHOD_DLPI,    2, [ constant value for isis method dlpi ])
+AC_DEFINE(ISIS_METHOD_BPF,     3, [ constant value for isis method bpf ])
+AC_CHECK_HEADER(net/bpf.h)
+AC_CHECK_HEADER(sys/dlpi.h)
+AC_MSG_CHECKING(zebra IS-IS I/O method)
+if test x"$opsys" = x"gnu-linux"; then
+  AC_MSG_RESULT(pfpacket)
+  ISIS_METHOD_MACRO="ISIS_METHOD_PFPACKET"
+elif test x"$opsys" = x"sol2-6" -o x"$opsys" = x"sol8"; then
+  AC_MSG_RESULT(DLPI)
+  ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
+else
+  if test $ac_cv_header_net_bpf_h = no; then
+    if test $ac_cv_header_sys_dlpi_h = no; then
+      AC_MSG_RESULT(none)
+      AC_MSG_WARN([*** IS-IS support will not be built ***])
+      ISISD=""
+    else
+      AC_MSG_RESULT(DLPI)
+    fi
+    ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
+  else
+    AC_MSG_RESULT(BPF)
+    ISIS_METHOD_MACRO="ISIS_METHOD_BPF"
+  fi
+fi
+AC_DEFINE_UNQUOTED(ISIS_METHOD, $ISIS_METHOD_MACRO, [ selected method for isis, == one of the constants ])
+
 dnl ------------------------------------
 dnl check for broken CMSG_FIRSTHDR macro
 dnl ------------------------------------
@@ -620,9 +846,15 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #define _XPG4_2
 #define __EXTENSIONS__
 #endif
-#include <stdlib.h>
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 
 main()
 {
@@ -641,29 +873,26 @@ main()
 dnl ------------------------------
 dnl check kernel route read method
 dnl ------------------------------
-AC_CACHE_CHECK(route read method check, zebra_rtread,
-[if test "$netlink" = yes; then
-  RTREAD_METHOD="rtread_netlink.o"
-  zebra_rtread="netlink"
+AC_CACHE_CHECK([route read method], [quagga_cv_rtread_method],
+[if test "x$netlink" = xyes; then
+  quagga_cv_rtread_method="netlink"
 else
-for zebra_rtread in /proc/net/route /dev/ip /dev/null;
+for quagga_cv_rtread_method in /proc/net/route /dev/ip /dev/null;
 do
-  test x`ls $zebra_rtread 2>/dev/null` = x"$zebra_rtread" && break
+  test x`ls $quagga_cv_rtread_method 2>/dev/null` = x"$quagga_cv_rtread_method" && break
 done
-case $zebra_rtread in
-  "/proc/net/route") RTREAD_METHOD="rtread_proc.o"
-                     zebra_rtread="proc";;
+case $quagga_cv_rtread_method in
+  "/proc/net/route") quagga_cv_rtread_method="proc";;
   "/dev/ip")
                      case "$host" in
-                       *-freebsd*)    RTREAD_METHOD=rtread_sysctl.o
-                                      zebra_rtread="sysctl";;
-                       *)             RTREAD_METHOD="rtread_getmsg.o"
-                                      zebra_rtread="getmsg";;
+                       *-freebsd*)    quagga_cv_rtread_method="sysctl";;
+                       *)             quagga_cv_rtread_method="getmsg";;
                      esac;;
-  *)                 RTREAD_METHOD="rtread_sysctl.o"
-                     zebra_rtread="sysctl";;
+       *)
+                     quagga_cv_rtread_method="sysctl";;
 esac
 fi])
+RTREAD_METHOD=rtread_${quagga_cv_rtread_method}.o
 AC_SUBST(RTREAD_METHOD)
 
 dnl -----------------------------
@@ -701,17 +930,12 @@ AC_SUBST(IOCTL_METHOD)
 dnl ---------------------------------------------------------------
 dnl figure out how to specify an interface in multicast sockets API
 dnl ---------------------------------------------------------------
-AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex],,,[#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif])
+AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], QUAGGA_INCLUDES)
 
 AC_MSG_CHECKING([for BSD struct ip_mreq hack])
 AC_TRY_COMPILE([#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
-#endif],[#if (defined(__FreeBSD__) && (__FreeBSD_version >= 500022 || (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) || (defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 106010000)
+#endif],[#if (defined(__FreeBSD__) && ((__FreeBSD_version >= 500022 && __FreeBSD_version < 700000) || (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) || (defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 106010000)
   return (0);
 #else
   #error No support for BSD struct ip_mreq hack detected
@@ -719,43 +943,77 @@ AC_TRY_COMPILE([#ifdef HAVE_SYS_PARAM_H
 AC_DEFINE(HAVE_BSD_STRUCT_IP_MREQ_HACK,,[Can pass ifindex in struct ip_mreq])],
 AC_MSG_RESULT(no))
 
+dnl ---------------------------------------------------------------
+dnl figure out how to check link-state
+dnl ---------------------------------------------------------------
+AC_CHECK_HEADER([net/if.h],
+  [AC_CHECK_HEADER( [net/if_media.h],
+    [m4_define([LINK_DETECT_INCLUDES],
+      QUAGGA_INCLUDES
+      [#include <net/if_media.h>
+    ])
+    AC_CHECK_MEMBERS( [struct ifmediareq.ifm_status],
+      AC_DEFINE(HAVE_BSD_LINK_DETECT,,[BSD link-detect]),
+      [], LINK_DETECT_INCLUDES)], 
+    [],
+    QUAGGA_INCLUDES)], 
+  [], QUAGGA_INCLUDES )
+
+dnl ------------------------
+dnl TCP_MD5SIG socket option
+dnl ------------------------
+
+AC_CHECK_HEADER([netinet/tcp.h], 
+   [m4_define([MD5_INCLUDES],
+      QUAGGA_INCLUDES
+      [#include <netinet/tcp.h>
+    ])
+    AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)],
+   [],
+   QUAGGA_INCLUDES)
+if test $ac_cv_have_decl_TCP_MD5SIG = no; then
+  AC_CHECK_HEADER([linux/tcp.h],
+       [m4_define([MD5_INCLUDES],
+          QUAGGA_INCLUDES
+          [#include <linux/tcp.h>
+        ])
+       AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)])
+fi
+
 dnl -----------------------
 dnl check proc file system.
 dnl -----------------------
-if test -r /proc/net/dev; then
-  AC_DEFINE(HAVE_PROC_NET_DEV,,/proc/net/dev)
-  IF_PROC=if_proc.o
-fi
-
-if test -r /proc/net/if_inet6; then
-  AC_DEFINE(HAVE_PROC_NET_IF_INET6,,/proc/net/if_inet6)
-  IF_PROC=if_proc.o
+if test "$netlink" != yes; then
+  if test -r /proc/net/dev; then
+    AC_DEFINE(HAVE_PROC_NET_DEV,,/proc/net/dev)
+    IF_PROC=if_proc.o
+  fi
+  if test -r /proc/net/if_inet6; then
+    AC_DEFINE(HAVE_PROC_NET_IF_INET6,,/proc/net/if_inet6)
+    IF_PROC=if_proc.o
+  fi
 fi
 AC_SUBST(IF_PROC)
 
 dnl -----------------------------
 dnl check ipforward detect method
 dnl -----------------------------
-AC_CACHE_CHECK(ipforward method check, zebra_ipforward_path,
-[for zebra_ipforward_path in /proc/net/snmp /dev/ip /dev/null;
+AC_CACHE_CHECK([ipforward method], [quagga_cv_ipforward_method],
+[for quagga_cv_ipforward_method in /proc/net/snmp /dev/ip /dev/null;
 do
-  test x`ls $zebra_ipforward_path 2>/dev/null` = x"$zebra_ipforward_path" && break
+  test x`ls $quagga_cv_ipforward_method 2>/dev/null` = x"$quagga_cv_ipforward_method" && break
 done
-case $zebra_ipforward_path in
-  "/proc/net/snmp")  IPFORWARD=ipforward_proc.o
-                     zebra_ipforward_path="proc";;
+case $quagga_cv_ipforward_method in
+  "/proc/net/snmp")  quagga_cv_ipforward_method="proc";;
   "/dev/ip")         
                      case "$host" in
-                       *-nec-sysv4*)  IPFORWARD=ipforward_ews.o
-                                      zebra_ipforward_path="ews";;
-                       *-freebsd*)    IPFORWARD=ipforward_sysctl.o
-                                      zebra_ipforward_path="sysctl";;
-                       *)             IPFORWARD=ipforward_solaris.o
-                                      zebra_ipforward_path="solaris";;
+                       *-nec-sysv4*)  quagga_cv_ipforward_method="ews";;
+                       *-freebsd*)    quagga_cv_ipforward_method="sysctl";;
+                       *)             quagga_cv_ipforward_method="solaris";;
                      esac;;
-  *)                 IPFORWARD=ipforward_sysctl.o
-                     zebra_ipforward_path="sysctl";;
+  *)                 quagga_cv_ipforward_method="sysctl";;
 esac])
+IPFORWARD=ipforward_${quagga_cv_ipforward_method}.o
 AC_SUBST(IPFORWARD)
 
 AC_CHECK_FUNCS(getaddrinfo, [have_getaddrinfo=yes], [have_getaddrinfo=no])
@@ -905,7 +1163,34 @@ dnl IPv6 header checks
 dnl ------------------
 if test "x${zebra_cv_ipv6}" = "xyes"; then
 AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h netinet/icmp6.h \
-                netinet6/in6_var.h netinet6/nd6.h])
+       netinet6/in6_var.h netinet6/nd6.h], [], [],
+       QUAGGA_INCLUDES)
+fi
+
+m4_define([QUAGGA_INCLUDES],dnl
+QUAGGA_INCLUDES
+[#if HAVE_NETINET6_IN6_H
+#include <netinet6/in6.h>
+#endif
+#if HAVE_NETINET_IN6_VAR_H
+#include <netinet/in6_var.h>
+#endif
+#if HAVE_NETINET_ICMP6_H
+# include <netinet/icmp6.h>
+#endif
+#if HAVE_NETINET6_IN6_VAR_H
+# include <netinet6/in6_var.h>
+#endif
+#if HAVE_NETINET6_ND6_H
+# include <netinet6/nd6.h>
+#endif
+])dnl
+
+dnl disable doc check
+if test "${enable_doc}" = "no";then
+  DOC=""
+else
+  DOC="doc"
 fi
 
 dnl --------------------
@@ -942,7 +1227,7 @@ else
 fi
 
 OSPFCLIENT=""
-if test "${enable_opaque_lsa}" = "yes"; then
+if test "${enable_opaque_lsa}" != "no"; then
   if test "${enable_ospfapi}" != "no";then
     AC_DEFINE(SUPPORT_OSPF_API,,OSPFAPI)
 
@@ -971,10 +1256,20 @@ case "${enable_isisd}" in
   *    ) ;;
 esac
 
+# XXX Perhaps auto-enable on Solaris, but that's messy for cross builds.
+case "${enable_solaris}" in
+  "yes") SOLARIS="solaris";;
+  "no" ) SOLARIS="";;
+  *    ) ;;
+esac
+
 if test "${enable_bgp_announce}" = "no";then
-  AC_DEFINE(DISABLE_BGP_ANNOUNCE,,Disable BGP installation to zebra)
+  AC_DEFINE(DISABLE_BGP_ANNOUNCE,1,Disable BGP installation to zebra)
+else
+  AC_DEFINE(DISABLE_BGP_ANNOUNCE,0,Disable BGP installation to zebra)
 fi
 
+AC_SUBST(DOC)
 AC_SUBST(ZEBRA)
 AC_SUBST(BGPD)
 AC_SUBST(RIPD)
@@ -983,6 +1278,7 @@ AC_SUBST(OSPFD)
 AC_SUBST(OSPF6D)
 AC_SUBST(WATCHQUAGGA)
 AC_SUBST(ISISD)
+AC_SUBST(SOLARIS)
 AC_SUBST(VTYSH)
 AC_SUBST(INCLUDES)
 AC_SUBST(CURSES)
@@ -992,7 +1288,6 @@ AC_CHECK_LIB(c, inet_ntop, [AC_DEFINE(HAVE_INET_NTOP,,inet_ntop)])
 AC_CHECK_LIB(c, inet_pton, [AC_DEFINE(HAVE_INET_PTON,,inet_pton)])
 AC_CHECK_LIB(crypt, crypt)
 AC_CHECK_LIB(resolv, res_init)
-AC_CHECK_LIB(m, main)
 
 dnl ---------------------------------------------------
 dnl BSD/OS 4.1 define inet_XtoY function as __inet_XtoY
@@ -1001,194 +1296,79 @@ AC_CHECK_FUNC(__inet_ntop, AC_DEFINE(HAVE_INET_NTOP,,__inet_ntop))
 AC_CHECK_FUNC(__inet_pton, AC_DEFINE(HAVE_INET_PTON,,__inet_pton))
 AC_CHECK_FUNC(__inet_aton, AC_DEFINE(HAVE_INET_ATON,,__inet_aton))
 
+dnl ---------------------------
+dnl check system has PCRE regexp
+dnl ---------------------------
+if test "x$enable_pcreposix" = "xyes"; then
+  AC_CHECK_LIB(pcreposix, pcreposix_regexec, ,[enable_pcreposix=no
+  AC_MSG_WARN([*** falling back to other regex library ***]) ])
+fi
+
+if test "x$enable_pcreposix" != "xyes"; then
 dnl ---------------------------
 dnl check system has GNU regexp
 dnl ---------------------------
-dnl AC_MSG_CHECKING(whether system has GNU regex)
+AC_MSG_CHECKING(whether system has GNU regex)
 AC_CHECK_LIB(c, regexec,
 [AC_DEFINE(HAVE_GNU_REGEX,,GNU regexp library)
  LIB_REGEX=""],
 [LIB_REGEX="regex.o"])
+fi
+AC_SUBST(HAVE_LIBPCREPOSIX)
 AC_SUBST(LIB_REGEX)
 
 dnl ------------------
 dnl check Net-SNMP library
 dnl ------------------
 if test "${enable_snmp}" = "yes"; then
-    LIBS="${LIBS} -lcrypto"
+    if test "$with_crypto" != "no"; then
+        LIBS="${LIBS} -lcrypto";
+    fi
     AC_CHECK_LIB(netsnmp, asn_parse_int,
        [AC_DEFINE(HAVE_NETSNMP,,Net SNMP) 
         AC_DEFINE(HAVE_SNMP,,SNMP)
         LIBS="${LIBS} -lnetsnmp"],
        [AC_MSG_ERROR([--enable-snmp given, but cannot find support for SNMP])])
-    
-    for ac_snmp in /usr/include \
-               /usr/local/include \
-               /dev/null; do
-       test -f "${ac_snmp}/net-snmp/library/asn1.h" && break
-    done
-    
-    case ${ac_snmp} in
-       /dev/null)
-               AC_MSG_ERROR([--enable-snmp given, but can not find header])
-               ;;
-       *)
-               SNMP_INCLUDES="-I${ac_snmp}/net-snmp"
-               SNMP_INCLUDES="${SNMP_INCLUDES} -I${ac_snmp}/net-snmp/library"
-               ;;
-    esac
-    
-    AC_SUBST(SNMP_INCLUDES)
-fi
-
-dnl ----------------------------
-dnl check sa_len of sockaddr
-dnl ----------------------------
-AC_MSG_CHECKING(whether struct sockaddr has a sa_len field)
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/socket.h>
-],[static struct sockaddr ac_i;int ac_j = sizeof (ac_i.sa_len);],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SA_LEN,,sa_len)],
- AC_MSG_RESULT(no))
-
-dnl ----------------------------
-dnl check sin_len of sockaddr_in
-dnl ----------------------------
-AC_MSG_CHECKING(whether struct sockaddr_in has a sin_len field)
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <netinet/in.h>
-],[static struct sockaddr_in ac_i;int ac_j = sizeof (ac_i.sin_len);],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SIN_LEN,,sin_len)],
- AC_MSG_RESULT(no))
-
-dnl ----------------------------
-dnl check sun_len of sockaddr_un
-dnl ----------------------------
-AC_MSG_CHECKING(whether struct sockaddr_un has a sun_len field)
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/un.h>
-],[static struct sockaddr_un ac_i;int ac_j = sizeof (ac_i.sun_len);],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SUN_LEN,,sun_len)],
- AC_MSG_RESULT(no))
 
-dnl -----------------------------------
-dnl check sin6_scope_id of sockaddr_in6
-dnl -----------------------------------
-if test "$zebra_cv_ipv6" = yes; then
-  AC_MSG_CHECKING(whether struct sockaddr_in6 has a sin6_scope_id field)
-  AC_TRY_COMPILE([#include <sys/types.h>
-#include <netinet/in.h>
-],[static struct sockaddr_in6 ac_i;int ac_j = sizeof (ac_i.sin6_scope_id);],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SIN6_SCOPE_ID,,scope id)],
- AC_MSG_RESULT(no))
+    AC_CHECK_HEADER([net-snmp/net-snmp-config.h],
+        [],
+        [AC_MSG_ERROR([--enable-snmp given, but cannot find net-snmp-config.h])],
+       QUAGGA_INCLUDES)
+    AC_SUBST(SNMP_INCLUDES)
 fi
 
-dnl ----------------------------
-dnl check socklen_t exist or not
-dnl ----------------------------
-AC_MSG_CHECKING(whther socklen_t is defined)
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-],[socklen_t ac_x;],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SOCKLEN_T,,socklen_t)],
- AC_MSG_RESULT(no))
-
-dnl ------------------------
-dnl check struct sockaddr_dl
-dnl ------------------------
-AC_MSG_CHECKING(whether struct sockaddr_dl exist)
-AC_EGREP_HEADER(sockaddr_dl,
-net/if_dl.h,
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SOCKADDR_DL,,sockaddr_dl)],
- AC_MSG_RESULT(no))
-
-dnl --------------------------
-dnl check structure ifaliasreq
-dnl --------------------------
-AC_MSG_CHECKING(whether struct ifaliasreq exist)
-AC_EGREP_HEADER(ifaliasreq,
-net/if.h,
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_IFALIASREQ,,ifaliasreq)],
- AC_MSG_RESULT(no))
-
-dnl ----------------------------
-dnl check structure in6_aliasreq
-dnl ----------------------------
-AC_MSG_CHECKING(whether struct in6_aliasreq exist)
-AC_EGREP_HEADER(in6_aliasreq,
-netinet6/in6_var.h,
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_IN6_ALIASREQ,,in6_aliasreq)],
- AC_MSG_RESULT(no))
-
-dnl -----------------------------------
-dnl check ifra_lifetime of in6_aliasreq
-dnl -----------------------------------
-AC_MSG_CHECKING(whether in6_aliasreq.ifra_lifetime exist)
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <netinet6/in6_var.h>
-],[static struct if6_aliasreq ac_i;int ac_j = sizeof (ac_i.ifra_lifetime);],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_IFRA_LIFETIME,,Have in6_aliasreq.ifra_lifetime)],
- AC_MSG_RESULT(no))
-
 dnl ---------------------------
-dnl check structure rt_addrinfo
+dnl sockaddr and netinet checks
 dnl ---------------------------
-AC_MSG_CHECKING(whether struct rt_addrinfo exist)
-AC_EGREP_HEADER(rt_addrinfo,
-net/route.h,
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_RT_ADDRINFO,,rt_addrinfo)],
- AC_MSG_RESULT(no))
+AC_CHECK_TYPES([struct sockaddr, struct sockaddr_in,
+       struct sockaddr_in6, struct sockaddr_un, struct sockaddr_dl,
+       socklen_t,
+       struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq,
+       struct nd_opt_adv_interval, struct rt_addrinfo,
+       struct nd_opt_homeagent_info, struct nd_opt_adv_interval],
+       [], [], QUAGGA_INCLUDES)
+
+AC_CHECK_MEMBERS([struct sockaddr.sa_len,
+       struct sockaddr_in.sin_len, struct sockaddr_un.sun_len,
+       struct sockaddr_in6.sin6_scope_id,
+       struct if6_aliasreq.ifra_lifetime,
+       struct nd_opt_adv_interval.nd_opt_ai_type],
+       [], [], QUAGGA_INCLUDES)
 
-dnl --------------------------
-dnl check structure in_pktinfo
-dnl --------------------------
-AC_MSG_CHECKING(whether struct in_pktinfo exist)
-AC_TRY_COMPILE([#include <netinet/in.h>
-],[struct in_pktinfo ac_x;],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_INPKTINFO,,in_pktinfo)],
- AC_MSG_RESULT(no))
-
-dnl ----------------------------------
-dnl check struct nd_opt_homeagent_info
-dnl ----------------------------------
-AC_MSG_CHECKING(whether struct nd_opt_homeagent_info exist)
-AC_EGREP_HEADER(nd_opt_homeagent_info,
-netinet/icmp6.h,
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_ND_OPT_HOMEAGENT_INFO,,nd_opt_homeagent_info)],
- AC_MSG_RESULT(no))
-
-dnl --------------------------------
-dnl check struct nd_opt_adv_interval
-dnl --------------------------------
-AC_MSG_CHECKING(whether struct nd_opt_adv_interval exist)
-AC_EGREP_HEADER(nd_opt_adv_interval,
-netinet/icmp6.h,
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_ND_OPT_ADV_INTERVAL,,nd_opt_adv_interval)],
- AC_MSG_RESULT(no))
-
-dnl ------------------------------------
-dnl check fields in  nd_opt_adv_interval
-dnl ------------------------------------
-AC_MSG_CHECKING(whether nd_opt_ai_type field exist)
-AC_EGREP_HEADER(nd_opt_ai_type,
-netinet/icmp6.h,
-[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_ND_OPT_ADV_INTERVAL_AI_FIELDS,,nd_opt_ai_type)],
- AC_MSG_RESULT(no))
+dnl ---------------------------
+dnl IRDP/pktinfo/icmphdr checks
+dnl ---------------------------
+AC_CHECK_TYPES([struct in_pktinfo], 
+ [AC_CHECK_TYPES([struct icmphdr],
+   [if test "${enable_irdp}" != "no"; then
+      AC_DEFINE(HAVE_IRDP,, IRDP)
+    fi],
+   [if test "${enable_irdp}" = "yes"; then
+      AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
+    fi], [QUAGGA_INCLUDES])],
+ [if test "${enable_irdp}" = "yes"; then
+    AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
+  fi], [QUAGGA_INCLUDES])
 
 dnl --------------------------------------
 dnl checking for getrusage struct and call
@@ -1200,6 +1380,14 @@ AC_TRY_COMPILE([#include <sys/resource.h>
  AC_DEFINE(HAVE_RUSAGE,,rusage)],
  AC_MSG_RESULT(no))
 
+dnl --------------------------------------
+dnl checking for clock_time monotonic struct and call
+dnl --------------------------------------
+AC_CHECK_DECL(CLOCK_MONOTONIC,
+       [AC_CHECK_LIB(rt, clock_gettime, [LIBS="$LIBS -lrt"])
+        AC_DEFINE(HAVE_CLOCK_MONOTONIC,, Have monotonic clock)
+], [AC_MSG_RESULT(no)], [QUAGGA_INCLUDES])
+
 dnl -------------------
 dnl capabilities checks
 dnl -------------------
@@ -1239,11 +1427,6 @@ if test "${enable_capabilities}" != "no"; then
 fi
 AC_SUBST(LIBCAP)
 
-dnl -------------------
-dnl test for ucontext.h
-dnl -------------------
-AC_CHECK_HEADERS(ucontext.h)
-
 dnl ---------------------------
 dnl check for glibc 'backtrace'
 dnl --------------------------- 
@@ -1263,7 +1446,7 @@ dnl order to check no alternative allocator
 dnl has been specified, which might not provide
 dnl mallinfo, e.g. such as Umem on Solaris.
 dnl -----------------------------------------
-AC_CHECK_HEADERS(malloc.h,
+AC_CHECK_HEADER([malloc.h],
  [AC_MSG_CHECKING(whether mallinfo is available)
   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
                         [[struct mallinfo ac_x; ac_x = mallinfo ();]])],
@@ -1271,8 +1454,7 @@ AC_CHECK_HEADERS(malloc.h,
        AC_DEFINE(HAVE_MALLINFO,,mallinfo)],
        AC_MSG_RESULT(no)
   )
- ]
-)
+ ], [], QUAGGA_INCLUDES)
 
 dnl ----------
 dnl configure date
@@ -1280,17 +1462,40 @@ dnl ----------
 CONFDATE=`date '+%Y%m%d'`
 AC_SUBST(CONFDATE)
 
+dnl Conditionally enable PIE support for GNU toolchains.
+AC_ARG_ENABLE(pie, AS_HELP_STRING([--disable-pie], [Do not build tools as a Position Independent Executables]))
+if test "$enable_pie" != "no"; then
+  AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [
+    save_CFLAGS=$CFLAGS
+    save_LDFLAGS=$LDFLAGS
+    CFLAGS="$CFLAGS -fPIE"
+    LDFLAGS="$LDFLAGS -pie"
+    AC_LINK_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
+      [ap_cv_cc_pie=yes], [ap_cv_cc_pie=no]
+    )
+    CFLAGS=$save_CFLAGS
+    LDFLAGS=$save_LDFLAGS
+  ])
+  if test "$ap_cv_cc_pie" = "yes"; then
+    PICFLAGS="-fPIE"
+    PILDFLAGS="-pie"
+  fi
+fi
+
+AC_SUBST(PICFLAGS)
+AC_SUBST(PILDFLAGS)
+
 dnl ------------------------------
 dnl set paths for state directory
 dnl ------------------------------
+AC_MSG_CHECKING(directory to use for state file)
 if test "${prefix}" = "NONE"; then
   quagga_statedir_prefix="";
 else
   quagga_statedir_prefix=${prefix}
 fi
 if test "${localstatedir}" = '${prefix}/var'; then
-  AC_CACHE_CHECK(state directory,ac_statedir,
-  [for QUAGGA_STATE_DIR in ${quagga_statedir_prefix}/var/run dnl
+  for QUAGGA_STATE_DIR in ${quagga_statedir_prefix}/var/run dnl
                        ${quagga_statedir_prefix}/var/adm dnl
                        ${quagga_statedir_prefix}/etc dnl
                        /var/run        dnl
@@ -1300,16 +1505,15 @@ if test "${localstatedir}" = '${prefix}/var'; then
   do
     test -d $QUAGGA_STATE_DIR && break
   done
-  quagga_statedir=$QUAGGA_STATE_DIR])
+  quagga_statedir=$QUAGGA_STATE_DIR
 else
   quagga_statedir=${localstatedir}
-  AC_MSG_CHECKING(directory to use for state file)
-  AC_MSG_RESULT(${quagga_statedir})
-  AC_SUBST(quagga_statedir)
 fi
 if test $quagga_statedir = "/dev/null"; then
     AC_MSG_ERROR('STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!')
 fi
+AC_MSG_RESULT(${quagga_statedir})
+AC_SUBST(quagga_statedir)
 
 AC_DEFINE_UNQUOTED(PATH_ZEBRA_PID, "$quagga_statedir/zebra.pid",zebra PID)
 AC_DEFINE_UNQUOTED(PATH_RIPD_PID, "$quagga_statedir/ripd.pid",ripd PID)
@@ -1341,19 +1545,11 @@ dnl ---------------------------
 dnl Check htonl works correctly
 dnl ---------------------------
 AC_MSG_CHECKING(for working htonl)
-AC_CACHE_VAL(ac_cv_htonl_works, [
-AC_TRY_LINK([#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif],
-[htonl (0);],
-ac_cv_htonl_works=yes,
-ac_cv_htonl_works=no)])
+AC_CACHE_VAL(ac_cv_htonl_works,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([QUAGGA_INCLUDES],[htonl (0);])],
+               [ac_cv_htonl_works=yes], [ac_cv_htonl_works=no])
+ ]
+)
 AC_MSG_RESULT($ac_cv_htonl_works)
 
 AC_CONFIG_FILES([Makefile lib/Makefile zebra/Makefile ripd/Makefile 
@@ -1372,19 +1568,19 @@ AC_CONFIG_FILES([solaris/Makefile])
 AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl])
 ## Hack, but working solution to avoid rebuilding of quagga.info.
 ## It's already in CVS until texinfo 4.7 is more common.
-AC_CONFIG_COMMANDS([info-time],[touch doc/quagga.info])
 AC_OUTPUT
 
 echo "
 Quagga configuration
 --------------------
 quagga version          : ${PACKAGE_VERSION}
-host operationg system  : ${host_os}
+host operating system  : ${host_os}
 source code location    : ${srcdir}
 compiler                : ${CC}
 compiler flags          : ${CFLAGS}
+make                    : ${MAKE-make}
 includes                : ${INCLUDES} ${SNMP_INCLUDES}
-linker flags            : ${LDFLAGS} ${LIBS} ${LIBCAP} ${LIBREADLINE}
+linker flags            : ${LDFLAGS} ${LIBS} ${LIBCAP} ${LIBREADLINE} ${LIBM}
 state file directory    : ${quagga_statedir}
 config file directory   : `eval echo \`echo ${sysconfdir}\``
 example directory       : `eval echo \`echo ${exampledir}\``