]> granicus.if.org Git - apache/blob - modules/http2/config.m4
merged latest changes in 2.4.x
[apache] / modules / http2 / config.m4
1 dnl Licensed to the Apache Software Foundation (ASF) under one or more
2 dnl contributor license agreements.  See the NOTICE file distributed with
3 dnl this work for additional information regarding copyright ownership.
4 dnl The ASF licenses this file to You under the Apache License, Version 2.0
5 dnl (the "License"); you may not use this file except in compliance with
6 dnl the License.  You may obtain a copy of the License at
7 dnl
8 dnl      http://www.apache.org/licenses/LICENSE-2.0
9 dnl
10 dnl Unless required by applicable law or agreed to in writing, software
11 dnl distributed under the License is distributed on an "AS IS" BASIS,
12 dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 dnl See the License for the specific language governing permissions and
14 dnl limitations under the License.
15
16 dnl #  start of module specific part
17 APACHE_MODPATH_INIT(http2)
18
19 dnl #  list of module object files
20 h2_objs="dnl
21 mod_h2.lo dnl
22 h2_alt_svc.lo dnl
23 h2_config.lo dnl
24 h2_conn.lo dnl
25 h2_conn_io.lo dnl
26 h2_ctx.lo dnl
27 h2_from_h1.lo dnl
28 h2_h2.lo dnl
29 h2_io.lo dnl
30 h2_io_set.lo dnl
31 h2_mplx.lo dnl
32 h2_request.lo dnl
33 h2_response.lo dnl
34 h2_session.lo dnl
35 h2_stream.lo dnl
36 h2_stream_set.lo dnl
37 h2_switch.lo dnl
38 h2_task.lo dnl
39 h2_task_input.lo dnl
40 h2_task_output.lo dnl
41 h2_task_queue.lo dnl
42 h2_to_h1.lo dnl
43 h2_util.lo dnl
44 h2_worker.lo dnl
45 h2_workers.lo dnl
46 "
47
48 dnl
49 dnl APACHE_CHECK_NGHTTP2
50 dnl
51 dnl Configure for nghttp2, giving preference to
52 dnl "--with-nghttp2=<path>" if it was specified.
53 dnl
54 AC_DEFUN(APACHE_CHECK_NGHTTP2,[
55   AC_CACHE_CHECK([for nghttp2], [ac_cv_nghttp2], [
56     dnl initialise the variables we use
57     ac_cv_nghttp2=no
58     ap_nghttp2_found=""
59     ap_nghttp2_base=""
60     ap_nghttp2_libs=""
61
62     dnl Determine the nghttp2 base directory, if any
63     AC_MSG_CHECKING([for user-provided nghttp2 base directory])
64     AC_ARG_WITH(nghttp2, APACHE_HELP_STRING(--with-nghttp2=PATH, nghttp2 installation directory), [
65       dnl If --with-nghttp2 specifies a directory, we use that directory
66       if test "x$withval" != "xyes" -a "x$withval" != "x"; then
67         dnl This ensures $withval is actually a directory and that it is absolute
68         ap_nghttp2_base="`cd $withval ; pwd`"
69       fi
70     ])
71     if test "x$ap_nghttp2_base" = "x"; then
72       AC_MSG_RESULT(none)
73     else
74       AC_MSG_RESULT($ap_nghttp2_base)
75     fi
76
77     dnl Run header and version checks
78     saved_CPPFLAGS="$CPPFLAGS"
79     saved_LIBS="$LIBS"
80     saved_LDFLAGS="$LDFLAGS"
81
82     dnl Before doing anything else, load in pkg-config variables
83     if test -n "$PKGCONFIG"; then
84       saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
85       AC_MSG_CHECKING([for pkg-config along $PKG_CONFIG_PATH])
86       if test "x$ap_nghttp2_base" != "x" -a \
87               -f "${ap_nghttp2_base}/lib/pkgconfig/libnghttp2.pc"; then
88         dnl Ensure that the given path is used by pkg-config too, otherwise
89         dnl the system libnghttp2.pc might be picked up instead.
90         PKG_CONFIG_PATH="${ap_nghttp2_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
91         export PKG_CONFIG_PATH
92       fi
93       AC_ARG_ENABLE(nghttp2-staticlib-deps,APACHE_HELP_STRING(--enable-nghttp2-staticlib-deps,[link mod_h2 with dependencies of libnghttp2's static libraries (as indicated by "pkg-config --static"). Must be specified in addition to --enable-h2.]), [
94         if test "$enableval" = "yes"; then
95           PKGCONFIG_LIBOPTS="--static"
96         fi
97       ])
98       ap_nghttp2_libs="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-l --silence-errors libnghttp2`"
99       if test $? -eq 0; then
100         ap_nghttp2_found="yes"
101         pkglookup="`$PKGCONFIG --cflags-only-I libnghttp2`"
102         APR_ADDTO(CPPFLAGS, [$pkglookup])
103         APR_ADDTO(MOD_CFLAGS, [$pkglookup])
104         APR_ADDTO(ab_CFLAGS, [$pkglookup])
105         pkglookup="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-L libnghttp2`"
106         APR_ADDTO(LDFLAGS, [$pkglookup])
107         APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
108         pkglookup="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-other libnghttp2`"
109         APR_ADDTO(LDFLAGS, [$pkglookup])
110         APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
111       fi
112       PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
113     fi
114
115     dnl fall back to the user-supplied directory if not found via pkg-config
116     if test "x$ap_nghttp2_base" != "x" -a "x$ap_nghttp2_found" = "x"; then
117       APR_ADDTO(CPPFLAGS, [-I$ap_nghttp2_base/include])
118       APR_ADDTO(MOD_CFLAGS, [-I$ap_nghttp2_base/include])
119       APR_ADDTO(ab_CFLAGS, [-I$ap_nghttp2_base/include])
120       APR_ADDTO(LDFLAGS, [-L$ap_nghttp2_base/lib])
121       APR_ADDTO(MOD_LDFLAGS, [-L$ap_nghttp2_base/lib])
122       if test "x$ap_platform_runtime_link_flag" != "x"; then
123         APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_nghttp2_base/lib])
124         APR_ADDTO(MOD_LDFLAGS, [$ap_platform_runtime_link_flag$ap_nghttp2_base/lib])
125       fi
126     fi
127
128     AC_MSG_CHECKING([for nghttp2 version >= 1.0.0])
129     AC_TRY_COMPILE([#include <nghttp2/nghttp2ver.h>],[
130 #if !defined(NGHTTP2_VERSION_NUM)
131 #error "Missing nghttp2 version"
132 #endif
133 #if NGHTTP2_VERSION_NUM < 0x010000
134 #error "Unsupported nghttp2 version " NGHTTP2_VERSION_TEXT
135 #endif],
136       [AC_MSG_RESULT(OK)
137        ac_cv_nghttp2=yes],
138       [AC_MSG_RESULT(FAILED)])
139
140     if test "x$ac_cv_nghttp2" = "xyes"; then
141       ap_nghttp2_libs="${ap_nghttp2_libs:--lnghttp2} `$apr_config --libs`"
142       APR_ADDTO(MOD_LDFLAGS, [$ap_nghttp2_libs])
143       APR_ADDTO(LIBS, [$ap_nghttp2_libs])
144       APR_SETVAR(ab_LDFLAGS, [$MOD_LDFLAGS])
145       APACHE_SUBST(ab_CFLAGS)
146       APACHE_SUBST(ab_LDFLAGS)
147
148       dnl Run library and function checks
149       liberrors=""
150       AC_CHECK_HEADERS([nghttp2/nghttp2.h])
151       AC_CHECK_FUNCS([nghttp2_session_server_new2], [], [liberrors="yes"])
152       if test "x$liberrors" != "x"; then
153         AC_MSG_WARN([nghttp2 library is unusable])
154       fi
155     else
156       AC_MSG_WARN([nghttp2 version is too old])
157     fi
158
159     dnl restore
160     CPPFLAGS="$saved_CPPFLAGS"
161     LIBS="$saved_LIBS"
162     LDFLAGS="$saved_LDFLAGS"
163   ])
164   if test "x$ac_cv_nghttp2" = "xyes"; then
165     AC_DEFINE(HAVE_NGHTTP2, 1, [Define if nghttp2 is available])
166   fi
167 ])
168
169
170 dnl #  hook module into the Autoconf mechanism (--enable-h2 option)
171 APACHE_MODULE(h2, [HTTP/2 support (mod_h2)], $h2_objs, , most, [
172     APACHE_CHECK_NGHTTP2
173     if test "$ac_cv_nghttp2" = "yes" ; then
174         if test "x$enable_ssl" = "xshared"; then
175            # The only symbol which needs to be exported is the module
176            # structure, so ask libtool to hide everything else:
177            APR_ADDTO(MOD_H2_LDADD, [-export-symbols-regex h2_module])
178         fi
179     else
180         enable_h2=no
181     fi
182 ])
183
184 dnl #  end of module specific part
185 APACHE_MODPATH_FINISH
186