]> git.ipfire.org Git - thirdparty/lldpd.git/blame - configure.ac
build: make autogen.sh a little bit more generic
[thirdparty/lldpd.git] / configure.ac
CommitLineData
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
8AC_PREREQ([2.64])
4593c0dc
VB
9
10dnl Use something like this if you need to patch autoconf files and
11dnl regenerate configure outside upstream git tree:
12dnl AC_INIT([lldpd], [0.5.7], [bernat@luffy.cx])
13AC_INIT([lldpd],
14 [m4_esyscmd_s([git describe --tags --always 2> /dev/null || date +%F])],
15 [bernat@luffy.cx])
16
4b292b55 17AC_CONFIG_SRCDIR([src/log.c])
43c02e7b 18AC_CONFIG_HEADER([config.h])
4b292b55
VB
19AC_CONFIG_FILES([Makefile src/Makefile src/compat/Makefile src/daemon/Makefile
20 src/lib/Makefile src/lib/lldpctl.pc src/client/Makefile
a5cf540c 21 tests/Makefile])
2acc1418 22AC_CONFIG_MACRO_DIR([m4])
43c02e7b 23
d38eae28
VB
24# Configure automake
25AM_INIT_AUTOMAKE([foreign -Wall -Werror])
33aa26d0 26AM_MAINTAINER_MODE
44cd2bed 27m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
d38eae28
VB
28
29# Configure libtool
8c37e19a 30#LT_PREREQ([2.2])
d38eae28
VB
31LT_INIT
32
33#######################
34### Checks
35
43c02e7b
VB
36# Checks for programs.
37AC_PROG_CC
6c586123 38AC_PROG_CC_C99
223227c8 39AC_PROG_CXX
d38eae28 40AM_PROG_CC_C_O
f5bc67ee 41AC_PROG_LIBTOOL
2acc1418 42
4b292b55
VB
43# Doxygen
44DX_HTML_FEATURE(ON)
45DX_DOT_FEATURE(OFF)
46DX_CHM_FEATURE(OFF)
47DX_CHI_FEATURE(OFF)
48DX_MAN_FEATURE(OFF)
49DX_RTF_FEATURE(OFF)
50DX_XML_FEATURE(OFF)
51DX_PDF_FEATURE(ON)
52DX_PS_FEATURE(OFF)
53DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
54
45e89c8c
VB
55# Check some compiler flags
56AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option])
45e89c8c
VB
57AX_CFLAGS_GCC_OPTION([-pipe])
58AX_CFLAGS_GCC_OPTION([-Wall])
59AX_CFLAGS_GCC_OPTION([-W])
60AX_CFLAGS_GCC_OPTION([-Wextra])
61AX_CFLAGS_GCC_OPTION([-Wformat])
62AX_CFLAGS_GCC_OPTION([-Wformat-security])
63AX_CFLAGS_GCC_OPTION([-Wcast-align])
64AX_CFLAGS_GCC_OPTION([-Winline])
65AX_CFLAGS_GCC_OPTION([-fstack-protector])
66AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
5fd6695c 67AX_CFLAGS_GCC_OPTION([-Wdeclaration-after-statement])
45e89c8c
VB
68AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
69AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
a37f8fd6
VB
70AX_LDFLAGS_OPTION([-Wl,-z,relro])
71AX_LDFLAGS_OPTION([-Wl,-z,now])
45e89c8c 72
8e4b9031
VB
73AC_CACHE_SAVE
74
d38eae28
VB
75# Checks for header files.
76AC_HEADER_RESOLV
396cfdfe 77AC_CHECK_HEADERS([valgrind/valgrind.h])
43c02e7b 78
d38eae28 79# Check for sys/queue.h completeness, missing bits will be in compat.h
2d2f913b
VB
80AC_CHECK_DECLS([
81TAILQ_FIRST,
82TAILQ_NEXT,
83TAILQ_FOREACH,
3685a1f7 84TAILQ_EMPTY],[],[],[[@%:@include <sys/queue.h>]])
d38eae28 85
35097709 86# On some systems, some ioctl are not declared
2d2f913b
VB
87AC_CHECK_DECLS([
88SIOCGIFVLAN,
89SIOCBONDINFOQUERY,
90SIOCBONDSLAVEINFOQUERY],[],[],[[@%:@include <linux/sockios.h>]])
35097709
VB
91AC_CHECK_MEMBERS([ifslave.slave_name, ifbond.num_slaves], [],
92 [AC_MSG_ERROR([linux/if_bonding.h is incomplete. See README file.])],
93 [
94@%:@include <arpa/inet.h>
95@%:@include <linux/if.h>
96@%:@include <linux/if_bonding.h>
97])
98
d38eae28
VB
99# Do we have PACKET_ORIGDEV (it can be present at runtime, put it in compat.h)
100AC_CHECK_DECLS([PACKET_ORIGDEV],[],[],[[@%:@include <linux/if_packet.h>]])
101
102# Check for ethtool stuff
103lldp_CHECK_HEADER_ETHTOOL
2d2f913b
VB
104AC_CHECK_DECLS([
105ADVERTISED_2500baseX_Full,
106ADVERTISED_Pause,
107ADVERTISED_Asym_Pause,
108ADVERTISED_10000baseT_Full,
109SPEED_10000],[],[],[[@%:@include <linux/ethtool.h>]])
d38eae28
VB
110
111# Check for ETHERTYPE_VLAN, put it in compat.h if not defined
112AC_CHECK_DECLS([ETHERTYPE_VLAN],[],[],[[@%:@include <net/ethernet.h>]])
113
114# Check some stuff in linux/if_vlan.h
19d42b55
VB
115AC_CHECK_HEADERS([ \
116 linux/if_vlan.h \
117],,AC_MSG_ERROR([You should get linux/if_vlan.h from some other place. See README file.]),[
118@%:@include <arpa/inet.h>
119@%:@include <linux/if.h>
120])
2d2f913b
VB
121AC_CHECK_DECLS([GET_VLAN_REALDEV_NAME_CMD,GET_VLAN_VID_CMD],[],[],
122 [[@%:@include <linux/if_vlan.h>]])
43c02e7b 123
8e4b9031
VB
124AC_CACHE_SAVE
125
43c02e7b 126# Checks for typedefs, structures, and compiler characteristics.
6bb9c4e0 127lldp_CHECK___PROGNAME
43c02e7b
VB
128
129# Checks for library functions.
4b292b55 130AC_CONFIG_LIBOBJ_DIR([src/compat])
d38eae28
VB
131AC_FUNC_MALLOC
132AC_FUNC_REALLOC
43c02e7b 133AC_REPLACE_FUNCS([strlcpy])
b7997528 134AC_REPLACE_FUNCS([getifaddrs])
8e4b9031
VB
135AC_CACHE_SAVE
136
d38eae28
VB
137## Unit tests wich check
138PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
43c02e7b 139
e5c94652 140# Libevent
c461e5da 141lldp_CHECK_LIBEVENT
e5c94652 142
d38eae28
VB
143#######################
144### Options
43c02e7b 145
d38eae28
VB
146# SNMP
147AC_ARG_WITH([snmp],
148 AS_HELP_STRING(
149 [--with-snmp],
150 [Enable the use of SNMP @<:@default=no@:>@]
151 ))
152if test x"$with_snmp" = x"yes"; then
153 lldp_CHECK_SNMP
315587ef
VB
154fi
155
8beb9a73 156# XML
1480ce74
AH
157AC_ARG_WITH([xml],
158 AC_HELP_STRING(
159 [--with-xml],
5a9cb3db 160 [Enable XML output via libxml2 @<:@default=no@:>@]
1480ce74
AH
161 ))
162if test x"$with_xml" = x"yes"; then
163 lldp_CHECK_XML2
164fi
165
8b7150e4
VB
166# JSON
167AC_ARG_WITH([json],
168 AC_HELP_STRING(
169 [--with-json],
170 [Enable JSON output via Jansson @<:@default=no@:>@]
171 ))
172if test x"$with_json" = x"yes"; then
173 lldp_CHECK_JANSSON
174fi
175
d38eae28
VB
176# Privsep settings
177lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
178lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
179lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [/var/run/lldpd])
89840df0 180
d38eae28
VB
181# CDP/FDP/EDP/SONMP
182lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
183lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
184lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
185lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
a1347cd8 186
d38eae28
VB
187# LLDPMED/Dot1/Dot3
188lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
189lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
190lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
a1347cd8 191
d38eae28
VB
192#######################
193# Output results
194AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
195AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
1480ce74 196AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
8b7150e4 197AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"yes"])
43c02e7b 198AC_OUTPUT
d38eae28 199
e5c94652
VB
200if test x"$LIBEVENT_LDFLAGS" = x; then
201 libevent=system
202else
203 libevent=embedded
204fi
205
d38eae28
VB
206cat <<EOF
207
208------------------ Summary ------------------
209 $PACKAGE_NAME version $PACKAGE_VERSION
210 Prefix.........: $prefix
211 C Compiler.....: $CC $CFLAGS $CPPFLAGS
212 Linker.........: $LD $LDFLAGS $LIBS
e5c94652 213 Libevent.......: $libevent
d38eae28
VB
214 Optional features:
215 SNMP support...: ${with_snmp-no}
216 CDP............: $enable_cdp
217 FDP............: $enable_fdp
218 EDP............: $enable_edp
219 SONMP..........: $enable_sonmp
220 LLDPMED........: $enable_lldpmed
221 DOT1...........: $enable_dot1
222 DOT3...........: $enable_dot3
1480ce74 223 XML output.....: ${with_xml-no}
8b7150e4 224 JSON output....: ${with_json-no}
d38eae28
VB
225---------------------------------------------
226
227Check the above options and compile with:
228 ${MAKE-make}
229
230EOF