1# Licensed under the Apache License, Version 2.0 (the "License"); 2# you may not use this file except in compliance with the License. 3# You may obtain a copy of the License at 4# 5# http://www.apache.org/licenses/LICENSE-2.0 6# 7# Unless required by applicable law or agreed to in writing, software 8# distributed under the License is distributed on an "AS IS" BASIS, 9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10# See the License for the specific language governing permissions and 11# limitations under the License. 12# 13 14AC_PREREQ([2.69]) 15AC_INIT([mod_http2], [2.0.2], [stefan.eissing@greenbytes.de]) 16 17LT_PREREQ([2.2.6]) 18LT_INIT() 19dnl See versioning rule: 20dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html 21AC_SUBST(LT_CURRENT, 11) 22AC_SUBST(LT_REVISION, 0) 23AC_SUBST(LT_AGE, 6) 24 25major=`echo $PACKAGE_VERSION |cut -d. -f1 | sed -e "s/[^0-9]//g"` 26minor=`echo $PACKAGE_VERSION |cut -d. -f2 | sed -e "s/[^0-9]//g"` 27patch=`echo $PACKAGE_VERSION |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"` 28 29PACKAGE_VERSION_NUM=`printf "0x%02x%02x%02x" "$major" "$minor" "$patch"` 30 31AC_SUBST(PACKAGE_VERSION_NUM) 32 33AC_CANONICAL_BUILD 34AC_CANONICAL_HOST 35AC_CANONICAL_TARGET 36 37AC_CONFIG_MACRO_DIR([m4]) 38 39AM_INIT_AUTOMAKE([subdir-objects no-define]) 40 41m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 42 43AC_CONFIG_SRCDIR([mod_http2/h2_config.c]) 44AC_CONFIG_HEADERS([mod_http2/config.h]) 45 46AC_ARG_ENABLE([werror], 47 [AS_HELP_STRING([--enable-werror], 48 [Turn on compile time warnings])], 49 [werror=$enableval], [werror=no]) 50 51AC_ARG_WITH([apxs], [AS_HELP_STRING([--with-apxs], 52 [Use APXS executable [default=check]])], 53 [request_apxs=$withval], [request_apxs=check]) 54 55AC_ARG_ENABLE([poll-streams], 56 [AS_HELP_STRING([--disable-poll-streams], 57 [Disable polling of h2 streams, even if available.])], 58 [poll_streams=$enableval], [poll_streams=yes]) 59 60# Checks for programs. 61AC_PROG_CC 62AC_PROG_CC_STDC 63 64# extern, we need to find where the apxs is. which then 65# can tell us the various directories we need. 66# 67if test x"$request_apxs" = "xcheck"; then 68 AC_PATH_PROG([APXS], [apxs]) 69 if test "x${APXS}" = "x"; then 70 AC_MSG_ERROR("no APXS installation found") 71 fi 72else 73 APXS="$request_apxs" 74 AC_MSG_NOTICE("using APXS=$APXS as configured") 75fi 76 77AC_SUBST(APR) 78 79prefix="$($APXS -q prefix)" 80prefix="${prefix:-/usr}" 81AC_SUBST(prefix) 82 83exec_prefix="$($APXS -q exec_prefix)" 84AC_SUBST(exec_prefix) 85APR_BINDIR="$($APXS -q APR_BINDIR)" 86AC_SUBST(APR_BINDIR) 87sbindir="$($APXS -q sbindir)" 88AC_SUBST(sbindir) 89progname="$($APXS -q progname)" 90AC_SUBST(progname) 91libdir="$($APXS -q libdir)" 92AC_SUBST(libdir) 93SYSCONF_DIR="$($APXS -q sysconfdir)" 94AC_SUBST(SYSCONF_DIR) 95LIBEXEC_DIR="$($APXS -q LIBEXECDIR)" 96AC_SUBST(LIBEXEC_DIR) 97 98LDFLAGS="-L$libdir $LDFLAGS" 99CPPFLAGS="-I$($APXS -q includedir) -I$($APXS -q APR_INCLUDEDIR) $($APXS -q EXTRA_CPPFLAGS) $CPPFLAGS" 100 101HTTPD_VERSION="$($APXS -q HTTPD_VERSION)" 102AC_SUBST(HTTPD_VERSION) 103 104APACHECTL="$sbindir/apachectl" 105if test ! -x "$APACHECTL"; then 106 # rogue distros rename things! =) 107 APACHECTL="$sbindir/apache2ctl" 108fi 109AC_SUBST(APACHECTL) 110 111if test -x "$APACHECTL"; then 112 DSO_MODULES="$($APACHECTL -t -D DUMP_MODULES | fgrep '(shared)'| sed 's/_module.*//g'|tr -d \\n)" 113 AC_SUBST(DSO_MODULES) 114 STATIC_MODULES="$($APACHECTL -t -D DUMP_MODULES | fgrep '(static)'| sed 's/_module.*//g'|tr -d \\n)" 115 AC_SUBST(STATIC_MODULES) 116else 117 AC_MSG_WARN("apachectl not found in '$BINDIR', test suite will not work!") 118 APACHECTL="" 119fi 120AC_SUBST(LOAD_LOG_CONFIG) 121AC_SUBST(LOAD_LOGIO) 122AC_SUBST(LOAD_UNIXD) 123AC_SUBST(LOAD_VERSION) 124AC_SUBST(LOAD_WATCHDOG) 125 126export BUILD_SUBDIRS="mod_http2" 127AC_SUBST(BUILD_SUBDIRS) 128 129# We need nghttp2 to be in our link path, check for it. 130# 131AC_CHECK_LIB([nghttp2], [nghttp2_session_server_new2], , 132[AC_MSG_ERROR("library nghttp2 not found")]) 133 134AC_CHECK_HEADERS([nghttp2/nghttp2.h]) 135# nghttp2 >= 1.3.0: access to stream weights 136AC_CHECK_FUNCS([nghttp2_stream_get_weight], 137 [CPPFLAGS="$CPPFLAGS -DH2_NG2_STREAM_API"], []) 138# nghttp2 >= 1.5.0: changing stream priorities 139AC_CHECK_FUNCS([nghttp2_session_change_stream_priority], 140 [CPPFLAGS="$CPPFLAGS -DH2_NG2_CHANGE_PRIO"], []) 141# nghttp2 >= 1.14.0: invalid header callback 142AC_CHECK_FUNCS([nghttp2_session_callbacks_set_on_invalid_header_callback], 143 [CPPFLAGS="$CPPFLAGS -DH2_NG2_INVALID_HEADER_CB"], []) 144dnl # nghttp2 >= 1.15.0: get/set stream window sizes 145AC_CHECK_FUNCS([nghttp2_session_get_stream_local_window_size], 146 [CPPFLAGS="$CPPFLAGS -DH2_NG2_LOCAL_WIN_SIZE"], []) 147AC_CHECK_FUNCS([nghttp2_option_set_no_closed_streams], 148 [CPPFLAGS="$CPPFLAGS -DH2_NG2_NO_CLOSED_STREAMS"], []) 149 150AC_PATH_PROG([NGHTTP], [nghttp]) 151if test "x${NGHTTP}" = "x"; then 152 if test -x "${prefix}/bin/nghttp"; then 153 NGHTTP="${prefix}/bin/nghttp" 154 else 155 AC_MSG_WARN("no nghttp found, test coverage will be incomplete") 156 fi 157fi 158AC_SUBST(NGHTTP) 159 160AC_PATH_PROG([H2LOAD], [h2load]) 161if test "x${H2LOAD}" = "x"; then 162 if test -x "${prefix}/bin/h2load"; then 163 H2LOAD="${prefix}/bin/h2load" 164 else 165 AC_MSG_WARN("no h2load found, test coverage will be incomplete") 166 fi 167fi 168AC_SUBST(H2LOAD) 169 170 171 172AC_CHECK_LIB([crypto], [SHA256_Init], [ 173CPPFLAGS="$CPPFLAGS -DH2_OPENSSL" 174LIBS="$LIBS -lcrypto"], 175[AC_MSG_ERROR("libcrypto not found")]) 176 177# Checks for header files. 178AC_CHECK_HEADERS([ \ 179 assert.h \ 180 stddef.h \ 181]) 182 183WERROR_CFLAGS="" 184if test "x$werror" != "xno"; then 185 AX_CHECK_COMPILE_FLAG([-Wall], [WERROR_CFLAGS="$WERROR_CFLAGS -Wall"]) 186 #AX_CHECK_COMPILE_FLAG([-Wconversion], [WERROR_CFLAGS="$WERROR_CFLAGS -Wconversion"]) 187 AX_CHECK_COMPILE_FLAG([-Wextra], [WERROR_CFLAGS="$WERROR_CFLAGS -Wextra"]) 188 AX_CHECK_COMPILE_FLAG([-Werror], [WERROR_CFLAGS="$WERROR_CFLAGS -Werror"]) 189 AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], [WERROR_CFLAGS="$WERROR_CFLAGS -Wmissing-prototypes"]) 190 AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], [WERROR_CFLAGS="$WERROR_CFLAGS -Wstrict-prototypes"]) 191 AX_CHECK_COMPILE_FLAG([-Wmissing-declarations], [WERROR_CFLAGS="$WERROR_CFLAGS -Wmissing-declarations"]) 192 AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [WERROR_CFLAGS="$WERROR_CFLAGS -Wpointer-arith"]) 193 # we like to use such things... 194 #AX_CHECK_COMPILE_FLAG([-Wdeclaration-after-statement], [WERROR_CFLAGS="$WERROR_CFLAGS -Wdeclaration-after-statement"]) 195 AX_CHECK_COMPILE_FLAG([-Wformat-security], [WERROR_CFLAGS="$WERROR_CFLAGS -Wformat-security"]) 196 AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [WERROR_CFLAGS="$WERROR_CFLAGS -Wwrite-strings"]) 197 AX_CHECK_COMPILE_FLAG([-Wshadow], [WERROR_CFLAGS="$WERROR_CFLAGS -Wshadow"]) 198 AX_CHECK_COMPILE_FLAG([-Winline], [WERROR_CFLAGS="$WERROR_CFLAGS -Winline"]) 199 AX_CHECK_COMPILE_FLAG([-Wnested-externs], [WERROR_CFLAGS="$WERROR_CFLAGS -Wnested-externs"]) 200 AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [WERROR_CFLAGS="$WERROR_CFLAGS -Wfloat-equal"]) 201 AX_CHECK_COMPILE_FLAG([-Wundef], [WERROR_CFLAGS="$WERROR_CFLAGS -Wundef"]) 202 AX_CHECK_COMPILE_FLAG([-Wendif-labels], [WERROR_CFLAGS="$WERROR_CFLAGS -Wendif-labels"]) 203 AX_CHECK_COMPILE_FLAG([-Wempty-body], [WERROR_CFLAGS="$WERROR_CFLAGS -Wempty-body"]) 204# does not make sense with APR as it prefers char* to void* 205# AX_CHECK_COMPILE_FLAG([-Wcast-align], [WERROR_CFLAGS="$WERROR_CFLAGS -Wcast-align"]) 206 AX_CHECK_COMPILE_FLAG([-Wvla], [WERROR_CFLAGS="$WERROR_CFLAGS -Wvla"]) 207 AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [WERROR_CFLAGS="$WERROR_CFLAGS -Wunreachable-code"]) 208 AX_CHECK_COMPILE_FLAG([-Waddress], [WERROR_CFLAGS="$WERROR_CFLAGS -Waddress"]) 209 AX_CHECK_COMPILE_FLAG([-Wattributes], [WERROR_CFLAGS="$WERROR_CFLAGS -Wattributes"]) 210 AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [WERROR_CFLAGS="$WERROR_CFLAGS -Wdiv-by-zero"]) 211 AX_CHECK_COMPILE_FLAG([-Wshorten-64-to-32], [WERROR_CFLAGS="$WERROR_CFLAGS -Wshorten-64-to-32"]) 212 AX_CHECK_COMPILE_FLAG([-Wno-sign-compare], [WERROR_CFLAGS="$WERROR_CFLAGS -Wno-sign-compare"]) 213 AX_CHECK_COMPILE_FLAG([-Wno-unused-parameter], [WERROR_CFLAGS="$WERROR_CFLAGS -Wno-unused-parameter"]) 214 #AX_CHECK_COMPILE_FLAG([-Wno-shadow], [WERROR_CFLAGS="$WERROR_CFLAGS -Wno-shadow"]) 215 #AX_CHECK_COMPILE_FLAG([-Wno-undef], [WERROR_CFLAGS="$WERROR_CFLAGS -Wno-undef"]) 216 217 AX_CHECK_COMPILE_FLAG(["-std=c89"], [WERROR_CFLAGS="$WERROR_CFLAGS -std=c89"]) 218 AX_CHECK_COMPILE_FLAG([-Wdeclaration-after-statement], [WERROR_CFLAGS="$WERROR_CFLAGS -Wdeclaration-after-statement"]) 219 220# gcc warnings, considered useful as in https://kristerw.blogspot.de/2017/09/useful-gcc-warning-options-not-enabled.html 221# 222 #AX_CHECK_COMPILE_FLAG(["-Wduplicated-cond"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wduplicated-cond"]) 223 #AX_CHECK_COMPILE_FLAG(["-Wduplicated-branches"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wduplicated-branches"]) 224 #AX_CHECK_COMPILE_FLAG(["-Wlogical-op"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wlogical-op"]) 225 #AX_CHECK_COMPILE_FLAG(["-Wrestrict"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wrestrict"]) 226 AX_CHECK_COMPILE_FLAG(["-Wnull-dereference"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wnull-dereference"]) 227 #AX_CHECK_COMPILE_FLAG(["-Wuseless-cast"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wuseless-cast"]) 228 #AX_CHECK_COMPILE_FLAG(["-Wjump-misses-init"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wjump-misses-init"]) 229 AX_CHECK_COMPILE_FLAG(["-Wdouble-promotion"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wdouble-promotion"]) 230 AX_CHECK_COMPILE_FLAG(["-Wshadow"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wshadow"]) 231 AX_CHECK_COMPILE_FLAG(["-Wformat=2"], [WERROR_CFLAGS="$WERROR_CFLAGS -Wformat=2"]) 232fi 233AC_SUBST(WERROR_CFLAGS) 234 235# Checks for typedefs, structures, and compiler characteristics. 236AC_TYPE_INT32_T 237AC_TYPE_SIZE_T 238AC_TYPE_SSIZE_T 239AC_TYPE_UINT32_T 240AC_TYPE_UINT8_T 241 242# Checks for library functions. 243AC_CHECK_FUNCS([memmove memset strcasecmp strchr]) 244 245AC_ARG_WITH([serverdir], [AS_HELP_STRING([--with-serverdir], 246 [Use serverdir directory for setup [default=gen/apache]])], 247 [request_serverdir=$withval], [request_serverdir=$PWD/test/gen/apache]) 248 249AC_ARG_WITH([curl], [AS_HELP_STRING([--with-curl], [Use curl from this prefix])], 250 [request_curl=$withval], [request_curl=check]) 251 252TEST_DIR="$PWD/test" 253AC_SUBST(TEST_DIR) 254 255GEN_DIR="$PWD/test/gen" 256AC_SUBST(GEN_DIR) 257 258SERVER_DIR="$request_serverdir" 259AC_SUBST(SERVER_DIR) 260 261HTTP_PORT=42001 262AC_SUBST(HTTP_PORT) 263 264HTTPS_PORT=42002 265AC_SUBST(HTTPS_PORT) 266 267HTTPD_USER="${USER:-www-data}" 268AC_SUBST(HTTPD_USER) 269 270MODULE_SRC="$PWD/mod_http2" 271AC_SUBST(MODULE_SRC) 272 273# we need curl for testing 274# 275curl_check="curl" 276CURL_BIN="-" 277if test "x$request_curl" != "xcheck"; then 278 curl_check="$request_curl/bin/curl" 279 test -x $curl_check && CURL_BIN=$curl_check 280else 281 AC_PATH_PROG([CURL_BIN],["$curl_check"], "-") 282 if test "x$CURL_BIN" = "x-"; then 283 curl_check="${prefix}/bin/curl" 284 test -x $curl_check && CURL_BIN=$curl_check 285 fi 286fi 287 288if test "x$CURL_BIN" = "x-"; then 289 CURL_MSG="$curl_check was not found. Tests will not work." 290 AC_MSG_WARN([$CURL_MSG]) 291else 292 CURL_MSG="$CURL_BIN" 293 AC_SUBST(CURL_BIN) 294 295 curl_h2=$( $CURL_BIN -V | fgrep 'HTTP2' ) 296 if test "x$curl_h2" = "x"; then 297 CURL_MSG="$CURL_BIN does not support HTTP/2. Tests will not work." 298 AC_MSG_WARN([$CURL_MSG]) 299 fi 300fi 301 302# Do we have a pkg-config? 303AC_ARG_VAR([PKGCONFIG], [pkg-config executable]) 304AC_PATH_PROG([PKGCONFIG], [pkg-config]) 305 306 307# do we poll streams, when available, or disable this (e.g. for test runs) 308if test "$poll_streams" = "no"; then 309CPPFLAGS="$CPPFLAGS -DH2_NO_POLL_STREAMS" 310fi 311 312 313AC_CONFIG_FILES([ 314 Makefile 315 mod_http2/Makefile 316 mod_http2/h2_version.h 317 test/Makefile 318 test/pyhttpd/config.ini 319]) 320 321AC_OUTPUT 322 323AC_MSG_NOTICE([summary of build options: 324 325 Version: ${VERSION} shared $LT_CURRENT:$LT_REVISION:$LT_AGE 326 Host type: ${host} 327 Install prefix: ${prefix} 328 APXS: ${APXS} 329 HTTPD-VERSION: ${HTTPD_VERSION} 330 C compiler: ${CC} 331 CFLAGS: ${CFLAGS} 332 WARNCFLAGS: ${WARNCFLAGS} 333 LDFLAGS: ${LDFLAGS} 334 LIBS: ${LIBS} 335 CPPFLAGS: ${CPPFLAGS} 336 curl ${CURL_MSG} 337 nghttp ${NGHTTP:--} 338 h2load ${H2LOAD:--} 339 apachectl ${APACHECTL:--} 340]) 341