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 -Wall -Werror])
32 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
35 m4_pattern_allow([AM_PROG_AR])
41 #######################
44 # Checks for programs.
47 if test x"$ac_cv_prog_cc_c99" = x"no"; then
48 AC_MSG_FAILURE([*** C99 support is mandatory])
67 DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
69 # Check some compiler flags
70 AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option])
71 AX_CFLAGS_GCC_OPTION([-fdiagnostics-color=auto])
72 AX_CFLAGS_GCC_OPTION([-pipe])
73 AX_CFLAGS_GCC_OPTION([-Wall])
74 AX_CFLAGS_GCC_OPTION([-W])
75 AX_CFLAGS_GCC_OPTION([-Wextra])
76 AX_CFLAGS_GCC_OPTION([-Wformat])
77 AX_CFLAGS_GCC_OPTION([-Wformat-security])
78 AX_CFLAGS_GCC_OPTION([-Wfatal-errors])
79 AX_CFLAGS_GCC_OPTION([-Wcast-align])
80 AX_CFLAGS_GCC_OPTION([-Winline])
81 AX_CFLAGS_GCC_OPTION([-fstack-protector])
82 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong])
83 AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer])
84 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
85 AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
86 AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers])
87 AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
88 AX_LDFLAGS_OPTION([-Wl,-z,relro])
89 AX_LDFLAGS_OPTION([-Wl,-z,now])
97 # Checks for header files.
99 AC_CHECK_HEADERS([valgrind/valgrind.h])
104 # Checks for typedefs, structures, and compiler characteristics.
105 lldp_CHECK___PROGNAME
108 # Checks for library functions.
109 AC_CONFIG_LIBOBJ_DIR([src/compat])
113 # setproctitle (maybe through libbsd)
114 AC_SEARCH_LIBS([setproctitle], [util bsd])
115 AC_REPLACE_FUNCS([setproctitle])
116 AC_CHECK_FUNCS([setproctitle_init])
118 AC_REPLACE_FUNCS([strlcpy
126 AC_CHECK_FUNCS([setresuid setresgid])
130 AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used])
134 # Check for res_init. On OSX, res_init is a symbol in libsystem_info
135 # and a macro in resolv.h. We need to ensure we test with resolv.h.
136 m4_pushdef([AC_LANG_CALL(C)], [
138 @%:@include <resolv.h>], [return $2 ();])])
139 AC_SEARCH_LIBS([res_init], resolv bind,
140 AC_DEFINE([HAVE_RES_INIT], 1,
141 [Define to indicate that res_init() exists]))
142 m4_popdef([AC_LANG_CALL(C)])
146 ## Unit tests wich check
147 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
152 # Compatibility with pkg.m4 < 0.27
153 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
154 [AC_ARG_WITH([pkgconfigdir],
155 [AS_HELP_STRING([--with-pkgconfigdir],
156 [install directory for *.pc pkg-config file])],
157 [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
158 AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
160 #######################
164 AC_ARG_WITH([readline],
167 [Enable the use of readline-like library @<:@default=check@:>@]),
169 [with_readline=check])
170 if test x"$with_readline" != x"no"; then
172 if test x"$with_readline" != x"check"; then
173 if test x"$ax_cv_lib_readline" = x"no"; then
174 AC_MSG_FAILURE([*** no readline support found])
178 ax_cv_lib_readline="no"
185 [Enable the use of SNMP @<:@default=no@:>@]
187 if test x"$with_snmp" = x"yes"; then
195 [Enable XML output via libxml2 @<:@default=no@:>@]
197 if test x"$with_xml" = x"yes"; then
205 [Enable JSON output via janson,json-c,no @<:@default=no@:>@]
207 if test x"$with_json" = x"yes"; then
210 if test x"$with_json" = x"jansson"; then
212 elif test x"$with_json" = x"json-c"; then
217 AC_ARG_WITH([seccomp],
220 [Enable seccomp support (with libseccomp) @<:@default=no@:>@]),
225 # OS X launchd support
226 lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
227 [/Library/LaunchDaemons])
228 AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
229 AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
230 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
233 lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
234 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)])
235 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
236 AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
237 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
240 lldp_ARG_WITH([sysusersdir], [Directory for sysusers files],
241 [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)])
242 AC_SUBST([sysusersdir], [$with_sysusersdir])
243 AM_CONDITIONAL(HAVE_SYSUSERSDIR,
244 [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ])
250 lldp_ARG_ENABLE([privsep], [Privilege separation], [yes])
251 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
252 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
255 dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway
256 if test "x$runstatedir" = x; then
257 AC_SUBST([runstatedir], ['${localstatedir}/run'])
259 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd])
260 lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
261 lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
264 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
265 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
266 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
267 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
270 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
271 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
272 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
275 lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.18], [no])
277 #######################
279 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
280 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
281 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
282 AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"json-c" || test -x"$with_json" = x"jansson"])
283 AM_CONDITIONAL([USE_JANSSON], [test x"$with_json" = x"jansson"])
284 AM_CONDITIONAL([USE_JSONC], [test x"$with_json" = x"json-c"])
285 AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
288 if test x"$LIBEVENT_EMBEDDED" = x; then
296 ------------------ Summary ------------------
297 $PACKAGE_NAME version $PACKAGE_VERSION
299 Prefix.........: $prefix
300 C Compiler.....: $CC $CFLAGS $CPPFLAGS
301 Linker.........: $LD $LDFLAGS $LIBS
302 Libevent.......: $libevent
303 Readline.......: ${ax_cv_lib_readline}
305 SNMP support...: ${with_snmp-no}
306 CDP............: $enable_cdp
307 FDP............: $enable_fdp
308 EDP............: $enable_edp
309 SONMP..........: $enable_sonmp
310 LLDPMED........: $enable_lldpmed
311 DOT1...........: $enable_dot1
312 DOT3...........: $enable_dot3
313 XML output.....: ${with_xml-no}
314 JSON output....: ${with_json-no}
315 Oldies support.: $enable_oldies
316 seccomp........: ${with_seccomp-no}
317 Privilege separation:
318 Enabled........: $enable_privsep
319 User/group.....: ${with_privsep_user}/${with_privsep_group}
320 Chroot.........: ${with_privsep_chroot}
321 ---------------------------------------------
323 Check the above options and compile with: