]> git.ipfire.org Git - thirdparty/lldpd.git/blame - configure.ac
osx: minimize differences with downstream Homebrew formula
[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 9
4593c0dc 10AC_INIT([lldpd],
a888bea6 11 [m4_esyscmd_s([./get-version])],
4593c0dc
VB
12 [bernat@luffy.cx])
13
4b292b55 14AC_CONFIG_SRCDIR([src/log.c])
43c02e7b 15AC_CONFIG_HEADER([config.h])
4b292b55
VB
16AC_CONFIG_FILES([Makefile src/Makefile src/compat/Makefile src/daemon/Makefile
17 src/lib/Makefile src/lib/lldpctl.pc src/client/Makefile
e9f4d63c
VB
18 tests/Makefile])
19AC_CONFIG_FILES([osx/Makefile osx/distribution.xml osx/im.bernat.lldpd.plist])
20AC_CONFIG_FILES([osx/scripts/preinstall], [chmod +x osx/scripts/preinstall])
21AC_CONFIG_FILES([osx/scripts/postinstall], [chmod +x osx/scripts/postinstall])
2acc1418 22AC_CONFIG_MACRO_DIR([m4])
fa71a00c 23AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
43c02e7b 24
d38eae28
VB
25# Configure automake
26AM_INIT_AUTOMAKE([foreign -Wall -Werror])
33aa26d0 27AM_MAINTAINER_MODE
44cd2bed 28m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
d38eae28 29
0339b9a2
VB
30# Automake 1.12...
31m4_pattern_allow([AM_PROG_AR])
32AM_PROG_AR
33
d38eae28 34# Configure libtool
d38eae28
VB
35LT_INIT
36
37#######################
38### Checks
39
43c02e7b
VB
40# Checks for programs.
41AC_PROG_CC
6c586123 42AC_PROG_CC_C99
223227c8 43AC_PROG_CXX
d38eae28 44AM_PROG_CC_C_O
f5bc67ee 45AC_PROG_LIBTOOL
fe80711e 46AC_PROG_LN_S
7ba4a183 47AC_PROG_EGREP
2acc1418 48
4b292b55
VB
49# Doxygen
50DX_HTML_FEATURE(ON)
51DX_DOT_FEATURE(OFF)
52DX_CHM_FEATURE(OFF)
53DX_CHI_FEATURE(OFF)
54DX_MAN_FEATURE(OFF)
55DX_RTF_FEATURE(OFF)
56DX_XML_FEATURE(OFF)
57DX_PDF_FEATURE(ON)
58DX_PS_FEATURE(OFF)
59DX_INIT_DOXYGEN([lldpd], [doxygen.cfg], [doxygen])
60
45e89c8c
VB
61# Check some compiler flags
62AX_CFLAGS_GCC_OPTION([-fdiagnostics-show-option])
45e89c8c
VB
63AX_CFLAGS_GCC_OPTION([-pipe])
64AX_CFLAGS_GCC_OPTION([-Wall])
65AX_CFLAGS_GCC_OPTION([-W])
66AX_CFLAGS_GCC_OPTION([-Wextra])
67AX_CFLAGS_GCC_OPTION([-Wformat])
68AX_CFLAGS_GCC_OPTION([-Wformat-security])
d56bb3bd 69AX_CFLAGS_GCC_OPTION([-Wfatal-errors])
45e89c8c
VB
70AX_CFLAGS_GCC_OPTION([-Wcast-align])
71AX_CFLAGS_GCC_OPTION([-Winline])
72AX_CFLAGS_GCC_OPTION([-fstack-protector])
73AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
74AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
d56bb3bd 75AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers])
45e89c8c 76AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
a37f8fd6
VB
77AX_LDFLAGS_OPTION([-Wl,-z,relro])
78AX_LDFLAGS_OPTION([-Wl,-z,now])
45e89c8c 79
e12c2365
VB
80# OS
81lldp_CHECK_OS
82
8e4b9031
VB
83AC_CACHE_SAVE
84
d38eae28
VB
85# Checks for header files.
86AC_HEADER_RESOLV
396cfdfe 87AC_CHECK_HEADERS([valgrind/valgrind.h])
c3e340b6 88lldp_CHECK_STDINT
43c02e7b 89
8e4b9031
VB
90AC_CACHE_SAVE
91
43c02e7b 92# Checks for typedefs, structures, and compiler characteristics.
6bb9c4e0 93lldp_CHECK___PROGNAME
43c02e7b
VB
94
95# Checks for library functions.
4b292b55 96AC_CONFIG_LIBOBJ_DIR([src/compat])
d38eae28
VB
97AC_FUNC_MALLOC
98AC_FUNC_REALLOC
66879d46 99AC_SEARCH_LIBS([setproctitle], [util bsd])
7354ec8f 100AC_REPLACE_FUNCS([strlcpy strnlen strndup fgetln setproctitle])
8dab5698 101AC_CHECK_FUNCS([setresuid setresgid])
e66b7f34 102
66879d46
VB
103case " $LIBS " in
104 *\ -lbsd\ *)
105 AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used])
106 ;;
107esac
108
d0a03372
VB
109# Check for res_init. On OSX, res_init is a symbol in libsystem_info
110# and a macro in resolv.h. We need to ensure we test with resolv.h.
111m4_pushdef([AC_LANG_CALL(C)], [
112 AC_LANG_PROGRAM([$1
113@%:@include <resolv.h>], [return $2 ();])])
114AC_SEARCH_LIBS([res_init], resolv bind,
115 AC_DEFINE([HAVE_RES_INIT], 1,
116 [Define to indicate that res_init() exists]))
117m4_popdef([AC_LANG_CALL(C)])
e66b7f34 118
8e4b9031
VB
119AC_CACHE_SAVE
120
d38eae28
VB
121## Unit tests wich check
122PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
43c02e7b 123
e5c94652 124# Libevent
c461e5da 125lldp_CHECK_LIBEVENT
e5c94652 126
d38eae28
VB
127#######################
128### Options
43c02e7b 129
35f6f4fb
VB
130# Readline
131AC_ARG_WITH([readline],
132 AS_HELP_STRING(
133 [--with-readline],
134 [Enable the use of readline-like library @<:@default=check@:>@]),
135 [],
136 [with_readline=check])
137if test x"$with_readline" != x"no"; then
138 AX_LIB_READLINE
139 if test x"$with_readline" != x"check"; then
140 if test x"$ax_cv_lib_readline" = x"no"; then
141 AC_MSG_FAILURE([*** no readline support found])
142 fi
143 fi
144else
145 ax_cv_lib_readline="no"
146fi
147
d38eae28
VB
148# SNMP
149AC_ARG_WITH([snmp],
150 AS_HELP_STRING(
151 [--with-snmp],
152 [Enable the use of SNMP @<:@default=no@:>@]
153 ))
154if test x"$with_snmp" = x"yes"; then
155 lldp_CHECK_SNMP
315587ef
VB
156fi
157
8beb9a73 158# XML
1480ce74
AH
159AC_ARG_WITH([xml],
160 AC_HELP_STRING(
161 [--with-xml],
5a9cb3db 162 [Enable XML output via libxml2 @<:@default=no@:>@]
1480ce74
AH
163 ))
164if test x"$with_xml" = x"yes"; then
165 lldp_CHECK_XML2
166fi
167
8b7150e4
VB
168# JSON
169AC_ARG_WITH([json],
170 AC_HELP_STRING(
171 [--with-json],
172 [Enable JSON output via Jansson @<:@default=no@:>@]
173 ))
174if test x"$with_json" = x"yes"; then
175 lldp_CHECK_JANSSON
176fi
177
d38eae28
VB
178# Privsep settings
179lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
180lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
181lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [/var/run/lldpd])
89840df0 182
d38eae28
VB
183# CDP/FDP/EDP/SONMP
184lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
185lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
186lldp_ARG_ENABLE([edp], [Extreme Discovery Protocol], [yes])
187lldp_ARG_ENABLE([sonmp], [SynOptics Network Management Protocol], [yes])
a1347cd8 188
d38eae28
VB
189# LLDPMED/Dot1/Dot3
190lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
191lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
192lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
a1347cd8 193
184bd199 194# Oldies
fda729fd 195lldp_ARG_ENABLE([oldies], [compatibility with Linux kernel older than 2.6.18], [no])
184bd199 196
d38eae28
VB
197#######################
198# Output results
199AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
200AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
1480ce74 201AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
8b7150e4 202AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"yes"])
43c02e7b 203AC_OUTPUT
d38eae28 204
4c1a8c61 205if test x"$LIBEVENT_EMBEDDED" = x; then
e5c94652
VB
206 libevent=system
207else
208 libevent=embedded
209fi
210
d38eae28
VB
211cat <<EOF
212
213------------------ Summary ------------------
214 $PACKAGE_NAME version $PACKAGE_VERSION
91e0280a 215 OS.............: $os
d38eae28
VB
216 Prefix.........: $prefix
217 C Compiler.....: $CC $CFLAGS $CPPFLAGS
218 Linker.........: $LD $LDFLAGS $LIBS
e5c94652 219 Libevent.......: $libevent
35f6f4fb 220 Readline.......: ${ax_cv_lib_readline}
d38eae28
VB
221 Optional features:
222 SNMP support...: ${with_snmp-no}
223 CDP............: $enable_cdp
224 FDP............: $enable_fdp
225 EDP............: $enable_edp
226 SONMP..........: $enable_sonmp
227 LLDPMED........: $enable_lldpmed
228 DOT1...........: $enable_dot1
229 DOT3...........: $enable_dot3
1480ce74 230 XML output.....: ${with_xml-no}
8b7150e4 231 JSON output....: ${with_json-no}
184bd199 232 Oldies support.: $enable_oldies
d38eae28
VB
233---------------------------------------------
234
235Check the above options and compile with:
236 ${MAKE-make}
237
238EOF