2 # Process this file with autoconf to produce a configure script.
4 #######################
11 [m4_esyscmd_s([./get-version])],
12 [https://github.com/lldpd/lldpd/issues],
14 [https://lldpd.github.io/])
16 AC_CONFIG_SRCDIR([src/log.c])
17 AC_CONFIG_HEADERS([config.h])
18 AC_CONFIG_FILES([Makefile
26 AC_CONFIG_MACRO_DIR([m4])
27 AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
30 AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror tar-ustar])
32 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
35 m4_pattern_allow([AM_PROG_AR])
42 #######################
45 # Checks for programs.
48 if test x"$ac_cv_prog_cc_c99" = x"no"; then
49 AC_MSG_FAILURE([*** C99 support is mandatory])
59 # Check for pkg-config
60 m4_ifndef([PKG_CHECK_MODULES], [
61 AC_MSG_ERROR([PKG_CHECK_MODULES not found. Please install pkg-config and re-run autogen.sh])])
73 DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
75 # Check some compiler flags
76 AX_CFLAGS_GCC_OPTION([-Wunknown-warning-option], [LLDP_CFLAGS])
77 AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option], [LLDP_CFLAGS])
78 AX_CFLAGS_GCC_OPTION([-fdiagnostics-color=auto], [LLDP_CFLAGS])
79 AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer], [LLDP_CFLAGS])
80 AX_CFLAGS_GCC_OPTION([-funsigned-char], [LLDP_CFLAGS])
81 AX_CFLAGS_GCC_OPTION([-pipe], [LLDP_CFLAGS])
82 AX_CFLAGS_GCC_OPTION([-Wall], [LLDP_CFLAGS])
83 AX_CFLAGS_GCC_OPTION([-W], [LLDP_CFLAGS])
84 AX_CFLAGS_GCC_OPTION([-Wextra], [LLDP_CFLAGS])
85 AX_CFLAGS_GCC_OPTION([-Wformat], [LLDP_CFLAGS])
86 AX_CFLAGS_GCC_OPTION([-Wformat-security], [LLDP_CFLAGS])
87 AX_CFLAGS_GCC_OPTION([-Wimplicit-fallthrough], [LLDP_CFLAGS])
88 AX_CFLAGS_GCC_OPTION([-Wfatal-errors], [LLDP_CFLAGS])
89 AX_CFLAGS_GCC_OPTION([-Wheader-guard], [LLDP_CFLAGS])
90 AX_CFLAGS_GCC_OPTION([-Wdocumentation], [LLDP_CFLAGS])
91 AX_CFLAGS_GCC_OPTION([-Winline], [LLDP_CFLAGS])
92 AX_CFLAGS_GCC_OPTION([-Wpointer-arith], [LLDP_CFLAGS])
93 AX_CFLAGS_GCC_OPTION([-Wmissing-prototypes], [LLDP_CFLAGS])
94 AX_CFLAGS_GCC_OPTION([-Wno-cast-align], [LLDP_CFLAGS]) dnl clang is bad at this
95 AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter], [LLDP_CFLAGS])
96 AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers], [LLDP_CFLAGS])
97 AX_CFLAGS_GCC_OPTION([-Wno-sign-compare], [LLDP_CFLAGS]) dnl Should be fixed later
98 AX_LDFLAGS_OPTION([-Wl,-z,relro], [LLDP_LDFLAGS])
99 AX_LDFLAGS_OPTION([-Wl,-z,now], [LLDP_LDFLAGS])
104 AC_ARG_ENABLE([hardening],
105 [AS_HELP_STRING([--enable-hardening],
106 [Enable compiler and linker options to frustrate memory corruption exploits @<:@default=yes@:>@])],
107 [hardening="$enableval"],
110 [AS_HELP_STRING([--enable-pie],
111 [Enable PIE (position independant executable) @<:@default=no@:>@])],
115 if test x"$hardening" != x"no"; then
116 AX_CFLAGS_GCC_OPTION([-fstack-protector], [LLDP_CFLAGS])
117 AX_CFLAGS_GCC_OPTION([-fstack-protector-all], [LLDP_CFLAGS])
118 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
119 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
120 AX_CFLAGS_GCC_OPTION([-fstack-clash-protection], [LLDP_CFLAGS])
121 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [LLDP_CPPFLAGS])
123 if test x"$pie" = x"yes"; then
124 AX_CFLAGS_GCC_OPTION([-fPIE], [LLDP_CFLAGS])
125 AX_LDFLAGS_OPTION([-fPIE -pie], [LLDP_BIN_LDFLAGS],
126 [AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_BIN_LDFLAGS])])
130 AC_ARG_ENABLE([sanitizers],
131 AS_HELP_STRING([--enable-sanitizers],
132 [Enable code instrumentation with selected sanitizers @<:@default=no@:>@]),
136 yes) sanitizers="-fsanitize=address,undefined" ;;
137 *) sanitizers="-fsanitize=$enableval" ;;
139 if test x"$sanitizers" != x; then
140 LLDP_CFLAGS="$LLDP_CFLAGS $sanitizers"
141 LLDP_LDFLAGS="$LLDP_LDFLAGS $sanitizers"
142 AC_DEFINE([HAVE_ADDRESS_SANITIZER], 1, [Define if have both address and leak sanitizer])
143 elif test x"$hardening" != x"no"; then
144 AX_LDFLAGS_OPTION([-fsanitize=safe-stack], [LLDP_BIN_LDFLAGS])
145 if test x"$ax_cv_ld_check_flag__fsanitize_safe_stack" != x"no"; then
146 AX_CFLAGS_GCC_OPTION([-fsanitize=safe-stack], [LLDP_CFLAGS])
152 AC_ARG_ENABLE([fuzzer],
153 AS_HELP_STRING([--enable-fuzzer],
154 [Enable fuzzing @<:@default=no@:>@]),
158 yes) fuzzer="-fsanitize=fuzzer" ;;
159 *) fuzzer="$enableval" ;;
161 if test x"$fuzzer" != x; then
162 AC_SUBST([FUZZ_DECODE_ENGINE], ["$fuzzer"])
163 AX_CFLAGS_GCC_OPTION([-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION], [LLDP_CFLAGS])
168 AC_ARG_ENABLE([gcov],
169 AS_HELP_STRING([--enable-gcov],
170 [Enable coverage instrumentation @<:@default=no@:>@]),
173 if test x"$gcov" != x"no"; then
174 LLDP_CFLAGS="$LLDP_CFLAGS --coverage"
175 LLDP_LDFLAGS="$LLDP_LDFLAGS --coverage"
184 # Checks for header files.
186 AC_CHECK_HEADERS([valgrind/valgrind.h])
191 # Checks for typedefs, structures, and compiler characteristics.
192 lldp_CHECK___PROGNAME
195 # Checks for library functions.
196 AC_CONFIG_LIBOBJ_DIR([src/compat])
201 # Some functions can be in libbsd
202 AC_ARG_WITH([libbsd],
205 [Use libbsd @<:@default=auto@:>@]),
208 if test x"$with_libbsd" != x"no"; then
209 PKG_CHECK_MODULES([libbsd], [libbsd-overlay], [
210 _save_CFLAGS="$CFLAGS"
212 CFLAGS="$CFLAGS $libbsd_CFLAGS"
213 LIBS="$LIBS $libbsd_LIBS"
214 AC_MSG_CHECKING([if libbsd can be linked correctly])
215 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
216 @%:@include <sys/time.h>
217 @%:@include <sys/types.h>
220 LLDP_CFLAGS="$LLDP_CFLAGS $libbsd_CFLAGS"
221 LLDP_LDFLAGS="$LLDP_LDFLAGS $libbsd_LIBS"
225 CFLAGS="$_save_CFLAGS"
227 if test x"$with_libbsd" = x"yes"; then
228 AC_MSG_FAILURE([*** no libbsd support found])
233 if test x"$with_libbsd" = x"yes"; then
234 AC_MSG_FAILURE([*** no libbsd support found])
240 # setproctitle may have an _init function
241 AC_REPLACE_FUNCS([setproctitle])
242 AC_CHECK_FUNCS([setproctitle_init])
244 AC_REPLACE_FUNCS([strlcpy
253 AC_CHECK_FUNCS([setresuid setresgid])
255 # Check for res_init. On OSX, res_init is a symbol in libsystem_info
256 # and a macro in resolv.h. We need to ensure we test with resolv.h.
257 m4_pushdef([AC_LANG_CALL(C)], [
259 @%:@include <resolv.h>], [return $2 ();])])
260 AC_SEARCH_LIBS([res_init], resolv bind,
261 AC_DEFINE([HAVE_RES_INIT], 1,
262 [Define to indicate that res_init() exists]))
263 m4_popdef([AC_LANG_CALL(C)])
267 ## Unit tests wich check
268 PKG_CHECK_MODULES([check], [check >= 0.9.4], [have_check=yes], [have_check=no])
270 # Third-party libraries
274 # Compatibility with pkg.m4 < 0.27
275 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
276 [AC_ARG_WITH([pkgconfigdir],
277 [AS_HELP_STRING([--with-pkgconfigdir],
278 [install directory for *.pc pkg-config file])],
279 [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
280 AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
282 #######################
286 AC_ARG_WITH([readline],
289 [Enable the use of readline-like library @<:@default=auto@:>@]),
291 [with_readline=auto])
292 if test x"$with_readline" != x"no"; then
293 AX_LIB_READLINE_LLDPD
294 if test x"$with_readline" != x"check" -a x"$with_readline" != x"auto"; then
295 if test x"$ax_cv_lib_readline" = x"no"; then
296 AC_MSG_FAILURE([*** no readline support found])
300 ax_cv_lib_readline="no"
307 [Enable the use of SNMP @<:@default=no@:>@]),
316 [Enable XML output via libxml2 @<:@default=auto@:>@]),
322 lldp_ARG_ENABLE([json0], [use of pre-0.9.2 JSON/json-c format], [no])
325 AC_ARG_WITH([seccomp],
328 [Enable seccomp support (with libseccomp, experimental) @<:@default=no@:>@]),
333 # OS X launchd support
334 lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
335 [/Library/LaunchDaemons])
336 AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
337 AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
338 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
341 lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
342 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)])
343 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
344 AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
345 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
348 lldp_ARG_WITH([sysusersdir], [Directory for sysusers files],
349 [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)])
350 AC_SUBST([sysusersdir], [$with_sysusersdir])
351 AM_CONDITIONAL(HAVE_SYSUSERSDIR,
352 [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ])
355 lldp_ARG_WITH([apparmordir], [Directory for AppArmor profiles (Linux)],
357 AC_SUBST([apparmordir], [$with_apparmordir])
358 AM_CONDITIONAL(HAVE_APPARMORDIR,
359 [test -n "$with_apparmordir" -a "x$with_apparmordir" != xno ])
365 lldp_ARG_ENABLE([privsep], [Privilege separation], [yes])
366 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
367 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
370 dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway
371 if test "x$runstatedir" = x; then
372 AC_SUBST([runstatedir], ['${localstatedir}/run'])
374 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd])
375 lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
376 lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
379 lldp_ARG_WITH_UNQUOTED([netlink-max-receive-bufsize], [Netlink maximum receive buffer size], [1024*1024])
380 lldp_ARG_WITH_UNQUOTED([netlink-receive-bufsize], [Netlink initial receive buffer size], [0])
381 lldp_ARG_WITH_UNQUOTED([netlink-send-bufsize], [Netlink send buffer size], [0])
384 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
385 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
386 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
387 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
390 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
391 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
392 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
393 lldp_ARG_ENABLE([custom], [Custom TLV support], [yes])
396 MIN_LINUX_KERNEL_VERSION=2.6.39
397 lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.39], [no])
398 if test x"$os" = x"Linux"; then
399 if test x"$enable_oldies" = x"no"; then
400 AC_DEFINE_UNQUOTED(MIN_LINUX_KERNEL_VERSION, "[$MIN_LINUX_KERNEL_VERSION]", [Minimal Linux kernel version required])
402 AC_DEFINE(MIN_LINUX_KERNEL_VERSION, "2.6.11", [Minimal kernel version required])
406 AX_BUILD_DATE_EPOCH(BUILD_DATE, "%FT%TZ", [BUILD_DATE="(unknown)"])
407 AC_DEFINE_UNQUOTED(BUILD_DATE, "[$BUILD_DATE]", [Build date and time])
409 dnl per reproducible-builds.org check SOURCE_DATE_EPOCH
411 if test -z "${SOURCE_DATE_EPOCH+set}" ; then
412 AC_DEFINE_UNQUOTED(LLDP_CC, "[$CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS]", [C compiler command])
413 AC_DEFINE_UNQUOTED(LLDP_LD, "[$LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS]", [Linker compiler command])
415 AC_DEFINE_UNQUOTED(LLDP_CC, "[C compiler command is not available for reproducible builds]", [C compiler command])
416 AC_DEFINE_UNQUOTED(LLDP_LD, "[Linker compiler command is not available for reproducible builds]", [Linker compiler command])
419 #######################
421 AC_SUBST([LLDP_CFLAGS])
422 AC_SUBST([LLDP_CPPFLAGS])
423 AC_SUBST([LLDP_LDFLAGS])
424 AC_SUBST([LLDP_BIN_LDFLAGS])
425 AM_CONDITIONAL([ENABLE_FUZZ_DECODE], [test x"$fuzzer" != x])
426 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
427 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
428 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
429 AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
430 dnl If old default of AR_FLAGS is otherwise being used (because of older automake),
431 dnl replace it with one without 'u'
432 if test "x$AR_FLAGS" = "xcru" ; then
437 if test x"$LIBEVENT_EMBEDDED" = x; then
445 ------------------ Summary ------------------
446 $PACKAGE_NAME version $PACKAGE_VERSION
448 Prefix.........: $prefix
449 C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS
450 Linker.........: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
451 Libevent.......: $libevent
452 Readline.......: ${ax_cv_lib_readline}
455 SNMP support...: ${with_snmp-no}
456 CDP............: $enable_cdp
457 FDP............: $enable_fdp
458 EDP............: $enable_edp
459 SONMP..........: $enable_sonmp
460 LLDPMED........: $enable_lldpmed
461 DOT1...........: $enable_dot1
462 DOT3...........: $enable_dot3
463 CUSTOM.........: $enable_custom
464 XML output.....: ${with_xml-no}
465 Oldies support.: $enable_oldies
466 seccomp........: ${with_seccomp-no}
467 libbsd.........: ${with_libbsd-no}
469 Privilege separation:
470 Enabled........: $enable_privsep
471 User/group.....: ${with_privsep_user}/${with_privsep_group}
472 Chroot.........: ${with_privsep_chroot}
474 Instrumentation (for devs only):
475 Sanitizers.....: ${sanitizers:-none}
476 Coverage.......: ${gcov}
477 ------------- Compiler version --------------
478 $($CC --version || true)
479 -------------- Linker version ---------------
480 $($LD --version || true)
481 ---------------------------------------------
483 Check the above options and compile with: