1 dnl OpenVPN -- An application to securely tunnel IP networks
2 dnl over a single UDP port, with support for SSL/TLS-based
3 dnl session authentication and key exchange,
4 dnl packet encryption, packet authentication, and
5 dnl packet compression.
7 dnl Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
9 dnl This program is free software; you can redistribute it and/or modify
10 dnl it under the terms of the GNU General Public License as published by
11 dnl the Free Software Foundation; either version 2 of the License, or
12 dnl (at your option) any later version.
14 dnl This program is distributed in the hope that it will be useful,
15 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
16 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 dnl GNU General Public License for more details.
19 dnl You should have received a copy of the GNU General Public License
20 dnl along with this program (see the file COPYING included with this
21 dnl distribution); if not, write to the Free Software Foundation, Inc.,
22 dnl 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 dnl Process this file with autoconf to produce a configure script.
28 AC_INIT([OpenVPN], [2.0.9], [openvpn-users@lists.sourceforge.net], [openvpn])
29 AM_CONFIG_HEADER(config.h)
30 AC_CONFIG_SRCDIR(syshead.h)
33 [ --disable-lzo Disable LZO compression support],
39 [ --disable-crypto Disable OpenSSL crypto support],
40 [CRYPTO="$enableval"],
45 [ --disable-ssl Disable OpenSSL SSL support for TLS-based key exchange],
51 [ --disable-multi Disable client/server support (--mode server + client mode)],
57 [ --disable-server Disable server support only (but retain client support)],
58 [MULTI_SERVER="$enableval"],
62 AC_ARG_ENABLE(plugins,
63 [ --disable-plugins Disable plug-in support],
64 [PLUGINS="$enableval"],
68 AC_ARG_ENABLE(management,
69 [ --disable-management Disable management server support],
70 [MANAGEMENT="$enableval"],
75 [ --disable-socks Disable Socks support],
81 [ --disable-http Disable HTTP proxy support],
82 [HTTP_PROXY="$enableval"],
86 AC_ARG_ENABLE(fragment,
87 [ --disable-fragment Disable internal fragmentation support (--fragment)],
88 [FRAGMENT="$enableval"],
93 [ --disable-debug Disable debugging support (disable gremlin and verb 7+ messages)],
99 [ --enable-small Enable smaller executable size (disable OCC, usage message, and verb 4 parm list)],
100 [SMALL="$enableval"],
104 AC_ARG_ENABLE(pthread,
105 [ --enable-pthread Enable pthread support (Experimental for OpenVPN 2.0)],
106 [PTHREAD="$enableval"],
110 AC_ARG_ENABLE(password-save,
111 [ --enable-password-save Allow --askpass and --auth-user-pass passwords to be read from a file],
112 [PASSWORD_SAVE="$enableval"],
116 AC_ARG_ENABLE(iproute2,
117 [ --enable-iproute2 Enable support for iproute2],
118 AC_DEFINE(CONFIG_FEATURE_IPROUTE, 1, [enable iproute2 support])
121 AC_ARG_ENABLE(strict,
122 [ --enable-strict Enable strict compiler warnings (debugging option)],
123 [STRICT="$enableval"],
127 AC_ARG_ENABLE(pedantic,
128 [ --enable-pedantic Enable pedantic compiler warnings, will not generate a working executable (debugging option)],
129 [PEDANTIC="$enableval"],
133 AC_ARG_ENABLE(profiling,
134 [ --enable-profiling Enable profiling (debugging option)],
135 [PROFILE="$enableval"],
139 AC_ARG_ENABLE(strict-options,
140 [ --enable-strict-options Enable strict options check between peers (debugging option)],
141 [STRICT_OPTIONS="$enableval"],
142 [STRICT_OPTIONS="no"]
145 AC_ARG_WITH(ssl-headers,
146 [ --with-ssl-headers=DIR Crypto/SSL Include files location],
147 [CS_HDR_DIR="$withval"]
148 [CPPFLAGS="$CPPFLAGS -I$withval"]
152 [ --with-ssl-lib=DIR Crypto/SSL Library location],
153 [LDFLAGS="$LDFLAGS -L$withval"]
156 AC_ARG_WITH(lzo-headers,
157 [ --with-lzo-headers=DIR LZO Include files location],
158 [LZO_HDR_DIR="$withval"]
159 [CPPFLAGS="$CPPFLAGS -I$withval"]
163 [ --with-lzo-lib=DIR LZO Library location],
164 [LDFLAGS="$LDFLAGS -L$withval"]
167 AC_ARG_WITH(ifconfig-path,
168 [ --with-ifconfig-path=PATH Path to ifconfig tool],
169 [IFCONFIG="$withval"],
170 [AC_PATH_PROG([IFCONFIG], [ifconfig], [ifconfig], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
172 AC_DEFINE_UNQUOTED(IFCONFIG_PATH, "$IFCONFIG", [Path to ifconfig tool])
174 AC_ARG_WITH(iproute-path,
175 [ --with-iproute-path=PATH Path to iproute tool],
176 [IPROUTE="$withval"],
177 [AC_PATH_PROG([IPROUTE], [ip], [ip], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
179 AC_DEFINE_UNQUOTED(IPROUTE_PATH, "$IPROUTE", [Path to iproute tool])
182 AC_ARG_WITH(route-path,
183 [ --with-route-path=PATH Path to route tool],
185 [AC_PATH_PROG([ROUTE], [route], [route], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
187 AC_DEFINE_UNQUOTED(ROUTE_PATH, "$ROUTE", [Path to route tool])
189 AC_ARG_WITH(mem-check,
190 [ --with-mem-check=TYPE Build with debug memory checking, TYPE = dmalloc or valgrind],
191 [MEMCHECK="$withval"]
197 AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
199 dnl fix search path, to allow compilers to find syshead.h
200 CPPFLAGS="$CPPFLAGS -I${srcdir}"
203 openvpn_target=$target
204 if test $target_alias; then
205 openvpn_target=$target_alias
207 AC_DEFINE_UNQUOTED(TARGET_ALIAS, "$openvpn_target", [A string representing our target])
210 AC_DEFINE(TARGET_LINUX, 1, [Are we running on Linux?])
211 dnl RH9 SSL headers workaround
212 if test -z $CS_HDR_DIR && test "$CRYPTO" = "yes"; then
213 CPPFLAGS="$CPPFLAGS $(pkg-config --cflags openssl 2>/dev/null)"
217 AC_DEFINE(TARGET_SOLARIS, 1, [Are we running on Solaris?])
220 AC_DEFINE(TARGET_OPENBSD, 1, [Are we running on OpenBSD?])
223 AC_DEFINE(TARGET_FREEBSD, 1, [Are we running on FreeBSD?])
226 AC_DEFINE(TARGET_NETBSD, 1, [Are we running NetBSD?])
229 dnl some Mac OS X tendering (we use vararg macros...)
230 AC_DEFINE(TARGET_DARWIN, 1, [Are we running on Mac OS X?])
231 CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
234 AC_MSG_RESULT([WARNING: configure support for mingw is incomplete])
235 AC_MSG_RESULT([WARNING: use makefile.w32 instead])
236 OPENVPN_ADD_LIBS(-lgdi32)
237 OPENVPN_ADD_LIBS(-lwsock32)
242 dnl Checks for programs.
245 AC_PROG_GCC_TRADITIONAL
247 dnl Checks for header files.
250 dnl Checks for typedefs, structures, and compiler characteristics.
259 AX_CPP_VARARG_MACRO_ISO
260 AX_CPP_VARARG_MACRO_GCC
263 dnl Check for more header files.
265 AC_CHECK_HEADERS(sys/time.h sys/socket.h sys/ioctl.h sys/stat.h dnl
266 sys/mman.h fcntl.h sys/file.h stdlib.h stdint.h dnl
267 stdarg.h unistd.h signal.h stdio.h string.h dnl
268 strings.h ctype.h errno.h syslog.h pwd.h grp.h dnl
269 net/if_tun.h net/if.h stropts.h sys/sockio.h dnl
270 netinet/in.h netinet/in_systm.h netinet/ip.h dnl
271 netinet/if_ether.h netinet/tcp.h resolv.h arpa/inet.h dnl
272 netdb.h sys/uio.h linux/if_tun.h linux/sockios.h dnl
273 linux/types.h sys/poll.h sys/epoll.h dnl
275 AC_CHECK_HEADERS(linux/errqueue.h,,,
276 [#ifdef HAVE_LINUX_TYPES_H
277 # include <linux/types.h>
282 dnl check that in_addr_t is defined
286 [AC_DEFINE(in_addr_t, uint32_t, [Some systems don't define in_addr_t])],
287 [#include "syshead.h"])
289 dnl check for basic types
293 [AC_DEFINE(uint8_t, unsigned char, [8-bit unsigned type])],
294 [#include "syshead.h"])
298 [AC_DEFINE(uint16_t, unsigned char, [16-bit unsigned type])],
299 [#include "syshead.h"])
303 [AC_DEFINE(uint32_t, unsigned long, [32-bit unsigned type])],
304 [#include "syshead.h"])
306 dnl check for IPv6 types
309 [AC_DEFINE(HAVE_TUN_PI, 1, [struct tun_pi needed for IPv6 support])],
311 [#include "syshead.h"])
314 [AC_DEFINE(HAVE_IPHDR, 1, [struct iphdr needed for IPv6 support])],
316 [#include "syshead.h"])
319 [AC_DEFINE(HAVE_IOVEC, 1, [struct iovec needed for IPv6 support])],
321 [#include "syshead.h"])
323 dnl check for extended socket error types
325 [struct sock_extended_err],
326 [AC_DEFINE(HAVE_SOCK_EXTENDED_ERR, 1, [struct sock_extended_err needed for extended socket error support])],
328 [#include "syshead.h"])
331 [AC_DEFINE(HAVE_MSGHDR, 1, [struct msghdr needed for extended socket error support])],
333 [#include "syshead.h"])
336 [AC_DEFINE(HAVE_CMSGHDR, 1, [struct cmsghdr needed for extended socket error support])],
338 [#include "syshead.h"])
340 AC_CHECK_SIZEOF(unsigned int)
341 AC_CHECK_SIZEOF(unsigned long)
345 dnl check for other types
349 dnl Check for libsocket
350 AC_SEARCH_LIBS(socket, socket)
353 AC_SEARCH_LIBS(inet_ntoa, nsl)
355 dnl Check for libresolv
356 AC_SEARCH_LIBS(gethostbyname, resolv nsl)
358 dnl optional library functions
360 AC_CHECK_FUNCS(daemon chroot getpwnam setuid nice system getpid dup dup2 dnl
361 getpass strerror syslog openlog mlockall getgrnam setgid dnl
362 setgroups stat flock readv writev setsockopt getsockopt dnl
363 setsid chdir gettimeofday putenv getpeername unlink dnl
364 poll chsize ftruncate)
367 dnl Required library functions
370 AC_CHECK_FUNCS(socket recv recvfrom send sendto listen dnl
371 accept connect bind select gethostbyname dnl
372 inet_ntoa time ctime memset vsnprintf, [],
373 [AC_MSG_ERROR([Required library function not found])])
379 dnl Checking for a working epoll
380 AC_CHECKING([for working epoll implementation])
381 OLDLDFLAGS="$LDFLAGS"
382 LDFLAGS="$LDFLAGS -Wl,--fatal-warnings"
383 AC_CHECK_FUNCS(epoll_create, AC_DEFINE([HAVE_EPOLL_CREATE], 1, []))
384 LDFLAGS="$OLDLDFLAGS"
387 dnl check for valgrind tool
390 if test "$MEMCHECK" = "valgrind"; then
391 AC_CHECKING([for valgrind tool and Header files])
392 AC_CHECK_HEADER(valgrind/memcheck.h,
394 AC_DEFINE(USE_VALGRIND, 1, [Use valgrind memory debugging library])
395 CFLAGS="-g -fno-inline"
397 [AC_MSG_ERROR([valgrind headers not found.])]
402 dnl check for pthread library
405 if test "$PTHREAD" = "yes"; then
406 AC_CHECKING([for pthread support])
407 AC_MSG_RESULT([********* WARNING: pthread support is experimental for OpenVPN 2.0])
412 AC_MSG_RESULT([WARNING: pthread support on OpenBSD is unstable!])
413 CFLAGS="$CFLAGS -pthread"
416 LIBS="$PTHREAD_LIBS $LIBS"
417 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
419 AC_DEFINE(USE_PTHREAD, 1, [Use pthread-based multithreading])
422 AC_MSG_RESULT([I don't know how to build with pthread support on this platform.])
423 AC_MSG_ERROR([try ./configure --disable-pthread])
428 dnl check for dmalloc library
431 if test "$MEMCHECK" = "dmalloc"; then
432 AC_CHECKING([for dmalloc Library and Header files])
433 AC_CHECK_HEADER(dmalloc.h,
434 [AC_CHECK_LIB(dmalloc, malloc,
436 if test "$PTHREAD" = "yes"; then
437 OPENVPN_ADD_LIBS(-ldmallocth)
439 OPENVPN_ADD_LIBS(-ldmalloc)
441 AC_DEFINE(DMALLOC, 1, [Use dmalloc memory debugging library])
443 [AC_MSG_ERROR([dmalloc library not found.])]
445 [AC_MSG_ERROR([dmalloc headers not found.])]
450 dnl Check for dlopen -- first try libc then libdl.
452 if test "$PLUGINS" = "yes"; then
453 AC_CHECKING([for libdl Library and Header files])
454 AC_CHECK_HEADER(dlfcn.h,
455 [AC_CHECK_FUNC(dlopen,
456 [AC_DEFINE(USE_LIBDL, 1, [Use libdl for dynamic library loading])],
457 [AC_CHECK_LIB(dl, dlopen,
459 OPENVPN_ADD_LIBS(-ldl)
460 AC_DEFINE(USE_LIBDL, 1, [Use libdl for dynamic library loading])
462 [AC_MSG_RESULT([libdl library not found.])]
465 [AC_MSG_RESULT([libdl headers not found.])]
470 dnl check for LZO library
473 if test "$LZO" = "yes"; then
475 AC_CHECKING([for LZO Library and Header files])
476 AC_CHECK_HEADER(lzo/lzo1x.h,
479 AC_DEFINE(LZO_HEADER_DIR, 1, [Use lzo/ directory prefix for LZO header files (for LZO 2.0)])
481 [ AC_CHECK_HEADER(lzo1x.h, [ LZO_H="1" ; lzolibs=lzo ]) ]
484 if test -n "$LZO_H"; then
486 for i in $lzolibs ; do
487 if test $havelzolib = 1 ; then break ; fi
488 AC_CHECK_LIB($i, lzo1x_1_15_compress,
490 OPENVPN_ADD_LIBS(-l$i)
491 AC_DEFINE(USE_LZO, 1, [Use LZO compression library])
496 if test $havelzolib = 0 ; then
497 AC_MSG_ERROR([LZO headers were found but LZO library was not found])
500 AC_MSG_RESULT([LZO headers were not found])
501 AC_MSG_RESULT([LZO library available from http://www.oberhumer.com/opensource/lzo/])
502 AC_MSG_ERROR([Or try ./configure --disable-lzo])
507 dnl check for OpenSSL-crypto library
510 if test "$CRYPTO" = "yes"; then
511 AC_CHECKING([for OpenSSL Crypto Library and Header files])
512 AC_CHECK_HEADER(openssl/evp.h,
513 [AC_CHECK_LIB(crypto, EVP_CIPHER_CTX_init,
515 AC_CHECKING([that OpenSSL Library is at least version 0.9.6])
518 #include "openssl/evp.h"
519 #if SSLEAY_VERSION_NUMBER >= 0x00906000L
524 AC_DEFINE(USE_CRYPTO, 1, [Use OpenSSL crypto library])
525 OPENVPN_ADD_LIBS(-lcrypto)
526 AC_CHECK_FUNCS(EVP_CIPHER_CTX_set_key_length)
528 dnl check for OpenSSL crypto acceleration capability
529 AC_CHECK_HEADERS(openssl/engine.h)
530 AC_CHECK_FUNCS(ENGINE_load_builtin_engines)
531 AC_CHECK_FUNCS(ENGINE_register_all_complete)
532 AC_CHECK_FUNCS(ENGINE_cleanup)
534 [AC_MSG_ERROR([OpenSSL crypto Library is too old.])]
537 [AC_MSG_ERROR([OpenSSL Crypto library not found.])]
539 [AC_MSG_ERROR([OpenSSL Crypto headers not found.])]
543 dnl check for OpenSSL-SSL library
546 if test "$SSL" = "yes"; then
547 AC_CHECKING([for OpenSSL SSL Library and Header files])
548 AC_CHECK_HEADER(openssl/ssl.h,
549 [AC_CHECK_LIB(ssl, SSL_CTX_new,
551 if test "$MEMCHECK" = "ssl"; then
552 AC_CHECKING([for Memory Debugging Capabilities in OpenSSL Library])
553 AC_CHECK_LIB(ssl, CRYPTO_mem_ctrl,
555 AC_DEFINE(CRYPTO_MDEBUG, 1, [Use memory debugging function in OpenSSL])
556 AC_MSG_RESULT([NOTE: OpenSSL library must be compiled with CRYPTO_MDEBUG])
558 [AC_MSG_ERROR([Memory Debugging function in OpenSSL library not found.])]
562 [AC_MSG_ERROR([OpenSSL SSL library not found.])]
564 [AC_MSG_ERROR([OpenSSL SSL headers not found.])]
566 AC_DEFINE(USE_SSL, 1, [Use OpenSSL SSL library])
567 OPENVPN_ADD_LIBS(-lssl)
571 dnl enable multi-client mode
572 if test "$MULTI" = "yes"; then
573 AC_DEFINE(ENABLE_CLIENT_SERVER, 1, [Enable client/server capability])
576 dnl enable client mode only, not server
577 if test "$MULTI_SERVER" = "no"; then
578 AC_DEFINE(ENABLE_CLIENT_ONLY, 1, [Enable client capability only])
581 dnl enable management server capability
582 if test "$MANAGEMENT" = "yes"; then
583 AC_DEFINE(ENABLE_MANAGEMENT, 1, [Enable management server capability])
587 if test "$SOCKS" = "yes"; then
588 AC_DEFINE(ENABLE_SOCKS, 1, [Enable Socks proxy support])
591 dnl enable HTTP proxy
592 if test "$HTTP_PROXY" = "yes"; then
593 AC_DEFINE(ENABLE_HTTP_PROXY, 1, [Enable HTTP proxy support])
597 if test "$DEBUG" = "yes"; then
598 AC_DEFINE(ENABLE_DEBUG, 1, [Enable debugging support])
601 dnl enable small size optimizations
602 if test "$SMALL" = "yes"; then
603 AC_DEFINE(ENABLE_SMALL, 1, [Enable smaller executable size])
606 dnl enable --fragment
607 if test "$FRAGMENT" = "yes"; then
608 AC_DEFINE(ENABLE_FRAGMENT, 1, [Enable internal fragmentation support])
611 dnl enable strict compiler warnings
612 if test "$STRICT" = "yes"; then
613 CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wsign-compare -Wno-unused-parameter -Wno-unused-function"
616 dnl enable pedantic compiler warnings
617 if test "$PEDANTIC" = "yes"; then
618 CFLAGS="$CFLAGS -ansi -pedantic"
622 if test "$PROFILE" = "yes"; then
623 CFLAGS="$CFLAGS -pg -DENABLE_PROFILING"
626 dnl enable strict options check between peers
627 if test "$STRICT_OPTIONS" = "yes"; then
628 AC_DEFINE(STRICT_OPTIONS_CHECK, 1, [Enable strict options check between peers])
631 dnl enable password save
632 if test "$PASSWORD_SAVE" = "yes"; then
633 AC_DEFINE(ENABLE_PASSWORD_SAVE, 1, [Allow --askpass and --auth-user-pass passwords to be read from a file])
636 AC_OUTPUT(Makefile openvpn.spec config-win32.h install-win32/openvpn.nsi)