winlin

refine configure, generate objs/makefile first.

正在显示 1 个修改的文件 包含 159 行增加159 行删除
@@ -49,6 +49,165 @@ SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\"" @@ -49,6 +49,165 @@ SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\""
49 if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/utest; \$(MAKE))"; fi 49 if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/utest; \$(MAKE))"; fi
50 50
51 ##################################################################################### 51 #####################################################################################
  52 +# build tools or compiler args.
  53 +# enable gdb debug
  54 +GDBDebug=" -g -O0"
  55 +# the warning level.
  56 +WarnLevel=" -Wall"
  57 +# the compile standard.
  58 +CppStd="-ansi"
  59 +# for library compile
  60 +LibraryCompile=" -fPIC"
  61 +# performance of gprof
  62 +SrsGprof=""; SrsGprofLink=""; if [ $SRS_GPROF = YES ]; then SrsGprof=" -pg -lc_p"; SrsGprofLink=" -pg"; fi
  63 +# performance of gperf
  64 +SrsGperf=""; SrsGperfLink=""; if [ $SRS_GPERF = YES ]; then SrsGperfLink=" -lpthread"; fi
  65 +# the cxx flag generated.
  66 +CXXFLAGS="${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}"
  67 +if [ $SRS_GPERF = YES ]; then CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"; fi
  68 +cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}
  69 +GCC = gcc
  70 +CXX = g++
  71 +AR = ar
  72 +LINK = g++
  73 +CXXFLAGS = ${CXXFLAGS}
  74 +
  75 +.PHONY: default srs librtmp
  76 +
  77 +default:
  78 +
  79 +END
  80 +
  81 +#####################################################################################
  82 +# Libraries, external library to build in srs,
  83 +# header(.h): add to ModuleLibIncs if need the specified library. for example, LibSTRoot
  84 +# library(.a): add to ModuleLibFiles if binary need the specifeid library. for example, LibSTfile
  85 +#
  86 +# st(state-threads) the basic network library for SRS.
  87 +LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a"
  88 +# hp(http-parser) the http request/url parser, for SRS to support HTTP callback.
  89 +LibHttpParserRoot=""; LibHttpParserfile=""
  90 +if [ $SRS_HTTP_PARSER = YES ]; then LibHttpParserRoot="${SRS_OBJS_DIR}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi
  91 +# openssl-1.0.1f, for the RTMP complex handshake.
  92 +LibSSLRoot="";LibSSLfile=""
  93 +if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS_OBJS_DIR}/openssl/include"; LibSSLfile="${SRS_OBJS_DIR}/openssl/lib/libssl.a ${SRS_OBJS_DIR}/openssl/lib/libcrypto.a"; fi fi
  94 +# gperftools-2.1, for mem check and mem/cpu profile
  95 +LibGperfRoot=""; LibGperfFile=""
  96 +if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS_DIR}/gperf/include"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_and_profiler.a"; fi
  97 +# the link options, always use static link
  98 +SrsLinkOptions="-ldl";
  99 +if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lssl"; fi fi
  100 +# if static specified, add static
  101 +# TODO: FIXME: remove static.
  102 +if [ $SRS_STATIC = YES ]; then SrsLinkOptions="${SrsLinkOptions} -static"; fi
  103 +# if mips, add -lgcc_eh, or stl compile failed.
  104 +if [ $SRS_MIPS_UBUNTU12 = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lgcc_eh"; fi
  105 +
  106 +#####################################################################################
  107 +# Modules, compile each module, then link to binary
  108 +#
  109 +#Core, depends only on system apis.
  110 +MODULE_ID="CORE"
  111 +MODULE_DEPENDS=()
  112 +ModuleLibIncs=(${SRS_OBJS_DIR})
  113 +MODULE_FILES=("srs_core" "srs_core_autofree" "srs_core_performance")
  114 +CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh
  115 +CORE_OBJS="${MODULE_OBJS[@]}"
  116 +#
  117 +#Kernel, depends on core, provides error/log/config, nothing about stream information.
  118 +MODULE_ID="KERNEL"
  119 +MODULE_DEPENDS=("CORE")
  120 +ModuleLibIncs=(${SRS_OBJS_DIR})
  121 +MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream"
  122 + "srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_file"
  123 + "srs_kernel_consts" "srs_kernel_aac" "srs_kernel_mp3" "srs_kernel_ts"
  124 + "srs_kernel_buffer")
  125 +KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh
  126 +KERNEL_OBJS="${MODULE_OBJS[@]}"
  127 +#
  128 +#RTMP Protocol, depends on core/kernel, provides rtmp/htttp protocol features.
  129 +MODULE_ID="RTMP"
  130 +MODULE_DEPENDS=("CORE" "KERNEL")
  131 +ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
  132 +MODULE_FILES=("srs_rtmp_amf0" "srs_rtmp_io" "srs_rtmp_stack" "srs_rtmp_sdk"
  133 + "srs_rtmp_handshake" "srs_rtmp_utility" "srs_rtmp_msg_array" "srs_rtmp_buffer"
  134 + "srs_raw_avc" "srs_rtsp_stack")
  135 +RTMP_INCS="src/protocol"; MODULE_DIR=${RTMP_INCS} . auto/modules.sh
  136 +RTMP_OBJS="${MODULE_OBJS[@]}"
  137 +#
  138 +#App Module
  139 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  140 + MODULE_ID="APP"
  141 + MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
  142 + ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS_DIR})
  143 + MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_st_socket" "srs_app_source"
  144 + "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http"
  145 + "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
  146 + "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" "srs_app_http_conn" "srs_app_http_hooks"
  147 + "srs_app_json" "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge"
  148 + "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client"
  149 + "srs_app_recv_thread" "srs_app_security" "srs_app_statistic"
  150 + "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener")
  151 + APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
  152 + APP_OBJS="${MODULE_OBJS[@]}"
  153 +fi
  154 +#
  155 +#LIBS Module, build libsrs.a for static link.
  156 +MODULE_ID="LIBS"
  157 +MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
  158 +ModuleLibIncs=(${SRS_OBJS_DIR})
  159 +MODULE_FILES=("srs_librtmp" "srs_lib_simple_socket" "srs_lib_bandwidth")
  160 +LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh
  161 +LIBS_OBJS="${MODULE_OBJS[@]}"
  162 +#
  163 +#Main Module
  164 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  165 + MODULE_ID="MAIN"
  166 + MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
  167 + ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibHttpParserRoot})
  168 + MODULE_FILES=("srs_main_server")
  169 + MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
  170 + MAIN_OBJS="${MODULE_OBJS[@]}"
  171 +fi
  172 +
  173 +#####################################################################################
  174 +# Binaries, main entrances, link the module and its depends modules,
  175 +# then link to a binary, for example, objs/srs
  176 +#
  177 +# disable all app when export librtmp
  178 +if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
  179 + # all main entrances
  180 + MAIN_ENTRANCES=("srs_main_server")
  181 + #
  182 + # all depends libraries
  183 + ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile} ${LibGperfFile})
  184 + # all depends objects
  185 + MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"
  186 + LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}"
  187 + #
  188 + # srs:
  189 + # srs(simple rtmp server) over st(state-threads)
  190 + BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
  191 +fi
  192 +# srs librtmp
  193 +if [ $SRS_LIBRTMP = YES ]; then
  194 + MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${LIBS_OBJS[@]}"
  195 + BUILD_KEY="librtmp" LIB_NAME="lib/srs_librtmp" . auto/libs.sh
  196 +fi
  197 +#
  198 +# utest, the unit-test cases of srs, base on gtest1.6
  199 +if [ $SRS_UTEST = YES ]; then
  200 + MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol"
  201 + "srs_utest_kernel" "srs_utest_core" "srs_utest_config"
  202 + "srs_utest_reload")
  203 + ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
  204 + ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile})
  205 + MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
  206 + MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]}"
  207 + LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh
  208 +fi
  209 +
  210 +#####################################################################################
52 # generate colorful summary script 211 # generate colorful summary script
53 . auto/summary.sh 212 . auto/summary.sh
54 213
@@ -231,165 +390,6 @@ _prepare_dir: @@ -231,165 +390,6 @@ _prepare_dir:
231 @mkdir -p ${SRS_OBJS_DIR} 390 @mkdir -p ${SRS_OBJS_DIR}
232 END 391 END
233 392
234 -#####################################################################################  
235 -# build tools or compiler args.  
236 -# enable gdb debug  
237 -GDBDebug=" -g -O0"  
238 -# the warning level.  
239 -WarnLevel=" -Wall"  
240 -# the compile standard.  
241 -CppStd="-ansi"  
242 -# for library compile  
243 -LibraryCompile=" -fPIC"  
244 -# performance of gprof  
245 -SrsGprof=""; SrsGprofLink=""; if [ $SRS_GPROF = YES ]; then SrsGprof=" -pg -lc_p"; SrsGprofLink=" -pg"; fi  
246 -# performance of gperf  
247 -SrsGperf=""; SrsGperfLink=""; if [ $SRS_GPERF = YES ]; then SrsGperfLink=" -lpthread"; fi  
248 -# the cxx flag generated.  
249 -CXXFLAGS="${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}"  
250 -if [ $SRS_GPERF = YES ]; then CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"; fi  
251 -cat << END > ${SRS_OBJS}/${SRS_MAKEFILE}  
252 -GCC = gcc  
253 -CXX = g++  
254 -AR = ar  
255 -LINK = g++  
256 -CXXFLAGS = ${CXXFLAGS}  
257 -  
258 -.PHONY: default srs librtmp  
259 -  
260 -default:  
261 -  
262 -END  
263 -  
264 -#####################################################################################  
265 -# Libraries, external library to build in srs,  
266 -# header(.h): add to ModuleLibIncs if need the specified library. for example, LibSTRoot  
267 -# library(.a): add to ModuleLibFiles if binary need the specifeid library. for example, LibSTfile  
268 -#  
269 -# st(state-threads) the basic network library for SRS.  
270 -LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a"  
271 -# hp(http-parser) the http request/url parser, for SRS to support HTTP callback.  
272 -LibHttpParserRoot=""; LibHttpParserfile=""  
273 -if [ $SRS_HTTP_PARSER = YES ]; then LibHttpParserRoot="${SRS_OBJS_DIR}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi  
274 -# openssl-1.0.1f, for the RTMP complex handshake.  
275 -LibSSLRoot="";LibSSLfile=""  
276 -if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS_OBJS_DIR}/openssl/include"; LibSSLfile="${SRS_OBJS_DIR}/openssl/lib/libssl.a ${SRS_OBJS_DIR}/openssl/lib/libcrypto.a"; fi fi  
277 -# gperftools-2.1, for mem check and mem/cpu profile  
278 -LibGperfRoot=""; LibGperfFile=""  
279 -if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS_DIR}/gperf/include"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_and_profiler.a"; fi  
280 -# the link options, always use static link  
281 -SrsLinkOptions="-ldl";  
282 -if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lssl"; fi fi  
283 -# if static specified, add static  
284 -# TODO: FIXME: remove static.  
285 -if [ $SRS_STATIC = YES ]; then SrsLinkOptions="${SrsLinkOptions} -static"; fi  
286 -# if mips, add -lgcc_eh, or stl compile failed.  
287 -if [ $SRS_MIPS_UBUNTU12 = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lgcc_eh"; fi  
288 -  
289 -#####################################################################################  
290 -# Modules, compile each module, then link to binary  
291 -#  
292 -#Core, depends only on system apis.  
293 -MODULE_ID="CORE"  
294 -MODULE_DEPENDS=()  
295 -ModuleLibIncs=(${SRS_OBJS_DIR})  
296 -MODULE_FILES=("srs_core" "srs_core_autofree" "srs_core_performance")  
297 -CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh  
298 -CORE_OBJS="${MODULE_OBJS[@]}"  
299 -#  
300 -#Kernel, depends on core, provides error/log/config, nothing about stream information.  
301 -MODULE_ID="KERNEL"  
302 -MODULE_DEPENDS=("CORE")  
303 -ModuleLibIncs=(${SRS_OBJS_DIR})  
304 -MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream"  
305 - "srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_file"  
306 - "srs_kernel_consts" "srs_kernel_aac" "srs_kernel_mp3" "srs_kernel_ts"  
307 - "srs_kernel_buffer")  
308 -KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh  
309 -KERNEL_OBJS="${MODULE_OBJS[@]}"  
310 -#  
311 -#RTMP Protocol, depends on core/kernel, provides rtmp/htttp protocol features.  
312 -MODULE_ID="RTMP"  
313 -MODULE_DEPENDS=("CORE" "KERNEL")  
314 -ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})  
315 -MODULE_FILES=("srs_rtmp_amf0" "srs_rtmp_io" "srs_rtmp_stack" "srs_rtmp_sdk"  
316 - "srs_rtmp_handshake" "srs_rtmp_utility" "srs_rtmp_msg_array" "srs_rtmp_buffer"  
317 - "srs_raw_avc" "srs_rtsp_stack")  
318 -RTMP_INCS="src/protocol"; MODULE_DIR=${RTMP_INCS} . auto/modules.sh  
319 -RTMP_OBJS="${MODULE_OBJS[@]}"  
320 -#  
321 -#App Module  
322 -if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then  
323 - MODULE_ID="APP"  
324 - MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")  
325 - ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS_DIR})  
326 - MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_st_socket" "srs_app_source"  
327 - "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http"  
328 - "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"  
329 - "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" "srs_app_http_conn" "srs_app_http_hooks"  
330 - "srs_app_json" "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge"  
331 - "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client"  
332 - "srs_app_recv_thread" "srs_app_security" "srs_app_statistic"  
333 - "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener")  
334 - APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh  
335 - APP_OBJS="${MODULE_OBJS[@]}"  
336 -fi  
337 -#  
338 -#LIBS Module, build libsrs.a for static link.  
339 -MODULE_ID="LIBS"  
340 -MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")  
341 -ModuleLibIncs=(${SRS_OBJS_DIR})  
342 -MODULE_FILES=("srs_librtmp" "srs_lib_simple_socket" "srs_lib_bandwidth")  
343 -LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh  
344 -LIBS_OBJS="${MODULE_OBJS[@]}"  
345 -#  
346 -#Main Module  
347 -if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then  
348 - MODULE_ID="MAIN"  
349 - MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")  
350 - ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibHttpParserRoot})  
351 - MODULE_FILES=("srs_main_server")  
352 - MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh  
353 - MAIN_OBJS="${MODULE_OBJS[@]}"  
354 -fi  
355 -  
356 -#####################################################################################  
357 -# Binaries, main entrances, link the module and its depends modules,  
358 -# then link to a binary, for example, objs/srs  
359 -#  
360 -# disable all app when export librtmp  
361 -if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then  
362 - # all main entrances  
363 - MAIN_ENTRANCES=("srs_main_server")  
364 - #  
365 - # all depends libraries  
366 - ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile} ${LibGperfFile})  
367 - # all depends objects  
368 - MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]} ${MAIN_OBJS[@]}"  
369 - LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}"  
370 - #  
371 - # srs:  
372 - # srs(simple rtmp server) over st(state-threads)  
373 - BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh  
374 -fi  
375 -# srs librtmp  
376 -if [ $SRS_LIBRTMP = YES ]; then  
377 - MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${LIBS_OBJS[@]}"  
378 - BUILD_KEY="librtmp" LIB_NAME="lib/srs_librtmp" . auto/libs.sh  
379 -fi  
380 -#  
381 -# utest, the unit-test cases of srs, base on gtest1.6  
382 -if [ $SRS_UTEST = YES ]; then  
383 - MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol"  
384 - "srs_utest_kernel" "srs_utest_core" "srs_utest_config"  
385 - "srs_utest_reload")  
386 - ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})  
387 - ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile})  
388 - MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")  
389 - MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]}"  
390 - LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh  
391 -fi  
392 -  
393 echo 'configure ok! ' 393 echo 'configure ok! '
394 394
395 ##################################################################################### 395 #####################################################################################