]> git.ipfire.org Git - thirdparty/openvpn.git/blame - configure.ac
travis: compile with -Werror on Linux
[thirdparty/openvpn.git] / configure.ac
CommitLineData
6fbf66fa
JY
1dnl OpenVPN -- An application to securely tunnel IP networks
2dnl over a single UDP port, with support for SSL/TLS-based
3dnl session authentication and key exchange,
4dnl packet encryption, packet authentication, and
5dnl packet compression.
6dnl
49979459 7dnl Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net>
51bd56f4 8dnl Copyright (C) 2006-2012 Alon Bar-Lev <alon.barlev@gmail.com>
6fbf66fa
JY
9dnl
10dnl This program is free software; you can redistribute it and/or modify
11dnl it under the terms of the GNU General Public License as published by
12dnl the Free Software Foundation; either version 2 of the License, or
13dnl (at your option) any later version.
14dnl
15dnl This program is distributed in the hope that it will be useful,
16dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
17dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18dnl GNU General Public License for more details.
19dnl
caa54ac3
DS
20dnl You should have received a copy of the GNU General Public License along
21dnl with this program; if not, write to the Free Software Foundation, Inc.,
22dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6fbf66fa
JY
23
24dnl Process this file with autoconf to produce a configure script.
25
51bd56f4 26AC_PREREQ(2.59)
6fbf66fa 27
ce351583 28m4_include(version.m4)
51bd56f4
ABL
29AC_INIT([PRODUCT_NAME], [PRODUCT_VERSION], [PRODUCT_BUGREPORT], [PRODUCT_TARNAME])
30m4_include(compat.m4)
98bc1a3e 31AC_DEFINE([OPENVPN_VERSION_RESOURCE], [PRODUCT_VERSION_RESOURCE], [Version in windows resource format])
9de35d46
DS
32AC_SUBST([OPENVPN_VERSION_MAJOR], [PRODUCT_VERSION_MAJOR], [OpenVPN major version])
33AC_SUBST([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor version])
34AC_SUBST([OPENVPN_VERSION_PATCH], [PRODUCT_VERSION_PATCH], [OpenVPN patch level - may be a string or integer])
6a40276c
DS
35AC_DEFINE([OPENVPN_VERSION_MAJOR], [PRODUCT_VERSION_MAJOR], [OpenVPN major version - integer])
36AC_DEFINE([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor version - integer])
37AC_DEFINE([OPENVPN_VERSION_PATCH], ["PRODUCT_VERSION_PATCH"], [OpenVPN patch level - may be a string or integer])
98bc1a3e 38
51bd56f4 39AC_CONFIG_AUX_DIR([.])
631812fe 40AC_CONFIG_HEADERS([config.h include/openvpn-plugin.h])
34cb9132 41AC_CONFIG_SRCDIR([src/openvpn/syshead.h])
0fc5b8b3 42AC_CONFIG_MACRO_DIR([m4])
c615835a
GD
43
44dnl Initialize automake. automake < 1.12 didn't have serial-tests and
45dnl gives an error if it sees this, but for automake >= 1.13
46dnl serial-tests is required so we have to include it. Solution is to
47dnl test for the version of automake (by running an external command)
48dnl and provide it if necessary. Note we have to do this entirely using
49dnl m4 macros since automake queries this macro by running
50dnl 'autoconf --trace ...'.
51m4_define([serial_tests], [
52 m4_esyscmd([automake --version |
53 head -1 |
54 awk '{split ($NF,a,"."); if (a[1] == 1 && a[2] >= 12) { print "serial-tests" }}'
55 ])
56])
57AM_INIT_AUTOMAKE(foreign serial_tests) dnl NB: Do not [quote] this parameter.
51bd56f4
ABL
58AC_CANONICAL_HOST
59AC_USE_SYSTEM_EXTENSIONS
6fbf66fa 60
51bd56f4
ABL
61AC_ARG_ENABLE(
62 [lzo],
40a56e79 63 [AS_HELP_STRING([--disable-lzo], [disable LZO compression support @<:@default=yes@:>@])],
51bd56f4 64 ,
40a56e79 65 [enable_lzo="yes"]
6c34e74f
JY
66)
67
40efb635
GD
68AC_ARG_ENABLE(lz4,
69 [ --disable-lz4 Disable LZ4 compression support],
70 [enable_lz4="$enableval"],
71 [enable_lz4="yes"]
72)
73
38d96bd7
JY
74AC_ARG_ENABLE(comp-stub,
75 [ --enable-comp-stub Don't compile compression support but still allow limited interoperability with compression-enabled peers],
76 [enable_comp_stub="$enableval"],
77 [enable_comp_stub="no"]
6fbf66fa
JY
78)
79
c353af2f
SK
80AC_ARG_ENABLE(
81 [ofb-cfb],
104360b4 82 [AS_HELP_STRING([--disable-ofb-cfb], [disable support for OFB and CFB cipher modes @<:@default=yes@:>@])],
c353af2f
SK
83 ,
84 [enable_crypto_ofb_cfb="yes"]
85)
86
51bd56f4
ABL
87AC_ARG_ENABLE(
88 [x509-alt-username],
709f7a1f 89 [AS_HELP_STRING([--enable-x509-alt-username], [enable the --x509-username-field feature @<:@default=no@:>@])],
51bd56f4
ABL
90 ,
91 [enable_x509_alt_username="no"]
6fbf66fa
JY
92)
93
51bd56f4
ABL
94AC_ARG_ENABLE(
95 [server],
709f7a1f 96 [AS_HELP_STRING([--disable-server], [disable server support only (but retain client support) @<:@default=yes@:>@])],
51bd56f4
ABL
97 ,
98 [enable_server="yes"]
6fbf66fa
JY
99)
100
51bd56f4
ABL
101AC_ARG_ENABLE(
102 [plugins],
709f7a1f 103 [AS_HELP_STRING([--disable-plugins], [disable plug-in support @<:@default=yes@:>@])],
51bd56f4
ABL
104 ,
105 [enable_plugins="yes"]
0c1f7ad5
DS
106)
107
51bd56f4
ABL
108AC_ARG_ENABLE(
109 [management],
709f7a1f 110 [AS_HELP_STRING([--disable-management], [disable management server support @<:@default=yes@:>@])],
51bd56f4
ABL
111 ,
112 [enable_management="yes"]
ce98fd24
JY
113)
114
51bd56f4
ABL
115AC_ARG_ENABLE(
116 [pkcs11],
709f7a1f 117 [AS_HELP_STRING([--enable-pkcs11], [enable pkcs11 support @<:@default=no@:>@])],
51bd56f4 118 ,
18b5fbdf 119 [enable_pkcs11="no"]
6fbf66fa
JY
120)
121
51bd56f4
ABL
122AC_ARG_ENABLE(
123 [fragment],
709f7a1f 124 [AS_HELP_STRING([--disable-fragment], [disable internal fragmentation support (--fragment) @<:@default=yes@:>@])],
51bd56f4
ABL
125 ,
126 [enable_fragment="yes"]
8bc93d7f
JY
127)
128
51bd56f4
ABL
129AC_ARG_ENABLE(
130 [multihome],
709f7a1f 131 [AS_HELP_STRING([--disable-multihome], [disable multi-homed UDP server support (--multihome) @<:@default=yes@:>@])],
51bd56f4
ABL
132 ,
133 [enable_multihome="yes"]
6add6b2f
JY
134)
135
51bd56f4
ABL
136AC_ARG_ENABLE(
137 [port-share],
709f7a1f 138 [AS_HELP_STRING([--disable-port-share], [disable TCP server port-share support (--port-share) @<:@default=yes@:>@])],
51bd56f4
ABL
139 ,
140 [enable_port_share="yes"]
6fbf66fa
JY
141)
142
51bd56f4
ABL
143AC_ARG_ENABLE(
144 [debug],
709f7a1f 145 [AS_HELP_STRING([--disable-debug], [disable debugging support (disable gremlin and verb 7+ messages) @<:@default=yes@:>@])],
51bd56f4
ABL
146 ,
147 [enable_debug="yes"]
6fbf66fa
JY
148)
149
51bd56f4
ABL
150AC_ARG_ENABLE(
151 [small],
104360b4 152 [AS_HELP_STRING([--enable-small], [enable smaller executable size (disable OCC, usage message, and verb 4 parm list) @<:@default=no@:>@])],
51bd56f4
ABL
153 ,
154 [enable_small="no"]
6fbf66fa
JY
155)
156
51bd56f4
ABL
157AC_ARG_ENABLE(
158 [iproute2],
709f7a1f 159 [AS_HELP_STRING([--enable-iproute2], [enable support for iproute2 @<:@default=no@:>@])],
51bd56f4
ABL
160 ,
161 [enable_iproute2="no"]
fb7aa54a
JY
162)
163
51bd56f4
ABL
164AC_ARG_ENABLE(
165 [def-auth],
709f7a1f 166 [AS_HELP_STRING([--disable-def-auth], [disable deferred authentication @<:@default=yes@:>@])],
51bd56f4
ABL
167 ,
168 [enable_def_auth="yes"]
fb7aa54a
JY
169)
170
51bd56f4
ABL
171AC_ARG_ENABLE(
172 [pf],
709f7a1f 173 [AS_HELP_STRING([--disable-pf], [disable internal packet filter @<:@default=yes@:>@])],
51bd56f4
ABL
174 ,
175 [enable_pf="yes"]
6fbf66fa
JY
176)
177
ce8271f5
ABL
178AC_ARG_ENABLE(
179 [plugin-auth-pam],
5a57e201 180 [AS_HELP_STRING([--disable-plugin-auth-pam], [disable auth-pam plugin @<:@default=platform specific@:>@])],
ce8271f5 181 ,
5a57e201
ABL
182 [
183 case "$host" in
184 *-*-openbsd*) enable_plugin_auth_pam="no";;
185 *-mingw*) enable_plugin_auth_pam="no";;
186 *) enable_plugin_auth_pam="yes";;
187 esac
188 ]
ce8271f5
ABL
189)
190
191AC_ARG_ENABLE(
192 [plugin-down-root],
5a57e201
ABL
193 [AS_HELP_STRING([--disable-plugin-down-root], [disable down-root plugin @<:@default=platform specific@:>@])],
194 ,
195 [
196 case "$host" in
197 *-mingw*) enable_plugin_down_root="no";;
198 *) enable_plugin_down_root="yes";;
199 esac
200 ]
ce8271f5
ABL
201)
202
203AC_ARG_ENABLE(
204 [pam-dlopen],
205 [AS_HELP_STRING([--enable-pam-dlopen], [dlopen libpam @<:@default=no@:>@])],
206 ,
207 [enable_pam_dlopen="no"]
208)
209
51bd56f4
ABL
210AC_ARG_ENABLE(
211 [strict],
709f7a1f 212 [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])],
51bd56f4
ABL
213 ,
214 [enable_strict="no"]
6fbf66fa
JY
215)
216
51bd56f4
ABL
217AC_ARG_ENABLE(
218 [pedantic],
709f7a1f 219 [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings, will not generate a working executable (debugging option) @<:@default=no@:>@])],
51bd56f4
ABL
220 ,
221 [enable_pedantic="no"]
6fbf66fa
JY
222)
223
51194ffd
SK
224AC_ARG_ENABLE(
225 [werror],
42d9f324 226 [AS_HELP_STRING([--enable-werror], [promote compiler warnings to errors, will cause builds to fail if the compiler issues warnings (debugging option) @<:@default=no@:>@])],
51194ffd
SK
227 ,
228 [enable_werror="no"]
229)
230
51bd56f4
ABL
231AC_ARG_ENABLE(
232 [strict-options],
709f7a1f 233 [AS_HELP_STRING([--enable-strict-options], [enable strict options check between peers (debugging option) @<:@default=no@:>@])],
51bd56f4
ABL
234 ,
235 [enable_strict_options="no"]
6fbf66fa
JY
236)
237
51bd56f4
ABL
238AC_ARG_ENABLE(
239 [selinux],
709f7a1f 240 [AS_HELP_STRING([--enable-selinux], [enable SELinux support @<:@default=no@:>@])],
51bd56f4
ABL
241 ,
242 [enable_selinux="no"]
99385447
JY
243)
244
51bd56f4
ABL
245AC_ARG_ENABLE(
246 [systemd],
ccb636c7 247 [AS_HELP_STRING([--enable-systemd], [enable systemd support @<:@default=no@:>@])],
51bd56f4
ABL
248 ,
249 [enable_systemd="no"]
9449e6a9
FC
250)
251
0d1a75bf
LS
252AC_ARG_ENABLE(
253 [async-push],
1a8f6b91 254 [AS_HELP_STRING([--enable-async-push], [enable async-push support for plugins providing deferred authentication @<:@default=no@:>@])],
e62eccf0 255 ,
0d1a75bf
LS
256 [enable_async_push="no"]
257)
258
10b4b65e
ABL
259AC_ARG_WITH(
260 [special-build],
261 [AS_HELP_STRING([--with-special-build=STRING], [specify special build string])],
262 [test -n "${withval}" && AC_DEFINE_UNQUOTED([CONFIGURE_SPECIAL_BUILD], ["${withval}"], [special build string])]
263)
264
51bd56f4
ABL
265AC_ARG_WITH(
266 [mem-check],
709f7a1f 267 [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|dmalloc|valgrind|ssl @<:@default=no@:>@])],
51bd56f4
ABL
268 [
269 case "${withval}" in
270 dmalloc|valgrind|ssl|no) ;;
271 *) AC_MSG_ERROR([bad value ${withval} for --mem-check]) ;;
272 esac
273 ],
274 [with_mem_check="no"]
6fbf66fa
JY
275)
276
51bd56f4 277AC_ARG_WITH(
9b33b5a4 278 [crypto-library],
86d8cd68 279 [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|mbedtls @<:@default=openssl@:>@])],
51bd56f4 280 [
86d8cd68
SK
281 case "${withval}" in
282 openssl|mbedtls) ;;
9b33b5a4 283 *) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;;
51bd56f4
ABL
284 esac
285 ],
9b33b5a4 286 [with_crypto_library="openssl"]
0a180174 287)
0a180174 288
4590c383
CH
289AC_ARG_VAR([PLUGINDIR], [Path of plug-in directory @<:@default=LIBDIR/openvpn/plugins@:>@])
290if test -n "${PLUGINDIR}"; then
291 plugindir="${PLUGINDIR}"
292else
293 plugindir="\${libdir}/openvpn/plugins"
294fi
ce8271f5 295
6440083e 296AC_DEFINE_UNQUOTED([TARGET_ALIAS], ["${host}"], [A string representing our host])
c4d5bcd7 297AM_CONDITIONAL([TARGET_LINUX], [false])
86715242 298case "$host" in
51bd56f4
ABL
299 *-*-linux*)
300 AC_DEFINE([TARGET_LINUX], [1], [Are we running on Linux?])
c4d5bcd7 301 AM_CONDITIONAL([TARGET_LINUX], [true])
51bd56f4 302 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["L"], [Target prefix])
c6542257 303 have_sitnl="yes"
51bd56f4
ABL
304 ;;
305 *-*-solaris*)
306 AC_DEFINE([TARGET_SOLARIS], [1], [Are we running on Solaris?])
307 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["S"], [Target prefix])
4e2038ed 308 CPPFLAGS="$CPPFLAGS -D_XPG4_2"
9c490c26 309 test -x /bin/bash && SHELL="/bin/bash"
51bd56f4
ABL
310 ;;
311 *-*-openbsd*)
312 AC_DEFINE([TARGET_OPENBSD], [1], [Are we running on OpenBSD?])
313 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["O"], [Target prefix])
314 ;;
315 *-*-freebsd*)
316 AC_DEFINE([TARGET_FREEBSD], [1], [Are we running on FreeBSD?])
317 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["F"], [Target prefix])
318 ;;
319 *-*-netbsd*)
320 AC_DEFINE([TARGET_NETBSD], [1], [Are we running NetBSD?])
321 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["N"], [Target prefix])
322 ;;
323 *-*-darwin*)
324 AC_DEFINE([TARGET_DARWIN], [1], [Are we running on Mac OS X?])
325 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["M"], [Target prefix])
05f16e84 326 have_tap_header="yes"
e7303ace 327 ac_cv_type_struct_in_pktinfo=no
51bd56f4
ABL
328 ;;
329 *-mingw*)
330 AC_DEFINE([TARGET_WIN32], [1], [Are we running WIN32?])
331 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["W"], [Target prefix])
4b1a82db 332 CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
5fcd4933 333 CPPFLAGS="${CPPFLAGS} -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA"
51bd56f4 334 WIN32=yes
51bd56f4
ABL
335 ;;
336 *-*-dragonfly*)
337 AC_DEFINE([TARGET_DRAGONFLY], [1], [Are we running on DragonFlyBSD?])
338 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["D"], [Target prefix])
339 ;;
42f13dc0
GD
340 *-aix*)
341 AC_DEFINE([TARGET_AIX], [1], [Are we running AIX?])
342 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["A"], [Target prefix])
343 ROUTE="/usr/sbin/route"
344 have_tap_header="yes"
345 ac_cv_header_net_if_h="no" # exists, but breaks things
346 ;;
51bd56f4
ABL
347 *)
348 AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["X"], [Target prefix])
05f16e84 349 have_tap_header="yes"
51bd56f4 350 ;;
6fbf66fa
JY
351esac
352
51bd56f4
ABL
353PKG_PROG_PKG_CONFIG
354AC_PROG_CPP
6fbf66fa 355AC_PROG_INSTALL
51bd56f4 356AC_PROG_LN_S
7046ff20 357AC_PROG_SED
51bd56f4 358AC_PROG_MAKE_SET
6fbf66fa 359
c3fc703d
ABL
360AC_ARG_VAR([IFCONFIG], [full path to ipconfig utility])
361AC_ARG_VAR([ROUTE], [full path to route utility])
362AC_ARG_VAR([IPROUTE], [full path to ip utility])
363AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests
364AC_ARG_VAR([MAN2HTML], [path to man2html utility])
7046ff20 365AC_ARG_VAR([GIT], [path to git utility])
ba79c71d 366AC_ARG_VAR([SYSTEMD_ASK_PASSWORD], [path to systemd-ask-password utility])
ca5b4c2a 367AC_ARG_VAR([SYSTEMD_UNIT_DIR], [Path of systemd unit directory @<:@default=LIBDIR/systemd/system@:>@])
3de7be7b 368AC_ARG_VAR([TMPFILES_DIR], [Path of tmpfiles directory @<:@default=LIBDIR/tmpfiles.d@:>@])
c3fc703d
ABL
369AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
370AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
371AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
ba79c71d 372AC_PATH_PROGS([SYSTEMD_ASK_PASSWORD], [systemd-ask-password],, [$PATH:/usr/local/bin:/usr/bin:/bin])
c3fc703d
ABL
373AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests
374AC_CHECK_PROGS([MAN2HTML], [man2html])
7046ff20 375AC_CHECK_PROGS([GIT], [git]) # optional
c3fc703d
ABL
376AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool])
377AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
378AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
ba79c71d 379AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
c3fc703d 380
9223336a
SK
381# Set -std=c99 unless user already specified a -std=
382case "${CFLAGS}" in
383 *-std=*) ;;
384 *) CFLAGS="${CFLAGS} -std=c99" ;;
385esac
386
98bc1a3e
ABL
387#
388# Libtool
389#
390ifdef(
391 [LT_INIT],
392 [
393 LT_INIT([win32-dll])
394 LT_LANG([Windows Resource])
395 ],
396 [
397 AC_LIBTOOL_WIN32_DLL
398 AC_LIBTOOL_RC
399 AC_PROG_LIBTOOL
400 ]
401)
402
6fbf66fa
JY
403AC_C_CONST
404AC_C_INLINE
405AC_C_VOLATILE
406AC_TYPE_OFF_T
407AC_TYPE_PID_T
408AC_TYPE_SIZE_T
409AC_TYPE_UID_T
51bd56f4
ABL
410AC_TYPE_INT8_T
411AC_TYPE_INT16_T
412AC_TYPE_INT32_T
413AC_TYPE_INT64_T
414AC_TYPE_UINT8_T
415AC_TYPE_UINT16_T
416AC_TYPE_UINT32_T
417AC_TYPE_UINT64_T
418AC_TYPE_SIGNAL
6fbf66fa
JY
419AX_CPP_VARARG_MACRO_ISO
420AX_CPP_VARARG_MACRO_GCC
0dbd45db 421AX_TYPE_SOCKLEN_T
6fbf66fa 422AX_EMPTY_ARRAY
51bd56f4
ABL
423AC_CHECK_SIZEOF([unsigned int])
424AC_CHECK_SIZEOF([unsigned long])
425AC_CHECK_HEADERS([ \
e5fc56a7 426 stdio.h stdarg.h limits.h \
51bd56f4
ABL
427 time.h errno.h fcntl.h io.h direct.h \
428 ctype.h sys/types.h sys/socket.h \
bdae4110 429 signal.h unistd.h dlfcn.h \
51bd56f4
ABL
430 netinet/in.h netinet/in_systm.h \
431 netinet/tcp.h arpa/inet.h netdb.h \
432 windows.h winsock2.h ws2tcpip.h \
cdc65ea0 433 versionhelpers.h \
51bd56f4 434])
cab53332 435AC_CHECK_HEADERS([ \
a2d747bb 436 sys/time.h sys/ioctl.h sys/stat.h \
f641637a 437 sys/mman.h sys/file.h sys/wait.h \
7cacdfd4 438 unistd.h signal.h libgen.h stropts.h \
cab53332 439 syslog.h pwd.h grp.h \
7cacdfd4 440 sys/sockio.h sys/uio.h linux/sockios.h \
62063162 441 linux/types.h poll.h sys/epoll.h err.h \
cab53332 442])
6fbf66fa 443
51bd56f4
ABL
444SOCKET_INCLUDES="
445#ifdef HAVE_STDLIB_H
446#include <stdlib.h>
447#endif
448#ifdef HAVE_SYS_TYPES_H
449#include <sys/types.h>
450#endif
451#ifdef HAVE_SYS_SOCKET_H
452#include <sys/socket.h>
453#endif
7efa60d9
GD
454#ifdef HAVE_NET_IF_H
455#include <net/if.h>
456#endif
51bd56f4
ABL
457#ifdef HAVE_NETINET_IN_H
458#include <netinet/in.h>
459#endif
460#ifdef HAVE_WINDOWS_H
461#include <windows.h>
462#endif
463#ifdef HAVE_WINSOCK2_H
464#include <winsock2.h>
465#endif
466#ifdef HAVE_WS2TCPIP_H
467#include <ws2tcpip.h>
468#endif
2a744891
ABL
469#ifdef HAVE_NETINET_IN_SYSTM_H
470#include <netinet/in_systm.h>
471#endif
4025a595
ABL
472#ifdef HAVE_NETINET_IP_H
473#include <netinet/ip.h>
474#endif
51bd56f4 475"
1bda73a7 476
cab53332 477AC_CHECK_HEADERS(
ddb1f20a 478 [net/if.h netinet/ip.h resolv.h sys/un.h net/if_utun.h sys/kern_control.h],
51bd56f4 479 ,
51bd56f4 480 ,
cab53332 481 [[${SOCKET_INCLUDES}]]
51bd56f4
ABL
482)
483
484AC_CHECK_TYPES(
6fbf66fa 485 [in_addr_t],
51bd56f4
ABL
486 ,
487 [AC_DEFINE([in_addr_t], [uint32_t], [Workaround missing in_addr_t])],
488 [[${SOCKET_INCLUDES}]]
489)
dd6714ae
GD
490AC_CHECK_TYPES(
491 [in_port_t],
492 ,
493 [AC_DEFINE([in_port_t], [uint16_t], [Workaround missing in_port_t])],
494 [[${SOCKET_INCLUDES}]]
495)
6fbf66fa
JY
496AC_CHECK_TYPE(
497 [struct iphdr],
7c0a2b5f 498 [AC_DEFINE([HAVE_IPHDR], [1], [struct iphdr needed for IPv6 support])],
51bd56f4
ABL
499 ,
500 [[${SOCKET_INCLUDES}]]
501)
6fbf66fa
JY
502AC_CHECK_TYPE(
503 [struct sock_extended_err],
7c0a2b5f 504 [AC_DEFINE([HAVE_SOCK_EXTENDED_ERR], [1], [struct sock_extended_err needed for extended socket error support])],
51bd56f4
ABL
505 ,
506 [[${SOCKET_INCLUDES}]]
507)
6fbf66fa
JY
508AC_CHECK_TYPE(
509 [struct msghdr],
7c0a2b5f 510 [AC_DEFINE([HAVE_MSGHDR], [1], [struct msghdr needed for extended socket error support])],
51bd56f4
ABL
511 ,
512 [[${SOCKET_INCLUDES}]]
513)
6fbf66fa
JY
514AC_CHECK_TYPE(
515 [struct cmsghdr],
7c0a2b5f 516 [AC_DEFINE([HAVE_CMSGHDR], [1], [struct cmsghdr needed for extended socket error support])],
51bd56f4
ABL
517 ,
518 [[${SOCKET_INCLUDES}]]
519)
8bc93d7f
JY
520AC_CHECK_TYPE(
521 [struct in_pktinfo],
7c0a2b5f 522 [AC_DEFINE([HAVE_IN_PKTINFO], [1], [struct in_pktinfo needed for IP_PKTINFO support])],
51bd56f4
ABL
523 ,
524 [[${SOCKET_INCLUDES}]]
525)
87b468d4
HH
526AC_CHECK_TYPE(
527 [sa_family_t],
528 [AC_DEFINE([HAVE_SA_FAMILY_T], [1], [sa_family_t, needed to hold AF_* info])],
529 ,
530 [[${SOCKET_INCLUDES}]]
531)
7efa60d9
GD
532AC_CHECK_MEMBER(
533 [struct in_pktinfo.ipi_spec_dst],
534 [AC_DEFINE([HAVE_IPI_SPEC_DST], [1], [struct in_pktinfo.ipi_spec_dst needed for IP_PKTINFO support])],
535 ,
536 [[${SOCKET_INCLUDES}]]
537)
51bd56f4
ABL
538AC_CHECK_TYPE(
539 [struct sockaddr_in6],
540 ,
541 [AC_MSG_ERROR([struct sockaddr_in6 not found, needed for ipv6 transport support.])],
542 [[${SOCKET_INCLUDES}]]
543)
cab53332
ABL
544AC_CHECK_DECLS(
545 [SO_MARK],
546 ,
547 ,
548 [[${SOCKET_INCLUDES}]]
549)
9223336a
SK
550AC_CHECKING([anonymous union support])
551AC_COMPILE_IFELSE(
552 [AC_LANG_PROGRAM(
553 [[
554 struct mystruct {
555 union {
556 int m1;
557 char m2;
558 };
559 };
560 ]],
561 [[
562 struct mystruct s;
563 s.m1 = 1; s.m2 = 2;
564 ]]
565 )],
566 [
567 AC_MSG_RESULT([yes])
568 AC_DEFINE([HAVE_ANONYMOUS_UNION_SUPPORT], [], [Compiler supports anonymous unions])
569 ],
570 [AC_MSG_RESULT([no])]
571)
51bd56f4 572
f91ab283
SN
573saved_LDFLAGS="$LDFLAGS"
574LDFLAGS="$LDFLAGS -Wl,--wrap=exit"
575AC_MSG_CHECKING([linker supports --wrap])
576AC_LINK_IFELSE(
577 [AC_LANG_PROGRAM(
578 [[
579 void exit(int);
580 void __real_exit(int);
581 void __wrap_exit(int i) {
582 __real_exit(i);
583 }
584 ]],
585 [[
586 exit(0);
587 ]]
588 )],
589 [
590 AC_MSG_RESULT([yes])
591 have_ld_wrap_support=yes
592 ],
593 [AC_MSG_RESULT([no])],
594)
595LDFLAGS="$saved_LDFLAGS"
596
cab53332
ABL
597dnl We emulate signals in Windows
598AC_CHECK_DECLS(
599 [SIGHUP],
51bd56f4 600 ,
cab53332
ABL
601 [AC_DEFINE([SIGHUP], [1], [SIGHUP replacement])],
602 [[
603 #ifdef HAVE_SIGNAL_H
604 #include <signal.h>
605 #endif
606 ]]
51bd56f4 607)
cab53332
ABL
608AC_CHECK_DECLS(
609 [SIGINT],
610 ,
611 [AC_DEFINE([SIGINT], [2], [SIGINT replacement])],
612 [[
613 #ifdef HAVE_SIGNAL_H
614 #include <signal.h>
615 #endif
616 ]]
617)
618AC_CHECK_DECLS(
619 [SIGUSR1],
620 ,
621 [AC_DEFINE([SIGUSR1], [10], [SIGUSR1 replacement])],
622 [[
623 #ifdef HAVE_SIGNAL_H
624 #include <signal.h>
625 #endif
626 ]]
627)
628AC_CHECK_DECLS(
629 [SIGUSR2],
630 ,
631 [AC_DEFINE([SIGUSR2], [12], [SIGUSR2 replacement])],
632 [[
633 #ifdef HAVE_SIGNAL_H
634 #include <signal.h>
635 #endif
636 ]]
637)
638AC_CHECK_DECLS(
639 [SIGTERM],
640 ,
641 [AC_DEFINE([SIGTERM], [15], [SIGTERM replacement])],
642 [[
643 #ifdef HAVE_SIGNAL_H
644 #include <signal.h>
645 #endif
646 ]]
647)
648
649AC_FUNC_FORK
650
51bd56f4
ABL
651AC_CHECK_FUNCS([ \
652 daemon chroot getpwnam setuid nice system getpid dup dup2 \
fd2a29ab 653 getpass syslog openlog mlockall getgrnam setgid \
51bd56f4 654 setgroups stat flock readv writev time gettimeofday \
cab53332 655 ctime memset vsnprintf strdup \
51bd56f4
ABL
656 setsid chdir putenv getpeername unlink \
657 chsize ftruncate execve getpeereid umask basename dirname access \
658 epoll_create \
659])
aee7428c
ABL
660
661AC_CHECK_LIB(
662 [dl],
663 [dlopen],
664 [DL_LIBS="-ldl"]
665)
666AC_SUBST([DL_LIBS])
667
668AC_CHECK_LIB(
669 [nsl],
670 [inet_ntoa],
671 [SOCKETS_LIBS="${SOCKETS_LIBS} -lnsl"]
672)
673AC_CHECK_LIB(
674 [socket],
675 [socket],
676 [SOCKETS_LIBS="${SOCKETS_LIBS} -lsocket"]
677)
678AC_CHECK_LIB(
679 [resolv],
680 [gethostbyname],
681 [SOCKETS_LIBS="${SOCKETS_LIBS} -lresolv"]
682)
683AC_SUBST([SOCKETS_LIBS])
684
685old_LIBS="${LIBS}"
686LIBS="${LIBS} ${SOCKETS_LIBS}"
f96baabc 687AC_CHECK_FUNCS([sendmsg recvmsg])
0eb2ee14 688# Windows use stdcall for winsock so we cannot auto detect these
51bd56f4
ABL
689m4_define(
690 [SOCKET_FUNCS],
691[socket recv recvfrom send sendto listen dnl
692accept connect bind select gethostbyname inet_ntoa]dnl
693)
694m4_define(
695 [SOCKET_OPT_FUNCS],
696 [setsockopt getsockopt getsockname poll]dnl
697)
1bda73a7 698if test "${WIN32}" = "yes"; then
f96baabc
GD
699# normal autoconf function checking does not find inet_ntop/inet_pton
700# because they need to include the actual header file and link ws2_32.dll
701 LIBS="${LIBS} -lws2_32"
702 AC_MSG_CHECKING([for MinGW inet_ntop()/inet_pton()])
703 AC_LINK_IFELSE(
704 [AC_LANG_PROGRAM(
705 [[
706#include <ws2tcpip.h>
707 ]],
708 [[
709int r = (int) inet_ntop (0, NULL, NULL, 0);
710 r += inet_pton(AF_INET, NULL, NULL);
711return r;
712 ]]
713 )],
714 [AC_MSG_RESULT([OK])
715 AC_DEFINE([HAVE_INET_NTOP],[1],[MinGW inet_ntop])
716 AC_DEFINE([HAVE_INET_PTON],[1],[MinGW inet_pton])
717 ],
718 [AC_MSG_RESULT([not found])]
719 )
51bd56f4
ABL
720 m4_foreach(
721 [F],
722 m4_split(SOCKET_FUNCS SOCKET_OPT_FUNCS),
723 m4_define([UF], [[m4_join([_], [HAVE], m4_toupper(F))]])
724 AC_DEFINE([UF], [1], [Win32 builtin])
725 )
1bda73a7 726else
f96baabc 727 AC_CHECK_FUNCS([inet_ntop inet_pton])
51bd56f4
ABL
728 AC_CHECK_FUNCS(
729 SOCKET_FUNCS,
730 ,
731 [AC_MSG_ERROR([Required library function not found])]
732 )
733 AC_CHECK_FUNCS(SOCKET_OPT_FUNCS)
734fi
aee7428c 735LIBS="${old_LIBS}"
7647a48c 736
403dc434
GD
737# we assume res_init() always exist, but need to find out *where*...
738AC_SEARCH_LIBS(__res_init, resolv bind, ,
739 AC_SEARCH_LIBS(res_9_init, resolv bind, ,
740 AC_SEARCH_LIBS(res_init, resolv bind, , )))
741
7cacdfd4
ABL
742AC_ARG_VAR([TAP_CFLAGS], [C compiler flags for tap])
743old_CFLAGS="${CFLAGS}"
744CFLAGS="${CFLAGS} ${TAP_CFLAGS}"
745AC_CHECK_HEADERS(
746 [ \
747 net/if_tun.h net/tun/if_tun.h \
748 linux/if_tun.h \
749 tap-windows.h \
750 ],
751 [have_tap_header="yes"]
752)
88f3a402
ABL
753AC_CHECK_DECLS(
754 [TUNSETPERSIST],
755 [AC_DEFINE([ENABLE_FEATURE_TUN_PERSIST], [1], [We have persist tun capability])],
756 ,
757 [[
758 #ifdef HAVE_LINUX_IF_TUN_H
759 #include <linux/if_tun.h>
760 #endif
761 ]]
762)
7cacdfd4
ABL
763CFLAGS="${old_CFLAGS}"
764test "${have_tap_header}" = "yes" || AC_MSG_ERROR([no tap header could be found])
765
cd5990e0
ABL
766AC_CHECK_LIB(
767 [selinux],
768 [setcon],
769 [SELINUX_LIBS="-lselinux"]
770)
771AC_SUBST([SELINUX_LIBS])
772
ce8271f5
ABL
773AC_ARG_VAR([LIBPAM_CFLAGS], [C compiler flags for libpam])
774AC_ARG_VAR([LIBPAM_LIBS], [linker flags for libpam])
775if test -z "${LIBPAM_LIBS}"; then
776 AC_CHECK_LIB(
777 [pam],
778 [pam_start],
779 [LIBPAM_LIBS="-lpam"]
780 )
781fi
782
51bd56f4
ABL
783case "${with_mem_check}" in
784 valgrind)
fb69bfd0 785 AC_CHECK_HEADERS(
51bd56f4
ABL
786 [valgrind/memcheck.h],
787 [
788 CFLAGS="${CFLAGS} -g -fno-inline"
789 AC_DEFINE(
790 [USE_VALGRIND],
791 [1],
792 [Use valgrind memory debugging library]
793 )
794 ],
795 [AC_MSG_ERROR([valgrind headers not found.])]
796 )
797 ;;
798 dmalloc)
fb69bfd0 799 AC_CHECK_HEADERS(
51bd56f4
ABL
800 [dmalloc.h],
801 [AC_CHECK_LIB(
802 [dmalloc],
803 [malloc],
804 [
e02570fd 805 LIBS="${LIBS} -ldmalloc"
51bd56f4
ABL
806 AC_DEFINE(
807 [DMALLOC],
808 [1],
809 [Use dmalloc memory debugging library]
810 )
811 ],
812 [AC_MSG_ERROR([dmalloc library not found.])]
813 )],
814 [AC_MSG_ERROR([dmalloc headers not found.])]
815 )
816 ;;
817 ssl)
818 AC_CHECK_LIB(
819 [ssl],
820 [CRYPTO_mem_ctrl],
821 [
822 AC_DEFINE(
823 [CRYPTO_MDEBUG],
824 [1],
825 [Use memory debugging function in OpenSSL]
826 )
827 AC_MSG_NOTICE([NOTE: OpenSSL library must be compiled with CRYPTO_MDEBUG])
828 ],
829 [AC_MSG_ERROR([Memory Debugging function in OpenSSL library not found.])]
830 )
831 ;;
832esac
6fbf66fa 833
9a3f6702
SK
834PKG_CHECK_MODULES(
835 [PKCS11_HELPER],
6575ad48 836 [libpkcs11-helper-1 >= 1.11],
9a3f6702
SK
837 [have_pkcs11_helper="yes"],
838 []
839)
840
cf49ff50 841if test "${with_crypto_library}" = "openssl"; then
31b0bebe
SK
842 AC_ARG_VAR([OPENSSL_CFLAGS], [C compiler flags for OpenSSL])
843 AC_ARG_VAR([OPENSSL_LIBS], [linker flags for OpenSSL])
844
845 if test -z "${OPENSSL_CFLAGS}" -a -z "${OPENSSL_LIBS}"; then
846 # if the user did not explicitly specify flags, try to autodetect
847 PKG_CHECK_MODULES(
848 [OPENSSL],
79ea67f7
DS
849 [openssl >= 1.0.1],
850 [have_openssl="yes"],
851 [] # If this fails, we will do another test next
31b0bebe 852 )
31b0bebe
SK
853 OPENSSL_LIBS=${OPENSSL_LIBS:--lssl -lcrypto}
854 fi
9b33b5a4 855
9b33b5a4
ABL
856 saved_CFLAGS="${CFLAGS}"
857 saved_LIBS="${LIBS}"
31b0bebe
SK
858 CFLAGS="${CFLAGS} ${OPENSSL_CFLAGS}"
859 LIBS="${LIBS} ${OPENSSL_LIBS}"
860
79ea67f7
DS
861 # If pkgconfig check failed or OPENSSL_CFLAGS/OPENSSL_LIBS env vars
862 # are used, check the version directly in the OpenSSL include file
863 if test "${have_openssl}" != "yes"; then
864 AC_MSG_CHECKING([additionally if OpenSSL is available and version >= 1.0.1])
865 AC_COMPILE_IFELSE(
866 [AC_LANG_PROGRAM(
867 [[
868#include <openssl/opensslv.h>
869 ]],
870 [[
871/* Version encoding: MNNFFPPS - see opensslv.h for details */
872#if OPENSSL_VERSION_NUMBER < 0x10001000L
873#error OpenSSL too old
874#endif
875 ]]
876 )],
877 [AC_MSG_RESULT([ok])],
878 [AC_MSG_ERROR([OpenSSL version too old])]
879 )
880 fi
881
31b0bebe
SK
882 AC_CHECK_FUNCS([SSL_CTX_new EVP_CIPHER_CTX_set_key_length],
883 ,
884 [AC_MSG_ERROR([openssl check failed])]
885 )
886
9b33b5a4
ABL
887 have_openssl_engine="yes"
888 AC_CHECK_FUNCS(
889 [ \
890 ENGINE_load_builtin_engines \
891 ENGINE_register_all_complete \
892 ENGINE_cleanup \
893 ],
894 ,
895 [have_openssl_engine="no"; break]
896 )
6b5dbf6c
JB
897 if test "${have_openssl_engine}" = "no"; then
898 AC_CHECK_DECL( [ENGINE_cleanup], [have_openssl_engine="yes"],,
899 [[
900 #include <openssl/engine.h>
901 ]]
902 )
903 fi
31b0bebe
SK
904 if test "${have_openssl_engine}" = "yes"; then
905 AC_DEFINE([HAVE_OPENSSL_ENGINE], [1], [OpenSSL engine support available])
906 fi
9b33b5a4 907
66407e11
SK
908 have_crypto_aead_modes="yes"
909 AC_CHECK_FUNCS(
910 [EVP_aes_256_gcm],
911 ,
912 [have_crypto_aead_modes="no"; break]
913 )
914
6554ac9f
ED
915 AC_CHECK_FUNCS(
916 [ \
aba98e90
ED
917 HMAC_CTX_new \
918 HMAC_CTX_free \
919 HMAC_CTX_reset \
c481ef00
ED
920 EVP_MD_CTX_new \
921 EVP_MD_CTX_free \
922 EVP_MD_CTX_reset \
8a01147f 923 EVP_CIPHER_CTX_reset \
17a476fd 924 OpenSSL_version \
6554ac9f
ED
925 SSL_CTX_get_default_passwd_cb \
926 SSL_CTX_get_default_passwd_cb_userdata \
88a827f2 927 SSL_CTX_set_security_level \
8a01147f
RP
928 X509_get0_notBefore \
929 X509_get0_notAfter \
17d1ab90 930 X509_get0_pubkey \
f05665df 931 X509_STORE_get0_objects \
47191f49
ED
932 X509_OBJECT_free \
933 X509_OBJECT_get_type \
b8ca5bc3
ED
934 EVP_PKEY_id \
935 EVP_PKEY_get0_RSA \
936 EVP_PKEY_get0_DSA \
bb23eca8 937 EVP_PKEY_get0_EC_KEY \
f7780af6
ED
938 RSA_set_flags \
939 RSA_bits \
940 RSA_get0_key \
941 RSA_set0_key \
c07c0358
ED
942 DSA_get0_pqg \
943 DSA_bits \
09776c5b
ED
944 RSA_meth_new \
945 RSA_meth_free \
946 RSA_meth_set_pub_enc \
947 RSA_meth_set_pub_dec \
948 RSA_meth_set_priv_enc \
949 RSA_meth_set_priv_dec \
950 RSA_meth_set_init \
720c880a 951 RSA_meth_set_sign \
09776c5b
ED
952 RSA_meth_set_finish \
953 RSA_meth_set0_app_data \
862cbe53 954 RSA_meth_get0_app_data \
bb23eca8 955 EC_GROUP_order_bits
07372a0f 956 ]
6554ac9f
ED
957 )
958
9b33b5a4
ABL
959 CFLAGS="${saved_CFLAGS}"
960 LIBS="${saved_LIBS}"
9b33b5a4 961
31b0bebe
SK
962 AC_DEFINE([ENABLE_CRYPTO_OPENSSL], [1], [Use OpenSSL library])
963 CRYPTO_CFLAGS="${OPENSSL_CFLAGS}"
964 CRYPTO_LIBS="${OPENSSL_LIBS}"
cf49ff50 965elif test "${with_crypto_library}" = "mbedtls"; then
86d8cd68
SK
966 AC_ARG_VAR([MBEDTLS_CFLAGS], [C compiler flags for mbedtls])
967 AC_ARG_VAR([MBEDTLS_LIBS], [linker flags for mbedtls])
31b0bebe 968
417fe4a7
SK
969 saved_CFLAGS="${CFLAGS}"
970 saved_LIBS="${LIBS}"
971
86d8cd68 972 if test -z "${MBEDTLS_CFLAGS}" -a -z "${MBEDTLS_LIBS}"; then
e860059b 973 # if the user did not explicitly specify flags, try to autodetect
1ae17b7e 974 LIBS="${LIBS} -lmbedtls -lmbedx509 -lmbedcrypto"
86d8cd68
SK
975 AC_CHECK_LIB(
976 [mbedtls],
977 [mbedtls_ssl_init],
1ae17b7e 978 [MBEDTLS_LIBS="-lmbedtls -lmbedx509 -lmbedcrypto"],
86d8cd68 979 [AC_MSG_ERROR([Could not find mbed TLS.])],
31b0bebe
SK
980 [${PKCS11_HELPER_LIBS}]
981 )
982 fi
9b33b5a4 983
86d8cd68
SK
984 CFLAGS="${MBEDTLS_CFLAGS} ${PKCS11_HELPER_CFLAGS} ${CFLAGS}"
985 LIBS="${MBEDTLS_LIBS} ${PKCS11_HELPER_LIBS} ${LIBS}"
417fe4a7 986
86d8cd68 987 AC_MSG_CHECKING([mbedtls version])
13b38eb0
ABL
988 AC_COMPILE_IFELSE(
989 [AC_LANG_PROGRAM(
990 [[
86d8cd68 991#include <mbedtls/version.h>
13b38eb0
ABL
992 ]],
993 [[
86d8cd68 994#if MBEDTLS_VERSION_NUMBER < 0x02000000 || MBEDTLS_VERSION_NUMBER >= 0x03000000
9a3f6702 995#error invalid version
13b38eb0
ABL
996#endif
997 ]]
998 )],
999 [AC_MSG_RESULT([ok])],
86d8cd68 1000 [AC_MSG_ERROR([mbed TLS 2.y.z required])]
13b38eb0 1001 )
9a3f6702 1002
66407e11
SK
1003 have_crypto_aead_modes="yes"
1004 AC_CHECK_FUNCS(
1005 [ \
86d8cd68
SK
1006 mbedtls_cipher_write_tag \
1007 mbedtls_cipher_check_tag \
66407e11
SK
1008 ],
1009 ,
1010 [have_crypto_aead_modes="no"; break]
1011 )
1012
31b0bebe
SK
1013 CFLAGS="${saved_CFLAGS}"
1014 LIBS="${saved_LIBS}"
86d8cd68
SK
1015 AC_DEFINE([ENABLE_CRYPTO_MBEDTLS], [1], [Use mbed TLS library])
1016 CRYPTO_CFLAGS="${MBEDTLS_CFLAGS}"
1017 CRYPTO_LIBS="${MBEDTLS_LIBS}"
cf49ff50 1018else
31b0bebe 1019 AC_MSG_ERROR([Invalid crypto library: ${with_crypto_library}])
13b38eb0
ABL
1020fi
1021
74bbc71b
ABL
1022AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
1023AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
1024have_lzo="yes"
1025if test -z "${LZO_LIBS}"; then
1026 AC_CHECK_LIB(
1027 [lzo2],
1028 [lzo1x_1_15_compress],
1029 [LZO_LIBS="-llzo2"],
1030 [AC_CHECK_LIB(
1031 [lzo],
1032 [lzo1x_1_15_compress],
1033 [LZO_LIBS="-llzo"],
1034 [have_lzo="no"]
1035 )]
1036 )
1037fi
1038if test "${have_lzo}" = "yes"; then
1039 saved_CFLAGS="${CFLAGS}"
1040 CFLAGS="${CFLAGS} ${LZO_CFLAGS}"
1041 AC_CHECK_HEADERS(
1042 [lzo/lzoutil.h],
1043 ,
1044 [AC_CHECK_HEADERS(
1045 [lzoutil.h],
1046 ,
1047 [AC_MSG_ERROR([lzoutil.h is missing])]
1048 )]
1049 )
1050 AC_CHECK_HEADERS(
1051 [lzo/lzo1x.h],
1052 ,
1053 [AC_CHECK_HEADERS(
1054 [lzo1x.h],
1055 ,
1056 [AC_MSG_ERROR([lzo1x.h is missing])]
1057 )]
1058 )
1059 CFLAGS="${saved_CFLAGS}"
6fbf66fa
JY
1060fi
1061
40efb635
GD
1062dnl
1063dnl check for LZ4 library
1064dnl
1065
1066AC_ARG_VAR([LZ4_CFLAGS], [C compiler flags for lz4])
1067AC_ARG_VAR([LZ4_LIBS], [linker flags for lz4])
1068if test "$enable_lz4" = "yes" && test "$enable_comp_stub" = "no"; then
5f6225c3
DS
1069 if test -z "${LZ4_CFLAGS}" -a -z "${LZ4_LIBS}"; then
1070 # if the user did not explicitly specify flags, try to autodetect
1071 PKG_CHECK_MODULES([LZ4],
f91e4863 1072 [liblz4 >= 1.7.1 liblz4 < 100],
5f6225c3 1073 [have_lz4="yes"],
e5b279f1
DS
1074 [LZ4_LIBS="-llz4"] # If this fails, we will do another test next.
1075 # We also add set LZ4_LIBS otherwise the
1076 # linker will not know about the lz4 library
5f6225c3
DS
1077 )
1078 fi
1079
1080 saved_CFLAGS="${CFLAGS}"
1081 saved_LIBS="${LIBS}"
1082 CFLAGS="${CFLAGS} ${LZ4_CFLAGS}"
1083 LIBS="${LIBS} ${LZ4_LIBS}"
1084
1085 # If pkgconfig check failed or LZ4_CFLAGS/LZ4_LIBS env vars
1086 # are used, check the version directly in the LZ4 include file
1087 if test "${have_lz4}" != "yes"; then
1088 AC_CHECK_HEADERS([lz4.h],
1089 [have_lz4h="yes"],
1090 [])
1091
1092 if test "${have_lz4h}" = "yes" ; then
1093 AC_MSG_CHECKING([additionally if system LZ4 version >= 1.7.1])
1094 AC_COMPILE_IFELSE(
1095 [AC_LANG_PROGRAM([[
1096#include <lz4.h>
1097 ]],
1098 [[
1099/* Version encoding: MMNNPP (Major miNor Patch) - see lz4.h for details */
1100#if LZ4_VERSION_NUMBER < 10701L
1101#error LZ4 is too old
1102#endif
1103 ]]
1104 )],
1105 [
1106 AC_MSG_RESULT([ok])
1107 have_lz4="yes"
1108 ],
1109 [AC_MSG_RESULT([system LZ4 library is too old])]
1110 )
1111 fi
1112 fi
40efb635 1113
f91e4863
DS
1114 # Double check we have a few needed functions
1115 if test "${have_lz4}" = "yes" ; then
5f6225c3 1116 AC_CHECK_LIB([lz4],
f91e4863
DS
1117 [LZ4_compress_default],
1118 [],
1119 [have_lz4="no"])
1120 AC_CHECK_LIB([lz4],
1121 [LZ4_decompress_safe],
1122 [],
5f6225c3 1123 [have_lz4="no"])
40efb635
GD
1124 fi
1125
5f6225c3 1126 if test "${have_lz4}" != "yes" ; then
f91e4863 1127 AC_MSG_RESULT([ usable LZ4 library or header not found, using version in src/compat/compat-lz4.*])
4308f237
GD
1128 AC_DEFINE([NEED_COMPAT_LZ4], [1], [use copy of LZ4 source in compat/])
1129 LZ4_LIBS=""
40efb635
GD
1130 fi
1131 OPTIONAL_LZ4_CFLAGS="${LZ4_CFLAGS}"
1132 OPTIONAL_LZ4_LIBS="${LZ4_LIBS}"
5f6225c3 1133 AC_DEFINE(ENABLE_LZ4, [1], [Enable LZ4 compression library])
40efb635 1134 CFLAGS="${saved_CFLAGS}"
5f6225c3 1135 LIBS="${saved_LIBS}"
40efb635
GD
1136fi
1137
1138
f33ee6bc
DS
1139dnl
1140dnl Check for systemd
1141dnl
3280d8c8 1142AM_CONDITIONAL([ENABLE_SYSTEMD], [test "${enable_systemd}" = "yes"])
f33ee6bc
DS
1143if test "$enable_systemd" = "yes" ; then
1144 PKG_CHECK_MODULES([libsystemd], [systemd libsystemd],
1145 [],
1146 [PKG_CHECK_MODULES([libsystemd], [libsystemd-daemon])]
1147 )
8ba3e258
DS
1148
1149 PKG_CHECK_EXISTS( [libsystemd > 216],
1150 [AC_DEFINE([SYSTEMD_NEWER_THAN_216], [1],
1151 [systemd is newer than v216])]
1152 )
1153
f33ee6bc
DS
1154 AC_CHECK_HEADERS(systemd/sd-daemon.h,
1155 ,
1156 [
1157 AC_MSG_ERROR([systemd development headers not found.])
1158 ])
1159
1160 saved_LIBS="${LIBS}"
1161 LIBS="${LIBS} ${libsystemd_LIBS}"
1162 AC_CHECK_FUNCS([sd_booted], [], [AC_MSG_ERROR([systemd library is missing sd_booted()])])
1163 OPTIONAL_SYSTEMD_LIBS="${libsystemd_LIBS}"
1164 AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd integration])
1165 LIBS="${saved_LIBS}"
ca5b4c2a
CH
1166
1167 if test -n "${SYSTEMD_UNIT_DIR}"; then
1168 systemdunitdir="${SYSTEMD_UNIT_DIR}"
1169 else
1170 systemdunitdir="\${libdir}/systemd/system"
1171 fi
3de7be7b
CH
1172
1173 if test -n "${TMPFILES_DIR}"; then
1174 tmpfilesdir="${TMPFILES_DIR}"
1175 else
1176 tmpfilesdir="\${libdir}/tmpfiles.d"
1177 fi
f33ee6bc 1178fi
40efb635 1179
38d96bd7 1180
7046ff20
ABL
1181AC_MSG_CHECKING([git checkout])
1182GIT_CHECKOUT="no"
1183if test -n "${GIT}" -a -d "${srcdir}/.git"; then
1184 AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h])
1185 GIT_CHECKOUT="yes"
1186fi
1187AC_MSG_RESULT([${GIT_CHECKOUT}])
1188
51bd56f4
ABL
1189if test -n "${SP_PLATFORM_WINDOWS}"; then
1190 AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #"
1191 AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
1192else
1193 AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['/'], [Path separator])
1194 AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["/"], [Path separator])
1195fi
1196
1197dnl enable --x509-username-field feature if requested
1198if test "${enable_x509_alt_username}" = "yes"; then
86d8cd68
SK
1199 if test "${with_crypto_library}" = "mbedtls" ; then
1200 AC_MSG_ERROR([mbed TLS does not support the --x509-username-field feature])
51bd56f4
ABL
1201 fi
1202
1203 AC_DEFINE([ENABLE_X509ALTUSERNAME], [1], [Enable --x509-username-field feature])
1204fi
1205
1206test "${ac_cv_header_sys_uio_h}" = "yes" && AC_DEFINE([HAVE_IOVEC], [1], [struct iovec needed for IPv6 support])
51bd56f4
ABL
1207test "${enable_server}" = "no" && AC_DEFINE([ENABLE_CLIENT_ONLY], [1], [Enable client capability only])
1208test "${enable_management}" = "yes" && AC_DEFINE([ENABLE_MANAGEMENT], [1], [Enable management server capability])
51bd56f4
ABL
1209test "${enable_multihome}" = "yes" && AC_DEFINE([ENABLE_MULTIHOME], [1], [Enable multi-homed UDP server capability])
1210test "${enable_debug}" = "yes" && AC_DEFINE([ENABLE_DEBUG], [1], [Enable debugging support])
1211test "${enable_small}" = "yes" && AC_DEFINE([ENABLE_SMALL], [1], [Enable smaller executable size])
1212test "${enable_fragment}" = "yes" && AC_DEFINE([ENABLE_FRAGMENT], [1], [Enable internal fragmentation support])
1213test "${enable_port_share}" = "yes" && AC_DEFINE([ENABLE_PORT_SHARE], [1], [Enable TCP Server port sharing])
1214test "${enable_def_auth}" = "yes" && AC_DEFINE([ENABLE_DEF_AUTH], [1], [Enable deferred authentication])
1215test "${enable_pf}" = "yes" && AC_DEFINE([ENABLE_PF], [1], [Enable internal packet filter])
1216test "${enable_strict_options}" = "yes" && AC_DEFINE([ENABLE_STRICT_OPTIONS_CHECK], [1], [Enable strict options check between peers])
c3fc703d 1217
cf49ff50
AQ
1218test "${enable_crypto_ofb_cfb}" = "yes" && AC_DEFINE([ENABLE_OFB_CFB_MODE], [1], [Enable OFB and CFB cipher modes])
1219test "${have_crypto_aead_modes}" = "yes" && AC_DEFINE([HAVE_AEAD_CIPHER_MODES], [1], [Use crypto library])
1220OPTIONAL_CRYPTO_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_CFLAGS}"
1221OPTIONAL_CRYPTO_LIBS="${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_LIBS}"
9b33b5a4 1222
bdae4110 1223if test "${enable_plugins}" = "yes"; then
bdae4110 1224 OPTIONAL_DL_LIBS="${DL_LIBS}"
8065cd1c 1225 AC_DEFINE([ENABLE_PLUGIN], [1], [Enable plug-in support])
ce8271f5
ABL
1226else
1227 enable_plugin_auth_pam="no"
1228 enable_plugin_down_root="no"
bdae4110
ABL
1229fi
1230
1e894662
AQ
1231AM_CONDITIONAL([HAVE_SITNL], [false])
1232
c3fc703d
ABL
1233if test "${enable_iproute2}" = "yes"; then
1234 test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing])
1235 AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
c6542257
AQ
1236else if test "${have_sitnl}" = "yes"; then
1237 AC_DEFINE([ENABLE_SITNL], [1], [enable sitnl support])
1e894662 1238 AM_CONDITIONAL([HAVE_SITNL], [true])
c6542257
AQ
1239else if test "${WIN32}" != "yes" -a "${have_sitnl}" != "yes"; then
1240 test -z "${ROUTE}" && AC_MSG_ERROR([route utility is required but missing])
1241 test -z "${IFCONFIG}" && AC_MSG_ERROR([ifconfig utility is required but missing])
1242fi
1243fi
c3fc703d 1244fi
51bd56f4 1245
cd5990e0
ABL
1246if test "${enable_selinux}" = "yes"; then
1247 test -z "${SELINUX_LIBS}" && AC_MSG_ERROR([libselinux required but missing])
1248 OPTIONAL_SELINUX_LIBS="${SELINUX_LIBS}"
1249 AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support])
1250fi
1251
74bbc71b
ABL
1252if test "${enable_lzo}" = "yes"; then
1253 test "${have_lzo}" != "yes" && AC_MSG_ERROR([lzo enabled but missing])
1254 OPTIONAL_LZO_CFLAGS="${LZO_CFLAGS}"
1255 OPTIONAL_LZO_LIBS="${LZO_LIBS}"
1256 AC_DEFINE([ENABLE_LZO], [1], [Enable LZO compression library])
1257fi
38d96bd7
JY
1258if test "${enable_comp_stub}" = "yes"; then
1259 test "${enable_lzo}" = "yes" && AC_MSG_ERROR([Cannot have both comp stub and lzo enabled (use --disable-lzo)])
40efb635 1260 test "${enable_lz4}" = "yes" && AC_MSG_ERROR([Cannot have both comp stub and LZ4 enabled (use --disable-lz4)])
38d96bd7 1261 AC_DEFINE([ENABLE_COMP_STUB], [1], [Enable compression stub capability])
07084261
ABL
1262fi
1263
18b5fbdf
ABL
1264if test "${enable_pkcs11}" = "yes"; then
1265 test "${have_pkcs11_helper}" != "yes" && AC_MSG_ERROR([PKCS11 enabled but libpkcs11-helper is missing])
18b5fbdf
ABL
1266 OPTIONAL_PKCS11_HELPER_CFLAGS="${PKCS11_HELPER_CFLAGS}"
1267 OPTIONAL_PKCS11_HELPER_LIBS="${PKCS11_HELPER_LIBS}"
1268 AC_DEFINE([ENABLE_PKCS11], [1], [Enable PKCS11])
3c6d3220
DW
1269 PKG_CHECK_MODULES(
1270 [P11KIT],
1271 [p11-kit-1],
1272 [proxy_module="`$PKG_CONFIG --variable=proxy_module p11-kit-1`"
1273 AC_DEFINE_UNQUOTED([DEFAULT_PKCS11_MODULE], "${proxy_module}", [p11-kit proxy])],
1274 []
1275 )
18b5fbdf
ABL
1276fi
1277
6a5d10e9
SK
1278AC_DEFUN([ACL_CHECK_ADD_COMPILE_FLAGS], [
1279 old_cflags="$CFLAGS"
1280 CFLAGS="$1 $CFLAGS"
1281 AC_MSG_CHECKING([whether the compiler acceppts $1])
1282 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [AC_MSG_RESULT([yes])],
1283 [AC_MSG_RESULT([no]); CFLAGS="$old_cflags"])]
adbf68c0 1284)
6a5d10e9 1285
46d09607 1286ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation])
6a5d10e9
SK
1287ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-function])
1288ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-parameter])
1289ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
adbf68c0 1290
51bd56f4
ABL
1291if test "${enable_pedantic}" = "yes"; then
1292 enable_strict="yes"
31444111 1293 CFLAGS="${CFLAGS} -pedantic"
058f0efd 1294 AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode])
51bd56f4
ABL
1295fi
1296if test "${enable_strict}" = "yes"; then
adbf68c0 1297 CFLAGS="${CFLAGS} -Wsign-compare -Wuninitialized"
99385447 1298fi
51194ffd
SK
1299if test "${enable_werror}" = "yes"; then
1300 CFLAGS="${CFLAGS} -Werror"
1301fi
99385447 1302
c3fc703d
ABL
1303if test "${WIN32}" = "yes"; then
1304 test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
1305fi
1306
ce8271f5
ABL
1307if test "${enable_plugin_auth_pam}" = "yes"; then
1308 PLUGIN_AUTH_PAM_CFLAGS="${LIBPAM_CFLAGS}"
1309 if test "${enable_pam_dlopen}" = "yes"; then
1310 AC_DEFINE([USE_PAM_DLOPEN], [1], [dlopen libpam])
1311 PLUGIN_AUTH_PAM_LIBS="${DL_LIBS}"
1312 else
1313 test -z "${LIBPAM_LIBS}" && AC_MSG_ERROR([libpam required but missing])
1314 PLUGIN_AUTH_PAM_LIBS="${LIBPAM_LIBS}"
1315 fi
1316fi
1317
0d1a75bf
LS
1318if test "${enable_async_push}" = "yes"; then
1319 AC_CHECK_HEADERS(
1320 [sys/inotify.h],
1321 AC_DEFINE([ENABLE_ASYNC_PUSH], [1], [Enable async push]),
1322 AC_MSG_ERROR([inotify.h not found.])
1323 )
1324fi
1325
fcff80aa
ABL
1326CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
1327AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])
1328
ac2447cd
ABL
1329TAP_WIN_COMPONENT_ID="PRODUCT_TAP_WIN_COMPONENT_ID"
1330TAP_WIN_MIN_MAJOR="PRODUCT_TAP_WIN_MIN_MAJOR"
1331TAP_WIN_MIN_MINOR="PRODUCT_TAP_WIN_MIN_MINOR"
1332AC_DEFINE_UNQUOTED([TAP_WIN_COMPONENT_ID], ["${TAP_WIN_COMPONENT_ID}"], [The tap-windows id])
1333AC_DEFINE_UNQUOTED([TAP_WIN_MIN_MAJOR], [${TAP_WIN_MIN_MAJOR}], [The tap-windows version number is required for OpenVPN])
1334AC_DEFINE_UNQUOTED([TAP_WIN_MIN_MINOR], [${TAP_WIN_MIN_MINOR}], [The tap-windows version number is required for OpenVPN])
1335AC_SUBST([TAP_WIN_COMPONENT_ID])
1336AC_SUBST([TAP_WIN_MIN_MAJOR])
1337AC_SUBST([TAP_WIN_MIN_MINOR])
1bda73a7 1338
bdae4110 1339AC_SUBST([OPTIONAL_DL_LIBS])
cd5990e0 1340AC_SUBST([OPTIONAL_SELINUX_LIBS])
9b33b5a4
ABL
1341AC_SUBST([OPTIONAL_CRYPTO_CFLAGS])
1342AC_SUBST([OPTIONAL_CRYPTO_LIBS])
74bbc71b
ABL
1343AC_SUBST([OPTIONAL_LZO_CFLAGS])
1344AC_SUBST([OPTIONAL_LZO_LIBS])
40efb635
GD
1345AC_SUBST([OPTIONAL_LZ4_CFLAGS])
1346AC_SUBST([OPTIONAL_LZ4_LIBS])
f33ee6bc 1347AC_SUBST([OPTIONAL_SYSTEMD_LIBS])
18b5fbdf
ABL
1348AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS])
1349AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
bdae4110 1350
ce8271f5
ABL
1351AC_SUBST([PLUGIN_AUTH_PAM_CFLAGS])
1352AC_SUBST([PLUGIN_AUTH_PAM_LIBS])
1353
51bd56f4 1354AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
7046ff20 1355AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"])
ce8271f5
ABL
1356AM_CONDITIONAL([ENABLE_PLUGIN_AUTH_PAM], [test "${enable_plugin_auth_pam}" = "yes"])
1357AM_CONDITIONAL([ENABLE_PLUGIN_DOWN_ROOT], [test "${enable_plugin_down_root}" = "yes"])
f91ab283 1358AM_CONDITIONAL([HAVE_LD_WRAP_SUPPORT], [test "${have_ld_wrap_support}" = "yes"])
1bda73a7 1359
880a2ae9 1360sampledir="\$(docdir)/sample"
ce8271f5 1361AC_SUBST([plugindir])
880a2ae9
ABL
1362AC_SUBST([sampledir])
1363
ca5b4c2a 1364AC_SUBST([systemdunitdir])
3de7be7b 1365AC_SUBST([tmpfilesdir])
ca5b4c2a 1366
222e6917
GD
1367AC_ARG_ENABLE(
1368 [unit-tests],
1369 [AS_HELP_STRING([--disable-unit-tests],
1370 [Disables building and running the unit tests suite])],
1371 [],
1372 [enable_unit_tests="yes"]
1373)
1374
1375# Check if cmocka is available - needed for unit testing
1376PKG_CHECK_MODULES(
1377 [CMOCKA], [cmocka],
1378 [have_cmocka="yes"],
1379 [AC_MSG_WARN([cmocka.pc not found on the system. Unit tests disabled])]
1380)
1381AM_CONDITIONAL([ENABLE_UNITTESTS], [test "${enable_unit_tests}" = "yes" -a "${have_cmocka}" = "yes" ])
1382AC_SUBST([ENABLE_UNITTESTS])
1383
7473f326 1384TEST_LDFLAGS="${OPTIONAL_CRYPTO_LIBS} ${OPTIONAL_PKCS11_HELPER_LIBS}"
222e6917 1385TEST_LDFLAGS="${TEST_LDFLAGS} ${OPTIONAL_LZO_LIBS} ${CMOCKA_LIBS}"
7473f326
SK
1386TEST_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${OPTIONAL_PKCS11_HELPER_CFLAGS}"
1387TEST_CFLAGS="${TEST_CFLAGS} ${OPTIONAL_LZO_CFLAGS}"
222e6917 1388TEST_CFLAGS="${TEST_CFLAGS} -I\$(top_srcdir)/include ${CMOCKA_CFLAGS}"
40cb4cfc
JN
1389
1390AC_SUBST([TEST_LDFLAGS])
1391AC_SUBST([TEST_CFLAGS])
1392
51bd56f4 1393AC_CONFIG_FILES([
6187644b 1394 version.sh
1bda73a7 1395 Makefile
98bc1a3e 1396 build/Makefile
4b1a82db
ABL
1397 build/msvc/Makefile
1398 build/msvc/msvc-generate/Makefile
34cb9132 1399 distro/Makefile
ca5b4c2a 1400 distro/systemd/Makefile
66bf378e
SK
1401 doc/Makefile
1402 doc/doxygen/Makefile
1403 doc/doxygen/openvpn.doxyfile
34cb9132
ABL
1404 include/Makefile
1405 src/Makefile
dc81e743 1406 src/compat/Makefile
34cb9132 1407 src/openvpn/Makefile
ce68686f 1408 src/openvpnmsica/Makefile
34cb9132 1409 src/openvpnserv/Makefile
ce8271f5
ABL
1410 src/plugins/Makefile
1411 src/plugins/auth-pam/Makefile
1412 src/plugins/down-root/Makefile
ce68686f 1413 src/tapctl/Makefile
34cb9132 1414 tests/Makefile
40cb4cfc
JN
1415 tests/unit_tests/Makefile
1416 tests/unit_tests/example_test/Makefile
698e268a 1417 tests/unit_tests/openvpn/Makefile
ac42df1a
SK
1418 tests/unit_tests/plugins/Makefile
1419 tests/unit_tests/plugins/auth-pam/Makefile
34cb9132 1420 sample/Makefile
1bda73a7 1421])
34cb9132 1422AC_CONFIG_FILES([tests/t_client.sh], [chmod +x tests/t_client.sh])
51bd56f4 1423AC_OUTPUT