]> git.ipfire.org Git - thirdparty/lldpd.git/blob - configure.ac
client: change description for chassis ID override
[thirdparty/lldpd.git] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 #######################
5 ### Base configuration
6
7 # Configure autoconf
8 AC_PREREQ([2.64])
9
10 AC_INIT([lldpd],
11 [m4_esyscmd_s([./get-version])],
12 [https://github.com/vincentbernat/lldpd/issues],
13 [lldpd],
14 [http://vincentbernat.github.io/lldpd/])
15
16 AC_CONFIG_SRCDIR([src/log.c])
17 AC_CONFIG_HEADER([config.h])
18 AC_CONFIG_FILES([Makefile
19 src/Makefile
20 src/compat/Makefile
21 src/daemon/Makefile
22 src/lib/Makefile
23 src/client/Makefile
24 tests/Makefile
25 osx/Makefile])
26 AC_CONFIG_MACRO_DIR([m4])
27 AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
28
29 # Configure automake
30 AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror tar-ustar])
31 AM_MAINTAINER_MODE
32 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
33
34 # Automake 1.12...
35 m4_pattern_allow([AM_PROG_AR])
36 AM_PROG_AR
37
38 # Configure libtool
39 LT_INIT
40 gl_LD_VERSION_SCRIPT
41
42 #######################
43 ### Checks
44
45 # Checks for programs.
46 AC_PROG_CC
47 AC_PROG_CC_C99
48 if test x"$ac_cv_prog_cc_c99" = x"no"; then
49 AC_MSG_FAILURE([*** C99 support is mandatory])
50 fi
51 AM_PROG_CC_C_O
52 AC_PROG_LIBTOOL
53 AC_PROG_LN_S
54 AC_PROG_EGREP
55 AC_PROG_AWK
56
57 # Doxygen
58 DX_HTML_FEATURE(ON)
59 DX_DOT_FEATURE(OFF)
60 DX_CHM_FEATURE(OFF)
61 DX_CHI_FEATURE(OFF)
62 DX_MAN_FEATURE(OFF)
63 DX_RTF_FEATURE(OFF)
64 DX_XML_FEATURE(OFF)
65 DX_PDF_FEATURE(ON)
66 DX_PS_FEATURE(OFF)
67 DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
68
69 # Check some compiler flags
70 AX_CFLAGS_GCC_OPTION([-Wunknown-warning-option], [LLDP_CFLAGS])
71 AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option], [LLDP_CFLAGS])
72 AX_CFLAGS_GCC_OPTION([-fdiagnostics-color=auto], [LLDP_CFLAGS])
73 AX_CFLAGS_GCC_OPTION([-pipe], [LLDP_CFLAGS])
74 AX_CFLAGS_GCC_OPTION([-Wall], [LLDP_CFLAGS])
75 AX_CFLAGS_GCC_OPTION([-W], [LLDP_CFLAGS])
76 AX_CFLAGS_GCC_OPTION([-Wextra], [LLDP_CFLAGS])
77 AX_CFLAGS_GCC_OPTION([-Wformat], [LLDP_CFLAGS])
78 AX_CFLAGS_GCC_OPTION([-Wformat-security], [LLDP_CFLAGS])
79 AX_CFLAGS_GCC_OPTION([-Wfatal-errors], [LLDP_CFLAGS])
80 AX_CFLAGS_GCC_OPTION([-Wcast-align], [LLDP_CFLAGS])
81 AX_CFLAGS_GCC_OPTION([-Wheader-guard], [LLDP_CFLAGS])
82 AX_CFLAGS_GCC_OPTION([-Wdocumentation], [LLDP_CFLAGS])
83 AX_CFLAGS_GCC_OPTION([-Winline], [LLDP_CFLAGS])
84 AX_CFLAGS_GCC_OPTION([-Wpointer-arith], [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])
91
92 AC_C_TYPEOF
93
94 # Hardening
95 AC_ARG_ENABLE([hardening],
96 [AS_HELP_STRING([--enable-hardening],
97 [Enable compiler and linker options to frustrate memory corruption exploits @<:@default=yes@:>@])],
98 [hardening="$enableval"],
99 [hardening="yes"])
100 AC_ARG_ENABLE([pie],
101 [AS_HELP_STRING([--enable-pie],
102 [Enable PIE (position independant executable) @<:@default=no@:>@])],
103 [pie="$enableval"],
104 [pie="no"])
105
106 if test x"$hardening" != x"no"; then
107 AX_CFLAGS_GCC_OPTION([-fstack-protector], [LLDP_CFLAGS])
108 AX_CFLAGS_GCC_OPTION([-fstack-protector-all], [LLDP_CFLAGS])
109 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
110 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
111 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [LLDP_CPPFLAGS])
112 AX_LDFLAGS_OPTION([-fsanitize=safe-stack], [LLDP_BIN_LDFLAGS])
113 if test x"$ax_cv_ld_check_flag__fsanitize_safe_stack" != x"no"; then
114 AX_CFLAGS_GCC_OPTION([-fsanitize=safe-stack], [LLDP_CFLAGS])
115 fi
116 fi
117 if test x"$pie" = x"yes"; then
118 AX_CFLAGS_GCC_OPTION([-fPIE], [LLDP_CFLAGS])
119 AX_LDFLAGS_OPTION([-fPIE -pie], [LLDP_BIN_LDFLAGS],
120 [AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_BIN_LDFLAGS])])
121 fi
122
123 # Sanitizers
124 AC_ARG_ENABLE([sanitizers],
125 AS_HELP_STRING([--enable-sanitizers],
126 [Enable code instrumentation with selected sanitizers @<:@default=no@:>@]),
127 [
128 case "$enableval" in
129 no) sanitizers= ;;
130 yes) sanitizers="-fsanitize=address,undefined" ;;
131 *) sanitizers="-fsanitize=$enableval" ;;
132 esac
133 if test x"$sanitizers" != x; then
134 LLDP_CFLAGS="$LLDP_CFLAGS $sanitizers"
135 LLDP_LDFLAGS="$LLDP_LDFLAGS $sanitizers"
136 AC_DEFINE([HAVE_ADDRESS_SANITIZER], 1, [Define if have both address and leak sanitizer])
137 fi
138 ])
139
140 # Code coverage
141 AC_ARG_ENABLE([gcov],
142 AS_HELP_STRING([--enable-gcov],
143 [Enable coverage instrumentation @<:@default=no@:>@]),
144 [gcov="$enableval"],
145 [gcov="no"])
146 if test x"$gcov" != x"no"; then
147 LLDP_CFLAGS="$LLDP_CFLAGS --coverage"
148 LLDP_LDFLAGS="$LLDP_LDFLAGS --coverage"
149 fi
150
151 # OS
152 lldp_CHECK_OS
153 lldp_CFLAGS_OS
154
155 AC_CACHE_SAVE
156
157 # Checks for header files.
158 AC_HEADER_RESOLV
159 AC_CHECK_HEADERS([valgrind/valgrind.h])
160 lldp_CHECK_STDINT
161
162 AC_CACHE_SAVE
163
164 # Checks for typedefs, structures, and compiler characteristics.
165 lldp_CHECK___PROGNAME
166 lldp_CHECK_ALIGNOF
167
168 # Checks for library functions.
169 AC_CONFIG_LIBOBJ_DIR([src/compat])
170 AC_FUNC_MALLOC
171 AC_FUNC_REALLOC
172 AC_FUNC_FORK
173
174 # Some functions can be in libbsd
175 PKG_CHECK_MODULES([libbsd], [libbsd-overlay], [
176 _save_CFLAGS="$CFLAGS"
177 _save_LIBS="$LIBS"
178 CFLAGS="$CFLAGS $libbsd_CFLAGS"
179 LIBS="$LIBS $libbsd_LIBS"
180 AC_MSG_CHECKING([if libbsd can be linked correctly])
181 AC_TRY_LINK([
182 @%:@include <sys/time.h>
183 @%:@include <sys/types.h>
184 ],[],
185 [
186 AC_MSG_RESULT(yes)
187 LLDP_CFLAGS="$LLDP_CFLAGS $libbsd_CFLAGS"
188 LLDP_LDFLAGS="$LLDP_LDFLAGS $libbsd_LIBS"
189 ],[
190 AC_MSG_RESULT(no)
191 CFLAGS="$_save_CFLAGS"
192 LIBS="$_save_LIBS"
193 ])
194 ], [:])
195
196 # setproctitle may have an _init function
197 AC_REPLACE_FUNCS([setproctitle])
198 AC_CHECK_FUNCS([setproctitle_init])
199 # Other functions
200 AC_REPLACE_FUNCS([strlcpy
201 strnlen
202 strndup
203 strtonum
204 getline
205 asprintf
206 vsyslog
207 daemon])
208 # Optional functions
209 AC_CHECK_FUNCS([setresuid setresgid])
210
211 # Check for res_init. On OSX, res_init is a symbol in libsystem_info
212 # and a macro in resolv.h. We need to ensure we test with resolv.h.
213 m4_pushdef([AC_LANG_CALL(C)], [
214 AC_LANG_PROGRAM([$1
215 @%:@include <resolv.h>], [return $2 ();])])
216 AC_SEARCH_LIBS([res_init], resolv bind,
217 AC_DEFINE([HAVE_RES_INIT], 1,
218 [Define to indicate that res_init() exists]))
219 m4_popdef([AC_LANG_CALL(C)])
220
221 AC_CACHE_SAVE
222
223 ## Unit tests wich check
224 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
225
226 # Third-party libraries
227 lldp_CHECK_LIBEVENT
228
229 # Compatibility with pkg.m4 < 0.27
230 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
231 [AC_ARG_WITH([pkgconfigdir],
232 [AS_HELP_STRING([--with-pkgconfigdir],
233 [install directory for *.pc pkg-config file])],
234 [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
235 AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
236
237 #######################
238 ### Options
239
240 # Readline
241 AC_ARG_WITH([readline],
242 AS_HELP_STRING(
243 [--with-readline],
244 [Enable the use of readline-like library @<:@default=auto@:>@]),
245 [],
246 [with_readline=auto])
247 if test x"$with_readline" != x"no"; then
248 AX_LIB_READLINE
249 if test x"$with_readline" != x"check" -a x"$with_readline" != x"auto"; then
250 if test x"$ax_cv_lib_readline" = x"no"; then
251 AC_MSG_FAILURE([*** no readline support found])
252 fi
253 fi
254 else
255 ax_cv_lib_readline="no"
256 fi
257
258 # SNMP
259 AC_ARG_WITH([snmp],
260 AS_HELP_STRING(
261 [--with-snmp],
262 [Enable the use of SNMP @<:@default=no@:>@]),
263 [],
264 [with_snmp=no])
265 lldp_CHECK_SNMP
266
267 # XML
268 AC_ARG_WITH([xml],
269 AS_HELP_STRING(
270 [--with-xml],
271 [Enable XML output via libxml2 @<:@default=auto@:>@]),
272 [],
273 [with_xml=auto])
274 lldp_CHECK_XML2
275
276 # JSON (built-in)
277 lldp_ARG_ENABLE([json0], [use of pre-0.9.2 JSON/json-c format], [no])
278
279 # Seccomp
280 AC_ARG_WITH([seccomp],
281 AS_HELP_STRING(
282 [--with-seccomp],
283 [Enable seccomp support (with libseccomp, experimental) @<:@default=no@:>@]),
284 [],
285 [with_seccomp=no])
286 lldp_CHECK_SECCOMP
287
288 # OS X launchd support
289 lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
290 [/Library/LaunchDaemons])
291 AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
292 AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
293 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
294
295 # Systemd
296 lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
297 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)])
298 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
299 AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
300 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
301
302 # sysusers
303 lldp_ARG_WITH([sysusersdir], [Directory for sysusers files],
304 [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)])
305 AC_SUBST([sysusersdir], [$with_sysusersdir])
306 AM_CONDITIONAL(HAVE_SYSUSERSDIR,
307 [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ])
308
309 # AppArmor
310 lldp_ARG_WITH([apparmordir], [Directory for AppArmor profiles (Linux)],
311 [no])
312 AC_SUBST([apparmordir], [$with_apparmordir])
313 AM_CONDITIONAL(HAVE_APPARMORDIR,
314 [test -n "$with_apparmordir" -a "x$with_apparmordir" != xno ])
315
316 # Systemtap/DTrace
317 lldp_SYSTEMTAP
318
319 # Privsep settings
320 lldp_ARG_ENABLE([privsep], [Privilege separation], [yes])
321 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
322 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
323
324 # Directories
325 dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway
326 if test "x$runstatedir" = x; then
327 AC_SUBST([runstatedir], ['${localstatedir}/run'])
328 fi
329 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd])
330 lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
331 lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
332
333 # Netlink
334 lldp_ARG_WITH_UNQUOTED([netlink-max-receive-bufsize], [Netlink maximum receive buffer size], [1024*1024])
335 lldp_ARG_WITH_UNQUOTED([netlink-receive-bufsize], [Netlink initial receive buffer size], [0])
336 lldp_ARG_WITH_UNQUOTED([netlink-send-bufsize], [Netlink send buffer size], [0])
337
338 # CDP/FDP/EDP/SONMP
339 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
340 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
341 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
342 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
343
344 # LLDPMED/Dot1/Dot3
345 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
346 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
347 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
348 lldp_ARG_ENABLE([custom], [Custom TLV support], [yes])
349
350 # Oldies
351 MIN_LINUX_KERNEL_VERSION=2.6.39
352 lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.39], [no])
353 if test x"$os" = x"Linux"; then
354 if test x"$enable_oldies" = x"no"; then
355 AC_DEFINE_UNQUOTED(MIN_LINUX_KERNEL_VERSION, "[$MIN_LINUX_KERNEL_VERSION]", [Minimal Linux kernel version required])
356 else
357 AC_DEFINE(MIN_LINUX_KERNEL_VERSION, "2.6.11", [Minimal kernel version required])
358 fi
359 fi
360
361 AX_BUILD_DATE_EPOCH(BUILD_DATE, "%FT%TZ", [BUILD_DATE="(unknown)"])
362 AC_DEFINE_UNQUOTED(BUILD_DATE, "[$BUILD_DATE]", [Build date and time])
363 AC_DEFINE_UNQUOTED(LLDP_CC, "[$CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS]", [C compiler command])
364 AC_DEFINE_UNQUOTED(LLDP_LD, "[$LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS]", [Linker compiler command])
365
366 #######################
367 # Output results
368 AC_SUBST([LLDP_CFLAGS])
369 AC_SUBST([LLDP_CPPFLAGS])
370 AC_SUBST([LLDP_LDFLAGS])
371 AC_SUBST([LLDP_BIN_LDFLAGS])
372 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
373 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
374 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
375 AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
376 dnl If old default of AR_FLAGS is otherwise being used (because of older automake),
377 dnl replace it with one without 'u'
378 if test "x$AR_FLAGS" = "xcru" ; then
379 AR_FLAGS="cr"
380 fi
381 AC_OUTPUT
382
383 if test x"$LIBEVENT_EMBEDDED" = x; then
384 libevent=system
385 else
386 libevent=embedded
387 fi
388
389 cat <<EOF
390
391 ------------------ Summary ------------------
392 $PACKAGE_NAME version $PACKAGE_VERSION
393 OS.............: $os
394 Prefix.........: $prefix
395 C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS
396 Linker.........: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
397 Libevent.......: $libevent
398 Readline.......: ${ax_cv_lib_readline}
399
400 Optional features:
401 SNMP support...: ${with_snmp-no}
402 CDP............: $enable_cdp
403 FDP............: $enable_fdp
404 EDP............: $enable_edp
405 SONMP..........: $enable_sonmp
406 LLDPMED........: $enable_lldpmed
407 DOT1...........: $enable_dot1
408 DOT3...........: $enable_dot3
409 CUSTOM.........: $enable_custom
410 XML output.....: ${with_xml-no}
411 Oldies support.: $enable_oldies
412 seccomp........: ${with_seccomp-no}
413
414 Privilege separation:
415 Enabled........: $enable_privsep
416 User/group.....: ${with_privsep_user}/${with_privsep_group}
417 Chroot.........: ${with_privsep_chroot}
418
419 Instrumentation (for devs only):
420 Sanitizers.....: ${sanitizers:-none}
421 Coverage.......: ${gcov}
422 ------------- Compiler version --------------
423 $($CC --version || true)
424 -------------- Linker version ---------------
425 $($LD --version || true)
426 ---------------------------------------------
427
428 Check the above options and compile with:
429 ${MAKE-make}
430
431 EOF