]> git.ipfire.org Git - thirdparty/lldpd.git/blob - configure.ac
client: fix segfault when displaying some information
[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 AC_PROG_CXX
52 AM_PROG_CC_C_O
53 AC_PROG_LIBTOOL
54 AC_PROG_LN_S
55 AC_PROG_EGREP
56 AC_PROG_AWK
57
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
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])
91 lldp_CHECK_CTORS
92
93 # Hardening
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"],
98 [hardening="yes"])
99 AC_ARG_ENABLE([pie],
100 [AS_HELP_STRING([--enable-pie],
101 [Enable PIE (position independant executable) @<:@default=no@:>@])],
102 [pie="$enableval"],
103 [pie="no"])
104
105 if test x"$hardening" != x"no"; then
106 AX_CFLAGS_GCC_OPTION([-fstack-protector], [LLDP_CFLAGS])
107 AX_CFLAGS_GCC_OPTION([-fstack-protector-all], [LLDP_CFLAGS])
108 AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
109 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [LLDP_CPPFLAGS])
110 fi
111 if test x"$pie" = x"yes"; then
112 AX_CFLAGS_GCC_OPTION([-fPIE], [LLDP_CFLAGS])
113 AX_LDFLAGS_OPTION([-fPIE -pie], [LLDP_BIN_LDFLAGS],
114 [AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_BIN_LDFLAGS])])
115 fi
116
117 # OS
118 lldp_CHECK_OS
119 lldp_CFLAGS_OS
120
121 AC_CACHE_SAVE
122
123 # Checks for header files.
124 AC_HEADER_RESOLV
125 AC_CHECK_HEADERS([valgrind/valgrind.h])
126 lldp_CHECK_STDINT
127
128 AC_CACHE_SAVE
129
130 # Checks for typedefs, structures, and compiler characteristics.
131 lldp_CHECK___PROGNAME
132 lldp_CHECK_ALIGNOF
133
134 # Checks for library functions.
135 AC_CONFIG_LIBOBJ_DIR([src/compat])
136 AC_FUNC_MALLOC
137 AC_FUNC_REALLOC
138 AC_FUNC_FORK
139
140 # Some functions can be in libbsd
141 PKG_CHECK_MODULES([libbsd], [libbsd-overlay], [], [:])
142 _save_CFLAGS="$CFLAGS"
143 _save_LIBS="$LIBS"
144 CFLAGS="$CFLAGS $libbsd_CFLAGS"
145 LIBS="$LIBS $libbsd_LIBS"
146 LLDP_CFLAGS="$LLDP_CFLAGS $libbsd_CFLAGS"
147 LLDP_LDFLAGS="$LLDP_LDFLAGS $libbsd_LIBS"
148
149 # setproctitle may have an _init function
150 AC_REPLACE_FUNCS([setproctitle])
151 AC_CHECK_FUNCS([setproctitle_init])
152 # Other functions
153 AC_REPLACE_FUNCS([strlcpy
154 strnlen
155 strndup
156 getline
157 asprintf
158 vsyslog
159 daemon])
160 # Optional functions
161 AC_CHECK_FUNCS([setresuid setresgid])
162
163 CFLAGS="$_save_CFLAGS"
164 LIBS="$_save_LIBS"
165
166 # Check for res_init. On OSX, res_init is a symbol in libsystem_info
167 # and a macro in resolv.h. We need to ensure we test with resolv.h.
168 m4_pushdef([AC_LANG_CALL(C)], [
169 AC_LANG_PROGRAM([$1
170 @%:@include <resolv.h>], [return $2 ();])])
171 AC_SEARCH_LIBS([res_init], resolv bind,
172 AC_DEFINE([HAVE_RES_INIT], 1,
173 [Define to indicate that res_init() exists]))
174 m4_popdef([AC_LANG_CALL(C)])
175
176 AC_CACHE_SAVE
177
178 ## Unit tests wich check
179 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
180
181 # Third-party libraries
182 lldp_CHECK_LIBEVENT
183 lldp_CHECK_LIBNL
184
185 # Compatibility with pkg.m4 < 0.27
186 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
187 [AC_ARG_WITH([pkgconfigdir],
188 [AS_HELP_STRING([--with-pkgconfigdir],
189 [install directory for *.pc pkg-config file])],
190 [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
191 AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
192
193 #######################
194 ### Options
195
196 # Readline
197 AC_ARG_WITH([readline],
198 AS_HELP_STRING(
199 [--with-readline],
200 [Enable the use of readline-like library @<:@default=auto@:>@]),
201 [],
202 [with_readline=auto])
203 if test x"$with_readline" != x"no"; then
204 AX_LIB_READLINE
205 if test x"$with_readline" != x"check" -a x"$with_readline" != x"auto"; then
206 if test x"$ax_cv_lib_readline" = x"no"; then
207 AC_MSG_FAILURE([*** no readline support found])
208 fi
209 fi
210 else
211 ax_cv_lib_readline="no"
212 fi
213
214 # SNMP
215 AC_ARG_WITH([snmp],
216 AS_HELP_STRING(
217 [--with-snmp],
218 [Enable the use of SNMP @<:@default=no@:>@]),
219 [],
220 [with_snmp=no])
221 lldp_CHECK_SNMP
222
223 # XML
224 AC_ARG_WITH([xml],
225 AS_HELP_STRING(
226 [--with-xml],
227 [Enable XML output via libxml2 @<:@default=auto@:>@]),
228 [],
229 [with_xml=auto])
230 lldp_CHECK_XML2
231
232 # JSON
233 AC_ARG_WITH([json],
234 AS_HELP_STRING(
235 [--with-json],
236 [Enable JSON output via janson or json-c @<:@default=auto@:>@]),
237 [],
238 [with_json=auto])
239 if test x"$with_json" = x"yes" -o x"$with_json" = x"auto"; then
240 _with_json="$with_json"
241 with_json=auto
242 lldp_CHECK_JANSSON
243 if test x"$with_json" = x"no"; then
244 with_json=auto
245 lldp_CHECK_JSONC
246 fi
247 if test x"$with_json" = x"no" -a x"$_with_json" = x"yes"; then
248 AC_MSG_FAILURE([*** no JSON support found])
249 fi
250 else
251 lldp_CHECK_JANSSON
252 lldp_CHECK_JSONC
253 fi
254
255 # Seccomp
256 AC_ARG_WITH([seccomp],
257 AS_HELP_STRING(
258 [--with-seccomp],
259 [Enable seccomp support (with libseccomp, experimental) @<:@default=no@:>@]),
260 [],
261 [with_seccomp=no])
262 lldp_CHECK_SECCOMP
263
264 # OS X launchd support
265 lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
266 [/Library/LaunchDaemons])
267 AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
268 AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
269 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
270
271 # Systemd
272 lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
273 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)])
274 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
275 AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
276 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
277
278 # sysusers
279 lldp_ARG_WITH([sysusersdir], [Directory for sysusers files],
280 [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)])
281 AC_SUBST([sysusersdir], [$with_sysusersdir])
282 AM_CONDITIONAL(HAVE_SYSUSERSDIR,
283 [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ])
284
285 # AppArmor
286 lldp_ARG_WITH([apparmordir], [Directory for AppArmor profiles (Linux)],
287 [no])
288 AC_SUBST([apparmordir], [$with_apparmordir])
289 AM_CONDITIONAL(HAVE_APPARMORDIR,
290 [test -n "$with_apparmordir" -a "x$with_apprmordir" != xno ])
291
292 # Systemtap/DTrace
293 lldp_SYSTEMTAP
294
295 # Privsep settings
296 lldp_ARG_ENABLE([privsep], [Privilege separation], [yes])
297 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
298 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
299
300 # Directories
301 dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway
302 if test "x$runstatedir" = x; then
303 AC_SUBST([runstatedir], ['${localstatedir}/run'])
304 fi
305 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd])
306 lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
307 lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
308
309 # CDP/FDP/EDP/SONMP
310 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
311 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
312 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
313 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
314
315 # LLDPMED/Dot1/Dot3
316 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
317 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
318 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
319 lldp_ARG_ENABLE([custom], [Custom TLV support], [yes])
320
321 # Oldies
322 MIN_LINUX_KERNEL_VERSION=2.6.39
323 lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.39], [no])
324 if test x"$os" = x"Linux"; then
325 if test x"$enable_oldies" = x"no"; then
326 AC_DEFINE_UNQUOTED(MIN_LINUX_KERNEL_VERSION, "[$MIN_LINUX_KERNEL_VERSION]", [Minimal Linux kernel version required])
327 else
328 AC_DEFINE(MIN_LINUX_KERNEL_VERSION, "2.6.11", [Minimal kernel version required])
329 fi
330 fi
331
332 #######################
333 # Output results
334 AC_SUBST([LLDP_CFLAGS])
335 AC_SUBST([LLDP_CPPFLAGS])
336 AC_SUBST([LLDP_LDFLAGS])
337 AC_SUBST([LLDP_BIN_LDFLAGS])
338 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
339 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
340 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
341 AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"json-c" || test -x"$with_json" = x"jansson"])
342 AM_CONDITIONAL([USE_JANSSON], [test x"$with_json" = x"jansson"])
343 AM_CONDITIONAL([USE_JSONC], [test x"$with_json" = x"json-c"])
344 AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
345 AC_OUTPUT
346
347 if test x"$LIBEVENT_EMBEDDED" = x; then
348 libevent=system
349 else
350 libevent=embedded
351 fi
352 if test x"$LIBNL_EMBEDDED" = x; then
353 libnl="system (if needed)"
354 else
355 libnl=embedded
356 fi
357
358 cat <<EOF
359
360 ------------------ Summary ------------------
361 $PACKAGE_NAME version $PACKAGE_VERSION
362 OS.............: $os
363 Prefix.........: $prefix
364 C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS
365 Linker.........: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
366 Libevent.......: $libevent
367 Libnl..........: $libnl
368 Readline.......: ${ax_cv_lib_readline}
369 Optional features:
370 SNMP support...: ${with_snmp-no}
371 CDP............: $enable_cdp
372 FDP............: $enable_fdp
373 EDP............: $enable_edp
374 SONMP..........: $enable_sonmp
375 LLDPMED........: $enable_lldpmed
376 DOT1...........: $enable_dot1
377 DOT3...........: $enable_dot3
378 CUSTOM.........: $enable_custom
379 XML output.....: ${with_xml-no}
380 JSON output....: ${with_json-no}
381 Oldies support.: $enable_oldies
382 seccomp........: ${with_seccomp-no}
383 Privilege separation:
384 Enabled........: $enable_privsep
385 User/group.....: ${with_privsep_user}/${with_privsep_group}
386 Chroot.........: ${with_privsep_chroot}
387 ---------------------------------------------
388
389 Check the above options and compile with:
390 ${MAKE-make}
391
392 EOF