]> git.ipfire.org Git - thirdparty/lldpd.git/blame - configure.ac
interfaces: use /proc/net/bonding as primary method
[thirdparty/lldpd.git] / configure.ac
CommitLineData
43c02e7b
VB
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
d38eae28
VB
4#######################
5### Base configuration
6
7# Configure autoconf
8AC_PREREQ([2.64])
4593c0dc 9
4593c0dc 10AC_INIT([lldpd],
a888bea6 11 [m4_esyscmd_s([./get-version])],
493b0d42
VB
12 [https://github.com/vincentbernat/lldpd/issues],
13 [lldpd],
14 [http://vincentbernat.github.io/lldpd/])
4593c0dc 15
4b292b55 16AC_CONFIG_SRCDIR([src/log.c])
43c02e7b 17AC_CONFIG_HEADER([config.h])
95493844
VB
18AC_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])
2acc1418 26AC_CONFIG_MACRO_DIR([m4])
fa71a00c 27AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
43c02e7b 28
d38eae28 29# Configure automake
4a0791a4 30AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror tar-ustar])
33aa26d0 31AM_MAINTAINER_MODE
44cd2bed 32m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
d38eae28 33
0339b9a2
VB
34# Automake 1.12...
35m4_pattern_allow([AM_PROG_AR])
36AM_PROG_AR
37
d38eae28 38# Configure libtool
d38eae28 39LT_INIT
f571f2db 40gl_LD_VERSION_SCRIPT
d38eae28
VB
41
42#######################
43### Checks
44
43c02e7b
VB
45# Checks for programs.
46AC_PROG_CC
6c586123 47AC_PROG_CC_C99
630cc035
VB
48if test x"$ac_cv_prog_cc_c99" = x"no"; then
49 AC_MSG_FAILURE([*** C99 support is mandatory])
50fi
223227c8 51AC_PROG_CXX
d38eae28 52AM_PROG_CC_C_O
f5bc67ee 53AC_PROG_LIBTOOL
fe80711e 54AC_PROG_LN_S
7ba4a183 55AC_PROG_EGREP
140e34f0 56AC_PROG_AWK
2acc1418 57
4b292b55
VB
58# Doxygen
59DX_HTML_FEATURE(ON)
60DX_DOT_FEATURE(OFF)
61DX_CHM_FEATURE(OFF)
62DX_CHI_FEATURE(OFF)
63DX_MAN_FEATURE(OFF)
64DX_RTF_FEATURE(OFF)
65DX_XML_FEATURE(OFF)
66DX_PDF_FEATURE(ON)
67DX_PS_FEATURE(OFF)
68DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
69
45e89c8c 70# Check some compiler flags
f42b8214 71AX_CFLAGS_GCC_OPTION([-Wunknown-warning-option], [LLDP_CFLAGS])
8d92800b
VB
72AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option], [LLDP_CFLAGS])
73AX_CFLAGS_GCC_OPTION([-fdiagnostics-color=auto], [LLDP_CFLAGS])
74AX_CFLAGS_GCC_OPTION([-pipe], [LLDP_CFLAGS])
75AX_CFLAGS_GCC_OPTION([-Wall], [LLDP_CFLAGS])
76AX_CFLAGS_GCC_OPTION([-W], [LLDP_CFLAGS])
77AX_CFLAGS_GCC_OPTION([-Wextra], [LLDP_CFLAGS])
78AX_CFLAGS_GCC_OPTION([-Wformat], [LLDP_CFLAGS])
79AX_CFLAGS_GCC_OPTION([-Wformat-security], [LLDP_CFLAGS])
80AX_CFLAGS_GCC_OPTION([-Wfatal-errors], [LLDP_CFLAGS])
81AX_CFLAGS_GCC_OPTION([-Wcast-align], [LLDP_CFLAGS])
09f0af1d
ALG
82AX_CFLAGS_GCC_OPTION([-Wheader-guard], [LLDP_CFLAGS])
83AX_CFLAGS_GCC_OPTION([-Wdocumentation], [LLDP_CFLAGS])
8d92800b 84AX_CFLAGS_GCC_OPTION([-Winline], [LLDP_CFLAGS])
8d92800b 85AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer], [LLDP_CFLAGS])
8d92800b
VB
86AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter], [LLDP_CFLAGS])
87AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers], [LLDP_CFLAGS])
88AX_CFLAGS_GCC_OPTION([-Wno-sign-compare], [LLDP_CFLAGS]) dnl Should be fixed later
89AX_LDFLAGS_OPTION([-Wl,-z,relro], [LLDP_LDFLAGS])
90AX_LDFLAGS_OPTION([-Wl,-z,now], [LLDP_LDFLAGS])
9b480716 91lldp_CHECK_CTORS
19a5c9b6 92
56663327
VB
93# Hardening
94AC_ARG_ENABLE([hardening],
95 [AS_HELP_STRING([--enable-hardening],
d2a01934 96 [Enable compiler and linker options to frustrate memory corruption exploits @<:@default=yes@:>@])],
56663327
VB
97 [hardening="$enableval"],
98 [hardening="yes"])
99
100if 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])
f42b8214
VB
106 AX_LDFLAGS_OPTION([-fPIE -pie], [LLDP_BIN_LDFLAGS],
107 [AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_BIN_LDFLAGS])])
56663327
VB
108fi
109
e12c2365
VB
110# OS
111lldp_CHECK_OS
3dc1eb8c 112lldp_CFLAGS_OS
24b8d79f 113
8e4b9031
VB
114AC_CACHE_SAVE
115
d38eae28
VB
116# Checks for header files.
117AC_HEADER_RESOLV
396cfdfe 118AC_CHECK_HEADERS([valgrind/valgrind.h])
c3e340b6 119lldp_CHECK_STDINT
43c02e7b 120
8e4b9031
VB
121AC_CACHE_SAVE
122
43c02e7b 123# Checks for typedefs, structures, and compiler characteristics.
6bb9c4e0 124lldp_CHECK___PROGNAME
dd1d33cf 125lldp_CHECK_ALIGNOF
43c02e7b
VB
126
127# Checks for library functions.
4b292b55 128AC_CONFIG_LIBOBJ_DIR([src/compat])
d38eae28
VB
129AC_FUNC_MALLOC
130AC_FUNC_REALLOC
45bf0bd0 131AC_FUNC_FORK
78d54e08 132# setproctitle (maybe through libbsd [until 0.5, it is only a stub function])
66879d46 133AC_SEARCH_LIBS([setproctitle], [util bsd])
1e0d651f
VB
134AC_REPLACE_FUNCS([setproctitle])
135AC_CHECK_FUNCS([setproctitle_init])
554d650d
VB
136# Other functions
137AC_REPLACE_FUNCS([strlcpy
138 strnlen
139 strndup
140 fgetln
141 asprintf
142 vsyslog
143 daemon])
144# Optional functions
8dab5698 145AC_CHECK_FUNCS([setresuid setresgid])
e66b7f34 146
66879d46
VB
147case " $LIBS " in
148 *\ -lbsd\ *)
149 AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used])
150 ;;
151esac
152
d0a03372
VB
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.
155m4_pushdef([AC_LANG_CALL(C)], [
156 AC_LANG_PROGRAM([$1
157@%:@include <resolv.h>], [return $2 ();])])
158AC_SEARCH_LIBS([res_init], resolv bind,
159 AC_DEFINE([HAVE_RES_INIT], 1,
160 [Define to indicate that res_init() exists]))
161m4_popdef([AC_LANG_CALL(C)])
e66b7f34 162
8e4b9031
VB
163AC_CACHE_SAVE
164
d38eae28
VB
165## Unit tests wich check
166PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
43c02e7b 167
13181ede 168# Third-party libraries
c461e5da 169lldp_CHECK_LIBEVENT
13181ede 170lldp_CHECK_LIBNL
e5c94652 171
135ff0f7
VB
172# Compatibility with pkg.m4 < 0.27
173m4_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}])])
179
d38eae28
VB
180#######################
181### Options
43c02e7b 182
35f6f4fb
VB
183# Readline
184AC_ARG_WITH([readline],
185 AS_HELP_STRING(
186 [--with-readline],
fa9b12c5 187 [Enable the use of readline-like library @<:@default=auto@:>@]),
35f6f4fb 188 [],
fa9b12c5 189 [with_readline=auto])
35f6f4fb
VB
190if test x"$with_readline" != x"no"; then
191 AX_LIB_READLINE
fa9b12c5 192 if test x"$with_readline" != x"check" -a x"$with_readline" != x"auto"; then
35f6f4fb
VB
193 if test x"$ax_cv_lib_readline" = x"no"; then
194 AC_MSG_FAILURE([*** no readline support found])
195 fi
196 fi
197else
198 ax_cv_lib_readline="no"
199fi
200
d38eae28
VB
201# SNMP
202AC_ARG_WITH([snmp],
203 AS_HELP_STRING(
204 [--with-snmp],
fa9b12c5
VB
205 [Enable the use of SNMP @<:@default=no@:>@]),
206 [],
207 [with_snmp=no])
208lldp_CHECK_SNMP
315587ef 209
8beb9a73 210# XML
1480ce74 211AC_ARG_WITH([xml],
00e40dba 212 AS_HELP_STRING(
1480ce74 213 [--with-xml],
dd8c9fe3 214 [Enable XML output via libxml2 @<:@default=auto@:>@]),
fa9b12c5 215 [],
dd8c9fe3 216 [with_xml=auto])
fa9b12c5 217lldp_CHECK_XML2
1480ce74 218
8b7150e4
VB
219# JSON
220AC_ARG_WITH([json],
00e40dba 221 AS_HELP_STRING(
8b7150e4 222 [--with-json],
dd8c9fe3 223 [Enable JSON output via janson or json-c @<:@default=auto@:>@]),
fa9b12c5 224 [],
dd8c9fe3 225 [with_json=auto])
fa9b12c5
VB
226if test x"$with_json" = x"yes" -o x"$with_json" = x"auto"; then
227 _with_json="$with_json"
228 with_json=auto
229 lldp_CHECK_JANSSON
230 if test x"$with_json" = x"no"; then
231 with_json=auto
232 lldp_CHECK_JSONC
233 fi
234 if test x"$with_json" = x"no" -a x"$_with_json" = x"yes"; then
235 AC_MSG_FAILURE([*** no JSON support found])
236 fi
237else
8b7150e4 238 lldp_CHECK_JANSSON
8ff14a6d 239 lldp_CHECK_JSONC
8b7150e4
VB
240fi
241
00e40dba
VB
242# Seccomp
243AC_ARG_WITH([seccomp],
244 AS_HELP_STRING(
245 [--with-seccomp],
5472ac18 246 [Enable seccomp support (with libseccomp, experimental) @<:@default=no@:>@]),
00e40dba
VB
247 [],
248 [with_seccomp=no])
249lldp_CHECK_SECCOMP
250
c3f85560 251# OS X launchd support
4dfe31fd
VB
252lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
253 [/Library/LaunchDaemons])
254AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
255AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
256 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
9d1524b7
VB
257
258# Systemd
259lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
29760896 260 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)])
4dfe31fd
VB
261AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
262AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
263 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
c3f85560 264
a9f77488
VB
265# sysusers
266lldp_ARG_WITH([sysusersdir], [Directory for sysusers files],
267 [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)])
268AC_SUBST([sysusersdir], [$with_sysusersdir])
269AM_CONDITIONAL(HAVE_SYSUSERSDIR,
270 [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ])
271
cd7ee899
VB
272# AppArmor
273lldp_ARG_WITH([apparmordir], [Directory for AppArmor profiles (Linux)],
274 [no])
275AC_SUBST([apparmordir], [$with_apparmordir])
276AM_CONDITIONAL(HAVE_APPARMORDIR,
277 [test -n "$with_apparmordir" -a "x$with_apprmordir" != xno ])
278
bdfe4193
VB
279# Systemtap/DTrace
280lldp_SYSTEMTAP
281
d38eae28 282# Privsep settings
71a7dbb3 283lldp_ARG_ENABLE([privsep], [Privilege separation], [yes])
d38eae28
VB
284lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
285lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
9a4ed64a
VB
286
287# Directories
288dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway
289if test "x$runstatedir" = x; then
290 AC_SUBST([runstatedir], ['${localstatedir}/run'])
291fi
292lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd])
3a3a3623 293lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
5133ce2f 294lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
89840df0 295
d38eae28
VB
296# CDP/FDP/EDP/SONMP
297lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
298lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
299lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
300lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
a1347cd8 301
d38eae28
VB
302# LLDPMED/Dot1/Dot3
303lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
304lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
305lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
fb1b78bb 306lldp_ARG_ENABLE([custom], [Custom TLV support], [yes])
a1347cd8 307
184bd199 308# Oldies
2472bfda 309MIN_LINUX_KERNEL_VERSION=2.6.39
d9fdc886 310lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.39], [no])
2472bfda
VB
311if 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])
314 else
315 AC_DEFINE(MIN_LINUX_KERNEL_VERSION, "2.6.11", [Minimal kernel version required])
316 fi
317fi
184bd199 318
d38eae28
VB
319#######################
320# Output results
8d92800b
VB
321AC_SUBST([LLDP_CFLAGS])
322AC_SUBST([LLDP_CPPFLAGS])
323AC_SUBST([LLDP_LDFLAGS])
f42b8214 324AC_SUBST([LLDP_BIN_LDFLAGS])
d38eae28
VB
325AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
326AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
1480ce74 327AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
8ff14a6d
MS
328AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"json-c" || test -x"$with_json" = x"jansson"])
329AM_CONDITIONAL([USE_JANSSON], [test x"$with_json" = x"jansson"])
330AM_CONDITIONAL([USE_JSONC], [test x"$with_json" = x"json-c"])
00e40dba 331AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
43c02e7b 332AC_OUTPUT
d38eae28 333
4c1a8c61 334if test x"$LIBEVENT_EMBEDDED" = x; then
e5c94652
VB
335 libevent=system
336else
337 libevent=embedded
338fi
13181ede
VB
339if test x"$LIBNL_EMBEDDED" = x; then
340 libnl="system (if needed)"
341else
342 libnl=embedded
343fi
e5c94652 344
d38eae28
VB
345cat <<EOF
346
347------------------ Summary ------------------
348 $PACKAGE_NAME version $PACKAGE_VERSION
91e0280a 349 OS.............: $os
d38eae28 350 Prefix.........: $prefix
8d92800b 351 C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS
f42b8214 352 Linker.........: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
e5c94652 353 Libevent.......: $libevent
13181ede 354 Libnl..........: $libnl
35f6f4fb 355 Readline.......: ${ax_cv_lib_readline}
d38eae28
VB
356 Optional features:
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
fb1b78bb 365 CUSTOM.........: $enable_custom
1480ce74 366 XML output.....: ${with_xml-no}
8b7150e4 367 JSON output....: ${with_json-no}
184bd199 368 Oldies support.: $enable_oldies
00e40dba 369 seccomp........: ${with_seccomp-no}
71a7dbb3
VB
370 Privilege separation:
371 Enabled........: $enable_privsep
08841844
VB
372 User/group.....: ${with_privsep_user}/${with_privsep_group}
373 Chroot.........: ${with_privsep_chroot}
d38eae28
VB
374---------------------------------------------
375
376Check the above options and compile with:
377 ${MAKE-make}
378
379EOF