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