Brotli: add support for dynamic modules.
Fixes build with nginx-1.9.11+.
Change-Id: I34f0b2e49eb5923f6cac1062df404728c455b21b
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Reviewed-on: https://nginx-review.googlesource.com/1079
Reviewed-by: Martin Maly <mmaly@google.com>
diff --git a/config b/config
index 90c04e1..9f4d15f 100644
--- a/config
+++ b/config
@@ -1,4 +1,4 @@
-# Copyright (C) 2015 Google Inc.
+# Copyright (C) 2015-2016 Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,11 +28,23 @@
# static module (no dependencies)
#
-HTTP_MODULES="$HTTP_MODULES \
- ngx_http_brotli_static_module"
+if [ -n "$ngx_module_link" ]; then
+ # nginx-1.9.11+
+ ngx_module_type=HTTP
+ ngx_module_name=ngx_http_brotli_static_module
+ ngx_module_incs=
+ ngx_module_deps=
+ ngx_module_srcs="$ngx_addon_dir/src/ngx_http_brotli_static_module.c"
+ ngx_module_libs=
-NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
- $ngx_addon_dir/src/ngx_http_brotli_static_module.c"
+ . auto/module
+else
+ HTTP_MODULES="$HTTP_MODULES \
+ ngx_http_brotli_static_module"
+
+ NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
+ $ngx_addon_dir/src/ngx_http_brotli_static_module.c"
+fi
have=NGX_HTTP_GZIP . auto/have
have=NGX_HTTP_BROTLI_STATIC . auto/have
@@ -102,21 +114,60 @@
exit 1
fi
-CORE_INCS="$CORE_INCS $ngx_feature_path"
-CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
-
if [ $HTTP_GZIP = YES ]; then
- module=$HTTP_GZIP_FILTER_MODULE
+ next=ngx_http_gzip_filter_module
elif echo $HTTP_FILTER_MODULES | grep ngx_pagespeed_etag_filter >/dev/null; then
- module=ngx_pagespeed_etag_filter
+ next=ngx_pagespeed_etag_filter
else
- module=$HTTP_RANGE_HEADER_FILTER_MODULE
+ next=ngx_http_range_header_filter_module
fi
-HTTP_FILTER_MODULES=`echo $HTTP_FILTER_MODULES \
- | sed "s/$module/$module ngx_http_brotli_filter_module/"`
+if [ -n "$ngx_module_link" ]; then
+ # nginx-1.9.11+
+ ngx_module_type=HTTP_FILTER
+ ngx_module_name=ngx_http_brotli_filter_module
+ ngx_module_incs="$ngx_feature_path"
+ ngx_module_deps=
+ ngx_module_srcs="$ngx_addon_dir/src/ngx_http_brotli_filter_module.cc"
+ ngx_module_libs="$ngx_feature_libs"
+ ngx_module_order="$ngx_module_name \
+ ngx_pagespeed \
+ ngx_http_postpone_filter_module \
+ ngx_http_ssi_filter_module \
+ ngx_http_charset_filter_module \
+ ngx_http_xslt_filter_module \
+ ngx_http_image_filter_module \
+ ngx_http_sub_filter_module \
+ ngx_http_addition_filter_module \
+ ngx_http_gunzip_filter_module \
+ ngx_http_userid_filter_module \
+ ngx_http_headers_filter_module"
-NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
- $ngx_addon_dir/src/ngx_http_brotli_filter_module.cc"
+ . auto/module
+
+ if [ $ngx_module_link != DYNAMIC ]; then
+ # ngx_module_order doesn't work with static modules,
+ # so we must re-order filters here.
+ HTTP_FILTER_MODULES=`echo $HTTP_FILTER_MODULES \
+ | sed "s/$ngx_module_name//" \
+ | sed "s/$next/$next $ngx_module_name/"`
+ fi
+else
+ CORE_INCS="$CORE_INCS $ngx_feature_path"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+
+ HTTP_FILTER_MODULES=`echo $HTTP_FILTER_MODULES \
+ | sed "s/$next/$next ngx_http_brotli_filter_module/"`
+
+ NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
+ $ngx_addon_dir/src/ngx_http_brotli_filter_module.cc"
+fi
+
+# workaround for a bug in nginx-1.9.11, see:
+# http://hg.nginx.org/nginx/rev/ff1e625ae55b
+NGX_VERSION=`grep nginx_version src/core/nginx.h | sed -e 's/^.* \(.*\)$/\1/'`
+if [ "$NGX_VERSION" = "1009011" ]; then
+ CFLAGS="$CFLAGS -Wno-write-strings"
+fi
have=NGX_HTTP_BROTLI_FILTER . auto/have