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