]> git.ipfire.org Git - thirdparty/lldpd.git/blob - configure.ac
configure: use `AC_PROG_EGREP` to find a suitable `grep -E`
[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([./get-version])],
15 [bernat@luffy.cx])
16
17 AC_CONFIG_SRCDIR([src/log.c])
18 AC_CONFIG_HEADER([config.h])
19 AC_CONFIG_FILES([Makefile src/Makefile src/compat/Makefile src/daemon/Makefile
20 src/lib/Makefile src/lib/lldpctl.pc src/client/Makefile
21 tests/Makefile])
22 AC_CONFIG_MACRO_DIR([m4])
23
24 # Configure automake
25 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
26 AM_MAINTAINER_MODE
27 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
28
29 # Automake 1.12...
30 m4_pattern_allow([AM_PROG_AR])
31 AM_PROG_AR
32
33 # Configure libtool
34 LT_INIT
35
36 #######################
37 ### Checks
38
39 # Checks for programs.
40 AC_PROG_CC
41 AC_PROG_CC_C99
42 AC_PROG_CXX
43 AM_PROG_CC_C_O
44 AC_PROG_LIBTOOL
45 AC_PROG_LN_S
46 AC_PROG_EGREP
47
48 # Doxygen
49 DX_HTML_FEATURE(ON)
50 DX_DOT_FEATURE(OFF)
51 DX_CHM_FEATURE(OFF)
52 DX_CHI_FEATURE(OFF)
53 DX_MAN_FEATURE(OFF)
54 DX_RTF_FEATURE(OFF)
55 DX_XML_FEATURE(OFF)
56 DX_PDF_FEATURE(ON)
57 DX_PS_FEATURE(OFF)
58 DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
59
60 # Check some compiler flags
61 AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option])
62 AX_CFLAGS_GCC_OPTION([-pipe])
63 AX_CFLAGS_GCC_OPTION([-Wall])
64 AX_CFLAGS_GCC_OPTION([-W])
65 AX_CFLAGS_GCC_OPTION([-Wextra])
66 AX_CFLAGS_GCC_OPTION([-Wformat])
67 AX_CFLAGS_GCC_OPTION([-Wformat-security])
68 AX_CFLAGS_GCC_OPTION([-Wfatal-errors])
69 AX_CFLAGS_GCC_OPTION([-Wcast-align])
70 AX_CFLAGS_GCC_OPTION([-Winline])
71 AX_CFLAGS_GCC_OPTION([-fstack-protector])
72 AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
73 AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
74 AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers])
75 AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
76 AX_LDFLAGS_OPTION([-Wl,-z,relro])
77 AX_LDFLAGS_OPTION([-Wl,-z,now])
78
79 # OS
80 lldp_CHECK_OS
81
82 AC_CACHE_SAVE
83
84 # Checks for header files.
85 AC_HEADER_RESOLV
86 AC_CHECK_HEADERS([valgrind/valgrind.h])
87
88 AC_CACHE_SAVE
89
90 # Checks for typedefs, structures, and compiler characteristics.
91 lldp_CHECK___PROGNAME
92
93 # Checks for library functions.
94 AC_CONFIG_LIBOBJ_DIR([src/compat])
95 AC_FUNC_MALLOC
96 AC_FUNC_REALLOC
97 AC_REPLACE_FUNCS([strlcpy strnlen fgetln])
98 AC_CHECK_FUNCS([setresuid setresgid])
99
100 AC_SEARCH_LIBS([__res_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists]),
101 AC_SEARCH_LIBS([res_9_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists]),
102 AC_SEARCH_LIBS([res_init], resolv bind, AC_DEFINE([HAVE_RES_INIT], 1, [Define to indicate that res_init() exists]))))
103
104 AC_CACHE_SAVE
105
106 ## Unit tests wich check
107 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
108
109 # Libevent
110 lldp_CHECK_LIBEVENT
111
112 #######################
113 ### Options
114
115 # Readline
116 AC_ARG_WITH([readline],
117 AS_HELP_STRING(
118 [--with-readline],
119 [Enable the use of readline-like library @<:@default=check@:>@]),
120 [],
121 [with_readline=check])
122 if test x"$with_readline" != x"no"; then
123 AX_LIB_READLINE
124 if test x"$with_readline" != x"check"; then
125 if test x"$ax_cv_lib_readline" = x"no"; then
126 AC_MSG_FAILURE([*** no readline support found])
127 fi
128 fi
129 else
130 ax_cv_lib_readline="no"
131 fi
132
133 # SNMP
134 AC_ARG_WITH([snmp],
135 AS_HELP_STRING(
136 [--with-snmp],
137 [Enable the use of SNMP @<:@default=no@:>@]
138 ))
139 if test x"$with_snmp" = x"yes"; then
140 lldp_CHECK_SNMP
141 fi
142
143 # XML
144 AC_ARG_WITH([xml],
145 AC_HELP_STRING(
146 [--with-xml],
147 [Enable XML output via libxml2 @<:@default=no@:>@]
148 ))
149 if test x"$with_xml" = x"yes"; then
150 lldp_CHECK_XML2
151 fi
152
153 # JSON
154 AC_ARG_WITH([json],
155 AC_HELP_STRING(
156 [--with-json],
157 [Enable JSON output via Jansson @<:@default=no@:>@]
158 ))
159 if test x"$with_json" = x"yes"; then
160 lldp_CHECK_JANSSON
161 fi
162
163 # Privsep settings
164 lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
165 lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
166 lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [/var/run/lldpd])
167
168 # CDP/FDP/EDP/SONMP
169 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
170 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
171 lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
172 lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
173
174 # LLDPMED/Dot1/Dot3
175 lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
176 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
177 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
178
179 # Oldies
180 lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.18], [no])
181
182 #######################
183 # Output results
184 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
185 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
186 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
187 AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"yes"])
188 AC_OUTPUT
189
190 if test x"$LIBEVENT_EMBEDDED" = x; then
191 libevent=system
192 else
193 libevent=embedded
194 fi
195
196 cat <<EOF
197
198 ------------------ Summary ------------------
199 $PACKAGE_NAME version $PACKAGE_VERSION
200 OS.............: $os
201 Prefix.........: $prefix
202 C Compiler.....: $CC $CFLAGS $CPPFLAGS
203 Linker.........: $LD $LDFLAGS $LIBS
204 Libevent.......: $libevent
205 Readline.......: ${ax_cv_lib_readline}
206 Optional features:
207 SNMP support...: ${with_snmp-no}
208 CDP............: $enable_cdp
209 FDP............: $enable_fdp
210 EDP............: $enable_edp
211 SONMP..........: $enable_sonmp
212 LLDPMED........: $enable_lldpmed
213 DOT1...........: $enable_dot1
214 DOT3...........: $enable_dot3
215 XML output.....: ${with_xml-no}
216 JSON output....: ${with_json-no}
217 Oldies support.: $enable_oldies
218 ---------------------------------------------
219
220 Check the above options and compile with:
221 ${MAKE-make}
222
223 EOF