]> git.ipfire.org Git - thirdparty/lldpd.git/blame - configure.ac
build: enable JSON/XML support automatically by default
[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
84b41218 30AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror])
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
VB
39LT_INIT
40
41#######################
42### Checks
43
43c02e7b
VB
44# Checks for programs.
45AC_PROG_CC
6c586123 46AC_PROG_CC_C99
630cc035
VB
47if test x"$ac_cv_prog_cc_c99" = x"no"; then
48 AC_MSG_FAILURE([*** C99 support is mandatory])
49fi
223227c8 50AC_PROG_CXX
d38eae28 51AM_PROG_CC_C_O
f5bc67ee 52AC_PROG_LIBTOOL
fe80711e 53AC_PROG_LN_S
7ba4a183 54AC_PROG_EGREP
140e34f0 55AC_PROG_AWK
2acc1418 56
4b292b55
VB
57# Doxygen
58DX_HTML_FEATURE(ON)
59DX_DOT_FEATURE(OFF)
60DX_CHM_FEATURE(OFF)
61DX_CHI_FEATURE(OFF)
62DX_MAN_FEATURE(OFF)
63DX_RTF_FEATURE(OFF)
64DX_XML_FEATURE(OFF)
65DX_PDF_FEATURE(ON)
66DX_PS_FEATURE(OFF)
67DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
68
45e89c8c
VB
69# Check some compiler flags
70AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option])
c6d3aa0f 71AX_CFLAGS_GCC_OPTION([-fdiagnostics-color=auto])
45e89c8c
VB
72AX_CFLAGS_GCC_OPTION([-pipe])
73AX_CFLAGS_GCC_OPTION([-Wall])
74AX_CFLAGS_GCC_OPTION([-W])
75AX_CFLAGS_GCC_OPTION([-Wextra])
76AX_CFLAGS_GCC_OPTION([-Wformat])
77AX_CFLAGS_GCC_OPTION([-Wformat-security])
d56bb3bd 78AX_CFLAGS_GCC_OPTION([-Wfatal-errors])
45e89c8c
VB
79AX_CFLAGS_GCC_OPTION([-Wcast-align])
80AX_CFLAGS_GCC_OPTION([-Winline])
81AX_CFLAGS_GCC_OPTION([-fstack-protector])
8f109ee2 82AX_CFLAGS_GCC_OPTION([-fstack-protector-strong])
3ff9f162 83AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer])
a577598b 84AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [CPPFLAGS])
45e89c8c 85AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
d56bb3bd 86AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers])
45e89c8c 87AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
a37f8fd6
VB
88AX_LDFLAGS_OPTION([-Wl,-z,relro])
89AX_LDFLAGS_OPTION([-Wl,-z,now])
45e89c8c 90
e12c2365
VB
91# OS
92lldp_CHECK_OS
3dc1eb8c 93lldp_CFLAGS_OS
24b8d79f 94
8e4b9031
VB
95AC_CACHE_SAVE
96
d38eae28
VB
97# Checks for header files.
98AC_HEADER_RESOLV
396cfdfe 99AC_CHECK_HEADERS([valgrind/valgrind.h])
c3e340b6 100lldp_CHECK_STDINT
43c02e7b 101
8e4b9031
VB
102AC_CACHE_SAVE
103
43c02e7b 104# Checks for typedefs, structures, and compiler characteristics.
6bb9c4e0 105lldp_CHECK___PROGNAME
dd1d33cf 106lldp_CHECK_ALIGNOF
43c02e7b
VB
107
108# Checks for library functions.
4b292b55 109AC_CONFIG_LIBOBJ_DIR([src/compat])
d38eae28
VB
110AC_FUNC_MALLOC
111AC_FUNC_REALLOC
45bf0bd0 112AC_FUNC_FORK
554d650d 113# setproctitle (maybe through libbsd)
66879d46 114AC_SEARCH_LIBS([setproctitle], [util bsd])
1e0d651f
VB
115AC_REPLACE_FUNCS([setproctitle])
116AC_CHECK_FUNCS([setproctitle_init])
554d650d
VB
117# Other functions
118AC_REPLACE_FUNCS([strlcpy
119 strnlen
120 strndup
121 fgetln
122 asprintf
123 vsyslog
124 daemon])
125# Optional functions
8dab5698 126AC_CHECK_FUNCS([setresuid setresgid])
e66b7f34 127
66879d46
VB
128case " $LIBS " in
129 *\ -lbsd\ *)
130 AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used])
131 ;;
132esac
133
d0a03372
VB
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.
136m4_pushdef([AC_LANG_CALL(C)], [
137 AC_LANG_PROGRAM([$1
138@%:@include <resolv.h>], [return $2 ();])])
139AC_SEARCH_LIBS([res_init], resolv bind,
140 AC_DEFINE([HAVE_RES_INIT], 1,
141 [Define to indicate that res_init() exists]))
142m4_popdef([AC_LANG_CALL(C)])
e66b7f34 143
8e4b9031
VB
144AC_CACHE_SAVE
145
d38eae28
VB
146## Unit tests wich check
147PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
43c02e7b 148
e5c94652 149# Libevent
c461e5da 150lldp_CHECK_LIBEVENT
e5c94652 151
135ff0f7
VB
152# Compatibility with pkg.m4 < 0.27
153m4_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}])])
159
d38eae28
VB
160#######################
161### Options
43c02e7b 162
35f6f4fb
VB
163# Readline
164AC_ARG_WITH([readline],
165 AS_HELP_STRING(
166 [--with-readline],
fa9b12c5 167 [Enable the use of readline-like library @<:@default=auto@:>@]),
35f6f4fb 168 [],
fa9b12c5 169 [with_readline=auto])
35f6f4fb
VB
170if test x"$with_readline" != x"no"; then
171 AX_LIB_READLINE
fa9b12c5 172 if test x"$with_readline" != x"check" -a x"$with_readline" != x"auto"; then
35f6f4fb
VB
173 if test x"$ax_cv_lib_readline" = x"no"; then
174 AC_MSG_FAILURE([*** no readline support found])
175 fi
176 fi
177else
178 ax_cv_lib_readline="no"
179fi
180
d38eae28
VB
181# SNMP
182AC_ARG_WITH([snmp],
183 AS_HELP_STRING(
184 [--with-snmp],
fa9b12c5
VB
185 [Enable the use of SNMP @<:@default=no@:>@]),
186 [],
187 [with_snmp=no])
188lldp_CHECK_SNMP
315587ef 189
8beb9a73 190# XML
1480ce74 191AC_ARG_WITH([xml],
00e40dba 192 AS_HELP_STRING(
1480ce74 193 [--with-xml],
dd8c9fe3 194 [Enable XML output via libxml2 @<:@default=auto@:>@]),
fa9b12c5 195 [],
dd8c9fe3 196 [with_xml=auto])
fa9b12c5 197lldp_CHECK_XML2
1480ce74 198
8b7150e4
VB
199# JSON
200AC_ARG_WITH([json],
00e40dba 201 AS_HELP_STRING(
8b7150e4 202 [--with-json],
dd8c9fe3 203 [Enable JSON output via janson or json-c @<:@default=auto@:>@]),
fa9b12c5 204 [],
dd8c9fe3 205 [with_json=auto])
fa9b12c5
VB
206if test x"$with_json" = x"yes" -o x"$with_json" = x"auto"; then
207 _with_json="$with_json"
208 with_json=auto
209 lldp_CHECK_JANSSON
210 if test x"$with_json" = x"no"; then
211 with_json=auto
212 lldp_CHECK_JSONC
213 fi
214 if test x"$with_json" = x"no" -a x"$_with_json" = x"yes"; then
215 AC_MSG_FAILURE([*** no JSON support found])
216 fi
217else
8b7150e4 218 lldp_CHECK_JANSSON
8ff14a6d 219 lldp_CHECK_JSONC
8b7150e4
VB
220fi
221
00e40dba
VB
222# Seccomp
223AC_ARG_WITH([seccomp],
224 AS_HELP_STRING(
225 [--with-seccomp],
226 [Enable seccomp support (with libseccomp) @<:@default=no@:>@]),
227 [],
228 [with_seccomp=no])
229lldp_CHECK_SECCOMP
230
c3f85560 231# OS X launchd support
4dfe31fd
VB
232lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
233 [/Library/LaunchDaemons])
234AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
235AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
236 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
9d1524b7
VB
237
238# Systemd
239lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
29760896 240 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)])
4dfe31fd
VB
241AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
242AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
243 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
c3f85560 244
a9f77488
VB
245# sysusers
246lldp_ARG_WITH([sysusersdir], [Directory for sysusers files],
247 [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)])
248AC_SUBST([sysusersdir], [$with_sysusersdir])
249AM_CONDITIONAL(HAVE_SYSUSERSDIR,
250 [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ])
251
bdfe4193
VB
252# Systemtap/DTrace
253lldp_SYSTEMTAP
254
d38eae28 255# Privsep settings
71a7dbb3 256lldp_ARG_ENABLE([privsep], [Privilege separation], [yes])
d38eae28
VB
257lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
258lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
9a4ed64a
VB
259
260# Directories
261dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway
262if test "x$runstatedir" = x; then
263 AC_SUBST([runstatedir], ['${localstatedir}/run'])
264fi
265lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd])
3a3a3623 266lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
5133ce2f 267lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
89840df0 268
d38eae28
VB
269# CDP/FDP/EDP/SONMP
270lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
271lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
272lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
273lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
a1347cd8 274
d38eae28
VB
275# LLDPMED/Dot1/Dot3
276lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
277lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
278lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
a1347cd8 279
184bd199 280# Oldies
fda729fd 281lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.18], [no])
184bd199 282
d38eae28
VB
283#######################
284# Output results
d627ab69
VB
285AC_SUBST([LLDP_CFLAGS], [$CFLAGS])
286AC_SUBST([LLDP_CPPFLAGS], [$CPPFLAGS])
e6515ff5 287AC_SUBST([LLDP_LDFLAGS], [$LDFLAGS])
d627ab69 288CFLAGS=
e6515ff5
VB
289CPPFLAGS=
290LDFLAGS=
d38eae28
VB
291AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
292AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
1480ce74 293AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
8ff14a6d
MS
294AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"json-c" || test -x"$with_json" = x"jansson"])
295AM_CONDITIONAL([USE_JANSSON], [test x"$with_json" = x"jansson"])
296AM_CONDITIONAL([USE_JSONC], [test x"$with_json" = x"json-c"])
00e40dba 297AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
43c02e7b 298AC_OUTPUT
d38eae28 299
4c1a8c61 300if test x"$LIBEVENT_EMBEDDED" = x; then
e5c94652
VB
301 libevent=system
302else
303 libevent=embedded
304fi
305
d38eae28
VB
306cat <<EOF
307
308------------------ Summary ------------------
309 $PACKAGE_NAME version $PACKAGE_VERSION
91e0280a 310 OS.............: $os
d38eae28 311 Prefix.........: $prefix
d627ab69 312 C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS
e6515ff5 313 Linker.........: $LD $LLDP_LDFLAGS $LIBS
e5c94652 314 Libevent.......: $libevent
35f6f4fb 315 Readline.......: ${ax_cv_lib_readline}
d38eae28
VB
316 Optional features:
317 SNMP support...: ${with_snmp-no}
318 CDP............: $enable_cdp
319 FDP............: $enable_fdp
320 EDP............: $enable_edp
321 SONMP..........: $enable_sonmp
322 LLDPMED........: $enable_lldpmed
323 DOT1...........: $enable_dot1
324 DOT3...........: $enable_dot3
1480ce74 325 XML output.....: ${with_xml-no}
8b7150e4 326 JSON output....: ${with_json-no}
184bd199 327 Oldies support.: $enable_oldies
00e40dba 328 seccomp........: ${with_seccomp-no}
71a7dbb3
VB
329 Privilege separation:
330 Enabled........: $enable_privsep
08841844
VB
331 User/group.....: ${with_privsep_user}/${with_privsep_group}
332 Chroot.........: ${with_privsep_chroot}
d38eae28
VB
333---------------------------------------------
334
335Check the above options and compile with:
336 ${MAKE-make}
337
338EOF