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([-fno-omit-frame-pointer], [LLDP_CFLAGS])
86 AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter], [LLDP_CFLAGS])
87 AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers], [LLDP_CFLAGS])
88 AX_CFLAGS_GCC_OPTION([-Wno-sign-compare], [LLDP_CFLAGS]) dnl Should be fixed later
89 AX_LDFLAGS_OPTION([-Wl,-z,relro], [LLDP_LDFLAGS])
90 AX_LDFLAGS_OPTION([-Wl,-z,now], [LLDP_LDFLAGS])
94 AC_ARG_ENABLE([hardening],
95 [AS_HELP_STRING([--enable-hardening],
96 [Enable compiler and linker options to frustrate memory corruption exploits @<:@default=yes@:>@])],
97 [hardening="$enableval"],
100 if test x"$hardening" != x"no"; then
101 AX_CFLAGS_GCC_OPTION([-fstack-protector], [LLDP_CFLAGS])
102 AX_CFLAGS_GCC_OPTION([-fstack-protector-all], [LLDP_CFLAGS])
103 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
104 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [LLDP_CPPFLAGS])
105 AX_CFLAGS_GCC_OPTION([-fPIE], [LLDP_CFLAGS])
106 AX_LDFLAGS_OPTION([-fPIE -pie], [LLDP_BIN_LDFLAGS],
107 [AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_BIN_LDFLAGS])])
116 # Checks for header files.
118 AC_CHECK_HEADERS([valgrind/valgrind.h])
123 # Checks for typedefs, structures, and compiler characteristics.
124 lldp_CHECK___PROGNAME
127 # Checks for library functions.
128 AC_CONFIG_LIBOBJ_DIR([src/compat])
132 # setproctitle (maybe through libbsd [until 0.5, it is only a stub function])
133 AC_SEARCH_LIBS([setproctitle], [util bsd])
134 AC_REPLACE_FUNCS([setproctitle])
135 AC_CHECK_FUNCS([setproctitle_init])
137 AC_REPLACE_FUNCS([strlcpy
145 AC_CHECK_FUNCS([setresuid setresgid])
149 AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used])
153 # Check for res_init. On OSX, res_init is a symbol in libsystem_info
154 # and a macro in resolv.h. We need to ensure we test with resolv.h.
155 m4_pushdef([AC_LANG_CALL(C)], [
157 @%:@include <resolv.h>], [return $2 ();])])
158 AC_SEARCH_LIBS([res_init], resolv bind,
159 AC_DEFINE([HAVE_RES_INIT], 1,
160 [Define to indicate that res_init() exists]))
161 m4_popdef([AC_LANG_CALL(C)])
165 ## Unit tests wich check
166 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
168 # Third-party libraries
172 # Compatibility with pkg.m4 < 0.27
173 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
174 [AC_ARG_WITH([pkgconfigdir],
175 [AS_HELP_STRING([--with-pkgconfigdir],
176 [install directory for *.pc pkg-config file])],
177 [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
178 AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
180 #######################
184 AC_ARG_WITH([readline],
187 [Enable the use of readline-like library @<:@default=auto@:>@]),
189 [with_readline=auto])
190 if test x"$with_readline" != x"no"; then
192 if test x"$with_readline" != x"check" -a x"$with_readline" != x"auto"; then
193 if test x"$ax_cv_lib_readline" = x"no"; then
194 AC_MSG_FAILURE([*** no readline support found])
198 ax_cv_lib_readline="no"
205 [Enable the use of SNMP @<:@default=no@:>@]),
214 [Enable XML output via libxml2 @<:@default=auto@:>@]),
223 [Enable JSON output via janson or json-c @<:@default=auto@:>@]),
226 if test x"$with_json" = x"yes" -o x"$with_json" = x"auto"; then
227 _with_json="$with_json"
230 if test x"$with_json" = x"no"; then
234 if test x"$with_json" = x"no" -a x"$_with_json" = x"yes"; then
235 AC_MSG_FAILURE([*** no JSON support found])
243 AC_ARG_WITH([seccomp],
246 [Enable seccomp support (with libseccomp, experimental) @<:@default=no@:>@]),
251 # OS X launchd support
252 lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
253 [/Library/LaunchDaemons])
254 AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
255 AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
256 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
259 lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
260 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)])
261 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
262 AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
263 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
266 lldp_ARG_WITH([sysusersdir], [Directory for sysusers files],
267 [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)])
268 AC_SUBST([sysusersdir], [$with_sysusersdir])
269 AM_CONDITIONAL(HAVE_SYSUSERSDIR,
270 [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ])
273 lldp_ARG_WITH([apparmordir], [Directory for AppArmor profiles (Linux)],
275 AC_SUBST([apparmordir], [$with_apparmordir])
276 AM_CONDITIONAL(HAVE_APPARMORDIR,
277 [test -n "$with_apparmordir" -a "x$with_apprmordir" != xno ])
283 lldp_ARG_ENABLE([privsep], [Privilege separation], [yes])
284 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
285 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
288 dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway
289 if test "x$runstatedir" = x; then
290 AC_SUBST([runstatedir], ['${localstatedir}/run'])
292 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd])
293 lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
294 lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
297 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
298 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
299 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
300 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
303 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
304 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
305 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
306 lldp_ARG_ENABLE([custom], [Custom TLV support], [yes])
309 MIN_LINUX_KERNEL_VERSION=2.6.39
310 lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.39], [no])
311 if test x"$os" = x"Linux"; then
312 if test x"$enable_oldies" = x"no"; then
313 AC_DEFINE_UNQUOTED(MIN_LINUX_KERNEL_VERSION, "[$MIN_LINUX_KERNEL_VERSION]", [Minimal Linux kernel version required])
315 AC_DEFINE(MIN_LINUX_KERNEL_VERSION, "2.6.11", [Minimal kernel version required])
319 #######################
321 AC_SUBST([LLDP_CFLAGS])
322 AC_SUBST([LLDP_CPPFLAGS])
323 AC_SUBST([LLDP_LDFLAGS])
324 AC_SUBST([LLDP_BIN_LDFLAGS])
325 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
326 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
327 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
328 AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"json-c" || test -x"$with_json" = x"jansson"])
329 AM_CONDITIONAL([USE_JANSSON], [test x"$with_json" = x"jansson"])
330 AM_CONDITIONAL([USE_JSONC], [test x"$with_json" = x"json-c"])
331 AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
334 if test x"$LIBEVENT_EMBEDDED" = x; then
339 if test x"$LIBNL_EMBEDDED" = x; then
340 libnl="system (if needed)"
347 ------------------ Summary ------------------
348 $PACKAGE_NAME version $PACKAGE_VERSION
350 Prefix.........: $prefix
351 C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS
352 Linker.........: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
353 Libevent.......: $libevent
354 Libnl..........: $libnl
355 Readline.......: ${ax_cv_lib_readline}
357 SNMP support...: ${with_snmp-no}
358 CDP............: $enable_cdp
359 FDP............: $enable_fdp
360 EDP............: $enable_edp
361 SONMP..........: $enable_sonmp
362 LLDPMED........: $enable_lldpmed
363 DOT1...........: $enable_dot1
364 DOT3...........: $enable_dot3
365 CUSTOM.........: $enable_custom
366 XML output.....: ${with_xml-no}
367 JSON output....: ${with_json-no}
368 Oldies support.: $enable_oldies
369 seccomp........: ${with_seccomp-no}
370 Privilege separation:
371 Enabled........: $enable_privsep
372 User/group.....: ${with_privsep_user}/${with_privsep_group}
373 Chroot.........: ${with_privsep_chroot}
374 ---------------------------------------------
376 Check the above options and compile with: