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