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