1 AC_INIT(openconnect, 3.20)
5 AM_MAINTAINER_MODE([enable])
6 AM_INIT_AUTOMAKE([foreign])
7 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
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}'])
15 AC_PREREQ([2.60], [], [AC_SUBST([localedir], ['$(datadir)/locale'])])
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}])])
27 AC_ARG_WITH([vpnc-script],
28 [AS_HELP_STRING([--with-vpnc-script],
29 [default location of vpnc-script helper])])
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.]
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]
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}"])
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])
55 AC_DEFINE_UNQUOTED(DEFAULT_VPNCSCRIPT, "${with_vpnc_script}")
59 AC_MSG_NOTICE([Applying feature macros for GNU build])
60 AC_DEFINE(_POSIX_C_SOURCE, 200112L)
62 AC_DEFINE(_BSD_SOURCE)
64 AC_DEFINE(_GNU_SOURCE)
67 AC_MSG_NOTICE([Applying feature macros for NetBSD build])
68 AC_DEFINE(_POSIX_C_SOURCE, 200112L)
69 AC_DEFINE(_NETBSD_SOURCE)
72 # On FreeBSD the only way to get vsyslog() visible is to define
73 # *nothing*, which makes absolutely everything visible.
74 # On Darwin enabling _POSIX_C_SOURCE breaks <sys/mount.h> because
75 # u_long and other types don't get defined. OpenBSD is similar.
85 symver_time="openconnect__time;"
89 AC_CHECK_FUNC(getline, [AC_DEFINE(HAVE_GETLINE, 1)], [symver_getline="openconnect__getline;"])
90 AC_CHECK_FUNC(strcasestr, [AC_DEFINE(HAVE_STRCASESTR, 1)], [])
91 AC_CHECK_FUNC(asprintf, [AC_DEFINE(HAVE_ASPRINTF, 1)], [symver_asprintf="openconnect__asprintf;"])
92 if test -n "$symver_asprintf"; then
93 AC_MSG_CHECKING([for va_copy])
94 AC_LINK_IFELSE([AC_LANG_PROGRAM([
100 [AC_DEFINE(HAVE_VA_COPY, 1)
101 AC_MSG_RESULT(va_copy)],
102 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
108 [AC_DEFINE(HAVE___VA_COPY, 1)
109 AC_MSG_RESULT(__va_copy)],
111 AC_MSG_ERROR([Your system lacks asprintf() and va_copy()])])
114 AC_SUBST(SYMVER_TIME, $symver_time)
115 AC_SUBST(SYMVER_GETLINE, $symver_getline)
116 AC_SUBST(SYMVER_ASPRINTF, $symver_asprintf)
118 AS_COMPILER_FLAGS(CFLAGS,
121 -Wno-missing-field-initializers
123 -Wno-unused-parameter
124 -Werror=pointer-to-int-cast
125 -Wdeclaration-after-statement
126 -Werror-implicit-function-declaration
130 -Wmissing-declarations
131 -Wmissing-include-dirs
140 [ --disable-nls do not use Native Language Support],
141 [USE_NLS=$enableval], [USE_NLS=yes])
143 if test "$USE_NLS" = "yes"; then
144 AC_PATH_PROG(MSGFMT, msgfmt)
145 if test "$MSGFMT" = ""; then
146 AC_ERROR([msgfmt could not be found. Try configuring with --disable-nls])
150 if test "$USE_NLS" = "yes"; then
151 AC_MSG_CHECKING([for functional NLS support])
152 AC_LINK_IFELSE([AC_LANG_PROGRAM([
154 #include <libintl.h>],[
155 setlocale(LC_ALL, "");
156 bindtextdomain("openconnect", "/tmp");
157 (void)dgettext("openconnect", "foo");])],
158 [AC_MSG_RESULT(yes)],
161 AC_LINK_IFELSE([AC_LANG_PROGRAM([
163 #include <libintl.h>],[
164 setlocale(LC_ALL, "");
165 bindtextdomain("openconnect", "/tmp");
166 (void)dgettext("openconnect", "foo");])],
167 [AC_MSG_RESULT(yes (with -lintl))]
174 if test "$USE_NLS" = "yes"; then
176 AC_DEFINE(ENABLE_NLS, 1)
178 AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"])
180 AC_ARG_WITH([gnutls],
181 AS_HELP_STRING([--with-gnutls],
182 [Use GnuTLS instead of OpenSSL (EXPERIMENTAL)]))
183 AC_ARG_WITH([openssl],
184 AS_HELP_STRING([--with-openssl],
185 [Location of OpenSSL build dir]))
188 if test "$with_gnutls" = "yes"; then
189 AC_MSG_ERROR([GnuTLS support is experimental. It does not work yet.])
190 elif test "$with_gnutls" = "shibboleet"; then
191 if test "$with_openssl" != "no" && test "$with_openssl" != ""; then
192 AC_MSG_ERROR([Cannot use both OpenSSL and GnuTLS simultaneously])
194 PKG_CHECK_MODULES(GNUTLS, gnutls)
197 elif test "$with_gnutls" != "" && test "$with_gnutls" != "no"; then
198 AC_MSG_ERROR([Values other than 'yes' or 'no' for --with-gnutls are not supported])
201 if test "$with_openssl" = "yes" || test "$with_openssl" = "" ; then
202 PKG_CHECK_MODULES(OPENSSL, openssl, [],
204 LIBS="$LIBS -lssl -lcrypto"
205 AC_MSG_CHECKING([for OpenSSL without pkg-config])
206 AC_LINK_IFELSE([AC_LANG_PROGRAM([
207 #include <openssl/ssl.h>
208 #include <openssl/err.h>],[
211 SSL_load_error_strings();
212 OpenSSL_add_all_algorithms();])],
214 AC_SUBST([OPENSSL_LIBS], ["-lssl -lcrypto"])
215 AC_SUBST([OPENSSL_CFLAGS], [])],
217 AC_ERROR([Could not build against OpenSSL])])
220 elif test "$with_openssl" != "no" ; then
221 OPENSSL_CFLAGS="-I${with_openssl}/include"
222 OPENSSL_LIBS="${with_openssl}/libssl.a ${with_openssl}/libcrypto.a -ldl -lz"
223 AC_SUBST(OPENSSL_CFLAGS)
224 AC_SUBST(OPENSSL_LIBS)
230 case "$ssl_library" in
232 AC_DEFINE(OPENCONNECT_GNUTLS, 1)
233 AC_SUBST(SSL_LIBS, [$GNUTLS_LIBS])
234 AC_SUBST(SSL_CFLAGS, [$GNUTLS_CFLAGS])
237 AC_DEFINE(OPENCONNECT_OPENSSL, 1)
238 AC_SUBST(SSL_LIBS, [$OPENSSL_LIBS])
239 AC_SUBST(SSL_CFLAGS, [$OPENSSL_CFLAGS])
242 AC_MSG_ERROR([Neither OpenSSL nor GnuTLS selected for SSL.])
245 AC_SUBST(SSL_LIBRARY, $ssl_library)
247 # Needs to happen after we default to static/shared libraries based on OpenSSL
250 # Ick. This seems like it's likely to be very fragile, but I can't see a better
251 # way. I shall console myself with the observation that the failure mode isn't
252 # particularly horrible — you just don't get symbol versioning if it fails.
254 if test "$enable_shared" = "yes" ; then
255 AC_MSG_CHECKING([if library symbol versioning is available]);
256 echo 'FOO { global: foo; local: *; };' > conftest.map
257 echo 'int foo = 0;' > conftest.$ac_ext
258 if AC_TRY_EVAL(ac_compile); then
260 libobjs=conftest.$ac_objext
261 if AC_TRY_EVAL(archive_cmds ${wl}--version-script ${wl}conftest.map); then
262 AC_SUBST(VERSION_SCRIPT_ARG, [--version-script])
263 symvers="yes (with --version-script)"
264 elif AC_TRY_EVAL(archive_cmds ${wl}-M ${wl}conftest.map); then
265 AC_SUBST(VERSION_SCRIPT_ARG, [-M])
266 symvers="yes (with -M)"
269 AC_MSG_RESULT(${symvers})
271 AM_CONDITIONAL(HAVE_SYMBOL_VERSIONING, [test "${symvers}" != "no"])
273 PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
275 PKG_CHECK_MODULES(ZLIB, zlib, [],
278 AC_MSG_CHECKING([for zlib without pkg-config])
279 AC_LINK_IFELSE([AC_LANG_PROGRAM([
282 deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
283 -12, 9, Z_DEFAULT_STRATEGY);])],
285 AC_SUBST([ZLIB_LIBS], [-lz])
286 AC_SUBST([ZLIB_CFLAGS], [])],
288 AC_ERROR([Could not build against zlib])])
291 PKG_CHECK_MODULES(LIBPROXY, libproxy-1.0,
292 [AC_SUBST(LIBPROXY_PC, libproxy-1.0)
293 AC_DEFINE([LIBPROXY_HDR], ["proxy.h"])
296 dnl Libproxy *can* exist without a .pc file, and its header may be called
297 dnl libproxy.h in that case.
298 if (test "$libproxy_pkg" = "no"); then
299 AC_MSG_CHECKING([for libproxy])
302 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libproxy.h>],
303 [(void)px_proxy_factory_new();])],
304 [AC_MSG_RESULT(yes (with libproxy.h))
305 AC_DEFINE([LIBPROXY_HDR], ["libproxy.h"])
306 AC_SUBST([LIBPROXY_LIBS], [-lproxy])],
307 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <proxy.h>],
308 [(void)px_proxy_factory_new();])],
309 [AC_MSG_RESULT(yes (with proxy.h))
310 AC_DEFINE([LIBPROXY_HDR], ["proxy.h"])
311 AC_SUBST([LIBPROXY_LIBS], [-lproxy])],
312 [AC_MSG_RESULT(no)])])
316 AC_CHECK_HEADER([if_tun.h],
317 [AC_DEFINE([IF_TUN_HDR], ["if_tun.h"])],
318 [AC_CHECK_HEADER([linux/if_tun.h],
319 [AC_DEFINE([IF_TUN_HDR], ["linux/if_tun.h"])],
320 [AC_CHECK_HEADER([net/if_tun.h],
321 [AC_DEFINE([IF_TUN_HDR], ["net/if_tun.h"])],
322 [AC_CHECK_HEADER([net/tun/if_tun.h],
323 [AC_DEFINE([IF_TUN_HDR], ["net/tun/if_tun.h"])])])])])
325 if test "${ssl_library}" = "openssl"; then
327 LIBS="$LIBS $OPENSSL_LIBS"
329 AC_MSG_CHECKING([for ENGINE_by_id() in OpenSSL])
330 AC_LINK_IFELSE([AC_LANG_PROGRAM(
331 [#include <openssl/engine.h>],
332 [ENGINE_by_id("foo");])],
334 AC_DEFINE(HAVE_ENGINE, [1], [OpenSSL has ENGINE support])],
336 AC_MSG_NOTICE([Building without OpenSSL TPM ENGINE support])])
338 AC_MSG_CHECKING([for dtls1_stop_timer() in OpenSSL])
339 AC_LINK_IFELSE([AC_LANG_PROGRAM(
340 [#include <openssl/ssl.h>
342 extern void dtls1_stop_timer(SSL *);],
343 [dtls1_stop_timer(NULL);])],
345 AC_DEFINE(HAVE_DTLS1_STOP_TIMER, [1], [OpenSSL has dtls1_stop_timer() function])],
350 AC_PATH_PROG(PYTHON, [python], [], $PATH:/bin:/usr/bin)
351 if (test -n "${ac_cv_path_PYTHON}"); then
352 AC_SUBST(PYTHON, ${ac_cv_path_PYTHON})
354 AC_MSG_NOTICE([Python not found; not building HTML pages])
356 AM_CONDITIONAL(BUILD_WWW, [test -n "${ac_cv_path_PYTHON}"])
358 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/po/LINGUAS $(top_srcdir)/openconnect.h'])
359 RAWLINGUAS=`sed -e "/^#/d" -e "s/#.*//" "${srcdir}/po/LINGUAS"`
361 LINGUAS=`echo $RAWLINGUAS`
364 APIMAJOR="`sed -n 's/^#define OPENCONNECT_API_VERSION_MAJOR \(.*\)/\1/p' ${srcdir}/openconnect.h`"
365 APIMINOR="`sed -n 's/^#define OPENCONNECT_API_VERSION_MINOR \(.*\)/\1/p' ${srcdir}/openconnect.h`"
369 # We want version.c to depend on the files that would affect the
370 # output of version.sh. But we cannot assume that they'll exist,
371 # and we cannot use $(wildcard) in a non-GNU makefile. So we just
372 # depend on the files which happen to exist at configure time.
374 for a in .git/index .git/packed-refs .git/refs/tags .git/HEAD; do
376 GITVERSIONDEPS="$GITVERSIONDEPS $a"
379 AC_SUBST(GITVERSIONDEPS)
381 AC_OUTPUT(Makefile openconnect.pc po/Makefile www/Makefile libopenconnect.map \
382 www/styles/Makefile www/inc/Makefile www/images/Makefile)