cosmetics
[tomato.git] / release / src / router / openvpn / configure.ac
blob116ff7c9bc15d05314d0eedd107189b28591cf28
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.
6 dnl
7 dnl  Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
8 dnl
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.
13 dnl
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.
18 dnl
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.
26 AC_PREREQ(2.50)
28 m4_include(version.m4)
29 AC_INIT([OpenVPN], [PRODUCT_VERSION], [openvpn-users@lists.sourceforge.net], [openvpn])
30 AM_CONFIG_HEADER(config.h)
31 AC_CONFIG_SRCDIR(syshead.h)
33 dnl Guess host type.
34 AC_CANONICAL_HOST
35 AC_CANONICAL_SYSTEM
36 AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
38 AC_ARG_WITH(cygwin-native,
39         [  --with-cygwin-native              Compile native win32],
40         [CYGWIN_NATIVE="${withval}"],
41         [CYGWIN_NATIVE="no"]
44 WIN32="no"
45 CYGWIN="no"
46 case "${host}" in
47         *-mingw*)
48                 WIN32="yes"
49                 cross_compiling="yes"
50         ;;
51         *-cygwin*)
52                 AC_MSG_CHECKING([cygwin mode to use])
53                 if test "${CYGWIN_NATIVE}" = "yes"; then
54                         AC_MSG_RESULT([Using native win32])
55                         CFLAGS="${CFLAGS} -mno-cygwin"
56                         CYGWIN="yes"
57                         WIN32="yes"
58                 else
59                         AC_MSG_RESULT([Using cygwin])
60                 fi
61         ;;
62         *)
63         ;;
64 esac
66 AC_ARG_ENABLE(lzo,
67    [  --disable-lzo           Disable LZO compression support],
68    [LZO="$enableval"],
69    [LZO="yes"]
72 AC_ARG_ENABLE(crypto,
73    [  --disable-crypto        Disable OpenSSL crypto support],
74    [CRYPTO="$enableval"],
75    [CRYPTO="yes"]
78 AC_ARG_ENABLE(ssl,
79    [  --disable-ssl           Disable OpenSSL SSL support for TLS-based key exchange],
80    [SSL="$enableval"],
81    [SSL="yes"]
84 AC_ARG_ENABLE(multi,
85    [  --disable-multi         Disable client/server support (--mode server + client mode)],
86    [MULTI="$enableval"],
87    [MULTI="yes"]
90 AC_ARG_ENABLE(server,
91    [  --disable-server        Disable server support only (but retain client support)],
92    [MULTI_SERVER="$enableval"],
93    [MULTI_SERVER="yes"]
96 AC_ARG_ENABLE(plugins,
97    [  --disable-plugins       Disable plug-in support],
98    [PLUGINS="$enableval"],
99    [PLUGINS="yes"]
102 AC_ARG_ENABLE(management,
103    [  --disable-management    Disable management server support],
104    [MANAGEMENT="$enableval"],
105    [MANAGEMENT="yes"]
108 AC_ARG_ENABLE(pkcs11,
109    [  --disable-pkcs11        Disable pkcs11 support],
110    [PKCS11="$enableval"],
111    [PKCS11="yes"]
114 AC_ARG_ENABLE(socks,
115    [  --disable-socks         Disable Socks support],
116    [SOCKS="$enableval"],
117    [SOCKS="yes"]
120 AC_ARG_ENABLE(http,
121    [  --disable-http          Disable HTTP proxy support],
122    [HTTP_PROXY="$enableval"],
123    [HTTP_PROXY="yes"]
126 AC_ARG_ENABLE(fragment,
127    [  --disable-fragment      Disable internal fragmentation support (--fragment)],
128    [FRAGMENT="$enableval"],
129    [FRAGMENT="yes"]
132 AC_ARG_ENABLE(multihome,
133    [  --disable-multihome     Disable multi-homed UDP server support (--multihome)],
134    [MULTIHOME="$enableval"],
135    [MULTIHOME="yes"]
138 AC_ARG_ENABLE(port-share,
139    [  --disable-port-share    Disable TCP server port-share support (--port-share)],
140    [PORT_SHARE="$enableval"],
141    [PORT_SHARE="yes"]
144 AC_ARG_ENABLE(debug,
145    [  --disable-debug         Disable debugging support (disable gremlin and verb 7+ messages)],
146    [DEBUG="$enableval"],
147    [DEBUG="yes"]
150 AC_ARG_ENABLE(small,
151    [  --enable-small          Enable smaller executable size (disable OCC, usage message, and verb 4 parm list)],
152    [SMALL="$enableval"],
153    [SMALL="no"]
156 AC_ARG_ENABLE(pthread,
157    [  --enable-pthread        Enable pthread support (Experimental for OpenVPN 2.0)],
158    [PTHREAD="$enableval"],
159    [PTHREAD="no"]
162 AC_ARG_ENABLE(password-save,
163    [  --enable-password-save  Allow --askpass and --auth-user-pass passwords to be read from a file],
164    [PASSWORD_SAVE="$enableval"],
165    [PASSWORD_SAVE="no"]
168 AC_ARG_ENABLE(iproute2,
169    [  --enable-iproute2       Enable support for iproute2],
170    test $enableval = "yes" && AC_DEFINE(CONFIG_FEATURE_IPROUTE, 1, [enable iproute2 support])   
173 AC_ARG_ENABLE(def-auth,
174    [  --disable-def-auth      Disable deferred authentication],
175    [DEF_AUTH="$enableval"],
176    [DEF_AUTH="yes"]
179 AC_ARG_ENABLE(pf,
180    [  --disable-pf            Disable internal packet filter],
181    [PF="$enableval"],
182    [PF="yes"]
185 AC_ARG_ENABLE(strict,
186    [  --enable-strict         Enable strict compiler warnings (debugging option)],
187    [STRICT="$enableval"],
188    [STRICT="no"]
191 AC_ARG_ENABLE(pedantic,
192    [  --enable-pedantic       Enable pedantic compiler warnings, will not generate a working executable (debugging option)],
193    [PEDANTIC="$enableval"],
194    [PEDANTIC="no"]
197 AC_ARG_ENABLE(profiling,
198    [  --enable-profiling      Enable profiling (debugging option)],
199    [PROFILE="$enableval"],
200    [PROFILE="no"]
203 AC_ARG_ENABLE(strict-options,
204    [  --enable-strict-options Enable strict options check between peers (debugging option)],
205    [STRICT_OPTIONS="$enableval"],
206    [STRICT_OPTIONS="no"]
209 AC_ARG_ENABLE(selinux,
210    [  --disable-selinux       Disable SELinux support],
211    [SELINUX="$enableval"],
212    [SELINUX="yes"]
215 AC_ARG_WITH(ssl-headers,
216    [  --with-ssl-headers=DIR  Crypto/SSL Include files location],
217    [CS_HDR_DIR="$withval"]
218    [CPPFLAGS="$CPPFLAGS -I$withval"] 
221 AC_ARG_WITH(ssl-lib,
222    [  --with-ssl-lib=DIR      Crypto/SSL Library location],
223    [LDFLAGS="$LDFLAGS -L$withval"] 
226 AC_ARG_WITH(lzo-headers,
227    [  --with-lzo-headers=DIR  LZO Include files location],
228    [LZO_HDR_DIR="$withval"]
229    [CPPFLAGS="$CPPFLAGS -I$withval"] 
232 AC_ARG_WITH(lzo-lib,
233    [  --with-lzo-lib=DIR      LZO Library location],
234    [LDFLAGS="$LDFLAGS -L$withval"] 
237 AC_ARG_WITH(pkcs11-helper-headers,
238    [  --with-pkcs11-helper-headers=DIR pkcs11-helper Include files location],
239    [PKCS11_HELPER_HDR_DIR="$withval"]
240    [CPPFLAGS="$CPPFLAGS -I$withval"] 
243 AC_ARG_WITH(pkcs11-helper-lib,
244    [  --with-pkcs11-helper-lib=DIR     pkcs11-helper Library location],
245    [LDFLAGS="$LDFLAGS -L$withval"] 
248 AC_ARG_WITH(ifconfig-path,
249    [  --with-ifconfig-path=PATH   Path to ifconfig tool],
250    [IFCONFIG="$withval"],
251    [AC_PATH_PROG([IFCONFIG], [ifconfig], [ifconfig], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
253 AC_DEFINE_UNQUOTED(IFCONFIG_PATH, "$IFCONFIG", [Path to ifconfig tool])
255 AC_ARG_WITH(iproute-path,
256    [  --with-iproute-path=PATH    Path to iproute tool],
257    [IPROUTE="$withval"],
258    [AC_PATH_PROG([IPROUTE], [ip], [ip], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
260 AC_DEFINE_UNQUOTED(IPROUTE_PATH, "$IPROUTE", [Path to iproute tool])
263 AC_ARG_WITH(route-path,
264    [  --with-route-path=PATH  Path to route tool],
265    [ROUTE="$withval"],
266    [AC_PATH_PROG([ROUTE], [route], [route], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])]
268 AC_DEFINE_UNQUOTED(ROUTE_PATH, "$ROUTE", [Path to route tool])
270 AC_ARG_WITH(mem-check,
271    [  --with-mem-check=TYPE  Build with debug memory checking, TYPE = dmalloc or valgrind],
272    [MEMCHECK="$withval"]
275 dnl fix search path, to allow compilers to find syshead.h
276 CPPFLAGS="$CPPFLAGS -I${srcdir}"
278 dnl check target OS
279 openvpn_target=$target
280 if test $target_alias; then
281   openvpn_target=$target_alias
283 AC_DEFINE_UNQUOTED(TARGET_ALIAS, "$openvpn_target", [A string representing our target])
284 case "$target" in
285 *linux*)
286         AC_DEFINE(TARGET_LINUX, 1, [Are we running on Linux?])
287         dnl RH9 SSL headers workaround
288         if test -z $CS_HDR_DIR && test "$CRYPTO" = "yes"; then
289            CPPFLAGS="$CPPFLAGS $(pkg-config --cflags openssl 2>/dev/null)"
290         fi
291         ;;
292 *solaris*)
293         AC_DEFINE(TARGET_SOLARIS, 1, [Are we running on Solaris?])
294         ;;
295 *openbsd*)
296         AC_DEFINE(TARGET_OPENBSD, 1, [Are we running on OpenBSD?])
297         ;;
298 *freebsd*)
299         AC_DEFINE(TARGET_FREEBSD, 1, [Are we running on FreeBSD?])
300         ;;
301 *netbsd*)
302         AC_DEFINE(TARGET_NETBSD, 1, [Are we running NetBSD?])
303         ;;
304 *darwin*)
305         dnl some Mac OS X tendering (we use vararg macros...)
306         AC_DEFINE(TARGET_DARWIN, 1, [Are we running on Mac OS X?])
307         CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
308         ;;
309 *mingw*)
310         AC_DEFINE(TARGET_WIN32, 1, [Are we running WIN32?])
311         OPENVPN_ADD_LIBS(-lgdi32)
312         OPENVPN_ADD_LIBS(-lws2_32)
313         OPENVPN_ADD_LIBS(-lwininet)
314         OPENVPN_ADD_LIBS(-lcrypt32)
315         OPENVPN_ADD_LIBS(-liphlpapi)
316         OPENVPN_ADD_LIBS(-lwinmm)
317         ;;
318 *dragonfly*)
319         AC_DEFINE(TARGET_DRAGONFLY, 1, [Are we running on DragonFlyBSD?])
320         ;;
321         
322 esac
324 dnl Checks for programs.
325 AC_PROG_CC
326 AC_PROG_INSTALL
327 AC_PROG_GCC_TRADITIONAL
328 AC_GNU_SOURCE
330 if test "${WIN32}" = "yes"; then
331         AC_ARG_VAR([MAN2HTML], [man2html utility])
332         AC_CHECK_PROGS([MAN2HTML], [man2html])
333         test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
336 dnl Checks for header files.
337 AC_HEADER_STDC
339 dnl Checks for typedefs, structures, and compiler characteristics.
340 AC_C_CONST
341 AC_C_INLINE
342 AC_C_VOLATILE
343 AC_TYPE_OFF_T
344 AC_TYPE_PID_T
345 AC_TYPE_SIZE_T
346 AC_TYPE_UID_T
347 TYPE_SOCKLEN_T
348 AC_HEADER_TIME
349 AX_CPP_VARARG_MACRO_ISO
350 AX_CPP_VARARG_MACRO_GCC
351 AX_EMPTY_ARRAY
353 dnl Check for more header files.
354 AC_CHECK_HEADERS(fcntl.h stdlib.h dnl
355                  stdarg.h stdio.h string.h dnl
356                  strings.h ctype.h errno.h dnl
359 if test "${WIN32}" != "yes"; then
360    AC_HEADER_SYS_WAIT
361    AC_CHECK_HEADERS(sys/time.h sys/socket.h sys/un.h sys/ioctl.h sys/stat.h dnl
362                  sys/mman.h fcntl.h sys/file.h stdlib.h stdint.h dnl
363                  stdarg.h unistd.h signal.h stdio.h string.h dnl
364                  strings.h ctype.h errno.h syslog.h pwd.h grp.h dnl
365                  net/if_tun.h net/tun/if_tun.h stropts.h sys/sockio.h dnl
366                  netinet/in.h netinet/in_systm.h dnl
367                  netinet/tcp.h arpa/inet.h dnl
368                  netdb.h sys/uio.h linux/if_tun.h linux/sockios.h dnl
369                  linux/types.h sys/poll.h sys/epoll.h err.h dnl
370    )
371    AC_CHECK_HEADERS(net/if.h,,,
372                  [#ifdef HAVE_SYS_SOCKET_H 
373                   # include <sys/socket.h>
374                   #endif
375                  ])
376    AC_CHECK_HEADERS(netinet/ip.h,,,
377                  [#ifdef HAVE_SYS_TYPES_H
378                   # include <sys/types.h>
379                   #endif
380                   #ifdef HAVE_NETINET_IN_H
381                   # include <netinet/in.h>
382                   #endif
383                   #ifdef HAVE_NETINET_IN_SYSTM_H
384                   # include <netinet/in_systm.h>
385                   #endif
386                  ])
387    AC_CHECK_HEADERS(netinet/if_ether.h,,,
388                  [#ifdef HAVE_SYS_TYPES_H
389                   # include <sys/types.h>
390                   #endif
391                   #ifdef HAVE_SYS_SOCKET_H
392                   # include <sys/socket.h>
393                   #endif
394                   #ifdef HAVE_NETINET_IN_H
395                   # include <netinet/in.h>
396                   #endif
397                  ])
398    AC_CHECK_HEADERS(resolv.h,,,
399                  [#ifdef HAVE_NETINET_IN_H 
400                   # include <netinet/in.h>
401                   #endif
402                  ])
403    AC_CHECK_HEADERS(linux/errqueue.h,,,
404         [#ifdef HAVE_LINUX_TYPES_H
405          # include <linux/types.h>
406          #endif
407         ])
410 AC_CACHE_SAVE
412 dnl check that in_addr_t is defined
413 AC_CHECK_TYPE(
414         [in_addr_t],
415         [],
416         [AC_DEFINE(in_addr_t, uint32_t, [Some systems don't define in_addr_t])],
417         [#include "syshead.h"])
419 dnl check for basic types
420 AC_CHECK_TYPE(
421         [uint8_t],
422         [],
423         [AC_DEFINE(uint8_t, unsigned char, [8-bit unsigned type])],
424         [#include "syshead.h"])
425 AC_CHECK_TYPE(
426         [uint16_t],
427         [],
428         [AC_DEFINE(uint16_t, unsigned char, [16-bit unsigned type])],
429         [#include "syshead.h"])
430 AC_CHECK_TYPE(
431         [uint32_t],
432         [],
433         [AC_DEFINE(uint32_t, unsigned long, [32-bit unsigned type])],
434         [#include "syshead.h"])
436 dnl check for IPv6 types
437 AC_CHECK_TYPE(
438         [struct tun_pi],
439         [AC_DEFINE(HAVE_TUN_PI, 1, [struct tun_pi needed for IPv6 support])],
440         [],
441         [#include "syshead.h"])
442 AC_CHECK_TYPE(
443         [struct iphdr],
444         [AC_DEFINE(HAVE_IPHDR, 1, [struct iphdr needed for IPv6 support])],
445         [],
446         [#include "syshead.h"])
447 AC_CHECK_TYPE(
448         [struct iovec],
449         [AC_DEFINE(HAVE_IOVEC, 1, [struct iovec needed for IPv6 support])],
450         [],
451         [#include "syshead.h"])
453 dnl check for extended socket error types
454 AC_CHECK_TYPE(
455         [struct sock_extended_err],
456         [AC_DEFINE(HAVE_SOCK_EXTENDED_ERR, 1, [struct sock_extended_err needed for extended socket error support])],
457         [],
458         [#include "syshead.h"])
459 AC_CHECK_TYPE(
460         [struct msghdr],
461         [AC_DEFINE(HAVE_MSGHDR, 1, [struct msghdr needed for extended socket error support])],
462         [],
463         [#include "syshead.h"])
464 AC_CHECK_TYPE(
465         [struct cmsghdr],
466         [AC_DEFINE(HAVE_CMSGHDR, 1, [struct cmsghdr needed for extended socket error support])],
467         [],
468         [#include "syshead.h"])
469 AC_CHECK_TYPE(
470         [struct in_pktinfo],
471         [AC_DEFINE(HAVE_IN_PKTINFO, 1, [struct in_pktinfo needed for IP_PKTINFO support])],
472         [],
473         [#include "syshead.h"])
475 AC_CHECK_SIZEOF(unsigned int)
476 AC_CHECK_SIZEOF(unsigned long)
478 AC_CACHE_SAVE
480 AC_CHECK_FUNCS([ctime memset vsnprintf strdup], ,
481                [AC_MSG_ERROR([Required library function not found])])
482 AC_CHECK_FUNCS(daemon chroot getpwnam setuid nice system getpid dup dup2 dnl
483                getpass strerror syslog openlog mlockall getgrnam setgid dnl
484                setgroups stat flock readv writev time dnl
485                setsid chdir putenv getpeername unlink dnl
486                chsize ftruncate execve getpeereid umask)
488 # Windows use stdcall for winsock so we cannot auto detect these
489 m4_define([SOCKET_FUNCS], [socket recv recvfrom send sendto listen dnl
490           accept connect bind select gethostbyname inet_ntoa])
491 m4_define([SOCKET_OPT_FUNCS], [setsockopt getsockopt getsockname poll])
493 if test "${WIN32}" = "yes"; then
495         AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [We fake gettimeofday for win32 at otime.c])
496         m4_foreach([F], m4_split(SOCKET_FUNCS SOCKET_OPT_FUNCS),
497                 m4_define(UF, [[m4_join([_], [HAVE], m4_toupper(F))]])
498                 AC_DEFINE([UF], [1], [Win32 builtin]))
500 else
502         dnl check for other types
503         AC_TYPE_SIGNAL
505         dnl Check for libsocket
506         AC_SEARCH_LIBS(socket, socket)
508         dnl Check for libnsl
509         AC_SEARCH_LIBS(inet_ntoa, nsl)
511         dnl Check for libresolv
512         AC_SEARCH_LIBS(gethostbyname, resolv nsl)
514         dnl optional library functions
515         AC_FUNC_FORK
517         AC_CHECK_FUNCS(gettimeofday)
519         AC_CHECK_FUNCS(SOCKET_FUNCS, ,
520                [AC_MSG_ERROR([Required library function not found])])
521         AC_CHECK_FUNCS(SOCKET_OPT_FUNCS sendmsg recvmsg)
525 dnl Required library functions
526 AC_FUNC_MEMCMP
529 dnl Check for res_init
531 AC_TRY_LINK([
532     #include <resolv.h>
533   ], [
534     res_init ();
535   ], [
536     AC_MSG_RESULT([res_init DEFINED])
537     AC_DEFINE([HAVE_RES_INIT], 1, [Indicates if res_init is available])
538   ], [
539     AC_MSG_RESULT([res_init UNDEFINED])
540   ])
543 dnl check libraries
546 dnl Checking for a working epoll
547 AC_CHECKING([for working epoll implementation])
548 OLDLDFLAGS="$LDFLAGS"
549 LDFLAGS="$LDFLAGS -Wl,--fatal-warnings"
550 AC_CHECK_FUNC(epoll_create, AC_DEFINE(HAVE_EPOLL_CREATE, 1, [epoll_create function is defined]))
551 LDFLAGS="$OLDLDFLAGS"
554 dnl check for valgrind tool
557 if test "$MEMCHECK" = "valgrind"; then
558    AC_CHECKING([for valgrind tool and Header files])
559    AC_CHECK_HEADER(valgrind/memcheck.h, 
560         [
561             AC_DEFINE(USE_VALGRIND, 1, [Use valgrind memory debugging library])
562             CFLAGS="-g -fno-inline"
563         ],
564         [AC_MSG_ERROR([valgrind headers not found.])]
565    )
569 dnl check for pthread library
572 if test "$PTHREAD" = "yes"; then
573   AC_CHECKING([for pthread support])
574   AC_MSG_RESULT([********* WARNING: pthread support is experimental for OpenVPN 2.0])
575   ACX_PTHREAD(
576         [
577             case "$target" in
578             *openbsd*)
579                 AC_MSG_RESULT([WARNING: pthread support on OpenBSD is unstable!])
580                 CFLAGS="$CFLAGS -pthread"
581                 ;;
582             esac
583             LIBS="$PTHREAD_LIBS $LIBS"
584             CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
585             CC="$PTHREAD_CC"
586             AC_DEFINE(USE_PTHREAD, 1, [Use pthread-based multithreading])
587         ],
588         [
589             AC_MSG_RESULT([I don't know how to build with pthread support on this platform.])
590             AC_MSG_ERROR([try ./configure --disable-pthread])
591         ])
595 dnl check for dmalloc library
598 if test "$MEMCHECK" = "dmalloc"; then
599    AC_CHECKING([for dmalloc Library and Header files])
600    AC_CHECK_HEADER(dmalloc.h, 
601         [AC_CHECK_LIB(dmalloc, malloc,
602             [
603                if test "$PTHREAD" = "yes"; then
604                    OPENVPN_ADD_LIBS(-ldmallocth)
605                else
606                    OPENVPN_ADD_LIBS(-ldmalloc)
607                fi
608                AC_DEFINE(DMALLOC, 1, [Use dmalloc memory debugging library])
609             ],
610             [AC_MSG_ERROR([dmalloc library not found.])]
611         )],
612         [AC_MSG_ERROR([dmalloc headers not found.])]
613    )
617 dnl Check for dlopen -- first try libc then libdl.
619 if test "${WIN32}" != "yes"; then
620    if test "$PLUGINS" = "yes"; then
621       AC_CHECKING([for libdl Library and Header files])
622       AC_CHECK_HEADER(dlfcn.h,
623            [AC_CHECK_FUNC(dlopen,
624                [AC_DEFINE(USE_LIBDL, 1, [Use libdl for dynamic library loading])],
625                [AC_CHECK_LIB(dl, dlopen,
626                    [
627                       OPENVPN_ADD_LIBS(-ldl)
628                       AC_DEFINE(USE_LIBDL, 1, [Use libdl for dynamic library loading])
629                    ],
630                    [AC_MSG_RESULT([libdl library not found.])]
631                )],
632            )],
633            [AC_MSG_RESULT([libdl headers not found.])]
634       )
635    fi
639 dnl Check if LoadLibrary exists on Windows
641 if test "${WIN32}" = "yes"; then
642    if test "$PLUGINS" = "yes"; then
643         AC_TRY_LINK([
644             #include <windows.h>
645           ], [
646             LoadLibrary (NULL);
647           ], [
648             AC_MSG_RESULT([LoadLibrary DEFINED])
649             AC_DEFINE(USE_LOAD_LIBRARY, 1, [Use LoadLibrary to load DLLs on Windows])
650           ], [
651             AC_MSG_RESULT([LoadLibrary UNDEFINED])
652           ])
653    fi
657 dnl check for LZO library
660 if test "$LZO" = "yes"; then
661    LZO_H=""
662    AC_CHECKING([for LZO Library and Header files])
663    AC_CHECK_HEADER(lzo/lzo1x.h,
664         [ LZO_H="2"
665           lzolibs="lzo2 lzo"
666           AC_DEFINE(LZO_HEADER_DIR, 1, [Use lzo/ directory prefix for LZO header files (for LZO 2.0)])
667         ],
668         [ AC_CHECK_HEADER(lzo1x.h, [ LZO_H="1" ; lzolibs=lzo ]) ]
669    )
671    if test -n "$LZO_H"; then
672      havelzolib=0
673      for i in $lzolibs ; do
674         if test $havelzolib = 1 ; then break ; fi
675         AC_CHECK_LIB($i, lzo1x_1_15_compress,
676           [
677             OPENVPN_ADD_LIBS(-l$i)
678             AC_DEFINE(USE_LZO, 1, [Use LZO compression library])
679             AC_DEFINE_UNQUOTED(LZO_VERSION_NUM, "$LZO_H", [LZO version number])
680             havelzolib=1
681           ]
682         )
683      done
684      if test $havelzolib = 0 ; then
685        AC_MSG_ERROR([LZO headers were found but LZO library was not found])
686      fi
687    else
688      AC_MSG_RESULT([LZO headers were not found])
689      AC_MSG_RESULT([LZO library available from http://www.oberhumer.com/opensource/lzo/])
690      AC_MSG_ERROR([Or try ./configure --disable-lzo])
691    fi
695 dnl check for OpenSSL-crypto library
698 if test "$CRYPTO" = "yes"; then
699    AC_CHECKING([for OpenSSL Crypto Library and Header files])
700    AC_CHECK_HEADER(openssl/evp.h,,
701         [AC_MSG_ERROR([OpenSSL Crypto headers not found.])])
703    for lib in crypto eay32; do
704       AC_CHECK_LIB($lib, EVP_CIPHER_CTX_init,
705             [
706                 cryptofound=1
707                 OPENVPN_ADD_LIBS(-l$lib)
708             ]
709       )
710    done
712    test -n "$cryptofound" || AC_MSG_ERROR([OpenSSL Crypto library not found.])
714    AC_MSG_CHECKING([that OpenSSL Library is at least version 0.9.6])
715    AC_EGREP_CPP(yes,
716      [
717        #include <openssl/evp.h>
718        #if SSLEAY_VERSION_NUMBER >= 0x00906000L
719          yes
720        #endif
721      ],
722      [
723        AC_MSG_RESULT([yes])
724        AC_DEFINE(USE_CRYPTO, 1, [Use OpenSSL crypto library])
725        AC_CHECK_FUNCS(EVP_CIPHER_CTX_set_key_length)
727        dnl check for OpenSSL crypto acceleration capability
728        AC_CHECK_HEADERS(openssl/engine.h)
729        AC_CHECK_FUNCS(ENGINE_load_builtin_engines)
730        AC_CHECK_FUNCS(ENGINE_register_all_complete)
731        AC_CHECK_FUNCS(ENGINE_cleanup)
732      ],
733      [AC_MSG_ERROR([OpenSSL crypto Library is too old.])]
734    )
737 dnl check for OpenSSL-SSL library
740    if test "$SSL" = "yes"; then
741       AC_CHECKING([for OpenSSL SSL Library and Header files])
742       AC_CHECK_HEADER(openssl/ssl.h,,
743            [AC_MSG_ERROR([OpenSSL SSL headers not found.])]
744       )
746       for lib in ssl ssl32; do
747           AC_CHECK_LIB($lib, SSL_CTX_new,
748                 [
749                         sslfound=1
750                         OPENVPN_ADD_LIBS(-l$lib)
751                 ]
752           )
753       done
755       test -n "${sslfound}" || AC_MSG_ERROR([OpenSSL SSL library not found.])
757       if test "$MEMCHECK" = "ssl"; then
758              AC_CHECKING([for Memory Debugging Capabilities in OpenSSL Library])
759              AC_CHECK_LIB(ssl, CRYPTO_mem_ctrl,
760                  [
761                      AC_DEFINE(CRYPTO_MDEBUG, 1, [Use memory debugging function in OpenSSL])
762                      AC_MSG_RESULT([NOTE: OpenSSL library must be compiled with CRYPTO_MDEBUG])
763                  ],
764                  [AC_MSG_ERROR([Memory Debugging function in OpenSSL library not found.])]
765              )
766       fi
768       AC_DEFINE(USE_SSL, 1, [Use OpenSSL SSL library])
769    fi
772 dnl enable pkcs11 capability
773 if test "$PKCS11" = "yes"; then
774    AC_CHECKING([for pkcs11-helper Library and Header files])
775    AC_CHECK_HEADER(pkcs11-helper-1.0/pkcs11h-core.h,
776         [AC_CHECK_LIB(pkcs11-helper, pkcs11h_initialize,
777             [
778                    AC_DEFINE(USE_PKCS11, 1, [Enable PKCS11 capability])
779                    OPENVPN_ADD_LIBS(-lpkcs11-helper)
780             ],
781             [AC_MSG_RESULT([pkcs11-helper library not found.])]
782         )],
783         [AC_MSG_RESULT([pkcs11-helper headers not found.])]
784    )
787 dnl enable multi-client mode
788 if test "$MULTI" = "yes"; then
789    AC_DEFINE(ENABLE_CLIENT_SERVER, 1, [Enable client/server capability])
792 dnl enable client mode only, not server
793 if test "$MULTI_SERVER" = "no"; then
794    AC_DEFINE(ENABLE_CLIENT_ONLY, 1, [Enable client capability only])
797 dnl enable management server capability
798 if test "$MANAGEMENT" = "yes"; then
799    AC_DEFINE(ENABLE_MANAGEMENT, 1, [Enable management server capability])
802 dnl enable socks 
803 if test "$SOCKS" = "yes"; then
804    AC_DEFINE(ENABLE_SOCKS, 1, [Enable Socks proxy support])
807 dnl enable HTTP proxy
808 if test "$HTTP_PROXY" = "yes"; then
809    AC_DEFINE(ENABLE_HTTP_PROXY, 1, [Enable HTTP proxy support])
812 dnl compile --multihome option
813 if test "$MULTIHOME" = "yes"; then
814    AC_DEFINE(ENABLE_MULTIHOME, 1, [Enable multi-homed UDP server capability])
817 dnl enable debugging
818 if test "$DEBUG" = "yes"; then
819    AC_DEFINE(ENABLE_DEBUG, 1, [Enable debugging support])
822 dnl enable small size optimizations
823 if test "$SMALL" = "yes"; then
824    AC_DEFINE(ENABLE_SMALL, 1, [Enable smaller executable size])
827 dnl enable --fragment
828 if test "$FRAGMENT" = "yes"; then
829    AC_DEFINE(ENABLE_FRAGMENT, 1, [Enable internal fragmentation support])
832 dnl enable --port-share
833 if test "$PORT_SHARE" = "yes"; then
834    AC_DEFINE(ENABLE_PORT_SHARE, 1, [Enable TCP Server port sharing])
837 dnl enable deferred auth
838 if test "$DEF_AUTH" = "yes"; then
839    AC_DEFINE(CONFIGURE_DEF_AUTH, 1, [Enable deferred authentication])
842 dnl enable internal packet filter
843 if test "$PF" = "yes"; then
844    AC_DEFINE(CONFIGURE_PF, 1, [Enable internal packet filter])
847 dnl enable strict compiler warnings
848 if test "$STRICT" = "yes"; then
849    CFLAGS="$CFLAGS -Wall -Wno-unused-parameter -Wno-unused-function"
852 dnl enable pedantic compiler warnings
853 if test "$PEDANTIC" = "yes"; then
854    CFLAGS="$CFLAGS -ansi -pedantic"
857 dnl enable profiling
858 if test "$PROFILE" = "yes"; then
859    CFLAGS="$CFLAGS -pg -DENABLE_PROFILING"
862 dnl enable strict options check between peers
863 if test "$STRICT_OPTIONS" = "yes"; then
864    AC_DEFINE(STRICT_OPTIONS_CHECK, 1, [Enable strict options check between peers])
867 dnl enable password save
868 if test "$PASSWORD_SAVE" = "yes"; then
869    AC_DEFINE(ENABLE_PASSWORD_SAVE, 1, [Allow --askpass and --auth-user-pass passwords to be read from a file])
873 dnl check for SELinux library and headers
875 if test "$SELINUX" = "yes"; then
876    AC_CHECKING([for libselinux Library and Header files])
877    AC_CHECK_HEADER(selinux/selinux.h,
878       [AC_CHECK_LIB(selinux, setcon,
879          [
880             OPENVPN_ADD_LIBS(-lselinux)
881             AC_DEFINE(HAVE_SETCON, 1, [SELinux support])
882          ],
883             [AC_MSG_RESULT([SELinux library not found.])]
884          )],
885       [AC_MSG_RESULT([SELinux headers not found.])]
886    )
889 TAP_ID="PRODUCT_TAP_ID"
890 TAP_WIN32_MIN_MAJOR="PRODUCT_TAP_WIN32_MIN_MAJOR"
891 TAP_WIN32_MIN_MINOR="PRODUCT_TAP_WIN32_MIN_MINOR"
892 AC_DEFINE_UNQUOTED(TAP_ID, "${TAP_ID}", [The TAP-Win32 id defined in tap-win32/SOURCES])
893 AC_DEFINE_UNQUOTED(TAP_WIN32_MIN_MAJOR, ${TAP_WIN32_MIN_MAJOR}, [The TAP-Win32 version number is defined in tap-win32/SOURCES])
894 AC_DEFINE_UNQUOTED(TAP_WIN32_MIN_MINOR, ${TAP_WIN32_MIN_MINOR}, [The TAP-Win32 version number is defined in tap-win32/SOURCES])
895 AC_SUBST(TAP_ID)
896 AC_SUBST(TAP_WIN32_MIN_MAJOR)
897 AC_SUBST(TAP_WIN32_MIN_MINOR)
899 win32datadir="\${datadir}/${PACKAGE}-win32"
900 AC_SUBST(win32datadir)
901 AM_CONDITIONAL(WIN32, test "${WIN32}" = "yes")
903 # workaround for <autoconf-2.60
904 if test -z "${docdir}"; then
905         docdir="\$(datadir)/doc/\$(PACKAGE_NAME)"
906         AC_SUBST([docdir])
908 if test -z "${htmldir}"; then
909         htmldir="\$(docdir)"
910         AC_SUBST([htmldir])
912 # end workaround
914 AC_OUTPUT([
915         Makefile
916         openvpn.spec
917         config-win32.h
918         images/Makefile
919         service-win32/Makefile
920         install-win32/Makefile
921         install-win32/settings