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