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