]> git.proxmox.com Git - mirror_frr.git/blame - configure.ac
*: remove --enable-tcp-zebra, rework ZAPI path
[mirror_frr.git] / configure.ac
CommitLineData
7ea487bc 1##
447a8fe9 2## Configure template file for FRRouting.
7ea487bc 3## autoconf will generate configure script.
4##
5## Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
e8f2984c 6## Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st>
7ea487bc 7##
9bc6875a 8AC_PREREQ(2.60)
7ea487bc 9
4952d0f0 10AC_INIT(frr, 3.1-dev, [https://github.com/frrouting/frr/issues])
d6180888 11PACKAGE_URL="https://frrouting.org/"
447a8fe9 12PACKAGE_FULLNAME="FRRouting"
a07169b1
DL
13AC_SUBST(PACKAGE_FULLNAME)
14
5ee1bde7 15CONFIG_ARGS="$ac_configure_args"
80db5ac1 16AC_SUBST(CONFIG_ARGS)
a07169b1 17
fa1253d0 18AC_CONFIG_SRCDIR(lib/zebra.h)
62c9f504 19AC_CONFIG_MACRO_DIR([m4])
dfb9a545 20
21dnl -----------------------------------
22dnl Get hostname and other information.
23dnl -----------------------------------
24AC_CANONICAL_BUILD()
25AC_CANONICAL_HOST()
29ad6f68
DL
26
27AS_IF([test "$host" != "$build"], [
28 if test "$srcdir" = "."; then
29 AC_MSG_ERROR([cross-compilation is only possible with builddir separate from srcdir. create a separate directory and run as .../path-to-frr/configure.])
30 fi
31 test -d hosttools || mkdir hosttools
32 abssrc="`cd \"${srcdir}\"; pwd`"
33
34 AC_MSG_NOTICE([...])
35 AC_MSG_NOTICE([... cross-compilation: creating hosttools directory and self-configuring for build platform tools])
36 AC_MSG_NOTICE([... use HOST_CPPFLAGS / HOST_CFLAGS / HOST_LDFLAGS if neccessary])
37 AC_MSG_NOTICE([...])
38
39 ( CPPFLAGS="$HOST_CPPFLAGS"; \
40 CFLAGS="$HOST_CFLAGS"; \
41 LDFLAGS="$HOST_LDFLAGS"; \
42 cd hosttools; "${abssrc}/configure" "--host=$build" "--build=$build"; )
43
44 AC_MSG_NOTICE([...])
45 AC_MSG_NOTICE([... cross-compilation: finished self-configuring for build platform tools])
46 AC_MSG_NOTICE([...])
47
48 build_clippy="false"
4a121f99 49 HOSTTOOLS="hosttools/"
29ad6f68
DL
50], [
51 build_clippy="true"
4a121f99 52 HOSTTOOLS=""
29ad6f68 53])
4a121f99 54AC_SUBST(HOSTTOOLS)
29ad6f68 55AM_CONDITIONAL([BUILD_CLIPPY], [$build_clippy])
dfb9a545 56
f77cba1b
AS
57# Disable portability warnings -- our automake code (in particular
58# common.am) uses some constructs specific to gmake.
a6cf5da4 59AM_INIT_AUTOMAKE([1.12 -Wno-portability])
50cfc0d2 60m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
e54583ea 61AM_SILENT_RULES([yes])
303bb005 62AC_CONFIG_HEADERS(config.h)
7ea487bc 63
0be793e6 64AC_PATH_PROG(PERL, perl)
00c03bc9 65PKG_PROG_PKG_CONFIG
03ecfb67 66
d6b72f7a 67dnl default is to match previous behavior
c4f0efe6 68exampledir=${sysconfdir}
d6b72f7a 69AC_ARG_ENABLE([exampledir],
23925784 70 AS_HELP_STRING([--enable-exampledir],
d6b72f7a 71 [specify alternate directory for examples]),
72 exampledir="$enableval",)
c4f0efe6 73dnl XXX add --exampledir to autoconf standard directory list somehow
d6b72f7a 74AC_SUBST(exampledir)
75
cbd04084 76dnl default is to match previous behavior
77pkgsrcrcdir=""
cbd04084 78AC_ARG_ENABLE([pkgsrcrcdir],
23925784 79 AS_HELP_STRING([--enable-pkgsrcrcdir],
cbd04084 80 [specify directory for rc.d scripts]),
53d93be1 81 pkgsrcrcdir="$enableval",)
cbd04084 82dnl XXX add --pkgsrcrcdir to autoconf standard directory list somehow
cbd04084 83AC_SUBST(pkgsrcrcdir)
53d93be1 84AM_CONDITIONAL([PKGSRC], [test "x$pkgsrcrcdir" != "x"])
cbd04084 85
30771d65
DL
86AC_ARG_WITH([moduledir], [AS_HELP_STRING([--with-moduledir=DIR], [module directory (${libdir}/frr/modules)])], [
87 moduledir="$withval"
88], [
89 moduledir="\${libdir}/frr/modules"
90])
91AC_SUBST([moduledir], [$moduledir])
92
3f9c7369 93AC_ARG_ENABLE(tcmalloc,
428cd73f 94 AS_HELP_STRING([--enable-tcmalloc], [Turn on tcmalloc]),
3f9c7369
DS
95[case "${enableval}" in
96 yes) tcmalloc_enabled=true
97LIBS="$LIBS -ltcmalloc_minimal"
98 ;;
99 no) tcmalloc_enabled=false ;;
100 *) AC_MSG_ERROR(bad value ${enableval} for --enable-tcmalloc) ;;
101esac],[tcmalloc_enabled=false])
102
103
fbd0bae6
DL
104dnl Thanks autoconf, but we don't want a default -g -O2. We have our own
105dnl flag determination logic.
106CFLAGS="${CFLAGS:-}"
107
1969e4b9 108dnl --------------------
109dnl Check CC and friends
110dnl --------------------
a89b1641
DL
111dnl note orig_cflags is also used further down
112orig_cflags="$CFLAGS"
46bc0e43 113AC_LANG([C])
7ea487bc 114AC_PROG_CC
1969e4b9 115AC_PROG_CPP
46bc0e43 116AM_PROG_CC_C_O
a89b1641
DL
117dnl remove autoconf default "-g -O2"
118CFLAGS="$orig_cflags"
1769aff8 119AC_PROG_CC_C99
8aa42b82 120dnl NB: see C11 below
553bdfe3 121
a89b1641 122AC_PROG_EGREP
2fb975da 123PKG_PROG_PKG_CONFIG
a89b1641 124
553bdfe3
GT
125dnl autoconf 2.59 appears not to support AC_PROG_SED
126dnl AC_PROG_SED
127AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])
1969e4b9 128
1689cf7e 129dnl try and enable CFLAGS that are useful for FRR
a89b1641 130dnl - specifically, options to control warnings
1969e4b9 131
b31fd749 132AC_USE_SYSTEM_EXTENSIONS
988225dd
DL
133AC_DEFUN([AC_C_FLAG], [{
134 AC_LANG_PUSH(C)
135 ac_c_flag_save="$CFLAGS"
136 CFLAGS="$CFLAGS $1"
137 AC_MSG_CHECKING([[whether $CC supports $1]])
138 AC_COMPILE_IFELSE(
139 [AC_LANG_PROGRAM([[]])],
140 [
141 AC_MSG_RESULT([yes])
142 m4_if([$3], [], [], [
143 CFLAGS="$ac_c_flag_save"
144 $3
145 ])
146 ], [
147 CFLAGS="$ac_c_flag_save"
148 AC_MSG_RESULT([no])
149 $2
150 ])
151 AC_LANG_POP(C)
152 }])
153
92e50261
DL
154AC_DEFUN([AC_LINK_IFELSE_FLAGS], [{
155 AC_LANG_PUSH(C)
156 ac_cflags_save="$CFLAGS"
157 ac_libs_save="$LIBS"
158 CFLAGS="$CFLAGS $1"
159 LIBS="$LIBS $2"
160 AC_LINK_IFELSE(
161 [$3],
162 [
163 AC_MSG_RESULT([yes])
164 CFLAGS="$ac_cflags_save"
165 LIBS="$ac_libs_save"
166 $5
167 ], [
168 AC_MSG_RESULT([no])
169 CFLAGS="$ac_cflags_save"
170 LIBS="$ac_libs_save"
171 $4
172 ])
173 AC_LANG_POP(C)
174 }])
175
a89b1641
DL
176dnl ICC won't bail on unknown options without -diag-error 10006
177dnl need to do this first so we get useful results for the other options
178AC_C_FLAG([-diag-error 10006])
179
8aa42b82
DL
180dnl AC_PROG_CC_C99 may change CC to include -std=gnu99 or something
181ac_cc="$CC"
182CC="${CC% -std=gnu99}"
183CC="${CC% -std=c99}"
184
185AC_C_FLAG([-std=gnu11], [CC="$ac_cc"], [CC="$CC -std=gnu11"])
186
a89b1641
DL
187dnl if the user specified any CFLAGS, we don't add "-g -Os/-O2" here
188if test "z$orig_cflags" = "z"; then
189 AC_C_FLAG([-g])
190 AC_C_FLAG([-Os], [
191 AC_C_FLAG([-O2])
192 ])
193fi
194
195dnl always want these CFLAGS
196AC_C_FLAG([-fno-omit-frame-pointer])
197AC_C_FLAG([-Wall])
198AC_C_FLAG([-Wextra])
199AC_C_FLAG([-Wmissing-prototypes])
200AC_C_FLAG([-Wmissing-declarations])
201AC_C_FLAG([-Wpointer-arith])
202AC_C_FLAG([-Wbad-function-cast])
203AC_C_FLAG([-Wwrite-strings])
204if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then
205 AC_C_FLAG([-Wcast-qual])
206 AC_C_FLAG([-Wstrict-prototypes])
207 AC_C_FLAG([-Wmissing-noreturn])
208 AC_C_FLAG([-Wmissing-format-attribute])
209 AC_C_FLAG([-Wunreachable-code])
210 AC_C_FLAG([-Wpacked])
211 AC_C_FLAG([-Wpadded])
6a4b8832 212else
a89b1641 213 AC_C_FLAG([-Wno-unused-result])
1969e4b9 214fi
a89b1641
DL
215AC_C_FLAG([-Wno-unused-parameter])
216AC_C_FLAG([-Wno-missing-field-initializers])
217
218dnl ICC emits a broken warning for const char *x = a ? "b" : "c";
219dnl for some reason the string consts get 'promoted' to char *,
220dnl triggering a const to non-const conversion warning.
221AC_C_FLAG([-diag-disable 3179])
1969e4b9 222
aa9584c1
DS
223if test x"${enable_werror}" = x"yes" ; then
224 WERROR="-Werror"
225fi
226AC_SUBST(WERROR)
227
2e83e8e9
DL
228dnl need link on this one, not compile
229AC_LANG_PUSH(C)
230ac_ld_flag_save="$LDFLAGS"
231LDFLAGS="$LDFLAGS -rdynamic"
232AC_MSG_CHECKING([[whether linker supports -rdynamic]])
233AC_LINK_IFELSE(
234 [AC_LANG_PROGRAM([[]])],
235 [AC_MSG_RESULT([yes])],
236 [
237 LDFLAGS="$ac_ld_flag_save"
238 AC_MSG_RESULT([no])
239 ])
240AC_LANG_POP(C)
241
b31fd749
DL
242dnl ----------
243dnl Essentials
244dnl ----------
245
246AX_PTHREAD([
247 CC="$PTHREAD_CC"
248 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
249 LIBS="$PTHREAD_LIBS $LIBS"
250], [
1689cf7e 251 AC_MSG_FAILURE([This FRR version needs pthreads])
b31fd749
DL
252])
253
7ea487bc 254dnl --------------
255dnl Check programs
256dnl --------------
7ea487bc 257AC_PROG_INSTALL
6f0e3f6e 258AC_PROG_LN_S
7ea487bc 259AC_PROG_MAKE_SET
260AC_CHECK_TOOL(AR, ar)
7ea487bc 261
d46d2a24
PJ
262dnl -----------------
263dnl System extensions
264dnl -----------------
d46d2a24 265AC_GNU_SOURCE
7ea487bc 266
87efd646 267dnl -------
268dnl libtool
269dnl -------
95bb8305 270LT_INIT
87efd646 271
7ea487bc 272dnl ----------------------
273dnl Packages configuration
274dnl ----------------------
1080c13f
JN
275AC_ARG_WITH(pkg-extra-version,
276 AS_HELP_STRING([--with-pkg-extra-version=VER], [add extra version field, for packagers/distributions]),
277 [EXTRAVERSION=$withval],)
0be793e6
DL
278AC_ARG_WITH(pkg-git-version,
279 AS_HELP_STRING([--with-pkg-git-version], [add git information to MOTD and build version string]),
a16dcf7c 280 [ test "x$withval" != "xno" && with_pkg_git_version="yes" ])
08c369bd
DS
281AC_ARG_WITH(vtysh_pager,
282 AS_HELP_STRING([--with-vtysh-pager=PAGER], [control what pager is compiled in as default]),
283 VTYSH_PAGER=$withval, VTYSH_PAGER="more")
7ea487bc 284AC_ARG_ENABLE(vtysh,
1689cf7e 285 AS_HELP_STRING([--disable-vtysh], [do not build integrated vty shell for FRR]))
cbcd9bfc 286AC_ARG_ENABLE(doc,
23925784 287 AS_HELP_STRING([--disable-doc], [do not build docs]))
7ea487bc 288AC_ARG_ENABLE(zebra,
23925784 289 AS_HELP_STRING([--disable-zebra], [do not build zebra daemon]))
7ea487bc 290AC_ARG_ENABLE(bgpd,
23925784 291 AS_HELP_STRING([--disable-bgpd], [do not build bgpd]))
7ea487bc 292AC_ARG_ENABLE(ripd,
23925784 293 AS_HELP_STRING([--disable-ripd], [do not build ripd]))
7ea487bc 294AC_ARG_ENABLE(ripngd,
23925784 295 AS_HELP_STRING([--disable-ripngd], [do not build ripngd]))
7ea487bc 296AC_ARG_ENABLE(ospfd,
23925784 297 AS_HELP_STRING([--disable-ospfd], [do not build ospfd]))
7ea487bc 298AC_ARG_ENABLE(ospf6d,
23925784 299 AS_HELP_STRING([--disable-ospf6d], [do not build ospf6d]))
eac6e3f0
RW
300AC_ARG_ENABLE(ldpd,
301 AS_HELP_STRING([--enable-ldpd], [build ldpd]))
2fb975da
TT
302AC_ARG_ENABLE(nhrpd,
303 AS_HELP_STRING([--disable-nhrpd], [do not build nhrpd]))
7f57883e
DS
304AC_ARG_ENABLE(eigrpd,
305 AS_HELP_STRING([--disable-eigrpd], [do not build eigrpd]))
ca10883e
DS
306AC_ARG_ENABLE(babeld,
307 AS_HELP_STRING([--disable-babeld], [do not build babeld]))
9473e340
DS
308AC_ARG_ENABLE(watchfrr,
309 AS_HELP_STRING([--disable-watchfrr], [do not build watchfrr]))
9e867fe6 310AC_ARG_ENABLE(isisd,
c3a9461e 311 AS_HELP_STRING([--disable-isisd], [do not build isisd]))
12e41d03 312AC_ARG_ENABLE(pimd,
23925784 313 AS_HELP_STRING([--disable-pimd], [do not build pimd]))
7ea487bc 314AC_ARG_ENABLE(bgp-announce,
23925784 315 AS_HELP_STRING([--disable-bgp-announce,], [turn off BGP route announcement]))
65efcfce 316AC_ARG_ENABLE(bgp-vnc,
f95f2ad9 317 AS_HELP_STRING([--disable-bgp-vnc],[turn off BGP VNC support]))
65efcfce
LB
318AC_ARG_WITH(rfp-path,
319 AS_HELP_STRING([--with-rfp-path[=DIR]],[path to replaced stub RFP used with BGP VNC]))
7ea487bc 320AC_ARG_ENABLE(snmp,
23925784 321 AS_HELP_STRING([--enable-snmp=ARG], [enable SNMP support (smux or agentx)]))
7ea487bc 322AC_ARG_WITH(libpam,
23925784 323 AS_HELP_STRING([--with-libpam], [use libpam for PAM support in vtysh]))
1ef74ef7 324AC_ARG_ENABLE(ospfapi,
23925784 325 AS_HELP_STRING([--disable-ospfapi], [do not build OSPFAPI to access the OSPF LSA Database]))
1ef74ef7 326AC_ARG_ENABLE(ospfclient,
23925784
DL
327 AS_HELP_STRING([--disable-ospfclient], [do not build OSPFAPI client for OSPFAPI,
328 (this is the default if --disable-ospfapi is set)]))
7ea487bc 329AC_ARG_ENABLE(multipath,
23925784 330 AS_HELP_STRING([--enable-multipath=ARG], [enable multipath function, ARG must be digit]))
fe86b484 331AC_ARG_ENABLE(user,
b2f36157 332 AS_HELP_STRING([--enable-user=USER], [user to run FRR suite as (default frr)]))
fe86b484 333AC_ARG_ENABLE(group,
b2f36157 334 AS_HELP_STRING([--enable-group=GROUP], [group to run FRR suite as (default frr)]))
edd7c245 335AC_ARG_ENABLE(vty_group,
23925784 336 AS_HELP_STRING([--enable-vty-group=ARG], [set vty sockets to have specified group as owner]))
aa593d5e 337AC_ARG_ENABLE(configfile_mask,
23925784 338 AS_HELP_STRING([--enable-configfile-mask=ARG], [set mask for config files]))
aa593d5e 339AC_ARG_ENABLE(logfile_mask,
23925784 340 AS_HELP_STRING([--enable-logfile-mask=ARG], [set mask for log files]))
5fd1f747 341AC_ARG_ENABLE(shell_access,
23925784 342 AS_HELP_STRING([--enable-shell-access], [Allow users to access shell/telnet/ssh]))
71c0fb50 343AC_ARG_ENABLE(rtadv,
23925784 344 AS_HELP_STRING([--disable-rtadv], [disable IPV6 router advertisement feature]))
ca776988 345AC_ARG_ENABLE(irdp,
23925784 346 AS_HELP_STRING([--enable-irdp], [enable IRDP server support in zebra]))
41d3fc96 347AC_ARG_ENABLE(capabilities,
23925784 348 AS_HELP_STRING([--disable-capabilities], [disable using POSIX capabilities]))
47f6aef0 349AC_ARG_ENABLE(rusage,
23925784 350 AS_HELP_STRING([--disable-rusage], [disable using getrusage]))
6b6942f9 351AC_ARG_ENABLE(gcc_ultra_verbose,
23925784 352 AS_HELP_STRING([--enable-gcc-ultra-verbose], [enable ultra verbose GCC warnings]))
3453a712 353AC_ARG_ENABLE(linux24_tcp_md5,
23925784 354 AS_HELP_STRING([--enable-linux24-tcp-md5], [enable support for old, Linux-2.4 RFC2385 patch]))
8c99b4c1 355AC_ARG_ENABLE(backtrace,
23925784 356 AS_HELP_STRING([--disable-backtrace,], [disable crash backtraces (default autodetect)]))
924b9229 357AC_ARG_ENABLE(time-check,
23925784 358 AS_HELP_STRING([--disable-time-check], [disable slow thread warning messages]))
25f45887 359AC_ARG_ENABLE(pcreposix,
23925784 360 AS_HELP_STRING([--enable-pcreposix], [enable using PCRE Posix libs for regex functions]))
5adc2528 361AC_ARG_ENABLE(fpm,
23925784 362 AS_HELP_STRING([--enable-fpm], [enable Forwarding Plane Manager support]))
ddd82ff6 363AC_ARG_ENABLE(systemd,
23925784 364 AS_HELP_STRING([--enable-systemd], [enable Systemd support]))
aa9584c1
DS
365AC_ARG_ENABLE(werror,
366 AS_HELP_STRING([--enable-werror], [enable -Werror (recommended for developers only)]))
000cf1fb 367AC_ARG_ENABLE(cumulus,
23925784 368 AS_HELP_STRING([--enable-cumulus], [enable Cumulus Switch Special Extensions]))
df970aa6
DS
369AC_ARG_ENABLE(datacenter,
370 AS_HELP_STRING([--enable-datacenter], [enable Compilation for Data Center Extensions]))
76981cd3
DS
371AC_ARG_ENABLE(rr-semantics,
372 AS_HELP_STRING([--disable-rr-semantics], [disable the v6 Route Replace semantics]))
dad253b4
AS
373AC_ARG_ENABLE([protobuf],
374 AS_HELP_STRING([--enable-protobuf], [Enable experimental protobuf support]))
28436d6d 375AC_ARG_ENABLE([oldvpn_commands],
fcc65b0f 376 AS_HELP_STRING([--enable-oldvpn-commands], [Keep old vpn commands]))
6b6942f9 377
112072ac 378AC_CHECK_HEADERS(json-c/json.h)
ea2fd55a 379AC_CHECK_LIB(json-c, json_object_get, LIBS="$LIBS -ljson-c", [], [-lm])
112072ac 380if test $ac_cv_lib_json_c_json_object_get = no; then
10b8ab26
DS
381 AC_CHECK_LIB(json, json_object_get, LIBS="$LIBS -ljson")
382 if test $ac_cv_lib_json_json_object_get = no; then
383 AC_MSG_ERROR([lib json is needed to compile])
384 fi
c2f4c19c
DS
385fi
386
3b8282a8
AS
387AC_ARG_ENABLE([dev_build],
388 AS_HELP_STRING([--enable-dev-build], [build for development]))
389
924b9229 390if test x"${enable_time_check}" != x"no" ; then
391 if test x"${enable_time_check}" = x"yes" -o x"${enable_time_check}" = x ; then
392 AC_DEFINE(CONSUMED_TIME_CHECK,5000000,Consumed Time Check)
393 else
394 AC_DEFINE_UNQUOTED(CONSUMED_TIME_CHECK,$enable_time_check,Consumed Time Check)
395 fi
396fi
397
37219958
DS
398case "${enable_systemd}" in
399 "no") ;;
400 "yes")
401 AC_CHECK_LIB(systemd, sd_notify, LIBS="$LIBS -lsystemd")
402 if test $ac_cv_lib_systemd_sd_notify = no; then
403 AC_MSG_ERROR([enable systemd has been specified but systemd development env not found on your system])
63e30864
DS
404 else
405 AC_DEFINE(HAVE_SYSTEMD,,Compile systemd support in)
37219958
DS
406 fi
407 ;;
408 "*") ;;
409esac
ddd82ff6 410
76981cd3
DS
411if test "${enable_rr_semantics}" != "no" ; then
412 AC_DEFINE(HAVE_V6_RR_SEMANTICS,, Compile in v6 Route Replacement Semantics)
413fi
414
df970aa6
DS
415if test "${enable_datacenter}" = "yes" ; then
416 AC_DEFINE(HAVE_DATACENTER,,Compile extensions for a DataCenter)
8efe88ea
DL
417 DFLT_NAME="datacenter"
418else
419 DFLT_NAME="traditional"
000cf1fb 420fi
df970aa6
DS
421
422if test "${enable_cumulus}" = "yes" ; then
423 AC_DEFINE(HAVE_CUMULUS,,Compile Special Cumulus Code in)
424fi
425
8efe88ea
DL
426AC_SUBST(DFLT_NAME)
427AC_DEFINE_UNQUOTED(DFLT_NAME,["$DFLT_NAME"], Name of the configuration default set)
000cf1fb 428
576b6b5d
DS
429if test "${enable_shell_access}" = "yes"; then
430 AC_DEFINE(HAVE_SHELL_ACCESS,,Allow user to use ssh/telnet/bash)
431fi
432
4f8ea50c 433AM_CONDITIONAL([FPM], [test "x$enable_fpm" = "xyes"])
5adc2528 434
3b8282a8
AS
435if test "x${enable_dev_build}" = "xyes"; then
436 AC_DEFINE(DEV_BUILD,,Build for development)
437fi
438AM_CONDITIONAL([DEV_BUILD], [test "x$enable_dev_build" = "xyes"])
439
29ad6f68
DL
440#
441# Python for clippy
442#
443AS_IF([test "$host" = "$build"], [
444 PYTHONCONFIG=""
445
446 # ordering:
447 # 1. try python3, but respect the user's preference on which minor ver
448 # 2. try python, which might be py3 or py2 again on the user's preference
449 # 3. try python2 (can really only be 2.7 but eh)
450 # 4. try 3.5 > 3.4 > 3.3 > 3.2 > 2.7 through pkg-config (no user pref)
451 #
452 # (AX_PYTHON_DEVEL has no clue about py3 vs py2)
453 # (AX_PYTHON does not do what we need)
454
455 AC_CHECK_TOOLS([PYTHONCONFIG], [python3-config python-config python2-config])
456 if test -n "$PYTHONCONFIG"; then
457 PYTHON_CFLAGS="`\"${PYTHONCONFIG}\" --includes`"
458 PYTHON_LIBS="`\"${PYTHONCONFIG}\" --libs`"
459
460 AC_MSG_CHECKING([whether we found a working Python version])
461 AC_LINK_IFELSE_FLAGS([$PYTHON_CFLAGS], [$PYTHON_LIBS], [AC_LANG_PROGRAM([
462#include <Python.h>
463#if PY_VERSION_HEX < 0x02070000
464#error python too old
465#endif
466int main(void);
467],
468[
469{
470 Py_Initialize();
471 return 0;
472}
473])], [
474 PYTHONCONFIG=""
475 unset PYTHON_LIBS
476 unset PYTHON_CFLAGS
477 ])
478 fi
479
480 if test -z "$PYTHONCONFIG"; then
481 PKG_CHECK_MODULES([PYTHON], python-3.5, [], [
482 PKG_CHECK_MODULES([PYTHON], python-3.4, [], [
483 PKG_CHECK_MODULES([PYTHON], python-3.3, [], [
484 PKG_CHECK_MODULES([PYTHON], python-3.2, [], [
485 PKG_CHECK_MODULES([PYTHON], python-2.7, [], [
486 AC_MSG_FAILURE([could not find python-config or pkg-config python, please install Python development files from libpython-dev or similar])
487 ])])])])])
488
489
490 AC_MSG_CHECKING([whether we found a working Python version])
491 AC_LINK_IFELSE_FLAGS([$PYTHON_CFLAGS], [$PYTHON_LIBS], [AC_LANG_PROGRAM([
492#include <Python.h>
493#if PY_VERSION_HEX < 0x02070000
494#error python too old
495#endif
496int main(void);
497],
498[
499{
500 Py_Initialize();
501 return 0;
502}
503])], [
504 AC_MSG_FAILURE([could not find python-config or pkg-config python, please install Python development files from libpython-dev or similar])
505 ])
506 fi
507])
508AC_SUBST(PYTHON_CFLAGS)
509AC_SUBST(PYTHON_LIBS)
510
dad253b4
AS
511#
512# Logic for protobuf support.
513#
514if test "$enable_protobuf" = "yes"; then
515 have_protobuf=yes
516
517 # Check for protoc-c
518 AC_CHECK_PROG([PROTOC_C], [protoc-c], [protoc-c], [/bin/false])
519 if test "x$PROTOC_C" = "x/bin/false"; then
520 have_protobuf=no
521 else
522 found_protobuf_c=no
523 PKG_CHECK_MODULES([PROTOBUF_C], libprotobuf-c >= 0.14,
524 [found_protobuf_c=yes],
525 [AC_MSG_RESULT([pkg-config did not find libprotobuf-c])])
526
527 if test "x$found_protobuf_c" = "xyes"; then
528 LDFLAGS="$LDFLAGS $PROTOBUF_C_LIBS"
529 CFLAGS="$CFLAGS $PROTOBUF_C_CFLAGS"
530 else
531 AC_CHECK_HEADER([google/protobuf-c/protobuf-c.h], [],
532 [have_protobuf=no; AC_MSG_RESULT([Couldn't find google/protobuf-c.h])])
533 fi
534 fi
535fi
536
28436d6d
PG
537#
538# Logic for old vpn commans support.
539#
fcc65b0f 540if test "$enable_oldvpn_commands" = "yes"; then
28436d6d
PG
541 AC_DEFINE(KEEP_OLD_VPN_COMMANDS,, [Define for compiling with old vpn commands])
542fi
543
dad253b4
AS
544# Fail if the user explicity enabled protobuf support and we couldn't
545# find the compiler or libraries.
546if test "x$have_protobuf" = "xno" && test "x$enable_protobuf" = "xyes"; then
547 AC_MSG_ERROR([Protobuf enabled explicitly but can't find libraries/tools])
548fi
549
550if test "x$have_protobuf" = "xyes"; then
551 AC_DEFINE(HAVE_PROTOBUF,, protobuf)
552fi
553
554AM_CONDITIONAL([HAVE_PROTOBUF], [test "x$have_protobuf" = "xyes"])
555
556#
557# End of logic for protobuf support.
558#
559
3453a712
PJ
560if test "${enable_linux24_tcp_md5}" = "yes"; then
561 AC_DEFINE(HAVE_TCP_MD5_LINUX24,,Old Linux 2.4 TCP MD5 Signature Patch)
562fi
563
d2a0ccc6 564AC_MSG_CHECKING(if zebra should be configurable to send Route Advertisements)
565if test "${enable_rtadv}" != "no"; then
71c0fb50 566 AC_MSG_RESULT(yes)
d2a0ccc6 567 AC_DEFINE(HAVE_RTADV,,Enable IPv6 Routing Advertisement support)
2487bea1 568else
569 AC_MSG_RESULT(no)
71c0fb50 570fi
7ea487bc 571
ca776988 572if test "${enable_irdp}" = "yes"; then
573 AC_DEFINE(HAVE_IRDP,, IRDP )
574fi
575
0b02a1b4
JAG
576if test x"${enable_user}" = x"no"; then
577 enable_user=""
578else
579 if test x"${enable_user}" = x"yes" || test x"${enable_user}" = x""; then
b2f36157 580 enable_user="frr"
0b02a1b4 581 fi
b2f36157 582 AC_DEFINE_UNQUOTED(FRR_USER, "${enable_user}", frr User)
edd7c245 583fi
edd7c245 584
0b02a1b4
JAG
585if test x"${enable_group}" = x"no"; then
586 enable_group=""
587else
588 if test x"${enable_group}" = x"yes" || test x"${enable_group}" = x""; then
b2f36157 589 enable_group="frr"
0b02a1b4 590 fi
b2f36157 591 AC_DEFINE_UNQUOTED(FRR_GROUP, "${enable_group}", frr Group)
edd7c245 592fi
edd7c245 593
594if test x"${enable_vty_group}" = x"yes" ; then
8d4aee5d 595 AC_MSG_ERROR([--enable-vty-group requires a group as argument, not yes])
79cb2169 596elif test x"${enable_vty_group}" != x""; then
8d4aee5d 597 if test x"${enable_vty_group}" != x"no"; then
edd7c245 598 AC_DEFINE_UNQUOTED(VTY_GROUP, "${enable_vty_group}", VTY Sockets Group)
599 fi
600fi
26275b05 601AC_SUBST([enable_user])
602AC_SUBST([enable_group])
603AC_SUBST([enable_vty_group])
edd7c245 604
aa593d5e 605enable_configfile_mask=${enable_configfile_mask:-0600}
606AC_DEFINE_UNQUOTED(CONFIGFILE_MASK, ${enable_configfile_mask}, Mask for config files)
607
608enable_logfile_mask=${enable_logfile_mask:-0600}
609AC_DEFINE_UNQUOTED(LOGFILE_MASK, ${enable_logfile_mask}, Mask for log files)
610
7a6da5ba 611MPATH_NUM=1
7ea487bc 612
613case "${enable_multipath}" in
7c5d2b76 614 0)
7a6da5ba 615 MPATH_NUM=64
7c5d2b76 616 ;;
90fb3e13 617 [[1-9]|[1-9][0-9]|[1-9][0-9][0-9]])
7a6da5ba 618 MPATH_NUM="${enable_multipath}"
7ea487bc 619 ;;
620 "")
621 ;;
622 *)
6f0e3f6e 623 AC_MSG_FAILURE([Please specify digit to enable multipath ARG])
7ea487bc 624 ;;
625esac
626
7a6da5ba 627AC_DEFINE_UNQUOTED(MULTIPATH_NUM, $MPATH_NUM, Maximum number of paths for a route)
7ea487bc 628
08c369bd
DS
629AC_DEFINE_UNQUOTED(VTYSH_PAGER, "$VTYSH_PAGER", [What pager to use])
630
1080c13f
JN
631dnl -----------------------------------
632dnl Add extra version string to package
633dnl name, string and version fields.
634dnl -----------------------------------
635if test "x${EXTRAVERSION}" != "x" ; then
0be793e6
DL
636 VERSION="${VERSION}${EXTRAVERSION}"
637 PACKAGE_VERSION="${PACKAGE_VERSION}${EXTRAVERSION}"
3ab11ecc 638 AC_SUBST(PACKAGE_EXTRAVERSION, ["${EXTRAVERSION}"])
0be793e6 639 PACKAGE_STRING="${PACKAGE_STRING}${EXTRAVERSION}"
1080c13f
JN
640fi
641
a16dcf7c
DL
642if test "x$with_pkg_git_version" = "xyes"; then
643 if test -d "${srcdir}/.git"; then
644 AC_DEFINE(GIT_VERSION, [1], [include git version info])
645 else with_pkg_git_version="no"
646 AC_MSG_WARN([--with-pkg-git-version given, but this is not a git checkout])
647 fi
648fi
649AM_CONDITIONAL([GIT_VERSION], [test "x$with_pkg_git_version" = "xyes"])
0be793e6 650
6f0e3f6e
PJ
651dnl ------------------------------------
652dnl Check C keywords and standard types
653dnl ------------------------------------
654AC_C_CONST
655AC_C_INLINE
6f0e3f6e 656AC_C_VOLATILE
dc7a2bf1 657AC_HEADER_STDC
6f0e3f6e
PJ
658dnl AC_TYPE_PID_T
659AC_TYPE_UID_T
660AC_TYPE_MODE_T
661AC_TYPE_SIZE_T
6f0e3f6e 662AC_STRUCT_TM
dc7a2bf1 663
6f0e3f6e
PJ
664dnl -------------------------
665dnl Check other header files.
666dnl -------------------------
24f5e2fc
DL
667AC_CHECK_HEADERS([stropts.h sys/ksym.h \
668 linux/version.h asm/types.h \
669 sys/cdefs.h])
6f0e3f6e 670
899a4fd2
DL
671ac_stdatomic_ok=false
672AC_DEFINE(FRR_AUTOCONF_ATOMIC, 1, [did autoconf checks for atomic funcs])
673AC_CHECK_HEADER([stdatomic.h],[
674
675 AC_MSG_CHECKING([whether _Atomic qualifier works])
676 AC_LINK_IFELSE([AC_LANG_SOURCE([[
677#include <stdatomic.h>
678int main(int argc, char **argv) {
679 _Atomic int i = 0;
680 return i;
681}
682]])], [
683 AC_DEFINE(HAVE_STDATOMIC_H, 1, [found stdatomic.h])
684 AC_MSG_RESULT([yes])
685 ac_stdatomic_ok=true
686 ], [
687 AC_MSG_RESULT([no])
688 ])
689])
690
691AS_IF([$ac_stdatomic_ok], [true], [
692 AC_MSG_CHECKING([for __atomic_* builtins])
693 AC_LINK_IFELSE([AC_LANG_SOURCE([[
694int main(int argc, char **argv) {
695 volatile int i = 1;
696 __atomic_store_n (&i, 0, __ATOMIC_RELEASE);
697 return __atomic_load_n (&i, __ATOMIC_ACQUIRE);
698}
699]])], [
700 AC_DEFINE(HAVE___ATOMIC, 1, [found __atomic builtins])
701 AC_MSG_RESULT([yes])
702 ], [
703 AC_MSG_RESULT([no])
704
705 dnl FreeBSD 9 has a broken stdatomic.h where _Atomic doesn't work
706 AC_MSG_CHECKING([for __sync_* builtins])
707 AC_LINK_IFELSE([AC_LANG_SOURCE([[
708int main(int argc, char **argv) {
709 volatile int i = 1;
710 __sync_fetch_and_sub (&i, 1);
711 return __sync_val_compare_and_swap (&i, 0, 1);
712}
713]])], [
714 AC_DEFINE(HAVE___SYNC, 1, [found __sync builtins])
715 AC_MSG_RESULT([yes])
716
717 AC_MSG_CHECKING([for __sync_swap builtin])
718 AC_LINK_IFELSE([AC_LANG_SOURCE([[
719int main(int argc, char **argv) {
720 volatile int i = 1;
721 return __sync_swap (&i, 2);
722}
723]])], [
724 AC_DEFINE(HAVE___SYNC_SWAP, 1, [found __sync_swap builtin])
725 AC_MSG_RESULT([yes])
726 ], [
727 AC_MSG_RESULT([no])
728 ])
729
730 ], [
731 AC_MSG_RESULT([no])
732 AC_MSG_FAILURE([stdatomic.h unavailable and $CC has neither __atomic nor __sync builtins])
733 ])
734 ])
735])
736
6f0e3f6e 737dnl Utility macro to avoid retyping includes all the time
8e4da10b 738m4_define([FRR_INCLUDES],
6f0e3f6e
PJ
739[#ifdef SUNOS_5
740#define _XPG4_2
741#define __EXTENSIONS__
742#endif
743#include <stdio.h>
24f5e2fc
DL
744#include <stdlib.h>
745#include <stddef.h>
746#include <sys/types.h>
6f0e3f6e 747/* sys/conf.h depends on param.h on FBSD at least */
24f5e2fc 748#include <sys/param.h>
6f0e3f6e 749/* Required for MAXSIG */
24f5e2fc
DL
750#include <signal.h>
751#include <sys/socket.h>
ea057677
HT
752#ifdef __APPLE__
753# define __APPLE_USE_RFC_3542
754#endif
24f5e2fc
DL
755#include <netinet/in.h>
756#include <sys/time.h>
757#include <time.h>
758#include <net/if.h>
2b43bf23
DO
759])dnl
760
761dnl Same applies for HAVE_NET_IF_VAR_H, which HAVE_NETINET6_ND6_H and
762dnl HAVE_NETINET_IN_VAR_H depend upon. But if_var.h depends on if.h, hence
763dnl an additional round for it.
764
8e4da10b 765AC_CHECK_HEADERS([net/if_var.h], [], [], FRR_INCLUDES)
2b43bf23 766
8e4da10b
DL
767m4_define([FRR_INCLUDES],
768FRR_INCLUDES
2b43bf23
DO
769[#if HAVE_NET_IF_VAR_H
770# include <net/if_var.h>
771#endif
772])dnl
773
24f5e2fc
DL
774AC_CHECK_HEADERS([netinet/in_var.h \
775 net/if_dl.h net/netopt.h \
776 inet/nd.h netinet/ip_icmp.h \
6f0e3f6e 777 sys/sysctl.h sys/sockio.h kvm.h sys/conf.h],
8e4da10b 778 [], [], FRR_INCLUDES)
6f0e3f6e
PJ
779
780AC_CHECK_HEADERS([ucontext.h], [], [],
781[#ifndef __USE_GNU
782#define __USE_GNU
783#endif /* __USE_GNU */
8e4da10b 784FRR_INCLUDES
6f0e3f6e
PJ
785])
786
bccbd141
JT
787m4_define([UCONTEXT_INCLUDES],
788[#include <ucontext.h>])dnl
789
790AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.uc_regs],
791 [], [], [UCONTEXT_INCLUDES])
792AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.regs],
793 [AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.regs.nip],
794 [], [], [UCONTEXT_INCLUDES])],
795 [], [UCONTEXT_INCLUDES])
796AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.gregs],
797 [], [], [UCONTEXT_INCLUDES])
798
8e4da10b
DL
799m4_define([FRR_INCLUDES],
800FRR_INCLUDES
24f5e2fc
DL
801[
802#include <sys/un.h>
803#include <netinet/in_systm.h>
6f0e3f6e
PJ
804#if HAVE_NETINET_IN_VAR_H
805# include <netinet/in_var.h>
806#endif
807#if HAVE_NET_IF_DL_H
808# include <net/if_dl.h>
809#endif
6f0e3f6e
PJ
810#if HAVE_NET_NETOPT_H
811# include <net/netopt.h>
812#endif
24f5e2fc 813#include <net/route.h>
6f0e3f6e
PJ
814#if HAVE_INET_ND_H
815# include <inet/nd.h>
816#endif
24f5e2fc 817#include <arpa/inet.h>
11770e10
PJ
818/* Required for IDRP */
819#if HAVE_NETINET_IP_ICMP_H
820# include <netinet/ip_icmp.h>
821#endif
6f0e3f6e 822])dnl
dc7a2bf1 823
fa3232e1 824dnl V6 headers are checked below, after we check for v6
7ea487bc 825
ddfeb486
DL
826AC_MSG_CHECKING([which operating system interface to use])
827case "$host_os" in
828 sunos* | solaris2*)
829 AC_MSG_RESULT([Solaris])
830
831 AC_DEFINE(SUNOS_5, 1, [SunOS 5])
832 AC_DEFINE(SOLARIS_IPV6, 1, Solaris IPv6)
833
834 AC_CHECK_LIB(socket, main)
835 AC_CHECK_LIB(nsl, main)
836 AC_CHECK_LIB(umem, main)
837 AC_CHECK_FUNCS([printstack], [
838 AC_DEFINE([HAVE_PRINTSTACK],1,[Solaris printstack])
839 AC_DEFINE([HAVE_STACK_TRACE],1,[Stack symbols decode functionality])
840 ])
841 CURSES=-lcurses
842 SOLARIS="solaris"
843 ;;
844 linux*)
845 AC_MSG_RESULT([Linux])
846
847 AC_DEFINE(GNU_LINUX,,GNU Linux)
848 AC_DEFINE(HAVE_NETLINK,,netlink)
849 AC_DEFINE(LINUX_IPV6,1,Linux IPv6 stack)
850
851 dnl Linux has a compilation problem with mixing
852 dnl netinet/in.h and linux/in6.h they are not
853 dnl compatible. There has been discussion on
854 dnl how to fix it but no real progress on implementation
855 dnl when they fix it, remove this
856 AC_DEFINE(IPV6_MINHOPCOUNT, 73, Linux ipv6 Min Hop Count)
857
858 AC_CHECK_DECLS([IFLA_INFO_SLAVE_KIND], [], [], [#include <linux/if_link.h>])
859 ;;
860 openbsd*)
861 AC_MSG_RESULT([OpenBSD])
862
863 AC_DEFINE(OPEN_BSD,,OpenBSD)
864 AC_DEFINE(KAME,1,KAME IPv6)
004174c7
JAG
865
866 if test "x${enable_pimd}" != "xno"; then
867 case "$host_os" in
868 openbsd6.0)
869 ;;
870 openbsd[6-9]*)
871 AC_MSG_FAILURE([pimd cannot be enabled as PIM support has been removed from OpenBSD 6.1])
872 ;;
873 esac
874 fi
ddfeb486
DL
875 ;;
876 *)
877 AC_MSG_RESULT([BSD])
878
879 AC_DEFINE(HAVE_NET_RT_IFLIST,,NET_RT_IFLIST)
880 AC_DEFINE(KAME,1,KAME IPv6)
881 ;;
7ea487bc 882esac
883
62c9f504
PJ
884AC_SYS_LARGEFILE
885
7ea487bc 886dnl ---------------------
887dnl Integrated VTY option
888dnl ---------------------
889case "${enable_vtysh}" in
f0646db0
DS
890 "no") VTYSH="";;
891 *) VTYSH="vtysh";
7ea487bc 892 AC_DEFINE(VTYSH,,VTY shell)
fc9d0745 893dnl Vtysh uses libreadline, which looks for termcap functions at
6f0e3f6e 894dnl configure time. We follow readlines search order.
fc9d0745 895dnl The required procedures are in libtermcap on NetBSD, in
896dnl [TODO] on Linux, and in [TODO] on Solaris.
c0689394 897 AC_CHECK_LIB(termcap, tputs, LIBREADLINE="$LIBREADLINE -ltermcap",
a969459c 898 [AC_CHECK_LIB(tinfo, tputs, LIBREADLINE="$LIBREADLINE -ltinfo",
899 [AC_CHECK_LIB(curses, tputs, LIBREADLINE="$LIBREADLINE -lcurses",
900 [AC_CHECK_LIB(ncurses, tputs,
901 LIBREADLINE="$LIBREADLINE -lncurses")]
902 )]
903 )]
904 )
4c2f8e95 905 AC_CHECK_LIB(readline, main, LIBREADLINE="-lreadline $LIBREADLINE",,
a969459c 906 "$LIBREADLINE")
7ea487bc 907 if test $ac_cv_lib_readline_main = no; then
fc9d0745 908 AC_MSG_ERROR([vtysh needs libreadline but was not found and usable on your system.])
7ea487bc 909 fi
910 AC_CHECK_HEADER(readline/history.h)
911 if test $ac_cv_header_readline_history_h = no;then
912 AC_MSG_ERROR([readline is too old to have readline/history.h, please update to the latest readline library.])
913 fi
a969459c 914 AC_CHECK_LIB(readline, rl_completion_matches,
915 LIBREADLINE="$LIBREADLINE",, "$LIBREADLINE")
3d3de8c4 916 if test $ac_cv_lib_readline_rl_completion_matches = no; then
917 AC_DEFINE(rl_completion_matches,completion_matches,Old readline)
918 fi
919 ;;
7ea487bc 920esac
c0689394 921AC_SUBST(LIBREADLINE)
f027d331 922AM_CONDITIONAL(VTYSH, test "x$VTYSH" = "xvtysh")
7ea487bc 923
924dnl ----------
925dnl PAM module
6159928d 926dnl
1689cf7e 927dnl FRR detects the PAM library it is built against by checking for a
6159928d
DO
928dnl functional pam_misc.h (Linux-PAM) or openpam.h (OpenPAM) header. pam_misc.h
929dnl is known to #include pam_appl.h, the standard header of a PAM library, and
930dnl openpam.h doesn't do that, although depends on the header too. Hence a
931dnl little assistance to AC_CHECK_HEADER is necessary for the proper detection
932dnl of OpenPAM.
7ea487bc 933dnl ----------
24cd435b 934if test "$with_libpam" = "yes"; then
6f0e3f6e
PJ
935 AC_CHECK_HEADER([security/pam_misc.h],
936 [AC_DEFINE(HAVE_PAM_MISC_H,,Have pam_misc.h)
937 AC_DEFINE(PAM_CONV_FUNC,misc_conv,Have misc_conv)
938 pam_conv_func="misc_conv"
939 ],
8e4da10b 940 [], FRR_INCLUDES)
6f0e3f6e
PJ
941 AC_CHECK_HEADER([security/openpam.h],
942 [AC_DEFINE(HAVE_OPENPAM_H,,Have openpam.h)
943 AC_DEFINE(PAM_CONV_FUNC,openpam_ttyconv,Have openpam_ttyconv)
944 pam_conv_func="openpam_ttyconv"
945 ],
8e4da10b 946 [], FRR_INCLUDES[#include <security/pam_appl.h>])
24cd435b 947 if test -z "$ac_cv_header_security_pam_misc_h$ac_cv_header_security_openpam_h" ; then
948 AC_MSG_WARN([*** pam support will not be built ***])
949 with_libpam="no"
950 fi
951fi
952
7ea487bc 953if test "$with_libpam" = "yes"; then
6f0e3f6e 954dnl took this test from proftpds configure.in and suited to our needs
7ea487bc 955dnl -------------------------------------------------------------------------
956dnl
957dnl This next check looks funky due to a linker problem with some versions
958dnl of the PAM library. Prior to 0.72 release, the Linux PAM shared library
959dnl omitted requiring libdl linking information. PAM-0.72 or better ships
960dnl with RedHat 6.2 and Debian 2.2 or better.
961AC_CHECK_LIB(pam, pam_start,
24cd435b 962 [AC_CHECK_LIB(pam, $pam_conv_func,
7ea487bc 963 [AC_DEFINE(USE_PAM,,Use PAM for authentication)
964 LIBPAM="-lpam"],
965 [AC_DEFINE(USE_PAM,,Use PAM for authentication)
966 LIBPAM="-lpam -lpam_misc"]
967 )
968 ],
969
970 [AC_CHECK_LIB(pam, pam_end,
24cd435b 971 [AC_CHECK_LIB(pam, $pam_conv_func,
a159ed93 972 [AC_DEFINE(USE_PAM,,Use PAM for authentication)
7ea487bc 973 LIBPAM="-lpam -ldl"],
a159ed93 974 [AC_DEFINE(USE_PAM,,Use PAM for authentication)
7ea487bc 975 LIBPAM="-lpam -ldl -lpam_misc"]
976 )
977 ],AC_MSG_WARN([*** pam support will not be built ***]),
978 [-ldl])
979 ]
980)
981fi
982AC_SUBST(LIBPAM)
983
984dnl -------------------------------
985dnl Endian-ness check
986dnl -------------------------------
987AC_WORDS_BIGENDIAN
988
989dnl -------------------------------
990dnl check the size in byte of the C
991dnl -------------------------------
992dnl AC_CHECK_SIZEOF(char)
993dnl AC_CHECK_SIZEOF(int)
994dnl AC_CHECK_SIZEOF(short)
995dnl AC_CHECK_SIZEOF(long)
996
997dnl ----------------------------
998dnl check existance of functions
999dnl ----------------------------
6f0e3f6e
PJ
1000AC_FUNC_FNMATCH
1001AC_FUNC_FORK
6f0e3f6e 1002AC_FUNC_MKTIME
6f0e3f6e 1003AC_FUNC_STAT
6f0e3f6e
PJ
1004
1005dnl -------------------------------
1006dnl bgpd needs pow() and hence libm
1007dnl -------------------------------
1008TMPLIBS="$LIBS"
1009AC_CHECK_HEADER([math.h],
1010 [AC_CHECK_LIB([m], [pow],
1011 [LIBM="-lm"
1012 LIBS="$LIBS $LIBM"
6f0e3f6e
PJ
1013 AC_CHECK_FUNCS(pow,[],[LIBM=""])
1014 ])
1015])
1016if test x"$LIBM" = x ; then
1017 AC_MSG_WARN([Unable to find working pow function - bgpd may not link])
1018fi
1019LIBS="$TMPLIBS"
1020AC_SUBST(LIBM)
1021
1022dnl ---------------
1023dnl other functions
1024dnl ---------------
24f5e2fc
DL
1025AC_CHECK_FUNCS([ \
1026 strlcat strlcpy \
316d0ae5 1027 getgrouplist])
6f0e3f6e 1028
13460c44
FL
1029AC_CHECK_HEADER([asm-generic/unistd.h],
1030 [AC_CHECK_DECL(__NR_setns,
1031 AC_DEFINE(HAVE_NETNS,, Have netns),,
8e4da10b 1032 FRR_INCLUDES [#include <asm-generic/unistd.h>
13460c44 1033 ])
428cd73f 1034 AC_CHECK_FUNCS(setns)]
13460c44
FL
1035 )
1036
238497fc
PJ
1037dnl --------------------------
1038dnl Determine IS-IS I/O method
1039dnl --------------------------
745bf05f
DL
1040AC_DEFINE(ISIS_METHOD_PFPACKET, 1, [ constant value for isis method pfpacket ])
1041AC_DEFINE(ISIS_METHOD_DLPI, 2, [ constant value for isis method dlpi ])
1042AC_DEFINE(ISIS_METHOD_BPF, 3, [ constant value for isis method bpf ])
238497fc
PJ
1043AC_CHECK_HEADER(net/bpf.h)
1044AC_CHECK_HEADER(sys/dlpi.h)
1045AC_MSG_CHECKING(zebra IS-IS I/O method)
ddfeb486
DL
1046
1047case "$host_os" in
1048 linux*)
1049 AC_MSG_RESULT(pfpacket)
1050 ISIS_METHOD_MACRO="ISIS_METHOD_PFPACKET"
1051 ;;
1052 solaris* | sunos*)
1053 AC_MSG_RESULT(DLPI)
1054 ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
1055 ;;
1056 *)
1057 if test $ac_cv_header_net_bpf_h = no; then
1058 if test $ac_cv_header_sys_dlpi_h = no; then
1059 AC_MSG_RESULT(none)
1060 AC_MSG_WARN([*** IS-IS support will not be built ***])
1061 ISISD=""
1062 else
1063 AC_MSG_RESULT(DLPI)
1064 fi
1065 ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
238497fc 1066 else
ddfeb486
DL
1067 AC_MSG_RESULT(BPF)
1068 ISIS_METHOD_MACRO="ISIS_METHOD_BPF"
238497fc 1069 fi
ddfeb486
DL
1070 ;;
1071esac
745bf05f 1072AC_DEFINE_UNQUOTED(ISIS_METHOD, $ISIS_METHOD_MACRO, [ selected method for isis, == one of the constants ])
238497fc 1073
b99760ab 1074dnl ------------------------------------
1075dnl check for broken CMSG_FIRSTHDR macro
1076dnl ------------------------------------
6c20046f 1077AC_MSG_CHECKING(for broken CMSG_FIRSTHDR)
5b087528 1078AC_RUN_IFELSE([AC_LANG_SOURCE([[
b99760ab 1079#ifdef SUNOS_5
1080#define _XPG4_2
1081#define __EXTENSIONS__
1082#endif
24f5e2fc 1083#include <stdlib.h>
b99760ab 1084#include <sys/types.h>
1085#include <sys/socket.h>
1086
1087main()
1088{
1089 struct msghdr msg;
1090 char buf[4];
1091
1092 msg.msg_control = buf;
1093 msg.msg_controllen = 0;
1094
1095 if (CMSG_FIRSTHDR(&msg) != NULL)
1096 exit(0);
1097 exit (1);
5b087528 1098}]])],[AC_MSG_RESULT(yes - using workaround) AC_DEFINE(HAVE_BROKEN_CMSG_FIRSTHDR,,Broken CMSG_FIRSTHDR)],
d33e8d7b 1099[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
b99760ab 1100
42c98199 1101dnl ---------------------------------------------------------------
1102dnl figure out how to specify an interface in multicast sockets API
1103dnl ---------------------------------------------------------------
8e4da10b 1104AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], FRR_INCLUDES)
42c98199 1105
b3f2bf7c 1106AC_CHECK_HEADERS([linux/mroute.h], [], [],[
24f5e2fc
DL
1107 #include <sys/socket.h>
1108 #include <netinet/in.h>
b3f2bf7c
RW
1109 #define _LINUX_IN_H /* For Linux <= 2.6.25 */
1110 #include <linux/types.h>
1111])
1112
8e4da10b
DL
1113m4_define([FRR_INCLUDES],
1114FRR_INCLUDES
b3f2bf7c
RW
1115[#if HAVE_LINUX_MROUTE_H
1116# include <linux/mroute.h>
1117#endif
1118])dnl
1119
1120AC_CHECK_HEADERS([netinet/ip_mroute.h], [], [],[
24f5e2fc
DL
1121 #include <sys/socket.h>
1122 #include <sys/types.h>
1123 #include <netinet/in.h>
1124 #include <net/route.h>
b3f2bf7c
RW
1125])
1126
8e4da10b
DL
1127m4_define([FRR_INCLUDES],
1128FRR_INCLUDES
b3f2bf7c
RW
1129[#if HAVE_NETINET_IP_MROUTE_H
1130# include <netinet/ip_mroute.h>
1131#endif
1132])dnl
1133
42c98199 1134AC_MSG_CHECKING([for BSD struct ip_mreq hack])
24f5e2fc
DL
1135AC_TRY_COMPILE([#include <sys/param.h>],
1136[#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)
42c98199 1137 return (0);
1138#else
1139 #error No support for BSD struct ip_mreq hack detected
1140#endif],[AC_MSG_RESULT(yes)
1141AC_DEFINE(HAVE_BSD_STRUCT_IP_MREQ_HACK,,[Can pass ifindex in struct ip_mreq])],
1142AC_MSG_RESULT(no))
1143
10d04cdb
DT
1144AC_MSG_CHECKING([for RFC3678 protocol-independed API])
1145AC_TRY_COMPILE([
1146#include <sys/types.h>
1147#include <netinet/in.h>
1148], [struct group_req gr; int sock; setsockopt(sock, IPPROTO_IP, MCAST_JOIN_GROUP, (void*)&gr, sizeof(gr));
1149], [AC_MSG_RESULT(yes)
1150AC_DEFINE(HAVE_RFC3678,1,[Have RFC3678 protocol-independed API])],
1151AC_MSG_RESULT(no))
1152
c543a173
AS
1153dnl ---------------------------------------------------------------
1154dnl figure out how to check link-state
1155dnl ---------------------------------------------------------------
24f5e2fc
DL
1156AC_CHECK_HEADER( [net/if_media.h],
1157 [m4_define([LINK_DETECT_INCLUDES],
8e4da10b 1158 FRR_INCLUDES
24f5e2fc
DL
1159 [#include <net/if_media.h>
1160 ])
1161 AC_CHECK_MEMBERS( [struct ifmediareq.ifm_status],
1162 AC_DEFINE(HAVE_BSD_LINK_DETECT,,[BSD link-detect]),
1163 [], LINK_DETECT_INCLUDES)],
1164 [],
8e4da10b 1165 FRR_INCLUDES)
c543a173 1166
9234b382
DV
1167dnl ---------------------------------------------------------------
1168dnl Additional, newer way to check link-state using ifi_link_state.
1169dnl Not available in all BSD's when ifmediareq available
1170dnl ---------------------------------------------------------------
24f5e2fc
DL
1171AC_CHECK_MEMBERS([struct if_data.ifi_link_state],
1172 AC_DEFINE(HAVE_BSD_IFI_LINK_STATE,,[BSD ifi_link_state available]),
8e4da10b 1173 [], FRR_INCLUDES)
9234b382 1174
0df7c91f
PJ
1175dnl ------------------------
1176dnl TCP_MD5SIG socket option
1177dnl ------------------------
1178
1179AC_CHECK_HEADER([netinet/tcp.h],
1180 [m4_define([MD5_INCLUDES],
8e4da10b 1181 FRR_INCLUDES
0df7c91f
PJ
1182 [#include <netinet/tcp.h>
1183 ])
1184 AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)],
1185 [],
8e4da10b 1186 FRR_INCLUDES)
0df7c91f
PJ
1187if test $ac_cv_have_decl_TCP_MD5SIG = no; then
1188 AC_CHECK_HEADER([linux/tcp.h],
1189 [m4_define([MD5_INCLUDES],
8e4da10b 1190 FRR_INCLUDES
0df7c91f
PJ
1191 [#include <linux/tcp.h>
1192 ])
1193 AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)])
1194fi
1195
60060acc
RW
1196dnl ----------------------------------------------------------------------------
1197dnl figure out if domainname is available in the utsname struct (GNU extension).
1198dnl ----------------------------------------------------------------------------
1199AC_CHECK_MEMBERS([struct utsname.domainname], [], [], [#include <sys/utsname.h>])
1200
fa3232e1 1201dnl ------------------
1202dnl IPv6 header checks
1203dnl ------------------
24f5e2fc 1204AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h \
6f0e3f6e 1205 netinet6/in6_var.h netinet6/nd6.h], [], [],
8e4da10b 1206 FRR_INCLUDES)
fa3232e1 1207
8e4da10b
DL
1208m4_define([FRR_INCLUDES],dnl
1209FRR_INCLUDES
6f0e3f6e
PJ
1210[#if HAVE_NETINET6_IN6_H
1211#include <netinet6/in6.h>
1212#endif
1213#if HAVE_NETINET_IN6_VAR_H
1214#include <netinet/in6_var.h>
1215#endif
24f5e2fc 1216#include <netinet/icmp6.h>
6f0e3f6e
PJ
1217#if HAVE_NETINET6_IN6_VAR_H
1218# include <netinet6/in6_var.h>
1219#endif
1220#if HAVE_NETINET6_ND6_H
fbf24544 1221# include <netinet6/nd6.h>
6f0e3f6e
PJ
1222#endif
1223])dnl
1224
cbcd9bfc
JT
1225dnl disable doc check
1226if test "${enable_doc}" = "no";then
1227 DOC=""
1228else
1229 DOC="doc"
1230fi
1231
7ea487bc 1232dnl --------------------
1233dnl Daemon disable check
1234dnl --------------------
64d44794 1235AM_CONDITIONAL(ZEBRA, test "${enable_zebra}" != "no")
7ea487bc 1236
1237if test "${enable_bgpd}" = "no";then
1238 BGPD=""
1239else
1240 BGPD="bgpd"
1241fi
f027d331 1242AM_CONDITIONAL(BGPD, test "x$BGPD" = "xbgpd")
7ea487bc 1243
1244if test "${enable_ripd}" = "no";then
1245 RIPD=""
1246else
1247 RIPD="ripd"
1248fi
f027d331 1249AM_CONDITIONAL(RIPD, test "x$RIPD" = "xripd")
7ea487bc 1250
1251if test "${enable_ospfd}" = "no";then
1252 OSPFD=""
1253else
1254 OSPFD="ospfd"
1255fi
f027d331 1256AM_CONDITIONAL(OSPFD, test "x$OSPFD" = "xospfd")
7ea487bc 1257
6ba069f3
DS
1258if test "${enable_ldpd}" = "no";then
1259 LDPD=""
1260else
eac6e3f0 1261 LDPD="ldpd"
87ab4aec 1262 AC_DEFINE(HAVE_LDPD, 1, ldpd)
eac6e3f0
RW
1263fi
1264AM_CONDITIONAL(LDPD, test "x$LDPD" = "xldpd")
1265
42350cfc 1266NHRPD=""
ddfeb486
DL
1267case "$host_os" in
1268 linux*)
1269 if test "${enable_nhrpd}" != "no"; then
1270 NHRPD="nhrpd"
1271 fi
1272 ;;
1273 *)
1274 if test "${enable_nhrpd}" = "yes"; then
1275 AC_MSG_ERROR([nhrpd requires kernel APIs that are only present on Linux.])
1276 fi
1277 ;;
1278esac
2fb975da
TT
1279AM_CONDITIONAL(NHRPD, test "x$NHRPD" = "xnhrpd")
1280
7f57883e
DS
1281if test "${enable_eigrpd}" = "no";then
1282 EIGRPD=""
1283else
1284 EIGRPD="eigrpd"
1285fi
1286AM_CONDITIONAL(EIGRPD, test "x$EIGRPD" = "xeigrpd")
1287
9473e340
DS
1288if test "${enable_watchfrr}" = "no";then
1289 WATCHFRR=""
d0199430 1290else
9473e340 1291 WATCHFRR="watchfrr"
d0199430 1292fi
9473e340 1293AM_CONDITIONAL(WATCHFRR, test "x$WATCHFRR" = "xwatchfrr")
d0199430 1294
1ef74ef7 1295OSPFCLIENT=""
cd66cd4c 1296if test "${enable_ospfapi}" != "no";then
9a569848 1297 AC_DEFINE(SUPPORT_OSPF_API,,OSPFAPI)
1ef74ef7 1298
cd66cd4c 1299 if test "${enable_ospfclient}" != "no";then
1ef74ef7 1300 OSPFCLIENT="ospfclient"
1ef74ef7 1301 fi
7ea487bc 1302fi
cd66cd4c 1303
f027d331 1304AM_CONDITIONAL(OSPFCLIENT, test "x$OSPFCLIENT" = "xospfclient")
7ea487bc 1305
1306case "${enable_ripngd}" in
7ea487bc 1307 "no" ) RIPNGD="";;
80ec006d 1308 * ) RIPNGD="ripngd";;
7ea487bc 1309esac
f027d331 1310AM_CONDITIONAL(RIPNGD, test "x$RIPNGD" = "xripngd")
7ea487bc 1311
ca10883e
DS
1312case "${enable_babeld}" in
1313 "no" ) BABELD="";;
1314 * ) BABELD="babeld";;
1315esac
1316AM_CONDITIONAL(BABELD, test "x$BABELD" = "xbabeld")
1317
7ea487bc 1318case "${enable_ospf6d}" in
7ea487bc 1319 "no" ) OSPF6D="";;
80ec006d 1320 * ) OSPF6D="ospf6d";;
7ea487bc 1321esac
f027d331 1322AM_CONDITIONAL(OSPF6D, test "x$OSPF6D" = "xospf6d")
7ea487bc 1323
9e867fe6 1324case "${enable_isisd}" in
9e867fe6 1325 "no" ) ISISD="";;
c3a9461e 1326 * ) ISISD="isisd";;
9e867fe6 1327esac
f027d331 1328AM_CONDITIONAL(ISISD, test "x$ISISD" = "xisisd")
9e867fe6 1329
12e41d03 1330case "${enable_pimd}" in
12e41d03 1331 "no" ) PIMD="";;
f0646db0 1332 * ) PIMD="pimd";;
12e41d03
DL
1333esac
1334AM_CONDITIONAL(PIMD, test "x$PIMD" = "xpimd")
1335
7ea487bc 1336if test "${enable_bgp_announce}" = "no";then
750e8146
PJ
1337 AC_DEFINE(DISABLE_BGP_ANNOUNCE,1,Disable BGP installation to zebra)
1338else
1339 AC_DEFINE(DISABLE_BGP_ANNOUNCE,0,Disable BGP installation to zebra)
7ea487bc 1340fi
1341
65efcfce
LB
1342if test "${with_rfp_path}" = "yes" || test x"${with_rfp_path}" = x""; then
1343 with_rfp_path="bgpd/rfp-example"
1344fi
1345if test "${with_rfp_path}" != "no"; then
1346 VNC_RFP_PATH="${with_rfp_path}"
1347 AC_SUBST(VNC_RFP_PATH)
1348fi
1349
f95f2ad9 1350if test "${enable_bgp_vnc}" != "no";then
65efcfce
LB
1351 AC_DEFINE(ENABLE_BGP_VNC,1,Enable BGP VNC support)
1352 RFPTEST="${with_rfp_path}/rfptest"
1353 LIBRFP="${with_rfp_path}/librfp"
1354 RFPINC="${with_rfp_path}/librfp"
1355else
1356 RFPTEST=
1357 LIBRFP=
1358 RFPINC="bgpd/rfp-example/librfp"
1359fi
1360# set
f95f2ad9 1361AM_CONDITIONAL([ENABLE_BGP_VNC], [test x${enable_bgp_vnc} != xno])
65efcfce 1362
cbcd9bfc 1363AC_SUBST(DOC)
65efcfce
LB
1364AC_SUBST(RFPTEST)
1365AC_SUBST(LIBRFP)
1366AC_SUBST(RFPINC)
ca10883e 1367AC_SUBST(BABELD)
7ea487bc 1368AC_SUBST(BGPD)
1369AC_SUBST(RIPD)
1370AC_SUBST(RIPNGD)
1371AC_SUBST(OSPFD)
1372AC_SUBST(OSPF6D)
eac6e3f0 1373AC_SUBST(LDPD)
2fb975da 1374AC_SUBST(NHRPD)
7f57883e 1375AC_SUBST(EIGRPD)
9473e340 1376AC_SUBST(WATCHFRR)
9e867fe6 1377AC_SUBST(ISISD)
12e41d03 1378AC_SUBST(PIMD)
97cee877 1379AC_SUBST(SOLARIS)
7ea487bc 1380AC_SUBST(VTYSH)
7ea487bc 1381AC_SUBST(CURSES)
1382AC_SUBST(OSPFCLIENT)
1ef74ef7 1383AC_SUBST(OSPFAPI)
f9e75524
JAG
1384AC_CHECK_LIB(crypt, crypt, [],
1385 [AC_CHECK_LIB(crypto, DES_crypt)])
7ea487bc 1386AC_CHECK_LIB(resolv, res_init)
7ea487bc 1387
25f45887
JJ
1388dnl ---------------------------
1389dnl check system has PCRE regexp
1390dnl ---------------------------
1391if test "x$enable_pcreposix" = "xyes"; then
ad9a0825
DL
1392 AC_CHECK_LIB(pcreposix, regexec, [], [
1393 AC_MSG_ERROR([--enable-pcreposix given but unable to find libpcreposix])
1394 ])
25f45887 1395fi
25f45887 1396AC_SUBST(HAVE_LIBPCREPOSIX)
7ea487bc 1397
2fb975da
TT
1398dnl ------------------
1399dnl check C-Ares library
1400dnl ------------------
42350cfc 1401if test "${NHRPD}" != ""; then
92e50261
DL
1402 PKG_CHECK_MODULES([CARES], [libcares], , [
1403 AC_MSG_ERROR([trying to build nhrpd, but libcares not found. install c-ares and its -dev headers.])
1404 ])
2fb975da
TT
1405fi
1406
1407
7ea487bc 1408dnl ------------------
b1fc9acb 1409dnl check Net-SNMP library
7ea487bc 1410dnl ------------------
d6be5fb9 1411if test "${enable_snmp}" != ""; then
08d7f653
VB
1412 AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], [no])
1413 if test x"$NETSNMP_CONFIG" = x"no"; then
1414 AC_MSG_ERROR([--enable-snmp given but unable to find net-snmp-config])
1415 fi
46081234
DL
1416 SNMP_LIBS="`${NETSNMP_CONFIG} --agent-libs`"
1417 SNMP_CFLAGS="`${NETSNMP_CONFIG} --base-cflags`"
08d7f653 1418 AC_MSG_CHECKING([whether we can link to Net-SNMP])
92e50261 1419 AC_LINK_IFELSE_FLAGS([$SNMP_CFLAGS], [$SNMP_LIBS], [AC_LANG_PROGRAM([
08d7f653
VB
1420int main(void);
1421],
1422[
1423{
1424 return 0;
1425}
92e50261 1426])], [
08d7f653 1427 AC_MSG_ERROR([--enable-snmp given but not usable])])
d6be5fb9
VB
1428 case "${enable_snmp}" in
1429 yes)
1430 SNMP_METHOD=agentx
1431 ;;
1432 smux|agentx)
1433 SNMP_METHOD="${enable_snmp}"
1434 ;;
1435 *)
1436 AC_MSG_ERROR([--enable-snmp given with an unknown method (${enable_snmp}). Use smux or agentx])
1437 ;;
1438 esac
1439 AH_TEMPLATE([SNMP_SMUX], [Use SNMP SMUX to interface with snmpd])
1440 AH_TEMPLATE([SNMP_AGENTX], [Use SNMP AgentX to interface with snmpd])
1441 AC_DEFINE_UNQUOTED(AS_TR_CPP(SNMP_${SNMP_METHOD}),,SNMP method to interface with snmpd)
6cf9df08 1442fi
46081234
DL
1443AM_CONDITIONAL([SNMP], [test "x${SNMP_METHOD}" != "x"])
1444AC_SUBST(SNMP_LIBS)
1445AC_SUBST(SNMP_CFLAGS)
6cf9df08 1446
4db0cff1
QY
1447dnl ---------------
1448dnl math
1449dnl ---------------
1450AC_SEARCH_LIBS([sqrt], [m])
1451
b249c083
DL
1452dnl ---------------
1453dnl dlopen & dlinfo
1454dnl ---------------
30771d65
DL
1455AC_SEARCH_LIBS(dlopen, [dl dld], [], [
1456 AC_MSG_ERROR([unable to find the dlopen()])
1457])
1458
b249c083
DL
1459AC_CHECK_HEADERS([link.h])
1460
1461AC_MSG_CHECKING([for dlinfo(RTLD_DI_ORIGIN)])
1462AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1463#include <stdlib.h>
1464#ifdef HAVE_LINK_H
1465#include <link.h>
1466#endif
1467#include <dlfcn.h>
1468]], [[
1469 char origin[1];
1470 dlinfo (NULL, RTLD_DI_ORIGIN, &origin);
1471]])], [
1472 AC_MSG_RESULT(yes)
1473 AC_DEFINE(HAVE_DLINFO_ORIGIN, 1, [Have dlinfo RTLD_DI_ORIGIN])
1474], [
1475 AC_MSG_RESULT(no)
1476])
1477
1478AC_MSG_CHECKING([for dlinfo(RTLD_DI_LINKMAP)])
1479AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1480#include <stdlib.h>
1481#ifdef HAVE_LINK_H
1482#include <link.h>
1483#endif
1484#include <dlfcn.h>
1485]], [[
1486 struct link_map *lm = NULL;
1487 dlinfo (NULL, RTLD_DI_LINKMAP, &lm);
1488]])], [
1489 AC_MSG_RESULT(yes)
1490 AC_DEFINE(HAVE_DLINFO_LINKMAP, 1, [Have dlinfo RTLD_DI_LINKMAP])
1491], [
1492 AC_MSG_RESULT(no)
1493])
1494
6cf9df08 1495
62ff928b
DS
1496AM_CONDITIONAL(SNMP, test "x$SNMP_METHOD" = "xagentx")
1497
7ea487bc 1498dnl ---------------------------
6f0e3f6e 1499dnl sockaddr and netinet checks
7ea487bc 1500dnl ---------------------------
24f5e2fc
DL
1501AC_CHECK_TYPES([
1502 struct sockaddr_dl,
1503 struct vifctl, struct mfcctl, struct sioc_sg_req,
12e41d03 1504 vifi_t, struct sioc_vif_req, struct igmpmsg,
6f0e3f6e
PJ
1505 struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq,
1506 struct nd_opt_adv_interval, struct rt_addrinfo,
11770e10 1507 struct nd_opt_homeagent_info, struct nd_opt_adv_interval],
8e4da10b 1508 [], [], FRR_INCLUDES)
6f0e3f6e
PJ
1509
1510AC_CHECK_MEMBERS([struct sockaddr.sa_len,
1511 struct sockaddr_in.sin_len, struct sockaddr_un.sun_len,
ca3ccd87 1512 struct sockaddr_dl.sdl_len,
6f0e3f6e
PJ
1513 struct if6_aliasreq.ifra_lifetime,
1514 struct nd_opt_adv_interval.nd_opt_ai_type],
8e4da10b 1515 [], [], FRR_INCLUDES)
29c4c9bd 1516
6f0e3f6e 1517dnl ---------------------------
11770e10 1518dnl IRDP/pktinfo/icmphdr checks
6f0e3f6e
PJ
1519dnl ---------------------------
1520AC_CHECK_TYPES([struct in_pktinfo],
11770e10
PJ
1521 [AC_CHECK_TYPES([struct icmphdr],
1522 [if test "${enable_irdp}" != "no"; then
1523 AC_DEFINE(HAVE_IRDP,, IRDP)
1524 fi],
1525 [if test "${enable_irdp}" = "yes"; then
1526 AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
8e4da10b 1527 fi], [FRR_INCLUDES])],
6f0e3f6e
PJ
1528 [if test "${enable_irdp}" = "yes"; then
1529 AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
8e4da10b 1530 fi], [FRR_INCLUDES])
29c4c9bd 1531
12e41d03
DL
1532dnl -----------------------
1533dnl checking for IP_PKTINFO
1534dnl -----------------------
1535AC_MSG_CHECKING(for IP_PKTINFO)
1536AC_TRY_COMPILE([#include <netdb.h>], [
1537 int opt = IP_PKTINFO;
1538], [
1539 AC_MSG_RESULT(yes)
1540 AC_DEFINE(HAVE_IP_PKTINFO, 1, [Have IP_PKTINFO])
1541], [
1542 AC_MSG_RESULT(no)
1543])
1544
1545dnl ---------------------------
1546dnl checking for IP_RECVDSTADDR
1547dnl ---------------------------
1548AC_MSG_CHECKING(for IP_RECVDSTADDR)
1549AC_TRY_COMPILE([#include <netinet/in.h>], [
1550 int opt = IP_RECVDSTADDR;
1551], [
1552 AC_MSG_RESULT(yes)
1553 AC_DEFINE(HAVE_IP_RECVDSTADDR, 1, [Have IP_RECVDSTADDR])
1554], [
1555 AC_MSG_RESULT(no)
1556])
1557
1558dnl ----------------------
1559dnl checking for IP_RECVIF
1560dnl ----------------------
1561AC_MSG_CHECKING(for IP_RECVIF)
1562AC_TRY_COMPILE([#include <netinet/in.h>], [
1563 int opt = IP_RECVIF;
1564], [
1565 AC_MSG_RESULT(yes)
1566 AC_DEFINE(HAVE_IP_RECVIF, 1, [Have IP_RECVIF])
1567], [
1568 AC_MSG_RESULT(no)
1569])
1570
eac6e3f0
RW
1571dnl ----------------------
1572dnl checking for SO_BINDANY
1573dnl ----------------------
1574AC_MSG_CHECKING(for SO_BINDANY)
1575AC_TRY_COMPILE([#include <sys/socket.h>], [
1576 int opt = SO_BINDANY;
1577], [
1578 AC_MSG_RESULT(yes)
1579 AC_DEFINE(HAVE_SO_BINDANY, 1, [Have SO_BINDANY])
1580], [
1581 AC_MSG_RESULT(no)
1582])
1583
1584dnl ----------------------
1585dnl checking for IP_FREEBIND
1586dnl ----------------------
1587AC_MSG_CHECKING(for IP_FREEBIND)
1588AC_TRY_COMPILE([#include <netinet/in.h>], [
1589 int opt = IP_FREEBIND;
1590], [
1591 AC_MSG_RESULT(yes)
1592 AC_DEFINE(HAVE_IP_FREEBIND, 1, [Have IP_FREEBIND])
1593], [
1594 AC_MSG_RESULT(no)
1595])
1596
ba0cb3fe
DS
1597dnl --------------------------------------
1598dnl checking for be32dec existence or not
1599dnl --------------------------------------
1600AC_CHECK_DECLS([be32enc, be32dec], [], [],
1601 [#include <sys/endian.h>])
1602
c4376c9d
SH
1603dnl --------------------------------------
1604dnl checking for clock_time monotonic struct and call
1605dnl --------------------------------------
6511cab2
PJ
1606AC_CHECK_DECL(CLOCK_MONOTONIC,
1607 [AC_CHECK_LIB(rt, clock_gettime, [LIBS="$LIBS -lrt"])
9964fcfc 1608 AC_DEFINE(HAVE_CLOCK_MONOTONIC,, Have monotonic clock)
8e4da10b 1609], [AC_MSG_RESULT(no)], [FRR_INCLUDES])
c4376c9d 1610
bbf5ffa0
QY
1611dnl --------------------------------------
1612dnl checking for flex and bison
1613dnl --------------------------------------
4a06690f 1614
bbf5ffa0 1615AM_PROG_LEX
4a06690f 1616AC_MSG_CHECKING(version of flex)
1689cf7e
JAG
1617frr_ac_flex_version="$(eval $LEX -V | grep flex | head -n 1)"
1618frr_ac_flex_version="${frr_ac_flex_version##* }"
1619AC_MSG_RESULT([$frr_ac_flex_version])
1620AX_COMPARE_VERSION([$frr_ac_flex_version], [lt], [2.5.20], [
4a06690f
DL
1621 LEX="$SHELL $missing_dir/missing flex"
1622 if test -f "${srcdir}/lib/command_lex.c" -a -f "${srcdir}/lib/command_lex.h"; then
1623 AC_MSG_WARN([using pregenerated flex output files])
1624 else
1625 AC_MSG_ERROR([flex failure and pregenerated files not included (probably a git build)])
1626 fi
1627 AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
1628 AC_SUBST([LEXLIB], [''])
1629])
0d37f9f3 1630
bbf5ffa0 1631AC_PROG_YACC
0d37f9f3
DL
1632dnl thanks GNU bison for this b*llshit...
1633AC_MSG_CHECKING(version of bison)
1689cf7e
JAG
1634frr_ac_bison_version="$(eval $YACC -V | grep bison | head -n 1)"
1635frr_ac_bison_version="${frr_ac_bison_version##* }"
1636frr_ac_bison_missing="false"
1637case "x${frr_ac_bison_version}" in
0d37f9f3
DL
1638 x2.7*)
1639 BISON_OPENBRACE='"'
1640 BISON_CLOSEBRACE='"'
05dbb7df 1641 BISON_VERBOSE=''
1689cf7e 1642 AC_MSG_RESULT([$frr_ac_bison_version - 2.7 or older])
0d37f9f3
DL
1643 ;;
1644 x2.*|x1.*)
1689cf7e 1645 AC_MSG_RESULT([$frr_ac_bison_version])
0d37f9f3 1646 AC_MSG_WARN([installed bison is too old. Please install GNU bison 2.7.x or newer.])
1689cf7e 1647 frr_ac_bison_missing="true"
0d37f9f3
DL
1648 ;;
1649 x)
1650 AC_MSG_RESULT([none])
1651 AC_MSG_WARN([could not determine bison version. Please install GNU bison 2.7.x or newer.])
1689cf7e 1652 frr_ac_bison_missing="true"
0d37f9f3
DL
1653 ;;
1654 *)
1655 BISON_OPENBRACE='{'
1656 BISON_CLOSEBRACE='}'
05dbb7df 1657 BISON_VERBOSE='-Dparse.error=verbose'
1689cf7e 1658 AC_MSG_RESULT([$frr_ac_bison_version - 3.0 or newer])
0d37f9f3
DL
1659 ;;
1660esac
1661AC_SUBST(BISON_OPENBRACE)
1662AC_SUBST(BISON_CLOSEBRACE)
05dbb7df 1663AC_SUBST(BISON_VERBOSE)
0d37f9f3 1664
1689cf7e 1665if $frr_ac_bison_missing; then
0d37f9f3
DL
1666 YACC="$SHELL $missing_dir/missing bison -y"
1667 if test -f "${srcdir}/lib/command_parse.c" -a -f "${srcdir}/lib/command_parse.h"; then
1668 AC_MSG_WARN([using pregenerated bison output files])
1669 else
1670 AC_MSG_ERROR([bison failure and pregenerated files not included (probably a git build)])
1671 fi
1672fi
bbf5ffa0 1673
edd7c245 1674dnl -------------------
1675dnl capabilities checks
1676dnl -------------------
41d3fc96 1677if test "${enable_capabilities}" != "no"; then
1678 AC_MSG_CHECKING(whether prctl PR_SET_KEEPCAPS is available)
1679 AC_TRY_COMPILE([#include <sys/prctl.h>],[prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);],
1680 [AC_MSG_RESULT(yes)
1681 AC_DEFINE(HAVE_PR_SET_KEEPCAPS,,prctl)
8e4da10b 1682 frr_ac_keepcaps="yes"],
41d3fc96 1683 AC_MSG_RESULT(no)
edd7c245 1684 )
8e4da10b 1685 if test x"${frr_ac_keepcaps}" = x"yes"; then
41d3fc96 1686 AC_CHECK_HEADERS(sys/capability.h)
1687 fi
1688 if test x"${ac_cv_header_sys_capability_h}" = x"yes"; then
1689 AC_CHECK_LIB(cap, cap_init,
1690 [AC_DEFINE(HAVE_LCAPS,1,Capabilities)
1691 LIBCAP="-lcap"
8e4da10b 1692 frr_ac_lcaps="yes"]
41d3fc96 1693 )
ceacedba 1694 else
1695 AC_CHECK_HEADERS(priv.h,
1696 [AC_MSG_CHECKING(Solaris style privileges are available)
1697 AC_TRY_COMPILE([#include <priv.h>],[getpflags(PRIV_AWARE);],
1698 [AC_MSG_RESULT(yes)
1699 AC_DEFINE(HAVE_SOLARIS_CAPABILITIES,1,getpflags)
8e4da10b 1700 frr_ac_scaps="yes"],
ceacedba 1701 AC_MSG_RESULT(no)
1702 )
1703 ]
1704 )
1705 fi
8e4da10b
DL
1706 if test x"${frr_ac_scaps}" = x"yes" \
1707 -o x"${frr_ac_lcaps}" = x"yes"; then
ceacedba 1708 AC_DEFINE(HAVE_CAPABILITIES,1,capabilities)
41d3fc96 1709 fi
edd7c245 1710fi
1711AC_SUBST(LIBCAP)
1712
fb2d1502 1713dnl ---------------------------
1714dnl check for glibc 'backtrace'
1715dnl ---------------------------
8c99b4c1
DL
1716if test x"${enable_backtrace}" != x"no" ; then
1717 backtrace_ok=no
1718 AC_CHECK_HEADER([execinfo.h], [
1719 AC_SEARCH_LIBS([backtrace], [execinfo], [
1720 AC_DEFINE(HAVE_GLIBC_BACKTRACE,,[Glibc backtrace])
1721 AC_DEFINE(HAVE_STACK_TRACE,,[Stack symbol decoding])
1722 backtrace_ok=yes
1723 ],, [-lm])
eda3529e 1724 ])
8c99b4c1
DL
1725
1726 if test x"${enable_backtrace}" = x"yes" -a x"${backtrace_ok}" = x"no"; then
1727 dnl user explicitly requested backtrace but we failed to find support
1728 AC_MSG_FAILURE([failed to find backtrace support])
1729 fi
1730fi
fb2d1502 1731
41be32bf
PJ
1732dnl -----------------------------------------
1733dnl check for malloc mallinfo struct and call
1734dnl this must try and link using LIBS, in
1735dnl order to check no alternative allocator
1736dnl has been specified, which might not provide
1737dnl mallinfo, e.g. such as Umem on Solaris.
1738dnl -----------------------------------------
6f0e3f6e 1739AC_CHECK_HEADER([malloc.h],
41be32bf
PJ
1740 [AC_MSG_CHECKING(whether mallinfo is available)
1741 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
1742 [[struct mallinfo ac_x; ac_x = mallinfo ();]])],
1743 [AC_MSG_RESULT(yes)
1744 AC_DEFINE(HAVE_MALLINFO,,mallinfo)],
1745 AC_MSG_RESULT(no)
1746 )
8e4da10b 1747 ], [], FRR_INCLUDES)
41be32bf 1748
408ad943 1749dnl ----------
1750dnl configure date
1751dnl ----------
1752CONFDATE=`date '+%Y%m%d'`
1753AC_SUBST(CONFDATE)
1754
7ea487bc 1755dnl ------------------------------
a159ed93 1756dnl set paths for state directory
23bd12c3 1757dnl ------------------------------
e84999d9 1758AC_MSG_CHECKING(directory to use for state file)
23bd12c3 1759if test "${prefix}" = "NONE"; then
b2f36157 1760 frr_statedir_prefix="";
23bd12c3 1761else
b2f36157 1762 frr_statedir_prefix=${prefix}
23bd12c3 1763fi
1764if test "${localstatedir}" = '${prefix}/var'; then
8e4da10b 1765 for FRR_STATE_DIR in ${frr_statedir_prefix}/var/run dnl
b2f36157
DL
1766 ${frr_statedir_prefix}/var/adm dnl
1767 ${frr_statedir_prefix}/etc dnl
a159ed93 1768 /var/run dnl
1769 /var/adm dnl
1770 /etc dnl
1771 /dev/null;
23bd12c3 1772 do
8e4da10b 1773 test -d $FRR_STATE_DIR && break
23bd12c3 1774 done
8e4da10b 1775 frr_statedir=$FRR_STATE_DIR
23bd12c3 1776else
b2f36157 1777 frr_statedir=${localstatedir}
a159ed93 1778fi
b2f36157 1779if test $frr_statedir = "/dev/null"; then
a159ed93 1780 AC_MSG_ERROR('STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!')
1781fi
b2f36157
DL
1782AC_MSG_RESULT(${frr_statedir})
1783AC_SUBST(frr_statedir)
1784
b2f36157 1785AC_DEFINE_UNQUOTED(LDPD_SOCKET, "$frr_statedir/ldpd.sock",ldpd control socket)
b2f36157 1786AC_DEFINE_UNQUOTED(ZEBRA_SERV_PATH, "$frr_statedir/zserv.api",zebra api socket)
b2f36157 1787AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$frr_statedir",daemon vty directory)
7ea487bc 1788
95c4aff2
DL
1789dnl autoconf does this, but it does it too late...
1790test "x$prefix" = xNONE && prefix=$ac_default_prefix
1791test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
1792
1793dnl get the full path, recursing through variables...
1794vtysh_bin="$bindir/vtysh"
1795for I in 1 2 3 4 5 6 7 8 9 10; do
1796 eval vtysh_bin="\"$vtysh_bin\""
1797done
1798AC_DEFINE_UNQUOTED(VTYSH_BIN_PATH, "$vtysh_bin",path to vtysh binary)
1799
a07169b1
DL
1800CFG_SYSCONF="$sysconfdir"
1801CFG_SBIN="$sbindir"
1802CFG_STATE="$frr_statedir"
30771d65 1803CFG_MODULE="$moduledir"
a07169b1
DL
1804for I in 1 2 3 4 5 6 7 8 9 10; do
1805 eval CFG_SYSCONF="\"$CFG_SYSCONF\""
1806 eval CFG_SBIN="\"$CFG_SBIN\""
1807 eval CFG_STATE="\"$CFG_STATE\""
30771d65 1808 eval CFG_MODULE="\"$CFG_MODULE\""
a07169b1
DL
1809done
1810AC_SUBST(CFG_SYSCONF)
1811AC_SUBST(CFG_SBIN)
1812AC_SUBST(CFG_STATE)
30771d65
DL
1813AC_SUBST(CFG_MODULE)
1814AC_DEFINE_UNQUOTED(MODULE_PATH, "$CFG_MODULE", path to modules)
a07169b1 1815
7ea487bc 1816dnl ---------------------------
1817dnl Check htonl works correctly
1818dnl ---------------------------
1819AC_MSG_CHECKING(for working htonl)
6f0e3f6e 1820AC_CACHE_VAL(ac_cv_htonl_works,
8e4da10b 1821 [AC_LINK_IFELSE([AC_LANG_PROGRAM([FRR_INCLUDES],[htonl (0);])],
6f0e3f6e
PJ
1822 [ac_cv_htonl_works=yes], [ac_cv_htonl_works=no])
1823 ]
1824)
7ea487bc 1825AC_MSG_RESULT($ac_cv_htonl_works)
1826
0f8b5fd5 1827AC_CONFIG_FILES([Makefile ripd/Makefile
9473e340 1828 ripngd/Makefile bgpd/Makefile ospfd/Makefile watchfrr/Makefile
eac6e3f0 1829 ospf6d/Makefile ldpd/Makefile isisd/Makefile vtysh/Makefile
53d93be1 1830 doc/Makefile ospfclient/Makefile tests/Makefile
22ea387f 1831 bgpd/rfp-example/rfptest/Makefile bgpd/rfp-example/librfp/Makefile
ca10883e 1832 babeld/Makefile
12e41d03 1833 pimd/Makefile
7f57883e 1834 eigrpd/Makefile
2fb975da 1835 nhrpd/Makefile
1018422a 1836 tools/Makefile
22ea387f 1837 redhat/frr.spec
3ab11ecc 1838 snapcraft/snapcraft.yaml
b7a97f82 1839 lib/version.h
8efe88ea 1840 tests/lib/cli/test_cli.refout
14c17fd8 1841 doc/defines.texi
461c7bee
DL
1842 doc/bgpd.8
1843 doc/isisd.8
1844 doc/ospf6d.8
1845 doc/ospfclient.8
1846 doc/ospfd.8
1847 doc/ldpd.8
1848 doc/ripd.8
6c85c081 1849 doc/eigrpd.8
461c7bee
DL
1850 doc/ripngd.8
1851 doc/pimd.8
caba6093 1852 doc/nhrpd.8
461c7bee 1853 doc/vtysh.1
9473e340 1854 doc/watchfrr.8
461c7bee 1855 doc/zebra.8
438f5286 1856 doc/frr.1
cbd04084 1857 pkgsrc/bgpd.sh pkgsrc/ospf6d.sh pkgsrc/ospfd.sh
7f57883e
DS
1858 pkgsrc/ripd.sh pkgsrc/ripngd.sh pkgsrc/zebra.sh
1859 pkgsrc/eigrpd.sh])
65efcfce 1860
65efcfce 1861
26275b05 1862AC_CONFIG_FILES([solaris/Makefile])
1863
670bbf19 1864AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl])
65efcfce 1865
1689cf7e 1866## Hack, but working solution to avoid rebuilding of frr.info.
48577196 1867## It's already in CVS until texinfo 4.7 is more common.
14c17fd8 1868AC_OUTPUT
7ea487bc 1869
1870echo "
447a8fe9 1871FRRouting configuration
b2f36157
DL
1872------------------------------
1873FRR version : ${PACKAGE_VERSION}
1080c13f 1874host operating system : ${host_os}
7ea487bc 1875source code location : ${srcdir}
1876compiler : ${CC}
1877compiler flags : ${CFLAGS}
6f0e3f6e 1878make : ${MAKE-make}
6f0e3f6e 1879linker flags : ${LDFLAGS} ${LIBS} ${LIBCAP} ${LIBREADLINE} ${LIBM}
b2f36157 1880state file directory : ${frr_statedir}
dc7a2bf1 1881config file directory : `eval echo \`echo ${sysconfdir}\``
d6b72f7a 1882example directory : `eval echo \`echo ${exampledir}\``
30771d65 1883module directory : ${CFG_MODULE}
b2f36157
DL
1884user to run as : ${enable_user}
1885group to run as : ${enable_group}
1886group for vty sockets : ${enable_vty_group}
aa593d5e 1887config file mask : ${enable_configfile_mask}
1888log file mask : ${enable_logfile_mask}
dad253b4 1889zebra protobuf enabled : ${have_protobuf:-no}
dc7a2bf1 1890
1891The above user and group must have read/write access to the state file
105b8239 1892directory and to the config files in the config file directory."