]> git.ipfire.org Git - thirdparty/lldpd.git/blob - configure.ac
configure: cleanup libevent integration
[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_CC
36 AC_PROG_CXX
37 AM_PROG_CC_C_O
38 AC_PROG_LIBTOOL
39
40 # Check some compiler flags
41 AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option])
42 AX_CFLAGS_GCC_OPTION([-std=gnu99])
43 AX_CFLAGS_GCC_OPTION([-pipe])
44 AX_CFLAGS_GCC_OPTION([-Wall])
45 AX_CFLAGS_GCC_OPTION([-W])
46 AX_CFLAGS_GCC_OPTION([-Wextra])
47 AX_CFLAGS_GCC_OPTION([-Wformat])
48 AX_CFLAGS_GCC_OPTION([-Wformat-security])
49 AX_CFLAGS_GCC_OPTION([-Wcast-align])
50 AX_CFLAGS_GCC_OPTION([-Winline])
51 AX_CFLAGS_GCC_OPTION([-fstack-protector])
52 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
53 AX_CFLAGS_GCC_OPTION([-Wdeclaration-after-statement])
54 AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
55 AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
56 AX_LDFLAGS_OPTION([-Wl,-z,relro])
57 AX_LDFLAGS_OPTION([-Wl,-z,now])
58
59 AC_CACHE_SAVE
60
61 # Checks for header files.
62 AC_HEADER_RESOLV
63 AC_CHECK_HEADERS([valgrind/valgrind.h])
64
65 # Check for sys/queue.h completeness, missing bits will be in compat.h
66 AC_CHECK_DECLS([
67 TAILQ_FIRST,
68 TAILQ_NEXT,
69 TAILQ_FOREACH,
70 TAILQ_EMPTY],[],[],[[@%:@include <sys/queue.h>]])
71
72 # On some systems, some ioctl are not declared
73 AC_CHECK_DECLS([
74 SIOCGIFVLAN,
75 SIOCBONDINFOQUERY,
76 SIOCBONDSLAVEINFOQUERY],[],[],[[@%:@include <linux/sockios.h>]])
77 AC_CHECK_MEMBERS([ifslave.slave_name, ifbond.num_slaves], [],
78 [AC_MSG_ERROR([linux/if_bonding.h is incomplete. See README file.])],
79 [
80 @%:@include <arpa/inet.h>
81 @%:@include <linux/if.h>
82 @%:@include <linux/if_bonding.h>
83 ])
84
85 # Do we have PACKET_ORIGDEV (it can be present at runtime, put it in compat.h)
86 AC_CHECK_DECLS([PACKET_ORIGDEV],[],[],[[@%:@include <linux/if_packet.h>]])
87
88 # Check for ethtool stuff
89 lldp_CHECK_HEADER_ETHTOOL
90 AC_CHECK_DECLS([
91 ADVERTISED_2500baseX_Full,
92 ADVERTISED_Pause,
93 ADVERTISED_Asym_Pause,
94 ADVERTISED_10000baseT_Full,
95 SPEED_10000],[],[],[[@%:@include <linux/ethtool.h>]])
96
97 # Check for ETHERTYPE_VLAN, put it in compat.h if not defined
98 AC_CHECK_DECLS([ETHERTYPE_VLAN],[],[],[[@%:@include <net/ethernet.h>]])
99
100 # Check some stuff in linux/if_vlan.h
101 AC_CHECK_HEADERS([ \
102 linux/if_vlan.h \
103 ],,AC_MSG_ERROR([You should get linux/if_vlan.h from some other place. See README file.]),[
104 @%:@include <arpa/inet.h>
105 @%:@include <linux/if.h>
106 ])
107 AC_CHECK_DECLS([GET_VLAN_REALDEV_NAME_CMD,GET_VLAN_VID_CMD],[],[],
108 [[@%:@include <linux/if_vlan.h>]])
109
110 AC_CACHE_SAVE
111
112 # Checks for typedefs, structures, and compiler characteristics.
113 lldp_CHECK___PROGNAME
114
115 # Checks for library functions.
116 AC_FUNC_MALLOC
117 AC_FUNC_REALLOC
118 AC_REPLACE_FUNCS([strlcpy])
119 AC_REPLACE_FUNCS([getifaddrs])
120 AC_CACHE_SAVE
121
122 ## Unit tests wich check
123 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
124
125 # Libevent
126 lldp_CHECK_LIBEVENT
127
128 #######################
129 ### Options
130
131 # SNMP
132 AC_ARG_WITH([snmp],
133 AS_HELP_STRING(
134 [--with-snmp],
135 [Enable the use of SNMP @<:@default=no@:>@]
136 ))
137 if test x"$with_snmp" = x"yes"; then
138 lldp_CHECK_SNMP
139 fi
140
141 # XML
142 AC_ARG_WITH([xml],
143 AC_HELP_STRING(
144 [--with-xml],
145 [Enable XML output via libxml2 @<:@default=no@:>@]
146 ))
147 if test x"$with_xml" = x"yes"; then
148 lldp_CHECK_XML2
149 fi
150
151 # Privsep settings
152 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
153 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
154 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [/var/run/lldpd])
155
156 # CDP/FDP/EDP/SONMP
157 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
158 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
159 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
160 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
161
162 # LLDPMED/Dot1/Dot3
163 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
164 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
165 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
166
167 #######################
168 # Output results
169 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
170 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
171 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
172 AC_OUTPUT
173
174 if test x"$LIBEVENT_LDFLAGS" = x; then
175 libevent=system
176 else
177 libevent=embedded
178 fi
179
180 cat <<EOF
181
182 ------------------ Summary ------------------
183 $PACKAGE_NAME version $PACKAGE_VERSION
184 Prefix.........: $prefix
185 C Compiler.....: $CC $CFLAGS $CPPFLAGS
186 Linker.........: $LD $LDFLAGS $LIBS
187 Libevent.......: $libevent
188 Optional features:
189 SNMP support...: ${with_snmp-no}
190 CDP............: $enable_cdp
191 FDP............: $enable_fdp
192 EDP............: $enable_edp
193 SONMP..........: $enable_sonmp
194 LLDPMED........: $enable_lldpmed
195 DOT1...........: $enable_dot1
196 DOT3...........: $enable_dot3
197 XML output.....: ${with_xml-no}
198 ---------------------------------------------
199
200 Check the above options and compile with:
201 ${MAKE-make}
202
203 EOF