﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
1465	configure: use -iquote for $ngx_module_incs	foonlyboy@…		"- nginx-1.13.8
- Darwin pro.local 16.7.0 Darwin Kernel Version 16.7.0: Mon Nov 13 21:56:25 PST 2017; root:xnu-3789.72.11~1/RELEASE_X86_64 x86_64

I found a problem when trying to compile ngx_brotli on macOS/OSX
which might be rooted in nginx/configure (or at least needs some help there)

see also:
- [https://github.com/google/ngx_brotli/issues/64]
- [https://github.com/phusion/passenger/issues/2017]
- [https://github.com/nginx/nginx/blob/master/auto/module]

{{{
./configure --add-module=../ngx_brotli
make
}}}


---

in ngx_brotli/src/ngx_http_brotli_filter_module.c:

{{{
#include <brotli/encode.h>
}}}

pulls in </opt/local/include/brotli/encode.h>
instead of ""../ngx_brotli/deps/brotli/include/brotli/encode.h""
(I have installed ""brotli"" from macports which installs an incompatible version of brotli/encode.h)

This clearly is a bug in ngx_brotli, which should read:
{{{
#include ""brotli/encode.h""
}}}


But for this to have the desired efect, the CFLAGS have to be changed from:

{{{
-I ../ngx_brotli/deps/brotli/include
}}}
to

{{{
-iquote ../ngx_brotli/deps/brotli/include
}}}

as of my first guess the include path flag comes from
ngx_brotli/config:
{{{
ngx_module_incs=""$brotli/include""
}}}

(please excuse, I'm not yet that dig deep in the nginx module config api)

I think this should read something like:
{{{
ngx_module_incs_quote=""$brotli/include""
}}}

which should generate CFLAGS
{{{
-iquote ../ngx_brotli/deps/brotli/include
}}}



I patched ngx_brotli/src/ngx_http_brotli_filter_module.c

from:
{{{
#include <brotli/encode.h>
}}}

to (angle brackets replaced by quotes):
{{{
#include ""brotli/encode.h""
}}}

I then manually compiled the file,
fisrt using the CFLAGS as given, aka:

{{{
 -I ../ngx_brotli/deps/brotli/include
}}}

then modifing CFLAGS to -iquote

{{{
-iquote ../ngx_brotli/deps/brotli/include
}}}


first compile fails:

{{{
nginx-1.13.8 $ sh -x c-I
+ /usr/bin/cc -c -pipe -O -Wall -Wextra -Wpointer-arith -Wconditional-uninitialized -Wno-unused-parameter -Wno-deprecated-declarations -Werror -g -Wno-error -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I /opt/local/include -I /usr/local/src/openssl-1.1.0f/.openssl/include -I objs -I src/http -I src/http/modules -I src/http/v2 -I ../ngx_brotli/deps/brotli/include -I /opt/local/lib/ruby2.5/gems/2.5.0/gems/passenger-5.1.12/src -o objs/addon/src/ngx_http_brotli_filter_module.o ../ngx_brotli/src/ngx_http_brotli_filter_module.c
../ngx_brotli/src/ngx_http_brotli_filter_module.c:272:28: warning: implicit
      declaration of function 'BrotliEncoderInputBlockSize' is invalid in C99
      [-Wimplicit-function-declaration]
        ctx->brotli_ring = BrotliEncoderInputBlockSize(ctx->encoder);
}}}


my manually modified compile works (replaced -I by -iquote)

{{{
nginx-1.13.8 $ sh -x c-iquote 
+ /usr/bin/cc -c -pipe -O -Wall -Wextra -Wpointer-arith -Wconditional-uninitialized -Wno-unused-parameter -Wno-deprecated-declarations -Werror -g -Wno-error -Wno-deprecated-declarations -I src/core -I src/event -I src/event/modules -I src/os/unix -I /opt/local/include -I /usr/local/src/openssl-1.1.0f/.openssl/include -I objs -I src/http -I src/http/modules -I src/http/v2 -iquote ../ngx_brotli/deps/brotli/include -I /opt/local/lib/ruby2.5/gems/2.5.0/gems/passenger-5.1.12/src -o objs/addon/src/ngx_http_brotli_filter_module.o ../ngx_brotli/src/ngx_http_brotli_filter_module.c
}}}



---


I did set this to major priority (you might even want to raise this to critical)
because pulling in wrong header files can lead to really bad and hard to diagnose bugs.






























"	defect	new	minor		other	1.13.x				Darwin pro.local 16.7.0 Darwin Kernel Version 16.7.0: Mon Nov 13 21:56:25 PST 2017; root:xnu-3789.72.11~1/RELEASE_X86_64 x86_64	nginx-1.13.8
