configure.ac
6fbf66fa
 dnl  OpenVPN -- An application to securely tunnel IP networks
 dnl             over a single UDP port, with support for SSL/TLS-based
 dnl             session authentication and key exchange,
 dnl             packet encryption, packet authentication, and
 dnl             packet compression.
 dnl
564a2109
 dnl  Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
51bd56f4
 dnl  Copyright (C) 2006-2012 Alon Bar-Lev <alon.barlev@gmail.com>
6fbf66fa
 dnl
 dnl  This program is free software; you can redistribute it and/or modify
 dnl  it under the terms of the GNU General Public License as published by
 dnl  the Free Software Foundation; either version 2 of the License, or
 dnl  (at your option) any later version.
 dnl
 dnl  This program is distributed in the hope that it will be useful,
 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 dnl  GNU General Public License for more details.
 dnl
 dnl  You should have received a copy of the GNU General Public License
 dnl  along with this program (see the file COPYING included with this
 dnl  distribution); if not, write to the Free Software Foundation, Inc.,
 dnl  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 dnl Process this file with autoconf to produce a configure script.
 
51bd56f4
 AC_PREREQ(2.59)
6fbf66fa
 
ce351583
 m4_include(version.m4)
51bd56f4
 AC_INIT([PRODUCT_NAME], [PRODUCT_VERSION], [PRODUCT_BUGREPORT], [PRODUCT_TARNAME])
 m4_include(compat.m4)
98bc1a3e
 AC_DEFINE([OPENVPN_VERSION_RESOURCE], [PRODUCT_VERSION_RESOURCE], [Version in windows resource format])
 
51bd56f4
 AC_CONFIG_AUX_DIR([.])
ffb9d7d9
 AC_CONFIG_HEADERS([config.h])
34cb9132
 AC_CONFIG_SRCDIR([src/openvpn/syshead.h])
0fc5b8b3
 AC_CONFIG_MACRO_DIR([m4])
d378850a
 
 dnl Initialize automake.  automake < 1.12 didn't have serial-tests and
 dnl gives an error if it sees this, but for automake >= 1.13
 dnl serial-tests is required so we have to include it.  Solution is to
 dnl test for the version of automake (by running an external command)
 dnl and provide it if necessary.  Note we have to do this entirely using
 dnl m4 macros since automake queries this macro by running
 dnl 'autoconf --trace ...'.
 m4_define([serial_tests], [
     m4_esyscmd([automake --version |
                 head -1 |
                 awk '{split ($NF,a,"."); if (a[1] == 1 && a[2] >= 12) { print "serial-tests" }}'
     ])
 ])
 AM_INIT_AUTOMAKE(foreign serial_tests) dnl NB: Do not [quote] this parameter.
51bd56f4
 AC_CANONICAL_HOST
 AC_USE_SYSTEM_EXTENSIONS
6fbf66fa
 
51bd56f4
 AC_ARG_ENABLE(
 	[lzo],
40a56e79
 	[AS_HELP_STRING([--disable-lzo], [disable LZO compression support @<:@default=yes@:>@])],
51bd56f4
 	,
40a56e79
 	[enable_lzo="yes"]
6c34e74f
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[lzo-stub],
709f7a1f
 	[AS_HELP_STRING([--enable-lzo-stub], [don't compile LZO compression support but still allow limited interoperability with LZO-enabled peers @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_lzo_stub="no"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[crypto],
709f7a1f
 	[AS_HELP_STRING([--disable-crypto], [disable crypto support @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_crypto="yes"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
f71a780f
 	[ofb-cfb],
995be6fd
 	[AS_HELP_STRING([--disable-ofb-cfb], [disable support for OFB and CFB cipher modes @<:@default=yes@:>@])],
f71a780f
 	,
 	[enable_crypto_ofb_cfb="yes"]
 )
 
 AC_ARG_ENABLE(
51bd56f4
 	[ssl],
709f7a1f
 	[AS_HELP_STRING([--disable-ssl], [disable SSL support for TLS-based key exchange @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_ssl="yes"]
fbd18db6
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[x509-alt-username],
709f7a1f
 	[AS_HELP_STRING([--enable-x509-alt-username], [enable the --x509-username-field feature @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_x509_alt_username="no"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[multi],
709f7a1f
 	[AS_HELP_STRING([--disable-multi], [disable client/server support (--mode server + client mode) @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_multi="yes"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[server],
709f7a1f
 	[AS_HELP_STRING([--disable-server], [disable server support only (but retain client support) @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_server="yes"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[plugins],
709f7a1f
 	[AS_HELP_STRING([--disable-plugins], [disable plug-in support @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_plugins="yes"]
0c1f7ad5
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[management],
709f7a1f
 	[AS_HELP_STRING([--disable-management], [disable management server support @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_management="yes"]
ce98fd24
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[pkcs11],
709f7a1f
 	[AS_HELP_STRING([--enable-pkcs11], [enable pkcs11 support @<:@default=no@:>@])],
51bd56f4
 	,
18b5fbdf
 	[enable_pkcs11="no"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[socks],
709f7a1f
 	[AS_HELP_STRING([--disable-socks], [disable Socks support @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_socks="yes"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[http-proxy],
709f7a1f
 	[AS_HELP_STRING([--disable-http-proxy], [disable HTTP proxy support @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_http_proxy="yes"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[fragment],
709f7a1f
 	[AS_HELP_STRING([--disable-fragment], [disable internal fragmentation support (--fragment) @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_fragment="yes"]
8bc93d7f
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[multihome],
709f7a1f
 	[AS_HELP_STRING([--disable-multihome], [disable multi-homed UDP server support (--multihome) @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_multihome="yes"]
6add6b2f
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[port-share],
709f7a1f
 	[AS_HELP_STRING([--disable-port-share], [disable TCP server port-share support (--port-share) @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_port_share="yes"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[debug],
709f7a1f
 	[AS_HELP_STRING([--disable-debug], [disable debugging support (disable gremlin and verb 7+ messages) @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_debug="yes"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[small],
995be6fd
 	[AS_HELP_STRING([--enable-small], [enable smaller executable size (disable OCC, usage message, and verb 4 parm list) @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_small="no"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[iproute2],
709f7a1f
 	[AS_HELP_STRING([--enable-iproute2], [enable support for iproute2 @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_iproute2="no"]
fb7aa54a
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[def-auth],
709f7a1f
 	[AS_HELP_STRING([--disable-def-auth], [disable deferred authentication @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_def_auth="yes"]
fb7aa54a
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[pf],
709f7a1f
 	[AS_HELP_STRING([--disable-pf], [disable internal packet filter @<:@default=yes@:>@])],
51bd56f4
 	,
 	[enable_pf="yes"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
ce8271f5
 	[plugin-auth-pam],
5a57e201
 	[AS_HELP_STRING([--disable-plugin-auth-pam], [disable auth-pam plugin @<:@default=platform specific@:>@])],
ce8271f5
 	,
5a57e201
 	[
 		case "$host" in
 			*-*-openbsd*) enable_plugin_auth_pam="no";;
 			*-mingw*) enable_plugin_auth_pam="no";;
 			*) enable_plugin_auth_pam="yes";;
 		esac
 	]
ce8271f5
 )
 
 AC_ARG_ENABLE(
 	[plugin-down-root],
5a57e201
 	[AS_HELP_STRING([--disable-plugin-down-root], [disable down-root plugin @<:@default=platform specific@:>@])],
 	,
 	[
 		case "$host" in
 			*-mingw*) enable_plugin_down_root="no";;
 			*) enable_plugin_down_root="yes";;
 		esac
 	]
ce8271f5
 )
 
 AC_ARG_ENABLE(
 	[pam-dlopen],
 	[AS_HELP_STRING([--enable-pam-dlopen], [dlopen libpam @<:@default=no@:>@])],
 	,
 	[enable_pam_dlopen="no"]
 )
 
 AC_ARG_ENABLE(
51bd56f4
 	[strict],
709f7a1f
 	[AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_strict="no"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[pedantic],
709f7a1f
 	[AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings, will not generate a working executable (debugging option) @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_pedantic="no"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[strict-options],
709f7a1f
 	[AS_HELP_STRING([--enable-strict-options], [enable strict options check between peers (debugging option) @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_strict_options="no"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[selinux],
709f7a1f
 	[AS_HELP_STRING([--enable-selinux], [enable SELinux support @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_selinux="no"]
99385447
 )
 
51bd56f4
 AC_ARG_ENABLE(
 	[systemd],
709f7a1f
 	[AS_HELP_STRING([--enable-systemd], [enable systemd suppport @<:@default=no@:>@])],
51bd56f4
 	,
 	[enable_systemd="no"]
9449e6a9
 )
 
51bd56f4
 AC_ARG_WITH(
10b4b65e
 	[special-build],
 	[AS_HELP_STRING([--with-special-build=STRING], [specify special build string])],
 	[test -n "${withval}" && AC_DEFINE_UNQUOTED([CONFIGURE_SPECIAL_BUILD], ["${withval}"], [special build string])]
 )
 
 AC_ARG_WITH(
51bd56f4
 	[mem-check],
709f7a1f
 	[AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|dmalloc|valgrind|ssl @<:@default=no@:>@])],
51bd56f4
 	[
 		case "${withval}" in
 			dmalloc|valgrind|ssl|no) ;;
 			*) AC_MSG_ERROR([bad value ${withval} for --mem-check]) ;;
 		esac
 	],
 	[with_mem_check="no"]
6fbf66fa
 )
 
51bd56f4
 AC_ARG_WITH(
9b33b5a4
 	[crypto-library],
 	[AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|polarssl @<:@default=openssl@:>@])],
51bd56f4
 	[
 		case "${withval}" in 
 			openssl|polarssl) ;;
9b33b5a4
 			*) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;;
51bd56f4
 		esac
 	],
9b33b5a4
 	[with_crypto_library="openssl"]
0a180174
 )
 
ce8271f5
 AC_ARG_WITH(
 	[plugindir],
 	[AS_HELP_STRING([--with-plugindir], [plugin directory @<:@default=LIBDIR/openvpn@:>@])],
 	,
 	[with_plugindir="\$(libdir)/openvpn/plugins"]
 )
 
 
6440083e
 AC_DEFINE_UNQUOTED([TARGET_ALIAS], ["${host}"], [A string representing our host])
86715242
 case "$host" in
51bd56f4
 	*-*-linux*)
 		AC_DEFINE([TARGET_LINUX], [1], [Are we running on Linux?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["L"], [Target prefix])
 		;;
 	*-*-solaris*)
 		AC_DEFINE([TARGET_SOLARIS], [1], [Are we running on Solaris?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["S"], [Target prefix])
 		;;
 	*-*-openbsd*)
 		AC_DEFINE([TARGET_OPENBSD], [1], [Are we running on OpenBSD?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["O"], [Target prefix])
 		;;
 	*-*-freebsd*)
 		AC_DEFINE([TARGET_FREEBSD], [1], [Are we running on FreeBSD?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["F"], [Target prefix])
 		;;
 	*-*-netbsd*)
 		AC_DEFINE([TARGET_NETBSD], [1], [Are we running NetBSD?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["N"], [Target prefix])
 		;;
 	*-*-darwin*)
 		AC_DEFINE([TARGET_DARWIN], [1], [Are we running on Mac OS X?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["M"], [Target prefix])
05f16e84
 		have_tap_header="yes"
51bd56f4
 		dnl some Mac OS X tendering (we use vararg macros...)
 		CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
 		;;
 	*-mingw*)
 		AC_DEFINE([TARGET_WIN32], [1], [Are we running WIN32?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["W"], [Target prefix])
4b1a82db
 		CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
 		CPPFLAGS="${CPPFLAGS} -DNTDDI_VERSION=NTDDI_WINXP -D_WIN32_WINNT=_WIN32_WINNT_WINXP"
51bd56f4
 		WIN32=yes
 		;;
 	*-*-dragonfly*)
 		AC_DEFINE([TARGET_DRAGONFLY], [1], [Are we running on DragonFlyBSD?])
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["D"], [Target prefix])
 		;;
 	*)
 		AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["X"], [Target prefix])
05f16e84
 		have_tap_header="yes"
51bd56f4
 		;;
6fbf66fa
 esac
 
51bd56f4
 PKG_PROG_PKG_CONFIG
 AC_PROG_CPP
6fbf66fa
 AC_PROG_INSTALL
51bd56f4
 AC_PROG_LN_S
7046ff20
 AC_PROG_SED
51bd56f4
 AC_PROG_MAKE_SET
6fbf66fa
 
c3fc703d
 AC_ARG_VAR([IFCONFIG], [full path to ipconfig utility])
 AC_ARG_VAR([ROUTE], [full path to route utility])
 AC_ARG_VAR([IPROUTE], [full path to ip utility])
 AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests
 AC_ARG_VAR([MAN2HTML], [path to man2html utility])
7046ff20
 AC_ARG_VAR([GIT], [path to git utility])
ef21281b
 AC_ARG_VAR([SYSTEMD_ASK_PASSWORD], [path to systemd-ask-password utility])
c3fc703d
 AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
 AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
 AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
ef21281b
 AC_PATH_PROGS([SYSTEMD_ASK_PASSWORD], [systemd-ask-password],, [$PATH:/usr/local/bin:/usr/bin:/bin])
c3fc703d
 AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests
 AC_CHECK_PROGS([MAN2HTML], [man2html])
7046ff20
 AC_CHECK_PROGS([GIT], [git]) # optional
c3fc703d
 AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool])
 AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
 AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
ef21281b
 AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
c3fc703d
 
98bc1a3e
 #
 # Libtool
 #
 ifdef(
 	[LT_INIT],
 	[
 		LT_INIT([win32-dll])
 		LT_LANG([Windows Resource])
 	],
 	[
 		AC_LIBTOOL_WIN32_DLL
 		AC_LIBTOOL_RC
 		AC_PROG_LIBTOOL
 	]
 )
 
6fbf66fa
 AC_C_CONST
 AC_C_INLINE
 AC_C_VOLATILE
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_TYPE_UID_T
51bd56f4
 AC_TYPE_INT8_T
 AC_TYPE_INT16_T
 AC_TYPE_INT32_T
 AC_TYPE_INT64_T
 AC_TYPE_UINT8_T
 AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
 AC_TYPE_SIGNAL
6fbf66fa
 AX_CPP_VARARG_MACRO_ISO
 AX_CPP_VARARG_MACRO_GCC
0dbd45db
 AX_TYPE_SOCKLEN_T
6fbf66fa
 AX_EMPTY_ARRAY
51bd56f4
 AC_CHECK_SIZEOF([unsigned int])
 AC_CHECK_SIZEOF([unsigned long])
 AC_CHECK_HEADERS([ \
40299712
 	stdio.h stdarg.h stdbool.h limits.h \
51bd56f4
 	time.h errno.h fcntl.h io.h direct.h \
 	ctype.h sys/types.h sys/socket.h \
bdae4110
 	signal.h unistd.h dlfcn.h \
51bd56f4
 	netinet/in.h netinet/in_systm.h \
 	netinet/tcp.h arpa/inet.h netdb.h \
 	windows.h winsock2.h ws2tcpip.h \
84eb66bf
 	versionhelpers.h \
51bd56f4
 ])
cab53332
 AC_CHECK_HEADERS([ \
a2d747bb
 	sys/time.h sys/ioctl.h sys/stat.h \
f641637a
 	sys/mman.h sys/file.h sys/wait.h \
7cacdfd4
 	unistd.h signal.h libgen.h stropts.h \
cab53332
 	syslog.h pwd.h grp.h \
7cacdfd4
 	sys/sockio.h sys/uio.h linux/sockios.h \
cab53332
 	linux/types.h sys/poll.h sys/epoll.h err.h \
 ])
6fbf66fa
 
51bd56f4
 SOCKET_INCLUDES="
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
 #ifdef HAVE_WINDOWS_H
 #include <windows.h>
 #endif
 #ifdef HAVE_WINSOCK2_H
 #include <winsock2.h>
 #endif
 #ifdef HAVE_WS2TCPIP_H
 #include <ws2tcpip.h>
 #endif
2a744891
 #ifdef HAVE_NETINET_IN_SYSTM_H
 #include <netinet/in_systm.h>
 #endif
4025a595
 #ifdef HAVE_NETINET_IP_H
 #include <netinet/ip.h>
 #endif
51bd56f4
 "
1bda73a7
 
cab53332
 AC_CHECK_HEADERS(
e9739fbf
 	[net/if.h netinet/ip.h resolv.h sys/un.h net/if_utun.h sys/kern_control.h],
51bd56f4
 	,
 	,
cab53332
 	[[${SOCKET_INCLUDES}]]
51bd56f4
 )
 
 AC_CHECK_TYPES(
6fbf66fa
 	[in_addr_t],
51bd56f4
 	,
 	[AC_DEFINE([in_addr_t], [uint32_t], [Workaround missing in_addr_t])],
 	[[${SOCKET_INCLUDES}]]
 )
6fbf66fa
 AC_CHECK_TYPE(
 	[struct iphdr],
7c0a2b5f
 	[AC_DEFINE([HAVE_IPHDR], [1], [struct iphdr needed for IPv6 support])],
51bd56f4
 	,
 	[[${SOCKET_INCLUDES}]]
 )
6fbf66fa
 AC_CHECK_TYPE(
 	[struct sock_extended_err],
7c0a2b5f
 	[AC_DEFINE([HAVE_SOCK_EXTENDED_ERR], [1], [struct sock_extended_err needed for extended socket error support])],
51bd56f4
 	,
 	[[${SOCKET_INCLUDES}]]
 )
6fbf66fa
 AC_CHECK_TYPE(
 	[struct msghdr],
7c0a2b5f
 	[AC_DEFINE([HAVE_MSGHDR], [1], [struct msghdr needed for extended socket error support])],
51bd56f4
 	,
 	[[${SOCKET_INCLUDES}]]
 )
6fbf66fa
 AC_CHECK_TYPE(
 	[struct cmsghdr],
7c0a2b5f
 	[AC_DEFINE([HAVE_CMSGHDR], [1], [struct cmsghdr needed for extended socket error support])],
51bd56f4
 	,
 	[[${SOCKET_INCLUDES}]]
 )
8bc93d7f
 AC_CHECK_TYPE(
 	[struct in_pktinfo],
7c0a2b5f
 	[AC_DEFINE([HAVE_IN_PKTINFO], [1], [struct in_pktinfo needed for IP_PKTINFO support])],
51bd56f4
 	,
 	[[${SOCKET_INCLUDES}]]
 )
 AC_CHECK_TYPE(
 	[struct sockaddr_in6],
 	,
 	[AC_MSG_ERROR([struct sockaddr_in6 not found, needed for ipv6 transport support.])],
 	[[${SOCKET_INCLUDES}]]
 )
cab53332
 AC_CHECK_DECLS(
 	[SO_MARK],
 	,
 	,
 	[[${SOCKET_INCLUDES}]]
 )
51bd56f4
 
cab53332
 dnl We emulate signals in Windows
 AC_CHECK_DECLS(
 	[SIGHUP],
51bd56f4
 	,
cab53332
 	[AC_DEFINE([SIGHUP], [1], [SIGHUP replacement])],
 	[[
 		#ifdef HAVE_SIGNAL_H
 		#include <signal.h>
 		#endif
 	]]
51bd56f4
 )
cab53332
 AC_CHECK_DECLS(
 	[SIGINT],
 	,
 	[AC_DEFINE([SIGINT], [2], [SIGINT replacement])],
 	[[
 		#ifdef HAVE_SIGNAL_H
 		#include <signal.h>
 		#endif
 	]]
 )
 AC_CHECK_DECLS(
 	[SIGUSR1],
 	,
 	[AC_DEFINE([SIGUSR1], [10], [SIGUSR1 replacement])],
 	[[
 		#ifdef HAVE_SIGNAL_H
 		#include <signal.h>
 		#endif
 	]]
 )
 AC_CHECK_DECLS(
 	[SIGUSR2],
 	,
 	[AC_DEFINE([SIGUSR2], [12], [SIGUSR2 replacement])],
 	[[
 		#ifdef HAVE_SIGNAL_H
 		#include <signal.h>
 		#endif
 	]]
 )
 AC_CHECK_DECLS(
 	[SIGTERM],
 	,
 	[AC_DEFINE([SIGTERM], [15], [SIGTERM replacement])],
 	[[
 		#ifdef HAVE_SIGNAL_H
 		#include <signal.h>
 		#endif
 	]]
 )
 
 AC_FUNC_FORK
 
51bd56f4
 AC_CHECK_FUNCS([ \
 	daemon chroot getpwnam setuid nice system getpid dup dup2 \
 	getpass strerror syslog openlog mlockall getgrnam setgid \
 	setgroups stat flock readv writev time gettimeofday \
cab53332
 	ctime memset vsnprintf strdup \
51bd56f4
 	setsid chdir putenv getpeername unlink \
 	chsize ftruncate execve getpeereid umask basename dirname access \
 	epoll_create \
 ])
aee7428c
 
 AC_CHECK_LIB(
 	[dl],
 	[dlopen],
 	[DL_LIBS="-ldl"]
 )
 AC_SUBST([DL_LIBS])
 
 AC_CHECK_LIB(
 	[nsl],
 	[inet_ntoa],
 	[SOCKETS_LIBS="${SOCKETS_LIBS} -lnsl"]
 )
 AC_CHECK_LIB(
 	[socket],
 	[socket],
 	[SOCKETS_LIBS="${SOCKETS_LIBS} -lsocket"]
 )
 AC_CHECK_LIB(
 	[resolv],
 	[gethostbyname],
 	[SOCKETS_LIBS="${SOCKETS_LIBS} -lresolv"]
 )
 AC_SUBST([SOCKETS_LIBS])
 
 old_LIBS="${LIBS}"
 LIBS="${LIBS} ${SOCKETS_LIBS}"
f106f64b
 AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton])
0eb2ee14
 # Windows use stdcall for winsock so we cannot auto detect these
51bd56f4
 m4_define(
 	[SOCKET_FUNCS],
 [socket recv recvfrom send sendto listen dnl
 accept connect bind select gethostbyname inet_ntoa]dnl
 )
 m4_define(
 	[SOCKET_OPT_FUNCS],
 	[setsockopt getsockopt getsockname poll]dnl
 )
1bda73a7
 if test "${WIN32}" = "yes"; then
51bd56f4
 	m4_foreach(
 		[F],
 		m4_split(SOCKET_FUNCS SOCKET_OPT_FUNCS),
 			m4_define([UF], [[m4_join([_], [HAVE], m4_toupper(F))]])
 			AC_DEFINE([UF], [1], [Win32 builtin])
 	)
1bda73a7
 else
51bd56f4
 	AC_CHECK_FUNCS(
 		SOCKET_FUNCS,
 		,
 		[AC_MSG_ERROR([Required library function not found])]
 	)
 	AC_CHECK_FUNCS(SOCKET_OPT_FUNCS)
 fi
aee7428c
 LIBS="${old_LIBS}"
7647a48c
 
ae9aff25
 # we assume res_init() always exist, but need to find out *where*...
 AC_SEARCH_LIBS(__res_init, resolv bind, ,
     AC_SEARCH_LIBS(res_9_init, resolv bind, ,
 	AC_SEARCH_LIBS(res_init, resolv bind, , )))
 
7cacdfd4
 AC_ARG_VAR([TAP_CFLAGS], [C compiler flags for tap])
 old_CFLAGS="${CFLAGS}"
 CFLAGS="${CFLAGS} ${TAP_CFLAGS}"
 AC_CHECK_HEADERS(
 	[ \
 		net/if_tun.h net/tun/if_tun.h \
 		linux/if_tun.h \
 		tap-windows.h \
 	],
 	[have_tap_header="yes"]
 )
88f3a402
 AC_CHECK_DECLS(
 	[TUNSETPERSIST],
 	[AC_DEFINE([ENABLE_FEATURE_TUN_PERSIST], [1], [We have persist tun capability])],
 	,
 	[[
 		#ifdef HAVE_LINUX_IF_TUN_H
 		#include <linux/if_tun.h>
 		#endif
 	]]
 )
7cacdfd4
 CFLAGS="${old_CFLAGS}"
 test "${have_tap_header}" = "yes" || AC_MSG_ERROR([no tap header could be found])
 
cd5990e0
 AC_CHECK_LIB(
 	[selinux],
 	[setcon],
 	[SELINUX_LIBS="-lselinux"]
 )
 AC_SUBST([SELINUX_LIBS])
 
ce8271f5
 AC_ARG_VAR([LIBPAM_CFLAGS], [C compiler flags for libpam])
 AC_ARG_VAR([LIBPAM_LIBS], [linker flags for libpam])
 if test -z "${LIBPAM_LIBS}"; then
 	AC_CHECK_LIB(
 		[pam],
 		[pam_start],
 		[LIBPAM_LIBS="-lpam"]
 	)
 fi
 
51bd56f4
 case "${with_mem_check}" in
 	valgrind)
 		AC_CHECK_HEADER(
 			[valgrind/memcheck.h],
 			[
 				CFLAGS="${CFLAGS} -g -fno-inline"
 				AC_DEFINE(
 					[USE_VALGRIND],
 					[1],
 					[Use valgrind memory debugging library]
 				)
 			],
 			[AC_MSG_ERROR([valgrind headers not found.])]
 		)
 		;;
 	dmalloc)
 		AC_CHECK_HEADER(
 			[dmalloc.h],
 			[AC_CHECK_LIB(
 				[dmalloc],
 				[malloc],
 				[
e02570fd
 					LIBS="${LIBS} -ldmalloc"
51bd56f4
 					AC_DEFINE(
 						[DMALLOC],
 						[1],
 						[Use dmalloc memory debugging library]
 					)
 				],
 				[AC_MSG_ERROR([dmalloc library not found.])]
 			)],
 			[AC_MSG_ERROR([dmalloc headers not found.])]
 		)
 		;;
 	ssl)
 		AC_CHECK_LIB(
 			[ssl],
 			[CRYPTO_mem_ctrl],
 			[
 				AC_DEFINE(
 					[CRYPTO_MDEBUG],
 					[1],
 					[Use memory debugging function in OpenSSL]
 				)
 				AC_MSG_NOTICE([NOTE: OpenSSL library must be compiled with CRYPTO_MDEBUG])
 			],
 			[AC_MSG_ERROR([Memory Debugging function in OpenSSL library not found.])]
 		)
 		;;
 esac
6fbf66fa
 
9b33b5a4
 PKG_CHECK_MODULES(
b07223dd
 	[PKCS11_HELPER],
f8b590d5
 	[libpkcs11-helper-1 >= 1.11],
b07223dd
 	[have_pkcs11_helper="yes"],
 	[]
 )
 
 PKG_CHECK_MODULES(
9b33b5a4
 	[OPENSSL_CRYPTO],
 	[libcrypto >= 0.9.6],
 	[have_openssl_crypto="yes"],
 	[AC_CHECK_LIB(
 		[crypto],
 		[RSA_new],
 		[
 			have_openssl_crypto="yes"
 			OPENSSL_CRYPTO_LIBS="-lcrypto"
 		]
 	)]
 )
 
 PKG_CHECK_MODULES(
 	[OPENSSL_SSL],
 	[libssl >= 0.9.6],
 	[have_openssl_ssl="yes"],
 	[AC_CHECK_LIB(
 		[ssl],
 		[SSL_CTX_new],
 		[
 			have_openssl_ssl="yes"
 			OPENSSL_SSL_LIBS="-lssl"
588c5fe7
 		],
 		[],
 		[-lcrypto]
9b33b5a4
 	)]
 )
 
 if test "${have_openssl_crypto}" = "yes"; then
 	saved_CFLAGS="${CFLAGS}"
 	saved_LIBS="${LIBS}"
 	CFLAGS="${CFLAGS} ${OPENSSL_CRYPTO_CFLAGS}"
 	LIBS="${LIBS} ${OPENSSL_CRYPTO_LIBS}"
 	AC_CHECK_FUNCS([EVP_CIPHER_CTX_set_key_length])
 	have_openssl_engine="yes"
 	AC_CHECK_FUNCS(
 		[ \
 			ENGINE_load_builtin_engines \
 			ENGINE_register_all_complete \
 			ENGINE_cleanup \
 		],
 		,
 		[have_openssl_engine="no"; break]
 	)
 
 	CFLAGS="${saved_CFLAGS}"
 	LIBS="${saved_LIBS}"
 fi
 
 AC_ARG_VAR([POLARSSL_CFLAGS], [C compiler flags for polarssl])
 AC_ARG_VAR([POLARSSL_LIBS], [linker flags for polarssl])
 have_polarssl_ssl="yes"
 have_polarssl_crypto="yes"
 if test -z "${POLARSSL_LIBS}"; then
 	AC_CHECK_LIB(
 		[polarssl],
 		[ssl_init],
 		[POLARSSL_LIBS="-lpolarssl"],
 		[
 			have_polarssl_ssl="no"
 			AC_CHECK_LIB(
 				[polarssl],
 				[aes_crypt_cbc],
 				,
b07223dd
 				[have_polarssl_crypto="no"],
 				[${PKCS11_HELPER_LIBS}]
9b33b5a4
 			)
b07223dd
 		],
 		[${PKCS11_HELPER_LIBS}]
9b33b5a4
 	)
 fi
 
13b38eb0
 if test "${with_crypto_library}" = "polarssl" ; then
 	AC_MSG_CHECKING([polarssl version])
 	old_CFLAGS="${CFLAGS}"
 	CFLAGS="${POLARSSL_CFLAGS} ${CFLAGS}"
 	AC_COMPILE_IFELSE(
 		[AC_LANG_PROGRAM(
 			[[
 #include <polarssl/version.h>
 			]],
 			[[
a40b2304
 #if POLARSSL_VERSION_NUMBER < 0x01030800 || POLARSSL_VERSION_NUMBER >= 0x01040000
b07223dd
 #error invalid version
13b38eb0
 #endif
 			]]
 		)],
 		[AC_MSG_RESULT([ok])],
a40b2304
 		[AC_MSG_ERROR([PolarSSL 1.3.x required and must be 1.3.8 or later])]
13b38eb0
 	)
b07223dd
 
 	polarssl_with_pkcs11="no"
 	AC_COMPILE_IFELSE(
 		[AC_LANG_PROGRAM(
 			[[
 #include <polarssl/config.h>
 			]],
 			[[
 #ifndef POLARSSL_PKCS11_C
 #error pkcs11 wrapper missing
 #endif
 			]]
 		)],
 		polarssl_with_pkcs11="yes")
13b38eb0
 	CFLAGS="${old_CFLAGS}"
b07223dd
 
 	AC_MSG_CHECKING([polarssl pkcs11 support])
 	if test "${enable_pkcs11}" = "yes"; then
 		if test "${polarssl_with_pkcs11}" = "yes"; then
 			AC_MSG_RESULT([ok])
 		else
 			AC_MSG_ERROR([polarssl has no pkcs11 wrapper compiled in])
 		fi
 	else
 		if test "${polarssl_with_pkcs11}" != "yes"; then
 			AC_MSG_RESULT([ok])
 		else
 			AC_MSG_ERROR([PolarSSL compiled with PKCS11, while OpenVPN is not])
 		fi
 	fi
 
13b38eb0
 fi
 
74bbc71b
 AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
 AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
 have_lzo="yes"
 if test -z "${LZO_LIBS}"; then
 	AC_CHECK_LIB(
 		[lzo2],
 		[lzo1x_1_15_compress],
 		[LZO_LIBS="-llzo2"],
 		[AC_CHECK_LIB(
 			[lzo],
 			[lzo1x_1_15_compress],
 			[LZO_LIBS="-llzo"],
 			[have_lzo="no"]
 		)]
 	)
 fi
 if test "${have_lzo}" = "yes"; then
 	saved_CFLAGS="${CFLAGS}"
 	CFLAGS="${CFLAGS} ${LZO_CFLAGS}"
 	AC_CHECK_HEADERS(
 		[lzo/lzoutil.h],
 		,
 		[AC_CHECK_HEADERS(
 			[lzoutil.h],
 			,
 			[AC_MSG_ERROR([lzoutil.h is missing])]
 		)]
 	)
 	AC_CHECK_HEADERS(
 		[lzo/lzo1x.h],
 		,
 		[AC_CHECK_HEADERS(
 			[lzo1x.h],
 			,
 			[AC_MSG_ERROR([lzo1x.h is missing])]
 		)]
 	)
 	CFLAGS="${saved_CFLAGS}"
6fbf66fa
 fi
 
027dd7f6
 
 dnl
 dnl Check for systemd
 dnl
 
 if test "$enable_systemd" = "yes" ; then
     PKG_CHECK_MODULES([libsystemd], [systemd libsystemd],
                       [],
                       [PKG_CHECK_MODULES([libsystemd], [libsystemd-daemon])]
                       )
     AC_CHECK_HEADERS(systemd/sd-daemon.h,
        ,
        [
 	   AC_MSG_ERROR([systemd development headers not found.])
        ])
 
     saved_LIBS="${LIBS}"
     LIBS="${LIBS} ${libsystemd_LIBS}"
     AC_CHECK_FUNCS([sd_booted], [], [AC_MSG_ERROR([systemd library is missing sd_booted()])])
     OPTIONAL_SYSTEMD_LIBS="${libsystemd_LIBS}"
     AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd integration])
     LIBS="${saved_LIBS}"
 fi
 
 
7046ff20
 AC_MSG_CHECKING([git checkout])
 GIT_CHECKOUT="no"
 if test -n "${GIT}" -a -d "${srcdir}/.git"; then
 	AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h])
 	GIT_CHECKOUT="yes"
 fi
 AC_MSG_RESULT([${GIT_CHECKOUT}])
 
51bd56f4
 if test -n "${SP_PLATFORM_WINDOWS}"; then
 	AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #"
 	AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
 else
 	AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['/'], [Path separator])
 	AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["/"], [Path separator])
 fi
 
 dnl enable --x509-username-field feature if requested
 if test "${enable_x509_alt_username}" = "yes"; then
9b33b5a4
 	if test "${with_crypto_library}" = "polarssl" ; then
51bd56f4
 		AC_MSG_ERROR([PolarSSL does not support the --x509-username-field feature])
 	fi
 
 	AC_DEFINE([ENABLE_X509ALTUSERNAME], [1], [Enable --x509-username-field feature])
 fi
 
 test "${ac_cv_header_sys_uio_h}" = "yes" && AC_DEFINE([HAVE_IOVEC], [1], [struct iovec needed for IPv6 support])
 test "${enable_multi}" = "yes" && AC_DEFINE([ENABLE_CLIENT_SERVER], [1], [Enable client/server capability])
 test "${enable_server}" = "no" && AC_DEFINE([ENABLE_CLIENT_ONLY], [1], [Enable client capability only])
 test "${enable_management}" = "yes" && AC_DEFINE([ENABLE_MANAGEMENT], [1], [Enable management server capability])
 test "${enable_socks}" = "yes" && AC_DEFINE([ENABLE_SOCKS], [1], [Enable Socks proxy support])
 test "${enable_http_proxy}" = "yes" && AC_DEFINE([ENABLE_HTTP_PROXY], [1], [Enable HTTP proxy support])
 test "${enable_multihome}" = "yes" && AC_DEFINE([ENABLE_MULTIHOME], [1], [Enable multi-homed UDP server capability])
 test "${enable_debug}" = "yes" && AC_DEFINE([ENABLE_DEBUG], [1], [Enable debugging support])
 test "${enable_small}" = "yes" && AC_DEFINE([ENABLE_SMALL], [1], [Enable smaller executable size])
 test "${enable_fragment}" = "yes" && AC_DEFINE([ENABLE_FRAGMENT], [1], [Enable internal fragmentation support])
 test "${enable_port_share}" = "yes" && AC_DEFINE([ENABLE_PORT_SHARE], [1], [Enable TCP Server port sharing])
 test "${enable_def_auth}" = "yes" && AC_DEFINE([ENABLE_DEF_AUTH], [1], [Enable deferred authentication])
 test "${enable_pf}" = "yes" && AC_DEFINE([ENABLE_PF], [1], [Enable internal packet filter])
 test "${enable_strict_options}" = "yes" && AC_DEFINE([ENABLE_STRICT_OPTIONS_CHECK], [1], [Enable strict options check between peers])
c3fc703d
 
9b33b5a4
 case "${with_crypto_library}" in
 	openssl)
 		have_crypto_crypto="${have_openssl_crypto}"
 		have_crypto_ssl="${have_openssl_ssl}"
 		CRYPTO_CRYPTO_CFLAGS="${OPENSSL_CRYPTO_CFLAGS}"
 		CRYPTO_CRYPTO_LIBS="${OPENSSL_CRYPTO_LIBS}"
 		CRYPTO_SSL_CFLAGS="${OPENSSL_SSL_CFLAGS}"
 		CRYPTO_SSL_LIBS="${OPENSSL_SSL_LIBS}"
 		AC_DEFINE([ENABLE_CRYPTO_OPENSSL], [1], [Use OpenSSL library])
 		test "${have_openssl_engine}" = "yes" && AC_DEFINE([HAVE_OPENSSL_ENGINE], [1], [Use crypto library])
 		;;
 	polarssl)
 		have_crypto_crypto="${have_polarssl_crypto}"
 		have_crypto_ssl="${have_polarssl_ssl}"
21fdfb73
 		CRYPTO_CRYPTO_CFLAGS="${POLARSSL_CFLAGS}"
9b33b5a4
 		CRYPTO_CRYPTO_LIBS="${POLARSSL_LIBS}"
 		AC_DEFINE([ENABLE_CRYPTO_POLARSSL], [1], [Use PolarSSL library])
 		;;
 esac
 
 if test "${enable_ssl}" = "yes"; then
 	test "${enable_crypto}" != "yes" && AC_MSG_ERROR([crypto must be enabled for ssl])
 	test "${have_crypto_ssl}" != "yes" && AC_MSG_ERROR([${with_ssl_library} ssl is required but missing])
 	OPTIONAL_CRYPTO_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_SSL_CFLAGS}"
 	OPTIONAL_CRYPTO_LIBS="${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_SSL_LIBS}"
 	AC_DEFINE([ENABLE_SSL], [1], [Enable ssl library])
 fi
 
 if test "${enable_crypto}" = "yes"; then
9e6b8579
 	test "${have_crypto_crypto}" != "yes" && AC_MSG_ERROR([${with_crypto_library} crypto is required but missing])
f71a780f
 	test "${enable_crypto_ofb_cfb}" = "yes" && AC_DEFINE([ENABLE_OFB_CFB_MODE], [1], [Enable OFB and CFB cipher modes])
9b33b5a4
 	OPTIONAL_CRYPTO_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_CRYPTO_CFLAGS}"
 	OPTIONAL_CRYPTO_LIBS="${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_CRYPTO_LIBS}"
 	AC_DEFINE([ENABLE_CRYPTO], [1], [Enable crypto library])
 fi
 
bdae4110
 if test "${enable_plugins}" = "yes"; then
 	OPTIONAL_DL_LIBS="${DL_LIBS}"
030fcea0
 	AC_DEFINE([ENABLE_PLUGIN], [1], [Enable plug-in support])
ce8271f5
 else
 	enable_plugin_auth_pam="no"
 	enable_plugin_down_root="no"
bdae4110
 fi
 
c3fc703d
 if test "${enable_iproute2}" = "yes"; then
 	test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing])
 	AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
 else
 	if test "${WIN32}" != "yes"; then
 		test -z "${ROUTE}" && AC_MSG_ERROR([route utility is required but missing])
 		test -z "${IFCONFIG}" && AC_MSG_ERROR([ifconfig utility is required but missing])
 	fi
 fi
51bd56f4
 
cd5990e0
 if test "${enable_selinux}" = "yes"; then
 	test -z "${SELINUX_LIBS}" && AC_MSG_ERROR([libselinux required but missing])
 	OPTIONAL_SELINUX_LIBS="${SELINUX_LIBS}"
 	AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support])
 fi
 
74bbc71b
 if test "${enable_lzo}" = "yes"; then
 	test "${have_lzo}" != "yes" && AC_MSG_ERROR([lzo enabled but missing])
 	OPTIONAL_LZO_CFLAGS="${LZO_CFLAGS}"
 	OPTIONAL_LZO_LIBS="${LZO_LIBS}"
 	AC_DEFINE([ENABLE_LZO], [1], [Enable LZO compression library])
 fi
07084261
 if test "${enable_lzo_stub}" = "yes"; then
 	test "${enable_lzo}" = "yes" && AC_MSG_ERROR([Cannot have both lzo stub and lzo enabled])
 	AC_DEFINE([ENABLE_LZO_STUB], [1], [Enable LZO stub capability])
74bbc71b
 	AC_DEFINE([ENABLE_LZO], [1], [Enable LZO compression library])
07084261
 fi
 
18b5fbdf
 if test "${enable_pkcs11}" = "yes"; then
 	test "${have_pkcs11_helper}" != "yes" && AC_MSG_ERROR([PKCS11 enabled but libpkcs11-helper is missing])
 	test "${enable_ssl}" != "yes" && AC_MSG_ERROR([PKCS11 can be enabled only if SSL is enabled])
 	OPTIONAL_PKCS11_HELPER_CFLAGS="${PKCS11_HELPER_CFLAGS}"
 	OPTIONAL_PKCS11_HELPER_LIBS="${PKCS11_HELPER_LIBS}"
 	AC_DEFINE([ENABLE_PKCS11], [1], [Enable PKCS11])
6f1d3cf0
 	PKG_CHECK_MODULES(
 		[P11KIT],
 		[p11-kit-1],
 		[proxy_module="`$PKG_CONFIG --variable=proxy_module p11-kit-1`"
 		 AC_DEFINE_UNQUOTED([DEFAULT_PKCS11_MODULE], "${proxy_module}", [p11-kit proxy])],
 		[]
 	)
18b5fbdf
 fi
 
130c27b1
 # Set -std=gnu89 unless user already specified a -std=
 case "${CFLAGS}" in
   *-std=*) ;;
   *)       CFLAGS="${CFLAGS} -std=gnu89" ;;
 esac
 
51bd56f4
 if test "${enable_pedantic}" = "yes"; then
 	enable_strict="yes"
31444111
 	CFLAGS="${CFLAGS} -pedantic"
 	test "${WIN32}" != "yes" && CFLAGS="${CFLAGS} -ansi"
51bd56f4
 fi
 if test "${enable_strict}" = "yes"; then
 	CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function"
99385447
 fi
 
c3fc703d
 if test "${WIN32}" = "yes"; then
 	test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
 fi
 
ce8271f5
 if test "${enable_plugin_auth_pam}" = "yes"; then
 	PLUGIN_AUTH_PAM_CFLAGS="${LIBPAM_CFLAGS}"
 	if test "${enable_pam_dlopen}" = "yes"; then
 		AC_DEFINE([USE_PAM_DLOPEN], [1], [dlopen libpam])
 		PLUGIN_AUTH_PAM_LIBS="${DL_LIBS}"
 	else
 		test -z "${LIBPAM_LIBS}" && AC_MSG_ERROR([libpam required but missing])
 		PLUGIN_AUTH_PAM_LIBS="${LIBPAM_LIBS}"
 	fi
 fi
 
fcff80aa
 CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
 AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])
 
ac2447cd
 TAP_WIN_COMPONENT_ID="PRODUCT_TAP_WIN_COMPONENT_ID"
 TAP_WIN_MIN_MAJOR="PRODUCT_TAP_WIN_MIN_MAJOR"
 TAP_WIN_MIN_MINOR="PRODUCT_TAP_WIN_MIN_MINOR"
 AC_DEFINE_UNQUOTED([TAP_WIN_COMPONENT_ID], ["${TAP_WIN_COMPONENT_ID}"], [The tap-windows id])
 AC_DEFINE_UNQUOTED([TAP_WIN_MIN_MAJOR], [${TAP_WIN_MIN_MAJOR}], [The tap-windows version number is required for OpenVPN])
 AC_DEFINE_UNQUOTED([TAP_WIN_MIN_MINOR], [${TAP_WIN_MIN_MINOR}], [The tap-windows version number is required for OpenVPN])
 AC_SUBST([TAP_WIN_COMPONENT_ID])
 AC_SUBST([TAP_WIN_MIN_MAJOR])
 AC_SUBST([TAP_WIN_MIN_MINOR])
1bda73a7
 
bdae4110
 AC_SUBST([OPTIONAL_DL_LIBS])
cd5990e0
 AC_SUBST([OPTIONAL_SELINUX_LIBS])
9b33b5a4
 AC_SUBST([OPTIONAL_CRYPTO_CFLAGS])
 AC_SUBST([OPTIONAL_CRYPTO_LIBS])
74bbc71b
 AC_SUBST([OPTIONAL_LZO_CFLAGS])
 AC_SUBST([OPTIONAL_LZO_LIBS])
027dd7f6
 AC_SUBST([OPTIONAL_SYSTEMD_LIBS])
18b5fbdf
 AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS])
 AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
bdae4110
 
ce8271f5
 AC_SUBST([PLUGIN_AUTH_PAM_CFLAGS])
 AC_SUBST([PLUGIN_AUTH_PAM_LIBS])
 
51bd56f4
 AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
7046ff20
 AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"])
ce8271f5
 AM_CONDITIONAL([ENABLE_PLUGIN_AUTH_PAM], [test "${enable_plugin_auth_pam}" = "yes"])
 AM_CONDITIONAL([ENABLE_PLUGIN_DOWN_ROOT], [test "${enable_plugin_down_root}" = "yes"])
8e13e38a
 AM_CONDITIONAL([ENABLE_CRYPTO], [test "${enable_crypto}" = "yes"])
1bda73a7
 
ce8271f5
 plugindir="${with_plugindir}"
880a2ae9
 sampledir="\$(docdir)/sample"
ce8271f5
 AC_SUBST([plugindir])
880a2ae9
 AC_SUBST([sampledir])
 
1739c102
 VENDOR_SRC_ROOT="\$(abs_top_srcdir)/vendor/"
 VENDOR_DIST_ROOT="\$(abs_top_builddir)/vendor/dist"
 VENDOR_BUILD_ROOT="\$(abs_top_builddir)/vendor/.build"
 AC_SUBST([VENDOR_SRC_ROOT])
 AC_SUBST([VENDOR_BUILD_ROOT])
 AC_SUBST([VENDOR_DIST_ROOT])
 
 TEST_LDFLAGS="-lcmocka -L\$(abs_top_builddir)/vendor/dist/lib -Wl,-rpath,\$(abs_top_builddir)/vendor/dist/lib"
 TEST_CFLAGS="-I\$(top_srcdir)/include -I\$(abs_top_builddir)/vendor/dist/include"
 
 AC_SUBST([TEST_LDFLAGS])
 AC_SUBST([TEST_CFLAGS])
 
987910e8
 # Check if cmake is available and cmocka git submodule is initialized,
 # needed for unit testing
 AC_CHECK_PROGS([CMAKE], [cmake])
 if test -n "${CMAKE}"; then
57294aaa
    if test -f "${srcdir}/vendor/cmocka/CMakeLists.txt"; then
987910e8
       AM_CONDITIONAL([CMOCKA_INITIALIZED], [true])
    else
       AM_CONDITIONAL([CMOCKA_INITIALIZED], [false])
       AC_MSG_RESULT([!! WARNING !! The cmoka git submodule has not been initialized or updated.  Unit testing cannot be performed.])
    fi
 else
    AC_MSG_RESULT([!! WARNING !! CMake is NOT available.  Unit testing cannot be performed.])
    AM_CONDITIONAL([CMOCKA_INITIALIZED], [false])
 fi
 
 
51bd56f4
 AC_CONFIG_FILES([
6187644b
 	version.sh
1bda73a7
 	Makefile
98bc1a3e
 	build/Makefile
4b1a82db
 	build/msvc/Makefile
 	build/msvc/msvc-generate/Makefile
34cb9132
 	distro/Makefile
 	distro/rpm/Makefile
 	distro/rpm/openvpn.spec
 	include/Makefile
 	src/Makefile
dc81e743
 	src/compat/Makefile
34cb9132
 	src/openvpn/Makefile
 	src/openvpnserv/Makefile
ce8271f5
 	src/plugins/Makefile
 	src/plugins/auth-pam/Makefile
 	src/plugins/down-root/Makefile
34cb9132
 	tests/Makefile
1739c102
         tests/unit_tests/Makefile
0b8e0f53
         tests/unit_tests/plugins/Makefile
         tests/unit_tests/plugins/auth-pam/Makefile
1739c102
         tests/unit_tests/example_test/Makefile
         vendor/Makefile
34cb9132
 	sample/Makefile
 	doc/Makefile
1bda73a7
 ])
34cb9132
 AC_CONFIG_FILES([tests/t_client.sh], [chmod +x tests/t_client.sh])
51bd56f4
 AC_OUTPUT