Make vpnc-script mandatory.
[platform/upstream/openconnect.git] / configure.ac
1
2 AC_INIT(openconnect, 3.16)
3 PKG_PROG_PKG_CONFIG
4 AC_LANG_C
5 AC_CANONICAL_HOST
6 AM_MAINTAINER_MODE([enable])
7 AM_INIT_AUTOMAKE([foreign])
8 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
9
10 # Define htmldir and localedir for users of ancient autoconf building from git
11 AC_PREREQ([2.59c], [], [AC_SUBST([htmldir], [m4_ifset([AC_PACKAGE_TARNAME],
12           ['${datadir}/doc/${PACKAGE_TARNAME}'],
13           ['${datadir}/doc/${PACKAGE}'])
14 ])])
15
16 AC_PREREQ([2.60], [], [AC_SUBST([localedir], ['$(datadir)/locale'])])
17
18 AC_ARG_WITH([vpnc-script],
19         [AS_HELP_STRING([--with-vpnc-script],
20           [default location of vpnc-script helper])])
21
22 if test "$with_vpnc_script" = "yes" || test "$with_vpnc_script" = ""; then
23    with_vpnc_script=/etc/vpnc/vpnc-script
24    if ! test -x "$with_vpnc_script"; then
25       AC_MSG_ERROR([${with_vpnc_script} does not seem to be executable.]
26     [OpenConnect will not function correctly without a vpnc-script.]
27     [See http://www.infradead.org/openconnect/vpnc-script.html for more details.]
28     []
29     [If you are building a distribution package, please ensure that your]
30     [packaging is correct, and that a vpnc-script will be installed when the]
31     [user installs your package. You should provide a --with-vpnc-script=]
32     [argument to this configure script, giving the full path where the script]
33     [will be installed.]
34     []
35     [The standard location is ${with_vpnc_script}. To bypass this error and]
36     [build OpenConnect to use the script from this location, even though it's]
37     [not present at the time you are building OpenConnect, pass the argument]
38     ["--with-vpnc-script=${with_vpnc_script}"])
39   fi
40 elif test "$with_vpnc_script" = "no"; then
41    AC_ERROR([You cannot disable vpnc-script.]
42    [OpenConnect will not function correctly without it.]
43    [See http://www.infradead.org/openconnect/vpnc-script.html])
44 fi
45
46 AC_DEFINE_UNQUOTED(DEFAULT_VPNCSCRIPT, "${with_vpnc_script}")
47           
48 AC_ARG_ENABLE([nls],
49         [ --disable-nls           do not use Native Language Support],
50         [USE_NLS=$enableval], [USE_NLS=yes])
51 LIBINTL=
52 if test "$USE_NLS" = "yes"; then
53    AC_PATH_PROG(MSGFMT, msgfmt)
54    if test "$MSGFMT" = ""; then
55       AC_ERROR([msgfmt could not be found. Try configuring with --disable-nls])
56    fi
57 fi
58 LIBINTL=
59 if test "$USE_NLS" = "yes"; then
60    AC_MSG_CHECKING([for functional NLS support])
61    AC_LINK_IFELSE([AC_LANG_PROGRAM([
62     #include <locale.h>
63     #include <libintl.h>],[
64     setlocale(LC_ALL, "");
65     bindtextdomain("openconnect", "/tmp");
66     (void)dgettext("openconnect", "foo");])],
67     [AC_MSG_RESULT(yes)],
68     [oldLIBS="$LIBS"
69      LIBS="$LIBS -lintl"
70      AC_LINK_IFELSE([AC_LANG_PROGRAM([
71       #include <locale.h>
72       #include <libintl.h>],[
73       setlocale(LC_ALL, "");
74       bindtextdomain("openconnect", "/tmp");
75       (void)dgettext("openconnect", "foo");])],
76       [AC_MSG_RESULT(yes (with -lintl))]
77        LIBINTL="-lintl",
78       [AC_MSG_RESULT(no)
79        USE_NLS=no])
80      LIBS="$oldLIBS"])
81 fi
82
83 if test "$USE_NLS" = "yes"; then
84    AC_SUBST(LIBINTL)
85    AC_DEFINE(ENABLE_NLS, 1)
86 fi
87 AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"])
88
89 case $host_os in
90  *linux* | *gnu*)
91     AC_MSG_NOTICE([Applying feature macros for GNU build])
92     AC_DEFINE(_POSIX_C_SOURCE, 200112L)
93     # For strcasecmp() 
94     AC_DEFINE(_BSD_SOURCE)
95     # For asprintf()
96     AC_DEFINE(_GNU_SOURCE)
97     ;;
98  *netbsd*)
99     AC_MSG_NOTICE([Applying feature macros for NetBSD build])
100     AC_DEFINE(_POSIX_C_SOURCE, 200112L)
101     AC_DEFINE(_NETBSD_SOURCE)
102     ;;
103  *)
104     # On FreeBSD the only way to get vsyslog() visible is to define
105     #  *nothing*, which makes absolutely everything visible.
106     # On Darwin enabling _POSIX_C_SOURCE breaks <sys/mount.h> because
107     # u_long and other types don't get defined. OpenBSD is similar.
108     ;;
109 esac
110
111 AS_COMPILER_FLAGS(CFLAGS,
112         "-Wall
113          -Wextra
114          -Wno-missing-field-initializers
115          -Wno-sign-compare
116          -Wno-unused-parameter
117          -Werror=pointer-to-int-cast
118          -Wdeclaration-after-statement
119          -Werror-implicit-function-declaration
120          -Wformat-nonliteral
121          -Wformat-security
122          -Winit-self
123          -Wmissing-declarations
124          -Wmissing-include-dirs
125          -Wnested-externs
126          -Wpointer-arith
127          -Wwrite-strings")
128
129 AC_ARG_WITH([openssl],
130             AS_HELP_STRING([--with-openssl],
131                            [Location of OpenSSL build dir]),
132             [OPENSSL_CFLAGS="-I${with_openssl}/include"
133              OPENSSL_LIBS="${with_openssl}/libssl.a ${with_openssl}/libcrypto.a -ldl -lz"
134              AC_SUBST(OPENSSL_CFLAGS)
135              AC_SUBST(OPENSSL_LIBS)
136              AC_ENABLE_STATIC
137              AC_DISABLE_SHARED],
138             [PKG_CHECK_MODULES(OPENSSL, openssl, [],
139                                [oldLIBS="$LIBS"
140                                LIBS="$LIBS -lssl -lcrypto"
141                                AC_MSG_CHECKING([for OpenSSL without pkg-config])
142                                AC_LINK_IFELSE([AC_LANG_PROGRAM([
143                                 #include <openssl/ssl.h>
144                                 #include <openssl/err.h>],[
145                                 SSL_library_init();
146                                 ERR_clear_error();
147                                 SSL_load_error_strings();
148                                 OpenSSL_add_all_algorithms();])],
149                                [AC_MSG_RESULT(yes)
150                                 AC_SUBST([OPENSSL_LIBS], ["-lssl -lcrypto"])
151                                 AC_SUBST([OPENSSL_CFLAGS], [])],
152                                [AC_MSG_RESULT(no)
153                                 AC_ERROR([Could not build against OpenSSL])])
154                                 LIBS="$oldLIBS"])
155              AC_ENABLE_SHARED
156              AC_DISABLE_STATIC])
157
158 # Needs to happen after we default to static/shared libraries based on OpenSSL
159 AC_PROG_LIBTOOL
160
161 PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
162
163 PKG_CHECK_MODULES(ZLIB, zlib, [],
164                   [oldLIBS="$LIBS"
165                   LIBS="$LIBS -lz" 
166                   AC_MSG_CHECKING([for zlib without pkg-config])
167                   AC_LINK_IFELSE([AC_LANG_PROGRAM([
168                    #include <zlib.h>],[
169                    z_stream zs;
170                    deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
171                                 -12, 9, Z_DEFAULT_STRATEGY);])],
172                   [AC_MSG_RESULT(yes)
173                    AC_SUBST([ZLIB_LIBS], [-lz])
174                    AC_SUBST([ZLIB_CFLAGS], [])],
175                   [AC_MSG_RESULT(no)
176                    AC_ERROR([Could not build against zlib])])
177                   LIBS="$oldLIBS"])
178
179 PKG_CHECK_MODULES(LIBPROXY, libproxy-1.0,
180                 [AC_SUBST(LIBPROXY_PC, libproxy-1.0)
181                  AC_DEFINE([LIBPROXY_HDR], ["proxy.h"])
182                  libproxy_pkg=yes],
183                  libproxy_pkg=no)
184 dnl Libproxy *can* exist without a .pc file, and its header may be called
185 dnl libproxy.h in that case.
186 if (test "$libproxy_pkg" = "no"); then
187    AC_MSG_CHECKING([for libproxy])
188    oldLIBS="$LIBS"
189    LIBS="$LIBS -lproxy"
190    AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libproxy.h>],
191                            [(void)px_proxy_factory_new();])],
192           [AC_MSG_RESULT(yes (with libproxy.h))
193            AC_DEFINE([LIBPROXY_HDR], ["libproxy.h"])
194            AC_SUBST([LIBPROXY_LIBS], [-lproxy])],
195           [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <proxy.h>],
196                                   [(void)px_proxy_factory_new();])],
197                   [AC_MSG_RESULT(yes (with proxy.h))
198                    AC_DEFINE([LIBPROXY_HDR], ["proxy.h"])
199                    AC_SUBST([LIBPROXY_LIBS], [-lproxy])],
200                    [AC_MSG_RESULT(no)])])
201    LIBS="$oldLIBS"
202 fi
203
204 AC_CHECK_HEADER([if_tun.h],
205     [AC_DEFINE([IF_TUN_HDR], ["if_tun.h"])],
206     [AC_CHECK_HEADER([linux/if_tun.h],
207         [AC_DEFINE([IF_TUN_HDR], ["linux/if_tun.h"])],
208         [AC_CHECK_HEADER([net/if_tun.h],
209             [AC_DEFINE([IF_TUN_HDR], ["net/if_tun.h"])],
210             [AC_CHECK_HEADER([net/tun/if_tun.h],
211                 [AC_DEFINE([IF_TUN_HDR], ["net/tun/if_tun.h"])])])])])
212
213 AC_CHECK_LIB(ssl, ENGINE_by_id,
214              AC_DEFINE(HAVE_ENGINE, [1], [OpenSSL has ENGINE support]),
215              AC_MSG_NOTICE([Building without OpenSSL TPM ENGINE support]),
216              ${OPENSSL_LIBS})
217
218 AC_CHECK_LIB(ssl, dtls1_stop_timer,
219                   AC_DEFINE(HAVE_DTLS1_STOP_TIMER, [1], [OpenSSL has dtls1_stop_timer() function]),
220                   ,,${OPENSSL_LIBS})
221
222 AC_PATH_PROG(PYTHON, [python], [], $PATH:/bin:/usr/bin)
223 if (test -n "${ac_cv_path_PYTHON}"); then
224    AC_SUBST(PYTHON, ${ac_cv_path_PYTHON})
225 else
226    AC_MSG_NOTICE([Python not found; not building HTML pages])
227 fi
228 AM_CONDITIONAL(BUILD_WWW, [test -n "${ac_cv_path_PYTHON}"])
229
230 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/po/LINGUAS'])
231 RAWLINGUAS=`sed -e "/^#/d" -e "s/#.*//" "${srcdir}/po/LINGUAS"`
232 # Remove newlines
233 LINGUAS=`echo $RAWLINGUAS`
234 AC_SUBST(LINGUAS)
235
236 # We want version.c to depend on the files that would affect the
237 # output of version.sh. But we cannot assume that they'll exist,
238 # and we cannot use $(wildcard) in a non-GNU makefile. So we just
239 # depend on the files which happen to exist at configure time.
240 GITVERSIONDEPS=
241 for a in .git/index .git/packed-refs .git/refs/tags .git/HEAD; do
242     if test -r $a ; then
243        GITVERSIONDEPS="$GITVERSIONDEPS $a"
244     fi
245 done
246 AC_SUBST(GITVERSIONDEPS)
247
248 AC_OUTPUT(Makefile openconnect.pc po/Makefile www/Makefile \
249           www/styles/Makefile www/inc/Makefile www/images/Makefile)