Cope with ancient autoconf by defining $(htmldir) and $(localedir) manually
[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_ENABLE([nls],
19         [ --disable-nls           do not use Native Language Support],
20         [USE_NLS=$enableval], [USE_NLS=yes])
21 LIBINTL=
22 if test "$USE_NLS" = "yes"; then
23    AC_PATH_PROG(MSGFMT, msgfmt)
24    if test "$MSGFMT" = ""; then
25       AC_ERROR([msgfmt could not be found. Try configuring with --disable-nls])
26    fi
27 fi
28 LIBINTL=
29 if test "$USE_NLS" = "yes"; then
30    AC_MSG_CHECKING([for functional NLS support])
31    AC_LINK_IFELSE([AC_LANG_PROGRAM([
32     #include <locale.h>
33     #include <libintl.h>],[
34     setlocale(LC_ALL, "");
35     bindtextdomain("openconnect", "/tmp");
36     (void)dgettext("openconnect", "foo");])],
37     [AC_MSG_RESULT(yes)],
38     [oldLIBS="$LIBS"
39      LIBS="$LIBS -lintl"
40      AC_LINK_IFELSE([AC_LANG_PROGRAM([
41       #include <locale.h>
42       #include <libintl.h>],[
43       setlocale(LC_ALL, "");
44       bindtextdomain("openconnect", "/tmp");
45       (void)dgettext("openconnect", "foo");])],
46       [AC_MSG_RESULT(yes (with -lintl))]
47        LIBINTL="-lintl",
48       [AC_MSG_RESULT(no)
49        USE_NLS=no])
50      LIBS="$oldLIBS"])
51 fi
52
53 if test "$USE_NLS" = "yes"; then
54    AC_SUBST(LIBINTL)
55    AC_DEFINE(ENABLE_NLS, 1)
56 fi
57 AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"])
58
59 case $host_os in
60  *linux* | *gnu*)
61     AC_MSG_NOTICE([Applying feature macros for GNU build])
62     AC_DEFINE(_POSIX_C_SOURCE, 200112L)
63     # For strcasecmp() 
64     AC_DEFINE(_BSD_SOURCE)
65     # For asprintf()
66     AC_DEFINE(_GNU_SOURCE)
67     ;;
68  *netbsd*)
69     AC_MSG_NOTICE([Applying feature macros for NetBSD build])
70     AC_DEFINE(_POSIX_C_SOURCE, 200112L)
71     AC_DEFINE(_NETBSD_SOURCE)
72     ;;
73  *)
74     # On FreeBSD the only way to get vsyslog() visible is to define
75     #  *nothing*, which makes absolutely everything visible.
76     # On Darwin enabling _POSIX_C_SOURCE breaks <sys/mount.h> because
77     # u_long and other types don't get defined. OpenBSD is similar.
78     ;;
79 esac
80
81 AS_COMPILER_FLAGS(CFLAGS,
82         "-Wall
83          -Wextra
84          -Wno-missing-field-initializers
85          -Wno-sign-compare
86          -Wno-unused-parameter
87          -Werror=pointer-to-int-cast
88          -Wdeclaration-after-statement
89          -Werror-implicit-function-declaration
90          -Wformat-nonliteral
91          -Wformat-security
92          -Winit-self
93          -Wmissing-declarations
94          -Wmissing-include-dirs
95          -Wnested-externs
96          -Wpointer-arith
97          -Wwrite-strings")
98
99 AC_ARG_WITH([openssl],
100             AS_HELP_STRING([--with-openssl],
101                            [Location of OpenSSL build dir]),
102             [OPENSSL_CFLAGS="-I${with_openssl}/include"
103              OPENSSL_LIBS="${with_openssl}/libssl.a ${with_openssl}/libcrypto.a -ldl -lz"
104              AC_SUBST(OPENSSL_CFLAGS)
105              AC_SUBST(OPENSSL_LIBS)
106              AC_ENABLE_STATIC
107              AC_DISABLE_SHARED],
108             [PKG_CHECK_MODULES(OPENSSL, openssl)
109              AC_ENABLE_SHARED
110              AC_DISABLE_STATIC])
111
112 # Needs to happen after we default to static/shared libraries based on OpenSSL
113 AC_PROG_LIBTOOL
114
115 PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
116
117 PKG_CHECK_MODULES(ZLIB, zlib, [],
118                   [oldLIBS="$LIBS"
119                   LIBS="$LIBS -lz" 
120                   AC_MSG_CHECKING([for zlib without pkg-config])
121                   AC_LINK_IFELSE([AC_LANG_PROGRAM([
122                    #include <zlib.h>],[
123                    z_stream zs;
124                    deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
125                                 -12, 9, Z_DEFAULT_STRATEGY);])],
126                   [AC_MSG_RESULT(yes)
127                    AC_SUBST([ZLIB_LIBS], [-lz])
128                    AC_SUBST([ZLIB_CFLAGS], [])],
129                   [AC_MSG_RESULT(no)
130                    AC_ERROR([Could not build against zlib])])])
131
132 PKG_CHECK_MODULES(LIBPROXY, libproxy-1.0,
133                 [AC_SUBST(LIBPROXY_PC, libproxy-1.0)
134                  AC_DEFINE([LIBPROXY_HDR], ["proxy.h"])
135                  libproxy_pkg=yes],
136                  libproxy_pkg=no)
137 dnl Libproxy *can* exist without a .pc file, and its header may be called
138 dnl libproxy.h in that case.
139 if (test "$libproxy_pkg" = "no"); then
140    AC_MSG_CHECKING([for libproxy])
141    oldLIBS="$LIBS"
142    LIBS="$LIBS -lproxy"
143    AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libproxy.h>],
144                            [(void)px_proxy_factory_new();])],
145           [AC_MSG_RESULT(yes (with libproxy.h))
146            AC_DEFINE([LIBPROXY_HDR], ["libproxy.h"])
147            AC_SUBST([LIBPROXY_LIBS], [-lproxy])],
148           [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <proxy.h>],
149                                   [(void)px_proxy_factory_new();])],
150                   [AC_MSG_RESULT(yes (with proxy.h))
151                    AC_DEFINE([LIBPROXY_HDR], ["proxy.h"])
152                    AC_SUBST([LIBPROXY_LIBS], [-lproxy])],
153                    [AC_MSG_RESULT(no)])])
154    LIBS="$oldLIBS"
155 fi
156
157 AC_CHECK_HEADER([if_tun.h],
158     [AC_DEFINE([IF_TUN_HDR], ["if_tun.h"])],
159     [AC_CHECK_HEADER([linux/if_tun.h],
160         [AC_DEFINE([IF_TUN_HDR], ["linux/if_tun.h"])],
161         [AC_CHECK_HEADER([net/if_tun.h],
162             [AC_DEFINE([IF_TUN_HDR], ["net/if_tun.h"])],
163             [AC_CHECK_HEADER([net/tun/if_tun.h],
164                 [AC_DEFINE([IF_TUN_HDR], ["net/tun/if_tun.h"])])])])])
165
166 AC_CHECK_LIB(ssl, ENGINE_by_id,
167              AC_DEFINE(HAVE_ENGINE, [1], [OpenSSL has ENGINE support]),
168              AC_MSG_NOTICE([Building without OpenSSL TPM ENGINE support]),
169              ${OPENSSL_LIBS})
170
171 AC_CHECK_LIB(ssl, dtls1_stop_timer,
172                   AC_DEFINE(HAVE_DTLS1_STOP_TIMER, [1], [OpenSSL has dtls1_stop_timer() function]),
173                   ,,${OPENSSL_LIBS})
174
175 AC_PATH_PROG(PYTHON, [python], [], $PATH:/bin:/usr/bin)
176 if (test -n "${ac_cv_path_PYTHON}"); then
177    AC_SUBST(PYTHON, ${ac_cv_path_PYTHON})
178 else
179    AC_MSG_NOTICE([Python not found; not building HTML pages])
180 fi
181 AM_CONDITIONAL(BUILD_WWW, [test -n "${ac_cv_path_PYTHON}"])
182
183 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/po/LINGUAS'])
184 RAWLINGUAS=`sed -e "/^#/d" -e "s/#.*//" "${srcdir}/po/LINGUAS"`
185 # Remove newlines
186 LINGUAS=`echo $RAWLINGUAS`
187 AC_SUBST(LINGUAS)
188
189 # We want version.c to depend on the files that would affect the
190 # output of version.sh. But we cannot assume that they'll exist,
191 # and we cannot use $(wildcard) in a non-GNU makefile. So we just
192 # depend on the files which happen to exist at configure time.
193 GITVERSIONDEPS=
194 for a in .git/index .git/packed-refs .git/refs/tags .git/HEAD; do
195     if test -r $a ; then
196        GITVERSIONDEPS="$GITVERSIONDEPS $a"
197     fi
198 done
199 AC_SUBST(GITVERSIONDEPS)
200
201 AC_OUTPUT(Makefile openconnect.pc po/Makefile www/Makefile \
202           www/styles/Makefile www/inc/Makefile www/images/Makefile)