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