Skip to content

Commit 63ca02a

Browse files
authored
Fix broken brotli build (upstream brotli dropped makefile support and sources.lst file) (#150)
* Fix config file to no longer depend on a sources.lst file. * Fix readme to show how to build with latest brotli. Also make the build files real-life with optimizations (so everyone doesn't have to search for the best way to compile things). * Fix typo * Cleanup config file to not depend on out-of-date libs * Remove unused variables.
1 parent 8f726ea commit 63ca02a

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ ngx_brotli is a set of two nginx modules:
1111
- ngx_brotli filter module - used to compress responses on-the-fly,
1212
- ngx_brotli static module - used to serve pre-compressed files.
1313

14-
[![TravisCI Build Status](https://travis-ci.org/google/ngx_brotli.svg?branch=master)](https://travis-ci.org/google/ngx_brotli)
1514

1615
## Table of Contents
1716

@@ -37,6 +36,29 @@ Both Brotli library and nginx module are under active development.
3736

3837
## Installation
3938

39+
### Statically compiled
40+
41+
Checkout the latest `ngx_brotli` and build the dependencies:
42+
43+
```
44+
git clone --recurse-submodules -j8 https://github.com/google/ngx_brotli
45+
cd ngx_brotli/deps/brotli
46+
mkdir out && cd out
47+
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed ..
48+
cmake --build . --config Release --target brotlienc
49+
cd ../../../..
50+
```
51+
52+
53+
$ cd nginx-1.x.x
54+
$ export CFLAGS="-m64 -march=native -mtune=native -Ofast -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections"
55+
$ export LDFLAGS="-m64 -Wl,-s -Wl,-Bsymbolic -Wl,--gc-sections"
56+
$ ./configure --add-module=/path/to/ngx_brotli
57+
$ make && make install
58+
59+
This will compile the module directly into Nginx.
60+
61+
4062
### Dynamically loaded
4163

4264
$ cd nginx-1.x.x
@@ -51,13 +73,7 @@ load_module modules/ngx_http_brotli_filter_module.so;
5173
load_module modules/ngx_http_brotli_static_module.so;
5274
```
5375

54-
### Statically compiled
5576

56-
$ cd nginx-1.x.x
57-
$ ./configure --add-module=/path/to/ngx_brotli
58-
$ make && make install
59-
60-
This will compile the module directly into Nginx.
6177

6278
## Configuration directives
6379

filter/config

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ ngx_module_type=HTTP_FILTER
4343
ngx_module_name=ngx_http_brotli_filter_module
4444

4545
brotli="$ngx_addon_dir/deps/brotli/c"
46-
if [ ! -f "$brotli/include/brotli/encode.h" ]; then
47-
brotli="/usr/local"
48-
fi
49-
if [ ! -f "$brotli/include/brotli/encode.h" ]; then
50-
brotli="/usr"
51-
fi
5246
if [ ! -f "$brotli/include/brotli/encode.h" ]; then
5347
cat << END
5448

@@ -63,33 +57,16 @@ END
6357
exit 1
6458
fi
6559

66-
BROTLI_LISTS_FILE="$brotli/../scripts/sources.lst"
67-
68-
if [ -f "$BROTLI_LISTS_FILE" ]; then
69-
70-
BROTLI_LISTS=`cat "$BROTLI_LISTS_FILE" | grep -v "#" | tr '\n' '#' | \
71-
sed 's/\\\\#//g' | tr -s ' ' '+' | tr -s '#' ' ' | \
72-
sed 's/+c/+$brotli/g' | sed 's/+=+/=/g'`
73-
for ITEM in ${BROTLI_LISTS}; do
74-
VAR=`echo $ITEM | sed 's/=.*//'`
75-
VAL=`echo $ITEM | sed 's/.*=//' | tr '+' ' '`
76-
eval ${VAR}=\"$VAL\"
77-
done
78-
79-
else # BROTLI_LISTS_FILE
80-
60+
BROTLI_OUTPUT_DIRECTORY="$brotli/../out"
8161
BROTLI_ENC_H="$brotli/include/brotli/encode.h \
8262
$brotli/include/brotli/port.h \
8363
$brotli/include/brotli/types.h"
84-
BROTLI_ENC_LIB="-lbrotlienc"
8564

86-
fi
8765

8866
ngx_module_incs="$brotli/include"
89-
ngx_module_deps="$BROTLI_COMMON_H $BROTLI_ENC_H"
90-
ngx_module_srcs="$BROTLI_COMMON_C $BROTLI_ENC_C \
91-
$BROTLI_MODULE_SRC_DIR/ngx_http_brotli_filter_module.c"
92-
ngx_module_libs="$BROTLI_ENC_LIB -lm"
67+
ngx_module_deps="$BROTLI_ENC_H"
68+
ngx_module_srcs="$BROTLI_MODULE_SRC_DIR/ngx_http_brotli_filter_module.c"
69+
ngx_module_libs="-L$BROTLI_OUTPUT_DIRECTORY -lbrotlienc -lbrotlicommon -lm"
9370
ngx_module_order="$ngx_module_name \
9471
ngx_pagespeed \
9572
ngx_http_postpone_filter_module \

0 commit comments

Comments
 (0)