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