]>
Commit | Line | Data |
---|---|---|
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 | |
8 | AC_PREREQ([2.64]) | |
4593c0dc | 9 | |
4593c0dc | 10 | AC_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 | 16 | AC_CONFIG_SRCDIR([src/log.c]) |
43c02e7b | 17 | AC_CONFIG_HEADER([config.h]) |
95493844 VB |
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]) | |
2acc1418 | 26 | AC_CONFIG_MACRO_DIR([m4]) |
fa71a00c | 27 | AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args]) |
43c02e7b | 28 | |
d38eae28 VB |
29 | # Configure automake |
30 | AM_INIT_AUTOMAKE([foreign -Wall -Werror]) | |
33aa26d0 | 31 | AM_MAINTAINER_MODE |
44cd2bed | 32 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)]) |
d38eae28 | 33 | |
0339b9a2 VB |
34 | # Automake 1.12... |
35 | m4_pattern_allow([AM_PROG_AR]) | |
36 | AM_PROG_AR | |
37 | ||
d38eae28 | 38 | # Configure libtool |
d38eae28 VB |
39 | LT_INIT |
40 | ||
41 | ####################### | |
42 | ### Checks | |
43 | ||
43c02e7b VB |
44 | # Checks for programs. |
45 | AC_PROG_CC | |
6c586123 | 46 | AC_PROG_CC_C99 |
223227c8 | 47 | AC_PROG_CXX |
d38eae28 | 48 | AM_PROG_CC_C_O |
f5bc67ee | 49 | AC_PROG_LIBTOOL |
fe80711e | 50 | AC_PROG_LN_S |
7ba4a183 | 51 | AC_PROG_EGREP |
140e34f0 | 52 | AC_PROG_AWK |
2acc1418 | 53 | |
4b292b55 VB |
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 | ||
45e89c8c VB |
66 | # Check some compiler flags |
67 | AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option]) | |
c6d3aa0f | 68 | AX_CFLAGS_GCC_OPTION([-fdiagnostics-color=auto]) |
45e89c8c VB |
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]) | |
d56bb3bd | 75 | AX_CFLAGS_GCC_OPTION([-Wfatal-errors]) |
45e89c8c VB |
76 | AX_CFLAGS_GCC_OPTION([-Wcast-align]) |
77 | AX_CFLAGS_GCC_OPTION([-Winline]) | |
78 | AX_CFLAGS_GCC_OPTION([-fstack-protector]) | |
8f109ee2 | 79 | AX_CFLAGS_GCC_OPTION([-fstack-protector-strong]) |
3ff9f162 | 80 | AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer]) |
45e89c8c VB |
81 | AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2]) |
82 | AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter]) | |
d56bb3bd | 83 | AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers]) |
45e89c8c | 84 | AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later |
a37f8fd6 VB |
85 | AX_LDFLAGS_OPTION([-Wl,-z,relro]) |
86 | AX_LDFLAGS_OPTION([-Wl,-z,now]) | |
45e89c8c | 87 | |
e12c2365 VB |
88 | # OS |
89 | lldp_CHECK_OS | |
3dc1eb8c | 90 | lldp_CFLAGS_OS |
24b8d79f | 91 | |
8e4b9031 VB |
92 | AC_CACHE_SAVE |
93 | ||
d38eae28 VB |
94 | # Checks for header files. |
95 | AC_HEADER_RESOLV | |
396cfdfe | 96 | AC_CHECK_HEADERS([valgrind/valgrind.h]) |
c3e340b6 | 97 | lldp_CHECK_STDINT |
43c02e7b | 98 | |
8e4b9031 VB |
99 | AC_CACHE_SAVE |
100 | ||
43c02e7b | 101 | # Checks for typedefs, structures, and compiler characteristics. |
6bb9c4e0 | 102 | lldp_CHECK___PROGNAME |
dd1d33cf | 103 | lldp_CHECK_ALIGNOF |
43c02e7b VB |
104 | |
105 | # Checks for library functions. | |
4b292b55 | 106 | AC_CONFIG_LIBOBJ_DIR([src/compat]) |
d38eae28 VB |
107 | AC_FUNC_MALLOC |
108 | AC_FUNC_REALLOC | |
45bf0bd0 | 109 | AC_FUNC_FORK |
554d650d | 110 | # setproctitle (maybe through libbsd) |
66879d46 | 111 | AC_SEARCH_LIBS([setproctitle], [util bsd]) |
1e0d651f VB |
112 | AC_REPLACE_FUNCS([setproctitle]) |
113 | AC_CHECK_FUNCS([setproctitle_init]) | |
554d650d VB |
114 | # Other functions |
115 | AC_REPLACE_FUNCS([strlcpy | |
116 | strnlen | |
117 | strndup | |
118 | fgetln | |
119 | asprintf | |
120 | vsyslog | |
121 | daemon]) | |
122 | # Optional functions | |
8dab5698 | 123 | AC_CHECK_FUNCS([setresuid setresgid]) |
e66b7f34 | 124 | |
66879d46 VB |
125 | case " $LIBS " in |
126 | *\ -lbsd\ *) | |
127 | AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used]) | |
128 | ;; | |
129 | esac | |
130 | ||
d0a03372 VB |
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)]) | |
e66b7f34 | 140 | |
8e4b9031 VB |
141 | AC_CACHE_SAVE |
142 | ||
d38eae28 VB |
143 | ## Unit tests wich check |
144 | PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no]) | |
43c02e7b | 145 | |
e5c94652 | 146 | # Libevent |
c461e5da | 147 | lldp_CHECK_LIBEVENT |
e5c94652 | 148 | |
135ff0f7 VB |
149 | # Compatibility with pkg.m4 < 0.27 |
150 | m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], | |
151 | [AC_ARG_WITH([pkgconfigdir], | |
152 | [AS_HELP_STRING([--with-pkgconfigdir], | |
153 | [install directory for *.pc pkg-config file])], | |
154 | [],[with_pkgconfigdir='$(libdir)/pkgconfig']) | |
155 | AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])]) | |
156 | ||
d38eae28 VB |
157 | ####################### |
158 | ### Options | |
43c02e7b | 159 | |
35f6f4fb VB |
160 | # Readline |
161 | AC_ARG_WITH([readline], | |
162 | AS_HELP_STRING( | |
163 | [--with-readline], | |
164 | [Enable the use of readline-like library @<:@default=check@:>@]), | |
165 | [], | |
166 | [with_readline=check]) | |
167 | if test x"$with_readline" != x"no"; then | |
168 | AX_LIB_READLINE | |
169 | if test x"$with_readline" != x"check"; then | |
170 | if test x"$ax_cv_lib_readline" = x"no"; then | |
171 | AC_MSG_FAILURE([*** no readline support found]) | |
172 | fi | |
173 | fi | |
174 | else | |
175 | ax_cv_lib_readline="no" | |
176 | fi | |
177 | ||
d38eae28 VB |
178 | # SNMP |
179 | AC_ARG_WITH([snmp], | |
180 | AS_HELP_STRING( | |
181 | [--with-snmp], | |
182 | [Enable the use of SNMP @<:@default=no@:>@] | |
183 | )) | |
184 | if test x"$with_snmp" = x"yes"; then | |
185 | lldp_CHECK_SNMP | |
315587ef VB |
186 | fi |
187 | ||
8beb9a73 | 188 | # XML |
1480ce74 | 189 | AC_ARG_WITH([xml], |
00e40dba | 190 | AS_HELP_STRING( |
1480ce74 | 191 | [--with-xml], |
5a9cb3db | 192 | [Enable XML output via libxml2 @<:@default=no@:>@] |
1480ce74 AH |
193 | )) |
194 | if test x"$with_xml" = x"yes"; then | |
195 | lldp_CHECK_XML2 | |
196 | fi | |
197 | ||
8b7150e4 VB |
198 | # JSON |
199 | AC_ARG_WITH([json], | |
00e40dba | 200 | AS_HELP_STRING( |
8b7150e4 | 201 | [--with-json], |
8ff14a6d | 202 | [Enable JSON output via janson,json-c,no @<:@default=no@:>@] |
8b7150e4 | 203 | )) |
71542b4e VB |
204 | if test x"$with_json" = x"yes"; then |
205 | with_json=jansson | |
206 | fi | |
8ff14a6d | 207 | if test x"$with_json" = x"jansson"; then |
8b7150e4 | 208 | lldp_CHECK_JANSSON |
8ff14a6d MS |
209 | elif test x"$with_json" = x"json-c"; then |
210 | lldp_CHECK_JSONC | |
8b7150e4 VB |
211 | fi |
212 | ||
00e40dba VB |
213 | # Seccomp |
214 | AC_ARG_WITH([seccomp], | |
215 | AS_HELP_STRING( | |
216 | [--with-seccomp], | |
217 | [Enable seccomp support (with libseccomp) @<:@default=no@:>@]), | |
218 | [], | |
219 | [with_seccomp=no]) | |
220 | lldp_CHECK_SECCOMP | |
221 | ||
c3f85560 | 222 | # OS X launchd support |
4dfe31fd VB |
223 | lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)], |
224 | [/Library/LaunchDaemons]) | |
225 | AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir]) | |
226 | AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR, | |
227 | [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ]) | |
9d1524b7 VB |
228 | |
229 | # Systemd | |
230 | lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files], | |
29760896 | 231 | [$($PKG_CONFIG --variable=systemdsystemunitdir systemd 2> /dev/null)]) |
4dfe31fd VB |
232 | AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) |
233 | AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR, | |
234 | [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) | |
c3f85560 | 235 | |
a9f77488 VB |
236 | # sysusers |
237 | lldp_ARG_WITH([sysusersdir], [Directory for sysusers files], | |
238 | [$($PKG_CONFIG --variable=sysusersdir systemd 2> /dev/null)]) | |
239 | AC_SUBST([sysusersdir], [$with_sysusersdir]) | |
240 | AM_CONDITIONAL(HAVE_SYSUSERSDIR, | |
241 | [test -n "$with_sysusersdir" -a "x$with_sysusersdir" != xno ]) | |
242 | ||
bdfe4193 VB |
243 | # Systemtap/DTrace |
244 | lldp_SYSTEMTAP | |
245 | ||
d38eae28 | 246 | # Privsep settings |
71a7dbb3 | 247 | lldp_ARG_ENABLE([privsep], [Privilege separation], [yes]) |
d38eae28 VB |
248 | lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd]) |
249 | lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd]) | |
9a4ed64a VB |
250 | |
251 | # Directories | |
252 | dnl On autoconf 2.69 and before, runstatedir is not configurable, let be able to use it anyway | |
253 | if test "x$runstatedir" = x; then | |
254 | AC_SUBST([runstatedir], ['${localstatedir}/run']) | |
255 | fi | |
256 | lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${runstatedir}/lldpd]) | |
3a3a3623 | 257 | lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket]) |
5133ce2f | 258 | lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid]) |
89840df0 | 259 | |
d38eae28 VB |
260 | # CDP/FDP/EDP/SONMP |
261 | lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes]) | |
262 | lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes]) | |
263 | lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes]) | |
264 | lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes]) | |
a1347cd8 | 265 | |
d38eae28 VB |
266 | # LLDPMED/Dot1/Dot3 |
267 | lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes]) | |
268 | lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes]) | |
269 | lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes]) | |
a1347cd8 | 270 | |
184bd199 | 271 | # Oldies |
fda729fd | 272 | lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.18], [no]) |
184bd199 | 273 | |
d38eae28 VB |
274 | ####################### |
275 | # Output results | |
276 | AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"]) | |
277 | AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"]) | |
1480ce74 | 278 | AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"]) |
8ff14a6d MS |
279 | AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"json-c" || test -x"$with_json" = x"jansson"]) |
280 | AM_CONDITIONAL([USE_JANSSON], [test x"$with_json" = x"jansson"]) | |
281 | AM_CONDITIONAL([USE_JSONC], [test x"$with_json" = x"json-c"]) | |
00e40dba | 282 | AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"]) |
43c02e7b | 283 | AC_OUTPUT |
d38eae28 | 284 | |
4c1a8c61 | 285 | if test x"$LIBEVENT_EMBEDDED" = x; then |
e5c94652 VB |
286 | libevent=system |
287 | else | |
288 | libevent=embedded | |
289 | fi | |
290 | ||
d38eae28 VB |
291 | cat <<EOF |
292 | ||
293 | ------------------ Summary ------------------ | |
294 | $PACKAGE_NAME version $PACKAGE_VERSION | |
91e0280a | 295 | OS.............: $os |
d38eae28 VB |
296 | Prefix.........: $prefix |
297 | C Compiler.....: $CC $CFLAGS $CPPFLAGS | |
298 | Linker.........: $LD $LDFLAGS $LIBS | |
e5c94652 | 299 | Libevent.......: $libevent |
35f6f4fb | 300 | Readline.......: ${ax_cv_lib_readline} |
d38eae28 VB |
301 | Optional features: |
302 | SNMP support...: ${with_snmp-no} | |
303 | CDP............: $enable_cdp | |
304 | FDP............: $enable_fdp | |
305 | EDP............: $enable_edp | |
306 | SONMP..........: $enable_sonmp | |
307 | LLDPMED........: $enable_lldpmed | |
308 | DOT1...........: $enable_dot1 | |
309 | DOT3...........: $enable_dot3 | |
1480ce74 | 310 | XML output.....: ${with_xml-no} |
8b7150e4 | 311 | JSON output....: ${with_json-no} |
184bd199 | 312 | Oldies support.: $enable_oldies |
00e40dba | 313 | seccomp........: ${with_seccomp-no} |
71a7dbb3 VB |
314 | Privilege separation: |
315 | Enabled........: $enable_privsep | |
08841844 VB |
316 | User/group.....: ${with_privsep_user}/${with_privsep_group} |
317 | Chroot.........: ${with_privsep_chroot} | |
d38eae28 VB |
318 | --------------------------------------------- |
319 | ||
320 | Check the above options and compile with: | |
321 | ${MAKE-make} | |
322 | ||
323 | EOF |