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