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
8 dnl http://www.apache.org/licenses/LICENSE-2.0
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.
16 dnl # start of module specific part
17 APACHE_MODPATH_INIT(http2)
19 dnl # list of module object files
49 dnl APACHE_CHECK_NGHTTP2
51 dnl Configure for nghttp2, giving preference to
52 dnl "--with-nghttp2=<path>" if it was specified.
54 AC_DEFUN(APACHE_CHECK_NGHTTP2,[
55 AC_CACHE_CHECK([for nghttp2], [ac_cv_nghttp2], [
56 dnl initialise the variables we use
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`"
71 if test "x$ap_nghttp2_base" = "x"; then
74 AC_MSG_RESULT($ap_nghttp2_base)
77 dnl Run header and version checks
78 saved_CPPFLAGS="$CPPFLAGS"
80 saved_LDFLAGS="$LDFLAGS"
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
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"
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])
112 PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
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])
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"
133 #if NGHTTP2_VERSION_NUM < 0x010000
134 #error "Unsupported nghttp2 version " NGHTTP2_VERSION_TEXT
138 [AC_MSG_RESULT(FAILED)])
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)
148 dnl Run library and function checks
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])
156 AC_MSG_WARN([nghttp2 version is too old])
160 CPPFLAGS="$saved_CPPFLAGS"
162 LDFLAGS="$saved_LDFLAGS"
164 if test "x$ac_cv_nghttp2" = "xyes"; then
165 AC_DEFINE(HAVE_NGHTTP2, 1, [Define if nghttp2 is available])
170 dnl # hook module into the Autoconf mechanism (--enable-h2 option)
171 APACHE_MODULE(h2, [HTTP/2 support (mod_h2)], $h2_objs, , most, [
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])
184 dnl # end of module specific part
185 APACHE_MODPATH_FINISH