]> git.ipfire.org Git - thirdparty/lldpd.git/blame - configure.ac
systemd: use full path for mkdir/cp
[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])],
4593c0dc
VB
12 [bernat@luffy.cx])
13
4b292b55 14AC_CONFIG_SRCDIR([src/log.c])
43c02e7b 15AC_CONFIG_HEADER([config.h])
4b292b55
VB
16AC_CONFIG_FILES([Makefile src/Makefile src/compat/Makefile src/daemon/Makefile
17 src/lib/Makefile src/lib/lldpctl.pc src/client/Makefile
e9f4d63c
VB
18 tests/Makefile])
19AC_CONFIG_FILES([osx/Makefile osx/distribution.xml osx/im.bernat.lldpd.plist])
20AC_CONFIG_FILES([osx/scripts/preinstall], [chmod +x osx/scripts/preinstall])
21AC_CONFIG_FILES([osx/scripts/postinstall], [chmod +x osx/scripts/postinstall])
9d1524b7 22AC_CONFIG_FILES([src/daemon/lldpd.service])
2acc1418 23AC_CONFIG_MACRO_DIR([m4])
fa71a00c 24AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
43c02e7b 25
d38eae28
VB
26# Configure automake
27AM_INIT_AUTOMAKE([foreign -Wall -Werror])
33aa26d0 28AM_MAINTAINER_MODE
44cd2bed 29m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
d38eae28 30
0339b9a2
VB
31# Automake 1.12...
32m4_pattern_allow([AM_PROG_AR])
33AM_PROG_AR
34
d38eae28 35# Configure libtool
d38eae28
VB
36LT_INIT
37
38#######################
39### Checks
40
43c02e7b
VB
41# Checks for programs.
42AC_PROG_CC
6c586123 43AC_PROG_CC_C99
223227c8 44AC_PROG_CXX
d38eae28 45AM_PROG_CC_C_O
f5bc67ee 46AC_PROG_LIBTOOL
fe80711e 47AC_PROG_LN_S
7ba4a183 48AC_PROG_EGREP
140e34f0 49AC_PROG_AWK
2acc1418 50
4b292b55
VB
51# Doxygen
52DX_HTML_FEATURE(ON)
53DX_DOT_FEATURE(OFF)
54DX_CHM_FEATURE(OFF)
55DX_CHI_FEATURE(OFF)
56DX_MAN_FEATURE(OFF)
57DX_RTF_FEATURE(OFF)
58DX_XML_FEATURE(OFF)
59DX_PDF_FEATURE(ON)
60DX_PS_FEATURE(OFF)
61DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
62
45e89c8c
VB
63# Check some compiler flags
64AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option])
45e89c8c
VB
65AX_CFLAGS_GCC_OPTION([-pipe])
66AX_CFLAGS_GCC_OPTION([-Wall])
67AX_CFLAGS_GCC_OPTION([-W])
68AX_CFLAGS_GCC_OPTION([-Wextra])
69AX_CFLAGS_GCC_OPTION([-Wformat])
70AX_CFLAGS_GCC_OPTION([-Wformat-security])
d56bb3bd 71AX_CFLAGS_GCC_OPTION([-Wfatal-errors])
45e89c8c
VB
72AX_CFLAGS_GCC_OPTION([-Wcast-align])
73AX_CFLAGS_GCC_OPTION([-Winline])
74AX_CFLAGS_GCC_OPTION([-fstack-protector])
75AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
76AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
d56bb3bd 77AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers])
45e89c8c 78AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
a37f8fd6
VB
79AX_LDFLAGS_OPTION([-Wl,-z,relro])
80AX_LDFLAGS_OPTION([-Wl,-z,now])
45e89c8c 81
e12c2365
VB
82# OS
83lldp_CHECK_OS
84
8e4b9031
VB
85AC_CACHE_SAVE
86
d38eae28
VB
87# Checks for header files.
88AC_HEADER_RESOLV
396cfdfe 89AC_CHECK_HEADERS([valgrind/valgrind.h])
c3e340b6 90lldp_CHECK_STDINT
43c02e7b 91
8e4b9031
VB
92AC_CACHE_SAVE
93
43c02e7b 94# Checks for typedefs, structures, and compiler characteristics.
6bb9c4e0 95lldp_CHECK___PROGNAME
43c02e7b
VB
96
97# Checks for library functions.
4b292b55 98AC_CONFIG_LIBOBJ_DIR([src/compat])
d38eae28
VB
99AC_FUNC_MALLOC
100AC_FUNC_REALLOC
66879d46 101AC_SEARCH_LIBS([setproctitle], [util bsd])
1e0d651f
VB
102AC_REPLACE_FUNCS([setproctitle])
103AC_CHECK_FUNCS([setproctitle_init])
104AC_REPLACE_FUNCS([strlcpy strnlen strndup fgetln])
8dab5698 105AC_CHECK_FUNCS([setresuid setresgid])
e66b7f34 106
66879d46
VB
107case " $LIBS " in
108 *\ -lbsd\ *)
109 AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used])
110 ;;
111esac
112
d0a03372
VB
113# Check for res_init. On OSX, res_init is a symbol in libsystem_info
114# and a macro in resolv.h. We need to ensure we test with resolv.h.
115m4_pushdef([AC_LANG_CALL(C)], [
116 AC_LANG_PROGRAM([$1
117@%:@include <resolv.h>], [return $2 ();])])
118AC_SEARCH_LIBS([res_init], resolv bind,
119 AC_DEFINE([HAVE_RES_INIT], 1,
120 [Define to indicate that res_init() exists]))
121m4_popdef([AC_LANG_CALL(C)])
e66b7f34 122
8e4b9031
VB
123AC_CACHE_SAVE
124
d38eae28
VB
125## Unit tests wich check
126PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
43c02e7b 127
e5c94652 128# Libevent
c461e5da 129lldp_CHECK_LIBEVENT
e5c94652 130
d38eae28
VB
131#######################
132### Options
43c02e7b 133
35f6f4fb
VB
134# Readline
135AC_ARG_WITH([readline],
136 AS_HELP_STRING(
137 [--with-readline],
138 [Enable the use of readline-like library @<:@default=check@:>@]),
139 [],
140 [with_readline=check])
141if test x"$with_readline" != x"no"; then
142 AX_LIB_READLINE
143 if test x"$with_readline" != x"check"; then
144 if test x"$ax_cv_lib_readline" = x"no"; then
145 AC_MSG_FAILURE([*** no readline support found])
146 fi
147 fi
148else
149 ax_cv_lib_readline="no"
150fi
151
d38eae28
VB
152# SNMP
153AC_ARG_WITH([snmp],
154 AS_HELP_STRING(
155 [--with-snmp],
156 [Enable the use of SNMP @<:@default=no@:>@]
157 ))
158if test x"$with_snmp" = x"yes"; then
159 lldp_CHECK_SNMP
315587ef
VB
160fi
161
8beb9a73 162# XML
1480ce74
AH
163AC_ARG_WITH([xml],
164 AC_HELP_STRING(
165 [--with-xml],
5a9cb3db 166 [Enable XML output via libxml2 @<:@default=no@:>@]
1480ce74
AH
167 ))
168if test x"$with_xml" = x"yes"; then
169 lldp_CHECK_XML2
170fi
171
8b7150e4
VB
172# JSON
173AC_ARG_WITH([json],
174 AC_HELP_STRING(
175 [--with-json],
176 [Enable JSON output via Jansson @<:@default=no@:>@]
177 ))
178if test x"$with_json" = x"yes"; then
179 lldp_CHECK_JANSSON
180fi
181
c3f85560 182# OS X launchd support
4dfe31fd
VB
183lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)],
184 [/Library/LaunchDaemons])
185AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir])
186AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR,
187 [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ])
9d1524b7
VB
188
189# Systemd
190lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files],
4dfe31fd
VB
191 [$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
192AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
193AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR,
194 [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
c3f85560 195
bdfe4193
VB
196# Systemtap/DTrace
197lldp_SYSTEMTAP
198
d38eae28
VB
199# Privsep settings
200lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
201lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
202lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [/var/run/lldpd])
89840df0 203
d38eae28
VB
204# CDP/FDP/EDP/SONMP
205lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
206lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
207lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
208lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
a1347cd8 209
d38eae28
VB
210# LLDPMED/Dot1/Dot3
211lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
212lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
213lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
a1347cd8 214
184bd199 215# Oldies
fda729fd 216lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.18], [no])
184bd199 217
d38eae28
VB
218#######################
219# Output results
220AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
221AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
1480ce74 222AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
8b7150e4 223AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"yes"])
43c02e7b 224AC_OUTPUT
d38eae28 225
4c1a8c61 226if test x"$LIBEVENT_EMBEDDED" = x; then
e5c94652
VB
227 libevent=system
228else
229 libevent=embedded
230fi
231
d38eae28
VB
232cat <<EOF
233
234------------------ Summary ------------------
235 $PACKAGE_NAME version $PACKAGE_VERSION
91e0280a 236 OS.............: $os
d38eae28
VB
237 Prefix.........: $prefix
238 C Compiler.....: $CC $CFLAGS $CPPFLAGS
239 Linker.........: $LD $LDFLAGS $LIBS
e5c94652 240 Libevent.......: $libevent
35f6f4fb 241 Readline.......: ${ax_cv_lib_readline}
d38eae28
VB
242 Optional features:
243 SNMP support...: ${with_snmp-no}
244 CDP............: $enable_cdp
245 FDP............: $enable_fdp
246 EDP............: $enable_edp
247 SONMP..........: $enable_sonmp
248 LLDPMED........: $enable_lldpmed
249 DOT1...........: $enable_dot1
250 DOT3...........: $enable_dot3
1480ce74 251 XML output.....: ${with_xml-no}
8b7150e4 252 JSON output....: ${with_json-no}
184bd199 253 Oldies support.: $enable_oldies
d38eae28
VB
254---------------------------------------------
255
256Check the above options and compile with:
257 ${MAKE-make}
258
259EOF