forked from ossrs/srs-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·215 lines (181 loc) · 8.21 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash
GLOBAL_FILE_MAKEFILE="Makefile"
GLOBAL_DIR_OBJS="objs"
mkdir -p ${GLOBAL_DIR_OBJS}
#####################################################################################
# prepare the depends tools
#####################################################################################
OS_IS_OSX=NO
uname -s|grep Darwin >/dev/null 2>&1
ret=$?; if [[ 0 -eq $ret ]]; then
OS_IS_OSX=YES
fi
echo "Is OSX: ${OS_IS_OSX}"
# check the arm flag file, if flag changed, need to rebuild the st.
_ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMALLOC_STACK -DMD_HAVE_EPOLL"
# for osx, use darwin for st, donot use epoll.
if [ $OS_IS_OSX = YES ]; then
_ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE"
fi
# st-1.9
if [[ -f ${GLOBAL_DIR_OBJS}/st-1.9/obj/libst.a ]]; then
echo "st-1.9t is ok.";
else
echo "build st-1.9t";
(
rm -rf ${GLOBAL_DIR_OBJS}/st-1.9 && cd ${GLOBAL_DIR_OBJS} && unzip ../3rdparty/st-1.9.zip && cd st-1.9 &&
patch -p0 < ../../3rdparty/patches/1.st.arm.patch &&
make EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" ${_ST_MAKE}
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build st-1.9 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${GLOBAL_DIR_OBJS}/st-1.9/obj/libst.a ]; then echo "build st-1.9 failed."; exit -1; fi
SED="sed -i"
if [ $OS_IS_OSX = YES ]; then SED="sed -i ''"; fi
# http-parser-2.1
if [[ -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/http_parser.h && -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then
echo "http-parser-2.1 is ok.";
else
echo "build http-parser-2.1";
(
rm -rf ${GLOBAL_DIR_OBJS}/http-parser-2.1 && cd ${GLOBAL_DIR_OBJS} && unzip ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
$SED "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&
$SED "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&
make package
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build http-parser-2.1 failed, ret=$ret"; exit $ret; fi
if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/http_parser.h ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
if [[ ! -f ${GLOBAL_DIR_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
#####################################################################################
# generate Makefile.
#####################################################################################
echo "generate Makefile"
cat << END > ${GLOBAL_FILE_MAKEFILE}
.PHONY: default help clean http hls all _prepare_dir
default: all
help:
@echo "Usage: make <help>|<clean>|<http>|<hls>|<rtmp>|<all>"
@echo " help display this help menu"
@echo " clean cleanup project"
@echo " http build the http load test tool over st(state-threads)"
@echo " hls build the hls load test tool over st(state-threads)"
@echo " rtmp build the rtmp load test tool over st(state-threads)"
@echo " all build the http/hls load test tool over st(state-threads)"
clean:
(cd ${GLOBAL_DIR_OBJS}; rm -rf src sb_*_load)
http: _prepare_dir
@echo "build the http load test tool over st(state-threads)"
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_http_load
rtmp: _prepare_dir
@echo "build the http load test tool over st(state-threads)"
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_rtmp_load
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_rtmp_load_fast
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_rtmp_publish
hls: _prepare_dir
@echo "build the HLS load test tool over st(state-threads)"
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_hls_load
all: _prepare_dir
@echo "build the http/hls/rtmp load test tool over st(state-threads)"
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_http_load
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_hls_load
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_rtmp_load
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_rtmp_load_fast
\$(MAKE) -f ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE} sb_rtmp_publish
@echo "build ok, you can:"
@echo " ./objs/sb_http_load"
@echo " ./objs/sb_hls_load"
@echo " ./objs/sb_rtmp_load"
@echo " ./objs/sb_rtmp_load_fast"
@echo " ./objs/sb_rtmp_publish"
# the ./configure will generate it.
_prepare_dir:
END
echo 'generate Makefile ok!'
# the performance analysis, uncomments the following when use gperf to analysis the performance. see third-party/readme.txt
#Performance="-pg"
#PerformanceLink="-pg"
# enable gdb debug
GDBDebug="-g -O0"
# the warning level.
WarnLevel="-Wall -Wextra"
# the compile standard.
CppStd="-std=c++98"
# other macros defined
UserMacros="-DSRS_HIJACK_IO -DSRS_DISABLE_LOG"
# the cxx flag generated.
CXXFLAGS="${CppStd} ${WarnLevel} ${GDBDebug} ${Performance} ${UserMacros}"
cat << END > ${GLOBAL_DIR_OBJS}/${GLOBAL_FILE_MAKEFILE}
CXXFLAGS = ${CXXFLAGS}
GCC = g++
LINK = \$(GCC)
AR = ar
.PHONY: default sb_http_load sb_hls_load sb_rtmp_load sb_rtmp_load_fast sb_rtmp_publish
default:
END
# Libraries
LibSTRoot="${GLOBAL_DIR_OBJS}/st-1.9/obj"
LibSTfile="${LibSTRoot}/libst.a"
LibHttpParserRoot="${GLOBAL_DIR_OBJS}/http-parser-2.1"
LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"
#Core Module
MODULE_ID="CORE"
MODULE_DEPENDS=()
ModuleLibIncs=(${LibHttpParserRoot})
MODULE_FILES=("htl_core_log" "htl_core_error" "htl_core_uri" "htl_core_aggregate_ret")
MODULE_DIR="src/core" . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}"
#OS Module
MODULE_ID="OS"
MODULE_DEPENDS=("CORE")
ModuleLibIncs=(${LibSTRoot})
MODULE_FILES=("htl_os_st")
MODULE_DIR="src/os" . auto/modules.sh
OS_OBJS="${MODULE_OBJS[@]}"
#APP Module
MODULE_ID="APP"
MODULE_DEPENDS=("CORE" "OS")
ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot})
MODULE_FILES=("htl_app_hls_load" "htl_app_http_load" "htl_app_http_client" "htl_app_rtmp_play"
"htl_app_m3u8_parser" "htl_app_task_base" "htl_app_rtmp_load" "htl_app_rtmp_protocol"
"htl_app_rtmp_publish" "htl_app_srs_hijack")
MODULE_DIR="src/app" . auto/modules.sh
APP_OBJS="${MODULE_OBJS[@]}"
#Main Module
MODULE_ID="MAIN"
MODULE_DEPENDS=("CORE" "OS" "APP")
ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot})
MODULE_FILES=("htl_main_hls_load" "htl_main_http_load" "htl_main_rtmp_load" "htl_main_rtmp_load_fast" "htl_main_utility" "htl_main_rtmp_publish")
MODULE_DIR="src/main" . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@].o}"
# all main entrances
MAIN_ENTRANCES=("htl_main_hls_load" "htl_main_http_load" "htl_main_rtmp_load" "htl_main_rtmp_load_fast" "htl_main_rtmp_publish")
# http load test tool over st(state-threads)
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile})
MODULE_OBJS="${CORE_OBJS[@]} ${OS_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
BUILD_KEY="sb_http_load" APP_MAIN="htl_main_http_load" APP_NAME="sb_http_load" LINK_OPTIONS="-ldl" SO_PATH="" . auto/apps.sh
# rtmp play load test tool over st(state-threads)
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile})
MODULE_OBJS="${CORE_OBJS[@]} ${OS_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
BUILD_KEY="sb_rtmp_load" APP_MAIN="htl_main_rtmp_load" APP_NAME="sb_rtmp_load" LINK_OPTIONS="-ldl" SO_PATH="" . auto/apps.sh
# rtmp play load test tool over st(state-threads)
# Remark, the fast algorithm may not work for other RTMP server, it's ok for SRS/GO-SRS.
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile})
MODULE_OBJS="${CORE_OBJS[@]} ${OS_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
BUILD_KEY="sb_rtmp_load_fast" APP_MAIN="htl_main_rtmp_load_fast" APP_NAME="sb_rtmp_load_fast" LINK_OPTIONS="-ldl" SO_PATH="" . auto/apps.sh
# rtmp publish load test tool over st(state-threads)
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile})
MODULE_OBJS="${CORE_OBJS[@]} ${OS_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
BUILD_KEY="sb_rtmp_publish" APP_MAIN="htl_main_rtmp_publish" APP_NAME="sb_rtmp_publish" LINK_OPTIONS="-ldl" SO_PATH="" . auto/apps.sh
# hls load test tool over direct TCP.
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile})
MODULE_OBJS="${CORE_OBJS[@]} ${OS_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
BUILD_KEY="sb_hls_load" APP_MAIN="htl_main_hls_load" APP_NAME="sb_hls_load" LINK_OPTIONS="-ldl" SO_PATH="" . auto/apps.sh
echo 'configure ok! '
# next step.
echo "you can:"
echo "\" make \" to build the http/hls load test tools."
echo "\" make help \" to get the usage of make"