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