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