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