NJS_ZLIB=${NJS_ZLIB:-YES}
NJS_QUICKJS=${NJS_QUICKJS:-YES}
+NJS_BUILD_DIR="$(pwd)/$NGX_OBJS/njs"
+case "$NGX_OBJS" in
+ /*) NJS_BUILD_DIR="$NGX_OBJS/njs" ;;
+esac
+
NJS_DEPS="$ngx_addon_dir/ngx_js.h \
$ngx_addon_dir/ngx_js_form.h \
$ngx_addon_dir/ngx_js_http.h \
NJS_ZLIB_LIB=
NJS_QUICKJS_LIB=
NJS_QUICKJS_INC=
-NJS_QUICKJS_DEFAULT_INCS="$ngx_addon_dir/../src $ngx_addon_dir/../build"
+NJS_QUICKJS_DEFAULT_INCS="$ngx_addon_dir/../src"
NJS_HAVE_QUICKJS=
if [ $NJS_QUICKJS != NO ]; then
fi
-NJS_ENGINE_DEP="$ngx_addon_dir/../build/libnjs.a"
-NJS_ENGINE_LIB="$ngx_addon_dir/../build/libnjs.a"
+NJS_ENGINE_DEP="$NJS_BUILD_DIR/libnjs.a"
+NJS_ENGINE_LIB="$NJS_BUILD_DIR/libnjs.a"
if [ "$NJS_HAVE_QUICKJS" = "YES" ]; then
- NJS_ENGINE_DEP="$ngx_addon_dir/../build/libqjs.a"
- NJS_ENGINE_LIB="$ngx_addon_dir/../build/libnjs.a $ngx_addon_dir/../build/libqjs.a"
+ NJS_ENGINE_DEP="$NJS_BUILD_DIR/libqjs.a"
+ NJS_ENGINE_LIB="$NJS_ENGINE_LIB $NJS_BUILD_DIR/libqjs.a"
QJS_SRCS="$QJS_SRCS $ngx_addon_dir/ngx_qjs_fetch.c"
fi
if [ $HTTP != NO ]; then
ngx_module_type=HTTP_AUX_FILTER
ngx_module_name="ngx_http_js_module ngx_http_js_core_module"
- ngx_module_incs="$ngx_addon_dir/../src $ngx_addon_dir/../build \
+ ngx_module_incs="$ngx_addon_dir/../src $NJS_BUILD_DIR \
$NJS_QUICKJS_INC"
ngx_module_deps="$NJS_ENGINE_DEP $NJS_DEPS $QJS_DEPS"
ngx_module_srcs="$ngx_addon_dir/ngx_http_js_module.c $NJS_SRCS $QJS_SRCS"
if [ $STREAM != NO ]; then
ngx_module_type=STREAM
ngx_module_name="ngx_stream_js_module ngx_stream_js_core_module"
- ngx_module_incs="$ngx_addon_dir/../src $ngx_addon_dir/../build \
+ ngx_module_incs="$ngx_addon_dir/../src $NJS_BUILD_DIR \
$NJS_QUICKJS_INC"
ngx_module_deps="$NJS_ENGINE_DEP $NJS_DEPS $QJS_DEPS"
ngx_module_srcs="$ngx_addon_dir/ngx_stream_js_module.c $NJS_SRCS $QJS_SRCS"
cat << END >> $NGX_MAKEFILE
-$ngx_addon_dir/../build/libnjs.a: $NGX_MAKEFILE
+$NJS_BUILD_DIR/libnjs.a: $NGX_MAKEFILE
cd $ngx_addon_dir/.. \\
- && if [ -f build/Makefile ]; then \$(MAKE) clean; fi \\
&& CFLAGS="\$(CFLAGS)" CC="\$(CC)" ./configure --no-openssl \\
- --no-libxml2 --no-zlib --no-pcre --no-quickjs --ld-opt="$NGX_LD_OPT" \\
- && \$(MAKE) libnjs
+ --no-libxml2 --no-zlib --no-pcre --no-quickjs \\
+ --no-root-makefile --build-dir="$NJS_BUILD_DIR" \\
+ --ld-opt="$NGX_LD_OPT" \\
+ && \$(MAKE) -f $NJS_BUILD_DIR/Makefile libnjs
-$ngx_addon_dir/../build/libqjs.a: $NGX_MAKEFILE
+$NJS_BUILD_DIR/libqjs.a: $NGX_MAKEFILE
cd $ngx_addon_dir/.. \\
- && if [ -f build/Makefile ]; then \$(MAKE) clean; fi \\
&& CFLAGS="\$(CFLAGS)" CC="\$(CC)" ./configure --no-openssl \\
- --no-libxml2 --no-zlib --no-pcre --ld-opt="$NGX_LD_OPT" \\
- && \$(MAKE) libnjs libqjs
+ --no-libxml2 --no-zlib --no-pcre --with-quickjs \\
+ --no-root-makefile --build-dir="$NJS_BUILD_DIR" \\
+ --quickjs-inc="$NJS_QUICKJS_INC" \\
+ --quickjs-lib="$NJS_QUICKJS_LIB" --ld-opt="$NGX_LD_OPT" \\
+ && \$(MAKE) -f $NJS_BUILD_DIR/Makefile libnjs libqjs
END