Configure: shared sources for addon modules.

Addon modules, both dynamic and static, can now use shared source files.
Shared sources result in only one make rule even if specified several
times in different modules.
This commit is contained in:
Maxim Dounin 2020-11-10 17:13:20 +03:00
parent 3030907f5f
commit 23597e97f5
3 changed files with 45 additions and 3 deletions

View File

@ -502,6 +502,7 @@ fi
for ngx_module in $DYNAMIC_MODULES for ngx_module in $DYNAMIC_MODULES
do do
eval ngx_module_srcs="\$${ngx_module}_SRCS" eval ngx_module_srcs="\$${ngx_module}_SRCS"
eval ngx_module_shrd="\$${ngx_module}_SHRD"
eval eval ngx_module_libs="\\\"\$${ngx_module}_LIBS\\\"" eval eval ngx_module_libs="\\\"\$${ngx_module}_LIBS\\\""
eval ngx_module_modules="\$${ngx_module}_MODULES" eval ngx_module_modules="\$${ngx_module}_MODULES"
@ -567,7 +568,7 @@ END
| sed -e "s/\(.*\.\)c/\1$ngx_objext/"` | sed -e "s/\(.*\.\)c/\1$ngx_objext/"`
ngx_module_objs= ngx_module_objs=
for ngx_src in $ngx_module_srcs for ngx_src in $ngx_module_srcs $ngx_module_shrd
do do
case "$ngx_src" in case "$ngx_src" in
src/*) src/*)

View File

@ -17,7 +17,6 @@ if [ "$ngx_module_link" = DYNAMIC ]; then
done done
DYNAMIC_MODULES="$DYNAMIC_MODULES $ngx_module" DYNAMIC_MODULES="$DYNAMIC_MODULES $ngx_module"
eval ${ngx_module}_SRCS=\"$ngx_module_srcs\"
eval ${ngx_module}_MODULES=\"$ngx_module_name\" eval ${ngx_module}_MODULES=\"$ngx_module_name\"
@ -31,6 +30,30 @@ if [ "$ngx_module_link" = DYNAMIC ]; then
eval ${ngx_module}_ORDER=\"$ngx_module_order\" eval ${ngx_module}_ORDER=\"$ngx_module_order\"
fi fi
srcs=
shrd=
for src in $ngx_module_srcs
do
found=no
for old in $DYNAMIC_MODULES_SRCS
do
if [ $src = $old ]; then
found=yes
break
fi
done
if [ $found = no ]; then
srcs="$srcs $src"
else
shrd="$shrd $src"
fi
done
eval ${ngx_module}_SRCS=\"$srcs\"
eval ${ngx_module}_SHRD=\"$shrd\"
DYNAMIC_MODULES_SRCS="$DYNAMIC_MODULES_SRCS $srcs"
if test -n "$ngx_module_incs"; then if test -n "$ngx_module_incs"; then
CORE_INCS="$CORE_INCS $ngx_module_incs" CORE_INCS="$CORE_INCS $ngx_module_incs"
fi fi
@ -107,7 +130,24 @@ elif [ "$ngx_module_link" = ADDON ]; then
eval ${ngx_module_type}_MODULES=\"\$${ngx_module_type}_MODULES \ eval ${ngx_module_type}_MODULES=\"\$${ngx_module_type}_MODULES \
$ngx_module_name\" $ngx_module_name\"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_module_srcs" srcs=
for src in $ngx_module_srcs
do
found=no
for old in $NGX_ADDON_SRCS
do
if [ $src = $old ]; then
found=yes
break
fi
done
if [ $found = no ]; then
srcs="$srcs $src"
fi
done
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $srcs"
if test -n "$ngx_module_incs"; then if test -n "$ngx_module_incs"; then
eval ${ngx_var}_INCS=\"\$${ngx_var}_INCS $ngx_module_incs\" eval ${ngx_var}_INCS=\"\$${ngx_var}_INCS $ngx_module_incs\"

View File

@ -132,6 +132,7 @@ STREAM_UPSTREAM_ZONE=YES
STREAM_SSL_PREREAD=NO STREAM_SSL_PREREAD=NO
DYNAMIC_MODULES= DYNAMIC_MODULES=
DYNAMIC_MODULES_SRCS=
NGX_ADDONS= NGX_ADDONS=
NGX_ADDON_SRCS= NGX_ADDON_SRCS=