Skip to content

Commit

Permalink
Dynamic modules.
Browse files Browse the repository at this point in the history
The auto/module script is extended to understand ngx_module_link=DYNAMIC.
When set, it links the module as a shared object rather than statically
into nginx binary.  The module can later be loaded using the "load_module"
directive.

New auto/module parameter ngx_module_order allows to define module loading
order in complex cases.  By default the order is set based on ngx_module_type.

3rd party modules can be compiled dynamically using the --add-dynamic-module
configure option, which will preset ngx_module_link to "DYNAMIC" before
calling the module config script.

Win32 support is rudimentary, and only works when using MinGW gcc (which
is able to handle exports/imports automatically).

In collaboration with Ruslan Ermilov.
  • Loading branch information
mdounin committed Feb 4, 2016
1 parent 0805ba1 commit 97f59dd
Show file tree
Hide file tree
Showing 21 changed files with 1,136 additions and 34 deletions.
22 changes: 22 additions & 0 deletions auto/cc/conf
Expand Up @@ -5,12 +5,17 @@

LINK="\$(CC)"

MAIN_LINK=
MODULE_LINK="-shared"

ngx_include_opt="-I "
ngx_compile_opt="-c"
ngx_pic_opt="-fPIC"
ngx_objout="-o "
ngx_binout="-o "
ngx_objext="o"
ngx_binext=
ngx_modext=".so"

ngx_long_start=
ngx_long_end=
Expand Down Expand Up @@ -45,6 +50,9 @@ if test -n "$CFLAGS"; then

sunc)

MAIN_LINK=
MODULE_LINK="-G"

case "$NGX_MACHINE" in

i86pc)
Expand Down Expand Up @@ -156,6 +164,20 @@ if [ "$NGX_PLATFORM" != win32 ]; then
fi


ngx_feature="-Wl,-E switch"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=-Wl,-E
ngx_feature_test=
. auto/feature

if [ $ngx_found = yes ]; then
MAIN_LINK="-Wl,-E"
fi


ngx_feature="gcc builtin atomic operations"
ngx_feature_name=NGX_HAVE_GCC_ATOMIC
ngx_feature_run=yes
Expand Down
6 changes: 6 additions & 0 deletions auto/cc/msvc
Expand Up @@ -118,6 +118,12 @@ NGX_RCC="rc -fo$NGX_RES \$(CORE_INCS) $NGX_WIN32_RC"
CORE_LINK="$NGX_RES $CORE_LINK"


# dynamic modules
#MAIN_LINK="-link -def:$NGX_OBJS/nginx.def"
#MODULE_LINK="-LD $NGX_OBJS/nginx.lib"


ngx_pic_opt=
ngx_objout="-Fo"
ngx_binout="-Fe"
ngx_objext="obj"
Expand Down
3 changes: 3 additions & 0 deletions auto/cc/sunc
Expand Up @@ -57,6 +57,9 @@ case "$NGX_MACHINE" in

esac

MAIN_LINK=
MODULE_LINK="-G"


# optimizations

Expand Down
1 change: 1 addition & 0 deletions auto/init
Expand Up @@ -5,6 +5,7 @@

NGX_MAKEFILE=$NGX_OBJS/Makefile
NGX_MODULES_C=$NGX_OBJS/ngx_modules.c
NGX_MODULES=

NGX_AUTO_HEADERS_H=$NGX_OBJS/ngx_auto_headers.h
NGX_AUTO_CONFIG_H=$NGX_OBJS/ngx_auto_config.h
Expand Down
24 changes: 24 additions & 0 deletions auto/install
Expand Up @@ -26,6 +26,18 @@ case ".$NGX_SBIN_PATH" in
esac


case ".$NGX_MODULES_PATH" in
./*)
;;

*)
NGX_MODULES_PATH=$NGX_PREFIX/$NGX_MODULES_PATH
;;
esac

NGX_MODULES_PATH=`dirname $NGX_MODULES_PATH/.`


case ".$NGX_CONF_PATH" in
./*)
;;
Expand Down Expand Up @@ -158,12 +170,24 @@ END
fi


if test -n "$NGX_MODULES"; then
cat << END >> $NGX_MAKEFILE

test -d '\$(DESTDIR)$NGX_MODULES_PATH' \
|| mkdir -p '\$(DESTDIR)$NGX_MODULES_PATH'
cp $NGX_MODULES '\$(DESTDIR)$NGX_MODULES_PATH'
END

fi


# create Makefile

cat << END >> Makefile

build:
\$(MAKE) -f $NGX_MAKEFILE
\$(MAKE) -f $NGX_MAKEFILE modules
\$(MAKE) -f $NGX_MAKEFILE manpage

install:
Expand Down
6 changes: 3 additions & 3 deletions auto/lib/conf
Expand Up @@ -58,19 +58,19 @@ if [ $USE_ZLIB = YES ]; then
. auto/lib/zlib/conf
fi

if [ $USE_LIBXSLT = YES ]; then
if [ $USE_LIBXSLT != NO ]; then
. auto/lib/libxslt/conf
fi

if [ $USE_LIBGD = YES ]; then
if [ $USE_LIBGD != NO ]; then
. auto/lib/libgd/conf
fi

if [ $USE_PERL = YES ]; then
. auto/lib/perl/conf
fi

if [ $HTTP_GEOIP = YES ]; then
if [ $USE_GEOIP != NO ]; then
. auto/lib/geoip/conf
fi

Expand Down
7 changes: 6 additions & 1 deletion auto/lib/geoip/conf
Expand Up @@ -67,7 +67,12 @@ fi
if [ $ngx_found = yes ]; then

CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"

if [ $USE_GEOIP = YES ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi

NGX_LIB_GEOIP=$ngx_feature_libs

if [ $NGX_IPV6 = YES ]; then
ngx_feature="GeoIP IPv6 support"
Expand Down
7 changes: 6 additions & 1 deletion auto/lib/libgd/conf
Expand Up @@ -67,7 +67,12 @@ fi
if [ $ngx_found = yes ]; then

CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"

if [ $USE_LIBGD = YES ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi

NGX_LIB_LIBGD=$ngx_feature_libs

else

Expand Down
13 changes: 11 additions & 2 deletions auto/lib/libxslt/conf
Expand Up @@ -76,7 +76,12 @@ fi
if [ $ngx_found = yes ]; then

CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"

if [ $USE_LIBXSLT = YES ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
fi

NGX_LIB_LIBXSLT=$ngx_feature_libs

else

Expand Down Expand Up @@ -152,5 +157,9 @@ fi


if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS -lexslt"
if [ $USE_LIBXSLT = YES ]; then
CORE_LIBS="$CORE_LIBS -lexslt"
fi

NGX_LIB_LIBXSLT="$NGX_LIB_LIBXSLT -lexslt"
fi

0 comments on commit 97f59dd

Please sign in to comment.