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