Use libsocket and libnsl as necessary on Solaris
[platform/upstream/openconnect.git] / configure.ac
1 AC_INIT(openconnect, 4.07)
2 PKG_PROG_PKG_CONFIG
3 AC_LANG_C
4 AC_CANONICAL_HOST
5 AM_MAINTAINER_MODE([enable])
6 AM_INIT_AUTOMAKE([foreign])
7 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
8
9 # Define htmldir and localedir for users of ancient autoconf building from git
10 AC_PREREQ([2.59c], [], [AC_SUBST([htmldir], [m4_ifset([AC_PACKAGE_TARNAME],
11           ['${datadir}/doc/${PACKAGE_TARNAME}'],
12           ['${datadir}/doc/${PACKAGE}'])
13 ])])
14
15 AC_PREREQ([2.60], [], [AC_SUBST([localedir], ['$(datadir)/locale'])])
16
17 # Upstream's pkg.m4 (since 0.27) offers this now, but define our own
18 # compatible version in case the local version of pkgconfig isn't new enough.
19 # https://bugs.freedesktop.org/show_bug.cgi?id=48743
20 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
21           [AC_ARG_WITH([pkgconfigdir],
22                        [AS_HELP_STRING([--with-pkgconfigdir],
23                        [install directory for openconnect.pc pkg-config file])],
24                         [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
25            AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
26
27 AC_ARG_WITH([vpnc-script],
28         [AS_HELP_STRING([--with-vpnc-script],
29           [default location of vpnc-script helper])])
30
31 if test "$with_vpnc_script" = "yes" || test "$with_vpnc_script" = ""; then
32    with_vpnc_script=/etc/vpnc/vpnc-script
33    if ! test -x "$with_vpnc_script"; then
34       AC_MSG_ERROR([${with_vpnc_script} does not seem to be executable.]
35     [OpenConnect will not function correctly without a vpnc-script.]
36     [See http://www.infradead.org/openconnect/vpnc-script.html for more details.]
37     []
38     [If you are building a distribution package, please ensure that your]
39     [packaging is correct, and that a vpnc-script will be installed when the]
40     [user installs your package. You should provide a --with-vpnc-script=]
41     [argument to this configure script, giving the full path where the script]
42     [will be installed.]
43     []
44     [The standard location is ${with_vpnc_script}. To bypass this error and]
45     [build OpenConnect to use the script from this location, even though it's]
46     [not present at the time you are building OpenConnect, pass the argument]
47     ["--with-vpnc-script=${with_vpnc_script}"])
48   fi
49 elif test "$with_vpnc_script" = "no"; then
50    AC_ERROR([You cannot disable vpnc-script.]
51    [OpenConnect will not function correctly without it.]
52    [See http://www.infradead.org/openconnect/vpnc-script.html])
53 fi
54
55 AC_DEFINE_UNQUOTED(DEFAULT_VPNCSCRIPT, "${with_vpnc_script}")
56 AC_SUBST(DEFAULT_VPNCSCRIPT, "${with_vpnc_script}")
57
58 case $host_os in
59  *linux* | *gnu*)
60     AC_MSG_NOTICE([Applying feature macros for GNU build])
61     AC_DEFINE(_POSIX_C_SOURCE, 200112L)
62     # For strcasecmp() 
63     AC_DEFINE(_BSD_SOURCE)
64     # For asprintf()
65     AC_DEFINE(_GNU_SOURCE)
66     ;;
67  *netbsd*)
68     AC_MSG_NOTICE([Applying feature macros for NetBSD build])
69     AC_DEFINE(_POSIX_C_SOURCE, 200112L)
70     AC_DEFINE(_NETBSD_SOURCE)
71     ;;
72  *)
73     # On FreeBSD the only way to get vsyslog() visible is to define
74     #  *nothing*, which makes absolutely everything visible.
75     # On Darwin enabling _POSIX_C_SOURCE breaks <sys/mount.h> because
76     # u_long and other types don't get defined. OpenBSD is similar.
77     ;;
78 esac
79
80 symver_time=
81 symver_getline=
82 symver_asprintf=
83
84 case $host_os in
85  *solaris*|*sunos*)
86     symver_time="openconnect__time;"
87     ;;
88 esac
89
90 AC_CHECK_FUNC(fdevname_r, [AC_DEFINE(HAVE_FDEVNAME_R, 1)], [])
91 AC_CHECK_FUNC(getline, [AC_DEFINE(HAVE_GETLINE, 1)], [symver_getline="openconnect__getline;"])
92 AC_CHECK_FUNC(strcasestr, [AC_DEFINE(HAVE_STRCASESTR, 1)], [])
93 AC_CHECK_FUNC(asprintf, [AC_DEFINE(HAVE_ASPRINTF, 1)], [symver_asprintf="openconnect__asprintf;"])
94 if test -n "$symver_asprintf"; then
95   AC_MSG_CHECKING([for va_copy])
96   AC_LINK_IFELSE([AC_LANG_PROGRAM([
97         #include <stdarg.h>
98         va_list a;],[
99         va_list b;
100         va_copy(b,a);
101         va_end(b);])],
102         [AC_DEFINE(HAVE_VA_COPY, 1)
103         AC_MSG_RESULT(va_copy)],
104         [AC_LINK_IFELSE([AC_LANG_PROGRAM([
105                 #include <stdarg.h>
106                 va_list a;],[
107                 va_list b;
108                 __va_copy(b,a);
109                 va_end(b);])],
110                 [AC_DEFINE(HAVE___VA_COPY, 1)
111                 AC_MSG_RESULT(__va_copy)],
112                 [AC_MSG_RESULT(no)
113                 AC_MSG_ERROR([Your system lacks asprintf() and va_copy()])])
114         ])
115 fi
116 AC_SUBST(SYMVER_TIME, $symver_time)
117 AC_SUBST(SYMVER_GETLINE, $symver_getline)
118 AC_SUBST(SYMVER_ASPRINTF, $symver_asprintf)
119
120 AS_COMPILER_FLAGS(CFLAGS,
121         "-Wall
122          -Wextra
123          -Wno-missing-field-initializers
124          -Wno-sign-compare
125          -Wno-unused-parameter
126          -Werror=pointer-to-int-cast
127          -Wdeclaration-after-statement
128          -Werror-implicit-function-declaration
129          -Wformat-nonliteral
130          -Wformat-security
131          -Winit-self
132          -Wmissing-declarations
133          -Wmissing-include-dirs
134          -Wnested-externs
135          -Wpointer-arith
136          -Wwrite-strings")
137
138 AC_CHECK_FUNC(socket, [], AC_CHECK_LIB(socket, socket, [], AC_ERROR(Cannot find socket() function)))
139 AC_CHECK_FUNC(inet_aton, [], AC_CHECK_LIB(nsl, inet_aton, [], AC_ERROR(Cannot find inet_aton() function)))
140
141 AC_ENABLE_SHARED
142 AC_DISABLE_STATIC
143
144 AC_ARG_ENABLE([nls],
145         [  --disable-nls           do not use Native Language Support],
146         [USE_NLS=$enableval], [USE_NLS=yes])
147 LIBINTL=
148 if test "$USE_NLS" = "yes"; then
149    AC_PATH_PROG(MSGFMT, msgfmt)
150    if test "$MSGFMT" = ""; then
151       AC_ERROR([msgfmt could not be found. Try configuring with --disable-nls])
152    fi
153 fi
154 LIBINTL=
155 if test "$USE_NLS" = "yes"; then
156    AC_MSG_CHECKING([for functional NLS support])
157    AC_LINK_IFELSE([AC_LANG_PROGRAM([
158     #include <locale.h>
159     #include <libintl.h>],[
160     setlocale(LC_ALL, "");
161     bindtextdomain("openconnect", "/tmp");
162     (void)dgettext("openconnect", "foo");])],
163     [AC_MSG_RESULT(yes)],
164     [oldLIBS="$LIBS"
165      LIBS="$LIBS -lintl"
166      AC_LINK_IFELSE([AC_LANG_PROGRAM([
167       #include <locale.h>
168       #include <libintl.h>],[
169       setlocale(LC_ALL, "");
170       bindtextdomain("openconnect", "/tmp");
171       (void)dgettext("openconnect", "foo");])],
172       [AC_MSG_RESULT(yes (with -lintl))]
173        LIBINTL="-lintl",
174       [AC_MSG_RESULT(no)
175        USE_NLS=no])
176      LIBS="$oldLIBS"])
177 fi
178
179 if test "$USE_NLS" = "yes"; then
180    AC_SUBST(LIBINTL)
181    AC_DEFINE(ENABLE_NLS, 1)
182 fi
183 AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"])
184
185 AC_ARG_WITH([system-cafile],
186             AS_HELP_STRING([--with-system-cafile],
187                            [Location of the default system CA certificate file for old (<3.0.20) GnuTLS versions]))
188
189 # We will use GnuTLS if it's requested, and if GnuTLS doesn't have DTLS
190 # support then we'll *also* use OpenSSL for that, but it appears *only*
191 # only in the openconnect executable and not the library (hence shouldn't
192 # be a problem for GPL'd programs using libopenconnect).
193 #
194 # If built with --with-gnutls --without-openssl then we'll even eschew
195 # OpenSSL for DTLS support and will build without any DTLS support at all
196 # if GnuTLS cannot manage.
197 #
198 # The default (for now) is to use OpenSSL for everything.
199
200 AC_ARG_WITH([gnutls],
201         AS_HELP_STRING([--with-gnutls], 
202                        [Use GnuTLS instead of OpenSSL (EXPERIMENTAL)]))
203 AC_ARG_WITH([openssl],
204             AS_HELP_STRING([--with-openssl],
205                            [Location of OpenSSL build dir]))
206 ssl_library=
207
208 if test "$with_gnutls" = "yes"; then
209     PKG_CHECK_MODULES(GNUTLS, gnutls)
210     if ! $PKG_CONFIG --atleast-version=2.12.16 gnutls; then
211        AC_MSG_ERROR([Your GnuTLS is too old. At least v2.12.16 is required])
212     fi
213     oldlibs="$LIBS"
214     LIBS="$LIBS $GNUTLS_LIBS"
215     AC_CHECK_FUNC(gnutls_dtls_set_data_mtu,
216                  [AC_DEFINE(HAVE_GNUTLS_DTLS_SET_DATA_MTU, 1)], [])
217     AC_CHECK_FUNC(gnutls_certificate_set_x509_system_trust,
218                  [AC_DEFINE(HAVE_GNUTLS_CERTIFICATE_SET_X509_SYSTEM_TRUST, 1)], [])
219     if test "$ac_cv_func_gnutls_certificate_set_x509_system_trust" != "yes"; then
220         # We will need to tell GnuTLS the path to the system CA file.
221         if test "$with_system_cafile" = "yes" || test "$with_system_cafile" = ""; then
222             unset with_system_cafile
223             AC_MSG_CHECKING([For location of system CA trust file])
224             for file in /etc/ssl/certs/ca-certificates.crt \
225                         /etc/pki/tls/cert.pem \
226                         /usr/local/share/certs/ca-root-nss.crt \
227                         /etc/ssl/cert.pem; do
228                 if grep 'BEGIN CERTIFICATE-----' $file >/dev/null 2>&1; then
229                     with_system_cafile=${file}
230                     break
231                 fi
232             done
233             AC_MSG_RESULT([${with_system_cafile-NOT FOUND}])
234         elif test "$with_system_cafile" = "no"; then
235             AC_MSG_ERROR([You cannot disable the system CA certificate file.])
236         fi
237         if test "$with_system_cafile" = ""; then
238             AC_MSG_ERROR([Unable to find a standard system CA certificate file.]
239     [Your GnuTLS requires a path to a CA certificate store. This is a file]
240     [which contains a list of the Certificate Authorities which are trusted.]
241     [Most distributions ship with this file in a standard location, but none]
242     [the known standard locations exist on your system. You should provide a]
243     [--with-system-cafile= argument to this configure script, giving the full]
244     [path to a default CA certificate file for GnuTLS to use. Also, please]
245     [send full details of your system, including 'uname -a' output and the]
246     [location of the system CA certificate store on your system, to the]
247     [openconnect-devel@lists.infradead.org mailing list.])
248         fi
249         AC_DEFINE_UNQUOTED([DEFAULT_SYSTEM_CAFILE], ["$with_system_cafile"])
250     fi
251     AC_CHECK_FUNC(gnutls_pkcs12_simple_parse,
252                  [AC_DEFINE(HAVE_GNUTLS_PKCS12_SIMPLE_PARSE, 1)], [])
253     AC_CHECK_FUNC(gnutls_certificate_set_key,
254                  [AC_DEFINE(HAVE_GNUTLS_CERTIFICATE_SET_KEY, 1)], [])
255     if test "$with_openssl" = "" || test "$with_openssl" = "no"; then
256         AC_CHECK_FUNC(gnutls_session_set_premaster,
257                  [have_gnutls_dtls=yes], [have_gnutls_dtls=no])
258     else
259         have_gnutls_dtls=no
260     fi
261     if test "$have_gnutls_dtls" = "yes"; then
262         if test "$with_openssl" = "" || test "$with_openssl" = "no"; then
263             # They either said no OpenSSL or didn't specify, and GnuTLS can
264             # do DTLS, so just use GnuTLS.
265             AC_DEFINE(HAVE_GNUTLS_SESSION_SET_PREMASTER, 1)    
266             ssl_library=gnutls
267             with_openssl=no
268         else
269             # They specifically asked for OpenSSL, so use it for DTLS even
270             # though GnuTLS could manage.
271             ssl_library=both
272         fi
273     else
274         if test "$with_openssl" = "no"; then
275             # GnuTLS doesn't have DTLS, but they don't want OpenSSL. So build
276             # without DTLS support at all.
277             ssl_library=gnutls
278         else
279             # GnuTLS doesn't have DTLS so use OpenSSL for it, but GnuTLS for
280             # the TCP connection (and thus in the library).
281             ssl_library=both
282         fi
283     fi
284     AC_CHECK_FUNC(gnutls_pkcs11_add_provider,
285                  [PKG_CHECK_MODULES(P11KIT, p11-kit-1, [AC_DEFINE(HAVE_P11KIT)
286                                           AC_SUBST(P11KIT_PC, p11-kit-1)], [:])], [])
287     LIBS="$oldlibs -ltspi"
288     AC_MSG_CHECKING([for tss library])
289     AC_LINK_IFELSE([AC_LANG_PROGRAM([
290                    #include <trousers/tss.h>
291                    #include <trousers/trousers.h>],[
292                    int err = Tspi_Context_Create((void *)0);
293                    Trspi_Error_String(err);])],
294                   [AC_MSG_RESULT(yes)
295                    AC_SUBST([TSS_LIBS], [-ltspi])
296                    AC_SUBST([TSS_CFLAGS], [])
297                    AC_DEFINE(HAVE_TROUSERS, 1)],
298                   [AC_MSG_RESULT(no)])
299     LIBS="$oldlibs"
300 elif test "$with_gnutls" != "" && test "$with_gnutls" != "no"; then
301     AC_MSG_ERROR([Values other than 'yes' or 'no' for --with-gnutls are not supported])
302 fi
303 if test "$with_openssl" = "yes" || test "$with_openssl" = "" || test "$ssl_library" = "both"; then
304     PKG_CHECK_MODULES(OPENSSL, openssl, [],
305         [oldLIBS="$LIBS"
306          LIBS="$LIBS -lssl -lcrypto"
307          AC_MSG_CHECKING([for OpenSSL without pkg-config])
308          AC_LINK_IFELSE([AC_LANG_PROGRAM([
309                                 #include <openssl/ssl.h>
310                                 #include <openssl/err.h>],[
311                                 SSL_library_init();
312                                 ERR_clear_error();
313                                 SSL_load_error_strings();
314                                 OpenSSL_add_all_algorithms();])],
315                         [AC_MSG_RESULT(yes)
316                          AC_SUBST([OPENSSL_LIBS], ["-lssl -lcrypto"])
317                          AC_SUBST([OPENSSL_CFLAGS], [])],
318                         [AC_MSG_RESULT(no)
319                          if test "$ssl_library" = "both"; then
320                              ssl_library="gnutls";
321                          else
322                              AC_ERROR([Could not build against OpenSSL]);
323                          fi])
324          LIBS="$oldLIBS"])
325     if test "$ssl_library" != "both" && test "$ssl_library" != "gnutls"; then
326         ssl_library=openssl
327     fi
328 elif test "$with_openssl" != "no" ; then
329     OPENSSL_CFLAGS="-I${with_openssl}/include"
330     OPENSSL_LIBS="${with_openssl}/libssl.a ${with_openssl}/libcrypto.a -ldl -lz"
331     AC_SUBST(OPENSSL_CFLAGS)
332     AC_SUBST(OPENSSL_LIBS)
333     enable_static=yes
334     enable_shared=no
335     AC_DEFINE(DTLS_OPENSSL, 1)
336     if test "$ssl_library" != "both"; then
337         ssl_library=openssl
338     fi
339 fi
340
341 case "$ssl_library" in
342     gnutls)
343         AC_DEFINE(OPENCONNECT_GNUTLS, 1)
344         AC_DEFINE(DTLS_GNUTLS, 1)
345         AC_SUBST(SSL_LIBRARY, [gnutls])
346         AC_SUBST(SSL_LIBS, ['$(GNUTLS_LIBS)'])
347         AC_SUBST(SSL_CFLAGS, ['$(GNUTLS_CFLAGS)'])
348         ;;
349     openssl)
350         AC_DEFINE(OPENCONNECT_OPENSSL, 1)
351         AC_DEFINE(DTLS_OPENSSL, 1)
352         AC_SUBST(SSL_LIBRARY, [openssl])
353         AC_SUBST(SSL_LIBS, ['$(OPENSSL_LIBS)'])
354         AC_SUBST(SSL_CFLAGS, ['$(OPENSSL_CFLAGS)'])
355         AC_SUBST(SYMVER_PRINT_ERR, ["openconnect_print_err_cb;"])
356         ;;
357     both)
358         # GnuTLS for TCP, OpenSSL for DTLS
359         AC_DEFINE(OPENCONNECT_GNUTLS, 1)
360         AC_DEFINE(DTLS_OPENSSL, 1)
361         AC_SUBST(SSL_LIBRARY, [gnutls])
362         AC_SUBST(SSL_LIBS, ['$(GNUTLS_LIBS)'])
363         AC_SUBST(SSL_CFLAGS, ['$(GNUTLS_CFLAGS)'])
364         AC_SUBST(DTLS_SSL_LIBS, ['$(OPENSSL_LIBS)'])
365         AC_SUBST(DTLS_SSL_CFLAGS, ['$(OPENSSL_CFLAGS)'])
366         AC_SUBST(SYMVER_PRINT_ERR, ["openconnect_print_err_cb;"])
367         ;;
368     *)
369         AC_MSG_ERROR([Neither OpenSSL nor GnuTLS selected for SSL.])
370         ;;
371 esac
372 AM_CONDITIONAL(OPENCONNECT_GNUTLS,  [ test "$ssl_library" != "openssl" ])
373 AM_CONDITIONAL(OPENCONNECT_OPENSSL, [ test "$ssl_library" = "openssl" ])
374
375 # Needs to happen after we default to static/shared libraries based on OpenSSL
376 AC_PROG_LIBTOOL
377
378 # Ick. This seems like it's likely to be very fragile, but I can't see a better
379 # way. I shall console myself with the observation that the failure mode isn't
380 # particularly horrible — you just don't get symbol versioning if it fails.
381 symvers=no
382 if test "$enable_shared" = "yes" ; then
383    AC_MSG_CHECKING([if library symbol versioning is available]);
384    echo 'FOO { global: foo; local: *; };' > conftest.map
385    echo 'int foo = 0;' > conftest.$ac_ext
386    if AC_TRY_EVAL(ac_compile); then
387       soname=conftest
388       libobjs=conftest.$ac_objext
389       if AC_TRY_EVAL(archive_cmds ${wl}--version-script ${wl}conftest.map); then
390          AC_SUBST(VERSION_SCRIPT_ARG, [--version-script])
391          symvers="yes (with --version-script)"
392       elif AC_TRY_EVAL(archive_cmds ${wl}-M ${wl}conftest.map); then
393          AC_SUBST(VERSION_SCRIPT_ARG, [-M])
394          symvers="yes (with -M)"
395       fi
396    fi
397    AC_MSG_RESULT(${symvers})
398 fi
399 AM_CONDITIONAL(HAVE_SYMBOL_VERSIONING, [test "${symvers}" != "no"])
400
401 PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
402
403 PKG_CHECK_MODULES(ZLIB, zlib, [AC_SUBST(ZLIB_PC, [zlib])],
404                   [oldLIBS="$LIBS"
405                   LIBS="$LIBS -lz" 
406                   AC_MSG_CHECKING([for zlib without pkg-config])
407                   AC_LINK_IFELSE([AC_LANG_PROGRAM([
408                    #include <zlib.h>],[
409                    z_stream zs;
410                    deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
411                                 -12, 9, Z_DEFAULT_STRATEGY);])],
412                   [AC_MSG_RESULT(yes)
413                    AC_SUBST([ZLIB_LIBS], [-lz])
414                    AC_SUBST([ZLIB_CFLAGS], [])],
415                   [AC_MSG_RESULT(no)
416                    AC_ERROR([Could not build against zlib])])
417                   LIBS="$oldLIBS"])
418
419 PKG_CHECK_MODULES(LIBPROXY, libproxy-1.0,
420                 [AC_SUBST(LIBPROXY_PC, libproxy-1.0)
421                  AC_DEFINE([LIBPROXY_HDR], ["proxy.h"])
422                  libproxy_pkg=yes],
423                  libproxy_pkg=no)
424 dnl Libproxy *can* exist without a .pc file, and its header may be called
425 dnl libproxy.h in that case.
426 if (test "$libproxy_pkg" = "no"); then
427    AC_MSG_CHECKING([for libproxy])
428    oldLIBS="$LIBS"
429    LIBS="$LIBS -lproxy"
430    AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libproxy.h>],
431                            [(void)px_proxy_factory_new();])],
432           [AC_MSG_RESULT(yes (with libproxy.h))
433            AC_DEFINE([LIBPROXY_HDR], ["libproxy.h"])
434            AC_SUBST([LIBPROXY_LIBS], [-lproxy])],
435           [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <proxy.h>],
436                                   [(void)px_proxy_factory_new();])],
437                   [AC_MSG_RESULT(yes (with proxy.h))
438                    AC_DEFINE([LIBPROXY_HDR], ["proxy.h"])
439                    AC_SUBST([LIBPROXY_LIBS], [-lproxy])],
440                    [AC_MSG_RESULT(no)])])
441    LIBS="$oldLIBS"
442 fi
443
444 PKG_CHECK_MODULES(LIBSTOKEN, stoken,
445                 [AC_SUBST(LIBSTOKEN_PC, stoken)
446                  AC_DEFINE([LIBSTOKEN_HDR], ["stoken.h"])
447                  libstoken_pkg=yes],
448                  libstoken_pkg=no)
449
450 AC_CHECK_HEADER([if_tun.h],
451     [AC_DEFINE([IF_TUN_HDR], ["if_tun.h"])],
452     [AC_CHECK_HEADER([linux/if_tun.h],
453         [AC_DEFINE([IF_TUN_HDR], ["linux/if_tun.h"])],
454         [AC_CHECK_HEADER([net/if_tun.h],
455             [AC_DEFINE([IF_TUN_HDR], ["net/if_tun.h"])],
456             [AC_CHECK_HEADER([net/tun/if_tun.h],
457                 [AC_DEFINE([IF_TUN_HDR], ["net/tun/if_tun.h"])])])])])
458
459 if test "$ssl_library" = "openssl" || test "$ssl_library" = "both"; then
460     oldLIBS="$LIBS"
461     LIBS="$LIBS $OPENSSL_LIBS"
462
463     if test "$ssl_library" = "openssl"; then
464         AC_MSG_CHECKING([for ENGINE_by_id() in OpenSSL])
465         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/engine.h>],
466                                         [ENGINE_by_id("foo");])],
467                        [AC_MSG_RESULT(yes)
468                         AC_DEFINE(HAVE_ENGINE, [1], [OpenSSL has ENGINE support])],
469                        [AC_MSG_RESULT(no)
470                         AC_MSG_NOTICE([Building without OpenSSL TPM ENGINE support])])
471     fi
472
473     AC_MSG_CHECKING([for dtls1_stop_timer() in OpenSSL])
474     AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>
475                                      #include <stdlib.h>
476                                      extern void dtls1_stop_timer(SSL *);],
477                                     [dtls1_stop_timer(NULL);])],
478                    [AC_MSG_RESULT(yes)
479                     AC_DEFINE(HAVE_DTLS1_STOP_TIMER, [1], [OpenSSL has dtls1_stop_timer() function])],
480                    [AC_MSG_RESULT(no)])
481     LIBS="$oldLIBS"
482 fi
483
484 AC_PATH_PROG(PYTHON, [python], [], $PATH:/bin:/usr/bin)
485 if (test -n "${ac_cv_path_PYTHON}"); then
486    AC_SUBST(PYTHON, ${ac_cv_path_PYTHON})
487 else
488    AC_MSG_NOTICE([Python not found; not building HTML pages])
489 fi
490 AM_CONDITIONAL(BUILD_WWW, [test -n "${ac_cv_path_PYTHON}"])
491
492 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/po/LINGUAS $(top_srcdir)/openconnect.h ${top_srcdir}/libopenconnect.map.in'])
493 RAWLINGUAS=`sed -e "/^#/d" -e "s/#.*//" "${srcdir}/po/LINGUAS"`
494 # Remove newlines
495 LINGUAS=`echo $RAWLINGUAS`
496 AC_SUBST(LINGUAS)
497
498 APIMAJOR="`sed -n 's/^#define OPENCONNECT_API_VERSION_MAJOR \(.*\)/\1/p' ${srcdir}/openconnect.h`"
499 APIMINOR="`sed -n 's/^#define OPENCONNECT_API_VERSION_MINOR \(.*\)/\1/p' ${srcdir}/openconnect.h`"
500 AC_SUBST(APIMAJOR)
501 AC_SUBST(APIMINOR)
502
503 # We want version.c to depend on the files that would affect the
504 # output of version.sh. But we cannot assume that they'll exist,
505 # and we cannot use $(wildcard) in a non-GNU makefile. So we just
506 # depend on the files which happen to exist at configure time.
507 GITVERSIONDEPS=
508 for a in ${srcdir}/.git/index ${srcdir}/.git/packed-refs \
509          ${srcdir}/.git/refs/tags ${srcdir}/.git/HEAD; do
510     if test -r $a ; then
511        GITVERSIONDEPS="$GITVERSIONDEPS $a"
512     fi
513 done
514 AC_SUBST(GITVERSIONDEPS)
515
516 AC_OUTPUT(Makefile openconnect.pc po/Makefile www/Makefile libopenconnect.map \
517           openconnect.8 www/styles/Makefile www/inc/Makefile www/images/Makefile)