]> git.ipfire.org Git - thirdparty/lldpd.git/blob - configure.ac
configure: enable compilation of a libevent archive
[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 dnl Use something like this if you need to patch autoconf files and
11 dnl regenerate configure outside upstream git tree:
12 dnl AC_INIT([lldpd], [0.5.7], [bernat@luffy.cx])
13 AC_INIT([lldpd],
14 [m4_esyscmd_s([git describe --tags --always 2> /dev/null || date +%F])],
15 [bernat@luffy.cx])
16
17 AC_CONFIG_SRCDIR([src/lldpd.c])
18 AC_CONFIG_HEADER([config.h])
19 AC_CONFIG_FILES([Makefile src/Makefile man/Makefile tests/Makefile])
20 AC_CONFIG_MACRO_DIR([m4])
21
22 # Configure automake
23 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
24 AM_MAINTAINER_MODE
25 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
26
27 # Configure libtool
28 #LT_PREREQ([2.2])
29 LT_INIT
30
31 #######################
32 ### Checks
33
34 # Checks for programs.
35 AC_PROG_AWK
36 AC_PROG_CC
37 AC_PROG_CPP
38 AC_PROG_INSTALL
39 AC_PROG_LN_S
40 AC_PROG_MAKE_SET
41 AC_PROG_CXX
42 AM_PROG_CC_C_O
43 AC_PROG_LIBTOOL
44
45 # Check some compiler flags
46 AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option])
47 AX_CFLAGS_GCC_OPTION([-std=gnu99])
48 AX_CFLAGS_GCC_OPTION([-pipe])
49 AX_CFLAGS_GCC_OPTION([-Wall])
50 AX_CFLAGS_GCC_OPTION([-W])
51 AX_CFLAGS_GCC_OPTION([-Wextra])
52 AX_CFLAGS_GCC_OPTION([-Wformat])
53 AX_CFLAGS_GCC_OPTION([-Wformat-security])
54 AX_CFLAGS_GCC_OPTION([-Wcast-align])
55 AX_CFLAGS_GCC_OPTION([-Winline])
56 AX_CFLAGS_GCC_OPTION([-fstack-protector])
57 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
58 AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
59 AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
60 AX_LDFLAGS_OPTION([-Wl,-z,relro])
61 AX_LDFLAGS_OPTION([-Wl,-z,now])
62
63 AC_CACHE_SAVE
64
65 # Checks for header files.
66 AC_HEADER_RESOLV
67 AC_CHECK_HEADERS([ \
68 arpa/inet.h \
69 fcntl.h \
70 malloc.h \
71 netdb.h \
72 netinet/in.h \
73 stdlib.h \
74 string.h \
75 sys/ioctl.h \
76 sys/param.h \
77 sys/socket.h \
78 sys/time.h \
79 sys/queue.h \
80 syslog.h \
81 unistd.h \
82 net/if.h \
83 linux/sockios.h \
84 ],,AC_MSG_ERROR([Required header missing.]))
85 AC_CHECK_HEADERS([ \
86 linux/wireless.h \
87 linux/if_bonding.h \
88 linux/if_bridge.h \
89 linux/if_packet.h \
90 ],,AC_MSG_ERROR([Required header missing.]),[
91 @%:@include <arpa/inet.h>
92 @%:@include <linux/if.h>
93 ])
94 AC_CHECK_HEADERS([ \
95 linux/filter.h \
96 ],,AC_MSG_ERROR([Required header missing.]),[
97 @%:@include <linux/types.h>
98 ])
99 AC_CHECK_HEADERS([ \
100 linux/if_vlan.h \
101 ],,AC_MSG_ERROR([You should get linux/if_vlan.h from some other place. See README file.]),[
102 @%:@include <arpa/inet.h>
103 @%:@include <linux/if.h>
104 ])
105 AC_CHECK_HEADERS([valgrind/valgrind.h])
106
107 AC_CACHE_SAVE
108
109 # Check for sys/queue.h completeness, missing bits will be in compat.h
110 AC_CHECK_DECLS([
111 TAILQ_FIRST,
112 TAILQ_NEXT,
113 TAILQ_FOREACH,
114 TAILQ_EMPTY,
115 SLIST_HEAD,
116 SLIST_ENTRY,
117 SLIST_INIT,
118 SLIST_INSERT_HEAD,
119 SLIST_FIRST,
120 SLIST_NEXT,
121 SLIST_REMOVE_HEAD,
122 SLIST_EMPTY],[],[],[[@%:@include <sys/queue.h>]])
123
124 # On some systems, some ioctl are not declared
125 AC_CHECK_DECLS([
126 SIOCGIFVLAN,
127 SIOCBONDINFOQUERY,
128 SIOCBONDSLAVEINFOQUERY],[],[],[[@%:@include <linux/sockios.h>]])
129 AC_CHECK_MEMBERS([ifslave.slave_name, ifbond.num_slaves], [],
130 [AC_MSG_ERROR([linux/if_bonding.h is incomplete. See README file.])],
131 [
132 @%:@include <arpa/inet.h>
133 @%:@include <linux/if.h>
134 @%:@include <linux/if_bonding.h>
135 ])
136
137 # Do we have PACKET_ORIGDEV (it can be present at runtime, put it in compat.h)
138 AC_CHECK_DECLS([PACKET_ORIGDEV],[],[],[[@%:@include <linux/if_packet.h>]])
139
140 # Check for ethtool stuff
141 lldp_CHECK_HEADER_ETHTOOL
142 AC_CHECK_DECLS([
143 ADVERTISED_2500baseX_Full,
144 ADVERTISED_Pause,
145 ADVERTISED_Asym_Pause,
146 ADVERTISED_10000baseT_Full,
147 SPEED_10000],[],[],[[@%:@include <linux/ethtool.h>]])
148
149 # Check for ETHERTYPE_VLAN, put it in compat.h if not defined
150 AC_CHECK_DECLS([ETHERTYPE_VLAN],[],[],[[@%:@include <net/ethernet.h>]])
151
152 # Check some stuff in linux/if_vlan.h
153 AC_CHECK_DECLS([GET_VLAN_REALDEV_NAME_CMD,GET_VLAN_VID_CMD],[],[],
154 [[@%:@include <linux/if_vlan.h>]])
155
156 AC_CACHE_SAVE
157
158 # Checks for typedefs, structures, and compiler characteristics.
159 AC_TYPE_UID_T
160 AC_C_INLINE
161 AC_TYPE_INT16_T
162 AC_TYPE_INT32_T
163 AC_TYPE_PID_T
164 AC_TYPE_SIZE_T
165 AC_TYPE_SSIZE_T
166 AC_TYPE_UINT16_T
167 AC_TYPE_UINT32_T
168 AC_TYPE_UINT8_T
169 lldp_CHECK___PROGNAME
170 lldp_CHECK_FD_SETSIZE
171
172 # Checks for library functions.
173 AC_FUNC_CHOWN
174 AC_FUNC_FORK
175 AC_FUNC_MALLOC
176 AC_FUNC_REALLOC
177 AC_CHECK_FUNCS([ \
178 atexit \
179 gethostbyname \
180 inet_ntoa memset \
181 regcomp \
182 select \
183 setenv \
184 socket \
185 strchr \
186 strdup \
187 strerror \
188 strndup \
189 tzset \
190 uname \
191 ],,[AC_MSG_ERROR(Required function not found.)])
192
193 AC_REPLACE_FUNCS([strlcpy])
194 AC_REPLACE_FUNCS([getifaddrs])
195
196 AC_CACHE_SAVE
197
198 ## Unit tests wich check
199 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
200
201 #######################
202 ### Options
203
204 # SNMP
205 AC_ARG_WITH([snmp],
206 AS_HELP_STRING(
207 [--with-snmp],
208 [Enable the use of SNMP @<:@default=no@:>@]
209 ))
210 if test x"$with_snmp" = x"yes"; then
211 lldp_CHECK_SNMP
212 fi
213
214 # XML
215 AC_ARG_WITH([xml],
216 AC_HELP_STRING(
217 [--with-xml],
218 [Enable XML output via libxml2 @<:@default=no@:>@]
219 ))
220 if test x"$with_xml" = x"yes"; then
221 lldp_CHECK_XML2
222 fi
223
224 # Libevent
225 lldp_ARG_WITH([libevent], [Location of libevent directory, la or archive], [])
226 lldp_CHECK_LIBEVENT([$with_libevent])
227
228 # Privsep settings
229 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
230 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
231 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [/var/run/lldpd])
232
233 # CDP/FDP/EDP/SONMP
234 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
235 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
236 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
237 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
238
239 # LLDPMED/Dot1/Dot3
240 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
241 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
242 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
243
244 #######################
245 # Output results
246 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
247 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
248 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
249 AC_OUTPUT
250
251 cat <<EOF
252
253 ------------------ Summary ------------------
254 $PACKAGE_NAME version $PACKAGE_VERSION
255 Prefix.........: $prefix
256 C Compiler.....: $CC $CFLAGS $CPPFLAGS
257 Linker.........: $LD $LDFLAGS $LIBS
258 Optional features:
259 SNMP support...: ${with_snmp-no}
260 CDP............: $enable_cdp
261 FDP............: $enable_fdp
262 EDP............: $enable_edp
263 SONMP..........: $enable_sonmp
264 LLDPMED........: $enable_lldpmed
265 DOT1...........: $enable_dot1
266 DOT3...........: $enable_dot3
267 XML output.....: ${with_xml-no}
268 ---------------------------------------------
269
270 Check the above options and compile with:
271 ${MAKE-make}
272
273 EOF