Skip to content

Commit

Permalink
Add reconfigure script and rewriter makefile for nginx with rtmp module
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrtonm authored and rinon committed Jul 27, 2023
1 parent 0d23578 commit 3882699
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/cmake-build-release

# ignore likely build dirs
/[Bb]uild*/
**/[Bb]uild*/

# CMake artefacts
CMakeLists.txt.user
Expand Down
2 changes: 1 addition & 1 deletion external/nginx/auto/init
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cat << END > Makefile
default: build

clean:
rm -rf Makefile $NGX_OBJS
rm -rf Makefile $NGX_OBJS compile_commands.json wrapper.h wrapper_2.ld wrapper.c

.PHONY: default clean
END
73 changes: 65 additions & 8 deletions external/nginx/auto/make
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,57 @@ CFLAGS = $CFLAGS
CPP = $CPP
LINK = $LINK

END
C_SYSTEM_INCLUDE = `$CC -print-file-name=include`
C_SYSTEM_INCLUDE_FIXED = `$CC -print-file-name=include-fixed`
IA2_ROOT = $NGX_OBJS/../ia2
PAD_TLS = \$(IA2_ROOT)/pad-tls/pad-tls

IA2_CALLGATES = $NGX_OBJS/libia2_callgates.so

IA2_CFLAGS = \\
-fPIC \\
-DPKEY=1 \\
-DLIBIA2_DEBUG=1 \\
-I \$(C_SYSTEM_INCLUDE) \\
-I \$(C_SYSTEM_INCLUDE_FIXED) \\
-Wno-error \\
-Werror=incompatible-pointer-types \\
-include $NGX_OBJS/../wrapper.h \\
-I $REPO_ROOT/libia2/include

IA2_PREREWRITER_LDFLAGS = \\
-Wl,--wrap=pthread_create

IA2_LDFLAGS = \\
\$(IA2_CALLGATES) \\
-pthread \\
-Wl,--wrap=main \\
-Wl,-z,now \\
-Wl,-z,relro \\
-Wl,-T\$(IA2_ROOT)/libia2/padding.ld \\
-Wl,--dynamic-list=\$(IA2_ROOT)/libia2/dynsym.syms \\
-Wl,--export-dynamic

IA2_MODULE_CFLAGS = \\
-fPIC \\
-DPKEY=2 \\
-DLIBIA2_DEBUG=1 \\
-I \$(C_SYSTEM_INCLUDE) \\
-I \$(C_SYSTEM_INCLUDE_FIXED) \\
-Wno-error \\
-Werror=incompatible-pointer-types \\
-include $NGX_OBJS/../wrapper.h \\
-I $REPO_ROOT/libia2/include

IA2_MODULE_LDFLAGS = \\
-Wl,-z,now \\
-Wl,-z,relro \\
-pthread \\
-Wl,--wrap=pthread_create \\
-Wl,@$NGX_OBJS/../wrapper_2.ld \\
-Wl,-T\$(IA2_ROOT)/libia2/padding.ld

END

if test -n "$NGX_PERL_CFLAGS"; then
echo NGX_PERL_CFLAGS = $NGX_PERL_CFLAGS >> $NGX_MAKEFILE
Expand Down Expand Up @@ -228,8 +277,16 @@ build: binary modules manpage

binary: $NGX_OBJS${ngx_dirsep}nginx$ngx_binext

$NGX_OBJS${ngx_dirsep}nginx$ngx_binext: $ngx_deps$ngx_spacer
\$(LINK) $ngx_long_start$ngx_binout$NGX_OBJS${ngx_dirsep}nginx$ngx_binext$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_main_link
\$(IA2_CALLGATES):
\$(CC) -shared -fPIC -Wl,-z,now $NGX_OBJS/../wrapper.c \
-I $REPO_ROOT/libia2/include -o \$(IA2_CALLGATES)

$NGX_OBJS/ngx_rtmp_module_tls_padded.so: $NGX_OBJS/ngx_rtmp_module.so
cp $NGX_OBJS/ngx_rtmp_module.so $NGX_OBJS/ngx_rtmp_module_tls_padded.so
\$(PAD_TLS) --allow-no-tls $NGX_OBJS/ngx_rtmp_module_tls_padded.so

$NGX_OBJS${ngx_dirsep}nginx$ngx_binext: $ngx_deps \$(IA2_CALLGATES) $NGX_OBJS/ngx_rtmp_module_tls_padded.so$ngx_spacer
\$(LINK) $ngx_long_start\$(IA2_LDFLAGS)$ngx_long_cont\$(IA2_PREREWRITER_LDFLAGS)$ngx_long_cont$ngx_binout$NGX_OBJS${ngx_dirsep}nginx$ngx_binext$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_main_link \$(IA2_ROOT)/libia2/liblibia2.a $NGX_OBJS/ngx_rtmp_module_tls_padded.so
$ngx_rcc
$ngx_long_end

Expand All @@ -242,7 +299,7 @@ END
if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS)"
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(IA2_CFLAGS)"
fi

cat << END >> $NGX_MAKEFILE
Expand Down Expand Up @@ -281,7 +338,7 @@ if [ $HTTP = YES ]; then
if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)"
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS) \$(IA2_CFLAGS)"
ngx_perl_cc="\$(CC) $ngx_compile_opt \$(NGX_PERL_CFLAGS)"
ngx_perl_cc="$ngx_perl_cc \$(CORE_INCS) \$(HTTP_INCS)"
fi
Expand Down Expand Up @@ -325,7 +382,7 @@ if [ $MAIL = YES ]; then
if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(MAIL_INCS)"
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(MAIL_INCS) \$(IA2_CFLAGS)"
fi

for ngx_src in $MAIL_SRCS
Expand Down Expand Up @@ -494,7 +551,7 @@ fi
if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
ngx_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(CFLAGS) \$(ALL_INCS)"
ngx_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(CFLAGS) \$(ALL_INCS) \$(IA2_MODULE_CFLAGS)"
ngx_perl_cc="\$(CC) $ngx_compile_opt $ngx_pic_opt \$(NGX_PERL_CFLAGS)"
ngx_perl_cc="$ngx_perl_cc \$(ALL_INCS)"
fi
Expand Down Expand Up @@ -622,7 +679,7 @@ END
modules: $ngx_obj

$ngx_obj: $ngx_deps$ngx_spacer
\$(LINK) $ngx_long_start$ngx_binout$ngx_obj$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_module_link
\$(LINK) $ngx_long_start\$(IA2_MODULE_LDFLAGS)$ngx_long_cont$ngx_binout$ngx_obj$ngx_long_cont$ngx_objs$ngx_libs$ngx_link$ngx_module_link
$ngx_long_end

$ngx_modules_obj: \$(CORE_DEPS)$ngx_cont$ngx_modules_c
Expand Down
4 changes: 3 additions & 1 deletion external/nginx/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#user nobody;
worker_processes 1;

load_module ngx_rtmp_module_tls_padded.so;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
Expand Down Expand Up @@ -33,7 +35,7 @@ http {
#gzip on;

server {
listen 80;
listen 8080;
server_name localhost;

#charset koi8-r;
Expand Down
Loading

0 comments on commit 3882699

Please sign in to comment.