2 # Process this file with autoconf to produce a configure script.
4 #######################
11 [m4_esyscmd_s([./get-version])],
12 [https://github.com/vincentbernat/lldpd/issues],
14 [http://vincentbernat.github.io/lldpd/])
16 AC_CONFIG_SRCDIR([src/log.c])
17 AC_CONFIG_HEADER([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])
68 DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
70 # Check some compiler flags
71 AX_CFLAGS_GCC_OPTION([-Wunknown-warning-option], [LLDP_CFLAGS])
72 AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option], [LLDP_CFLAGS])
73 AX_CFLAGS_GCC_OPTION([-fdiagnostics-color=auto], [LLDP_CFLAGS])
74 AX_CFLAGS_GCC_OPTION([-pipe], [LLDP_CFLAGS])
75 AX_CFLAGS_GCC_OPTION([-Wall], [LLDP_CFLAGS])
76 AX_CFLAGS_GCC_OPTION([-W], [LLDP_CFLAGS])
77 AX_CFLAGS_GCC_OPTION([-Wextra], [LLDP_CFLAGS])
78 AX_CFLAGS_GCC_OPTION([-Wformat], [LLDP_CFLAGS])
79 AX_CFLAGS_GCC_OPTION([-Wformat-security], [LLDP_CFLAGS])
80 AX_CFLAGS_GCC_OPTION([-Wfatal-errors], [LLDP_CFLAGS])
81 AX_CFLAGS_GCC_OPTION([-Wcast-align], [LLDP_CFLAGS])
82 AX_CFLAGS_GCC_OPTION([-Wheader-guard], [LLDP_CFLAGS])
83 AX_CFLAGS_GCC_OPTION([-Wdocumentation], [LLDP_CFLAGS])
84 AX_CFLAGS_GCC_OPTION([-Winline], [LLDP_CFLAGS])
85 AX_CFLAGS_GCC_OPTION([-Wpointer-arith], [LLDP_CFLAGS])
86 AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer], [LLDP_CFLAGS])
87 AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter], [LLDP_CFLAGS])
88 AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers], [LLDP_CFLAGS])
89 AX_CFLAGS_GCC_OPTION([-Wno-sign-compare], [LLDP_CFLAGS]) dnl Should be fixed later
90 AX_LDFLAGS_OPTION([-Wl,-z,relro], [LLDP_LDFLAGS])
91 AX_LDFLAGS_OPTION([-Wl,-z,now], [LLDP_LDFLAGS])
96 AC_ARG_ENABLE([hardening],
97 [AS_HELP_STRING([--enable-hardening],
98 [Enable compiler and linker options to frustrate memory corruption exploits @<:@default=yes@:>@])],
99 [hardening="$enableval"],
102 [AS_HELP_STRING([--enable-pie],
103 [Enable PIE (position independant executable) @<:@default=no@:>@])],
107 if test x"$hardening" != x"no"; then
108 AX_CFLAGS_GCC_OPTION([-fstack-protector], [LLDP_CFLAGS])
109 AX_CFLAGS_GCC_OPTION([-fstack-protector-all], [LLDP_CFLAGS])
110 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
111 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
112 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [LLDP_CPPFLAGS])
113 AX_LDFLAGS_OPTION([-fsanitize=safe-stack], [LLDP_BIN_LDFLAGS])
114 if test x"$ax_cv_ld_check_flag__fsanitize_safe_stack" != x"no"; then
115 AX_CFLAGS_GCC_OPTION([-fsanitize=safe-stack], [LLDP_CFLAGS])
118 if test x"$pie" = x"yes"; then
119 AX_CFLAGS_GCC_OPTION([-fPIE], [LLDP_CFLAGS])
120 AX_LDFLAGS_OPTION([-fPIE -pie], [LLDP_BIN_LDFLAGS],
121 [AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_BIN_LDFLAGS])])
125 AC_ARG_ENABLE([sanitizers],
126 AS_HELP_STRING([--enable-sanitizers],
127 [Enable code instrumentation with selected sanitizers @<:@default=no@:>@]),
131 yes) sanitizers="-fsanitize=address,undefined" ;;
132 *) sanitizers="-fsanitize=$enableval" ;;
134 if test x"$sanitizers" != x; then
135 LLDP_CFLAGS="$LLDP_CFLAGS $sanitizers"
136 LLDP_LDFLAGS="$LLDP_LDFLAGS $sanitizers"
137 AC_DEFINE([HAVE_ADDRESS_SANITIZER], 1, [Define if have both address and leak sanitizer])
142 AC_ARG_ENABLE([gcov],
143 AS_HELP_STRING([--enable-gcov],
144 [Enable coverage instrumentation @<:@default=no@:>@]),
147 if test x"$gcov" != x"no"; then
148 LLDP_CFLAGS="$LLDP_CFLAGS --coverage"
149 LLDP_LDFLAGS="$LLDP_LDFLAGS --coverage"
158 # Checks for header files.
160 AC_CHECK_HEADERS([valgrind/valgrind.h])
165 # Checks for typedefs, structures, and compiler characteristics.
166 lldp_CHECK___PROGNAME
169 # Checks for library functions.
170 AC_CONFIG_LIBOBJ_DIR([src/compat])
175 # Some functions can be in libbsd
176 PKG_CHECK_MODULES([libbsd], [libbsd-overlay], [
177 _save_CFLAGS="$CFLAGS"
179 CFLAGS="$CFLAGS $libbsd_CFLAGS"
180 LIBS="$LIBS $libbsd_LIBS"
181 AC_MSG_CHECKING([if libbsd can be linked correctly])
183 @%:@include <sys/time.h>
184 @%:@include <sys/types.h>
188 LLDP_CFLAGS="$LLDP_CFLAGS $libbsd_CFLAGS"
189 LLDP_LDFLAGS="$LLDP_LDFLAGS $libbsd_LIBS"
192 CFLAGS="$_save_CFLAGS"
197 # setproctitle may have an _init function
198 AC_REPLACE_FUNCS([setproctitle])
199 AC_CHECK_FUNCS([setproctitle_init])
201 AC_REPLACE_FUNCS([strlcpy
210 AC_CHECK_FUNCS([setresuid setresgid])
212 # Check for res_init. On OSX, res_init is a symbol in libsystem_info
213 # and a macro in resolv.h. We need to ensure we test with resolv.h.
214 m4_pushdef([AC_LANG_CALL(C)], [
216 @%:@include <resolv.h>], [return $2 ();])])
217 AC_SEARCH_LIBS([res_init], resolv bind,
218 AC_DEFINE([HAVE_RES_INIT], 1,
219 [Define to indicate that res_init() exists]))
220 m4_popdef([AC_LANG_CALL(C)])
224 ## Unit tests wich check
225 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
227 # Third-party libraries
230 # Compatibility with pkg.m4 < 0.27
231 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
232 [AC_ARG_WITH([pkgconfigdir],
233 [AS_HELP_STRING([--with-pkgconfigdir],
234 [install directory for *.pc pkg-config file])],
235 [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
236 AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
238 #######################
242 AC_ARG_WITH([readline],
245 [Enable the use of readline-like library @<:@default=auto@:>@]),
247 [with_readline=auto])
248 if test x"$with_readline" != x"no"; then
250 if test x"$with_readline" != x"check" -a x"$with_readline" != x"auto"; then
251 if test x"$ax_cv_lib_readline" = x"no"; then
252 AC_MSG_FAILURE([*** no readline support found])
256 ax_cv_lib_readline="no"
263 [Enable the use of SNMP @<:@default=no@:>@]),
272 [Enable XML output via libxml2 @<:@default=auto@:>@]),
278 lldp_ARG_ENABLE([json0], [use of pre-0.9.2 JSON/json-c format], [no])
281 AC_ARG_WITH([seccomp],
284 [Enable seccomp support (with libseccomp, experimental) @<:@default=no@:>@]),
289 # OS X launchd support
290 lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
291 [/Library/LaunchDaemons])
292 AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
293 AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
294 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
297 lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
298 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)])
299 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
300 AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
301 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
304 lldp_ARG_WITH([sysusersdir], [Directory for sysusers files],
305 [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)])
306 AC_SUBST([sysusersdir], [$with_sysusersdir])
307 AM_CONDITIONAL(HAVE_SYSUSERSDIR,
308 [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ])
311 lldp_ARG_WITH([apparmordir], [Directory for AppArmor profiles (Linux)],
313 AC_SUBST([apparmordir], [$with_apparmordir])
314 AM_CONDITIONAL(HAVE_APPARMORDIR,
315 [test -n "$with_apparmordir" -a "x$with_apparmordir" != xno ])
321 lldp_ARG_ENABLE([privsep], [Privilege separation], [yes])
322 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
323 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
326 dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway
327 if test "x$runstatedir" = x; then
328 AC_SUBST([runstatedir], ['${localstatedir}/run'])
330 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd])
331 lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
332 lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
335 lldp_ARG_WITH_UNQUOTED([netlink-max-receive-bufsize], [Netlink maximum receive buffer size], [1024*1024])
336 lldp_ARG_WITH_UNQUOTED([netlink-receive-bufsize], [Netlink initial receive buffer size], [0])
337 lldp_ARG_WITH_UNQUOTED([netlink-send-bufsize], [Netlink send buffer size], [0])
340 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
341 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
342 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
343 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
346 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
347 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
348 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
349 lldp_ARG_ENABLE([custom], [Custom TLV support], [yes])
352 MIN_LINUX_KERNEL_VERSION=2.6.39
353 lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.39], [no])
354 if test x"$os" = x"Linux"; then
355 if test x"$enable_oldies" = x"no"; then
356 AC_DEFINE_UNQUOTED(MIN_LINUX_KERNEL_VERSION, "[$MIN_LINUX_KERNEL_VERSION]", [Minimal Linux kernel version required])
358 AC_DEFINE(MIN_LINUX_KERNEL_VERSION, "2.6.11", [Minimal kernel version required])
362 AX_BUILD_DATE_EPOCH(BUILD_DATE, "%FT%TZ", [BUILD_DATE="(unknown)"])
363 AC_DEFINE_UNQUOTED(BUILD_DATE, "[$BUILD_DATE]", [Build date and time])
364 AC_DEFINE_UNQUOTED(LLDP_CC, "[$CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS]", [C compiler command])
365 AC_DEFINE_UNQUOTED(LLDP_LD, "[$LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS]", [Linker compiler command])
367 #######################
369 AC_SUBST([LLDP_CFLAGS])
370 AC_SUBST([LLDP_CPPFLAGS])
371 AC_SUBST([LLDP_LDFLAGS])
372 AC_SUBST([LLDP_BIN_LDFLAGS])
373 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
374 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
375 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
376 AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
377 dnl If old default of AR_FLAGS is otherwise being used (because of older automake),
378 dnl replace it with one without 'u'
379 if test "x$AR_FLAGS" = "xcru" ; then
384 if test x"$LIBEVENT_EMBEDDED" = x; then
392 ------------------ Summary ------------------
393 $PACKAGE_NAME version $PACKAGE_VERSION
395 Prefix.........: $prefix
396 C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS
397 Linker.........: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
398 Libevent.......: $libevent
399 Readline.......: ${ax_cv_lib_readline}
402 SNMP support...: ${with_snmp-no}
403 CDP............: $enable_cdp
404 FDP............: $enable_fdp
405 EDP............: $enable_edp
406 SONMP..........: $enable_sonmp
407 LLDPMED........: $enable_lldpmed
408 DOT1...........: $enable_dot1
409 DOT3...........: $enable_dot3
410 CUSTOM.........: $enable_custom
411 XML output.....: ${with_xml-no}
412 Oldies support.: $enable_oldies
413 seccomp........: ${with_seccomp-no}
415 Privilege separation:
416 Enabled........: $enable_privsep
417 User/group.....: ${with_privsep_user}/${with_privsep_group}
418 Chroot.........: ${with_privsep_chroot}
420 Instrumentation (for devs only):
421 Sanitizers.....: ${sanitizers:-none}
422 Coverage.......: ${gcov}
423 ------------- Compiler version --------------
424 $($CC --version || true)
425 -------------- Linker version ---------------
426 $($LD --version || true)
427 ---------------------------------------------
429 Check the above options and compile with: