blob: 9f4d15f34ec4a903399592e20f5259de6c23267b [file] [log] [blame]
# Copyright (C) 2015-2016 Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
ngx_addon_name=ngx_brotli
#
# static module (no dependencies)
#
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=
. 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
if [ -n "$NGX_BROTLI_STATIC_MODULE_ONLY" ]; then
return
fi
#
# filter module (depends on Brotli library)
#
ngx_feature_run=no
ngx_feature_cpp=yes
ngx_feature_incs="#include <brotli/enc/encode.h>"
ngx_feature_test="brotli::BrotliParams params;
params.quality = 11"
# auto-discovery
ngx_feature="Brotli library"
ngx_feature_cpp=yes
ngx_feature_path=
ngx_feature_libs="-lbrotlienc -lstdc++"
. $ngx_addon_dir/auto/feature
if [ $ngx_found = no ]; then
# FreeBSD, OpenBSD
ngx_feature="Brotli library in /usr/local/"
ngx_feature_cpp=yes
ngx_feature_path="/usr/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lbrotlienc -lstdc++"
else
ngx_feature_libs="-L/usr/local/lib -lbrotlienc -lstdc++"
fi
. $ngx_addon_dir/auto/feature
fi
if [ $ngx_found = no ]; then
# NetBSD
ngx_feature="Brotli library in /usr/pkg/"
ngx_feature_cpp=yes
ngx_feature_path="/usr/pkg/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lbrotlienc -lstdc++"
else
ngx_feature_libs="-L/usr/pkg/lib -lbrotlienc -lstdc++"
fi
. $ngx_addon_dir/auto/feature
fi
if [ $ngx_found = no ]; then
# MacPorts
ngx_feature="Brotli library in /opt/local/"
ngx_feature_cpp=yes
ngx_feature_path="/opt/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lbrotlienc -lstdc++"
else
ngx_feature_libs="-L/opt/local/lib -lbrotlienc -lstdc++"
fi
. $ngx_addon_dir/auto/feature
fi
if [ $ngx_found = no ]; then
echo "$0: error: ngx_brotli filter module requires Brotli library."
exit 1
fi
if [ $HTTP_GZIP = YES ]; then
next=ngx_http_gzip_filter_module
elif echo $HTTP_FILTER_MODULES | grep ngx_pagespeed_etag_filter >/dev/null; then
next=ngx_pagespeed_etag_filter
else
next=ngx_http_range_header_filter_module
fi
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"
. 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