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