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