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