winlin

use relative objs dir for makefile. for bug #191

# generate the binary
#
# params:
# $SRS_OBJS the objs directory. ie. objs
# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
# $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
# $SRS_MAKEFILE the makefile name. ie. Makefile
#
# $MAIN_ENTRANCES array, disable all except the $APP_MAIN itself. ie. ["srs_main_server" "srs_main_bandcheck"]
... ... @@ -14,7 +15,7 @@
FILE=${SRS_OBJS}/${SRS_MAKEFILE}
APP_TARGET="${SRS_OBJS}/${APP_NAME}"
APP_TARGET="${SRS_OBJS_DIR}/${APP_NAME}"
echo "generate app ${APP_NAME} depends...";
... ... @@ -45,7 +46,7 @@ for item in ${MODULE_OBJS[*]}; do
continue;
fi
OBJ_FILE=${SRS_OBJS}/$item
OBJ_FILE=${SRS_OBJS_DIR}/$item
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
... ... @@ -76,7 +77,7 @@ for item in ${MODULE_OBJS[*]}; do
continue;
fi
OBJ_FILE=${SRS_OBJS}/$item
OBJ_FILE=${SRS_OBJS_DIR}/$item
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
... ...
... ... @@ -582,21 +582,23 @@ fi
#####################################################################################
# build research code, librtmp
#####################################################################################
if [ $SRS_RESEARCH = YES ]; then
mkdir -p ${SRS_OBJS}/research
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
if [ $SRS_RESEARCH = YES ]; then
mkdir -p ${SRS_OBJS}/research
(cd research/hls && make ${SRS_JOBS} && mv ts_info ../../${SRS_OBJS}/research)
ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi
(cd ${SRS_WORKDIR}/research/hls && make ${SRS_JOBS} && mv ts_info ../../${SRS_OBJS_DIR}/research)
ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi
(cd research/ffempty && make ${SRS_JOBS} && mv ffempty ../../${SRS_OBJS}/research)
ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi
(cd research/ffempty && make ${SRS_JOBS} && mv ffempty ../../${SRS_OBJS_DIR}/research)
ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi
fi
fi
if [ $SRS_LIBRTMP = YES ]; then
mkdir -p ${SRS_OBJS}/research
# librtmp
(cd research/librtmp && mkdir -p objs && ln -sf `pwd`/objs ../../${SRS_OBJS}/research/librtmp)
(cd ${SRS_WORKDIR}/research/librtmp && mkdir -p objs && ln -sf `pwd`/objs ../../${SRS_OBJS_DIR}/research/librtmp)
ret=$?; if [[ $ret -ne 0 ]]; then echo "link research/librtmp failed, ret=$ret"; exit $ret; fi
fi
... ...
# generate the library for static link.
#
# params:
# $SRS_OBJS the objs directory. ie. objs
# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
# $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
# $SRS_MAKEFILE the makefile name. ie. Makefile
#
# $BUILD_KEY a string indicates the build key for Makefile. ie. dump
... ... @@ -10,7 +11,7 @@
FILE=${SRS_OBJS}/${SRS_MAKEFILE}
LIB_TARGET="${SRS_OBJS}/${LIB_NAME}"
LIB_TARGET="${SRS_OBJS_DIR}/${LIB_NAME}"
LIB_TAGET_STATIC="${LIB_TARGET}.a"
echo "generate lib ${LIB_NAME} depends..."
... ... @@ -29,14 +30,14 @@ for item in ${MODULE_OBJS[*]}; do
continue;
fi
OBJ_FILE=${SRS_OBJS}/$item
OBJ_FILE=${SRS_OBJS_DIR}/$item
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
echo "" >> ${FILE}
# build header file
echo -n " @bash auto/generate_header.sh ${SRS_OBJS}" >> ${FILE}
echo -n " @bash auto/generate_header.sh ${SRS_OBJS_DIR}" >> ${FILE}
echo "" >> ${FILE}
# archive librtmp.a
... ... @@ -49,14 +50,14 @@ for item in ${MODULE_OBJS[*]}; do
continue;
fi
OBJ_FILE=${SRS_OBJS}/$item
OBJ_FILE=${SRS_OBJS_DIR}/$item
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
echo "" >> ${FILE}
# parent Makefile, to create module output dir before compile it.
echo " mkdir -p ${SRS_OBJS}/include" >> ${SRS_MAKEFILE}
echo " mkdir -p ${SRS_OBJS}/lib" >> ${SRS_MAKEFILE}
echo " mkdir -p ${SRS_OBJS_DIR}/include" >> ${SRS_MAKEFILE}
echo " mkdir -p ${SRS_OBJS_DIR}/lib" >> ${SRS_MAKEFILE}
echo -n "generate lib ${LIB_NAME} ok"; echo '!';
... ...
# generate the module info to Makefile
#
# params:
# $SRS_OBJS the objs directory. ie. objs
# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
# $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
# $SRS_MAKEFILE the makefile name. ie. Makefile
#
# $MODULE_DIR the module dir. ie. src/os/linux
... ... @@ -73,7 +74,7 @@ echo "# OBJ for ${MODULE_ID}, each object file" >> ${FILE}
MODULE_OBJS=()
for item in ${MODULE_FILES[*]}; do
CPP_FILE="${MODULE_DIR}/${item}.cpp"
OBJ_FILE="${SRS_OBJS}/${MODULE_DIR}/${item}.o"
OBJ_FILE="${SRS_OBJS_DIR}/${MODULE_DIR}/${item}.o"
MODULE_OBJS="${MODULE_OBJS[@]} ${CPP_FILE}"
if [ -f ${CPP_FILE} ]; then
echo "${OBJ_FILE}: \$(${DEPS_NAME}) ${CPP_FILE} " >> ${FILE}
... ... @@ -84,6 +85,6 @@ done
echo "" >> ${FILE}
# parent Makefile, to create module output dir before compile it.
echo " mkdir -p ${SRS_OBJS}/${MODULE_DIR}" >> ${SRS_MAKEFILE}
echo " mkdir -p ${SRS_OBJS_DIR}/${MODULE_DIR}" >> ${SRS_MAKEFILE}
echo -n "generate module ${MODULE_ID} ok"; echo '!';
... ...
# generate utest Makefile
#
# params:
# $SRS_OBJS the objs directory. ie. objs
# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
# $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
# $SRS_MAKEFILE the makefile name. ie. Makefile
#
# $APP_NAME the app name to output. ie. srs_utest
... ... @@ -17,10 +18,10 @@ mkdir -p ${SRS_OBJS}/utest
# trunk of srs, which contains the src dir, relative to objs/utest, it's trunk
SRS_TRUNK_PREFIX=../..
# gest dir, relative to objs/utest, it's trunk/objs/gtest
GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS}/gtest
GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/gtest
cat << END > ${FILE}
# user must run make the ${SRS_OBJS}/utest dir
# user must run make the ${SRS_OBJS_DIR}/utest dir
# at the same dir of Makefile.
# A sample Makefile for building Google Test and using it in user
... ... @@ -52,7 +53,7 @@ CXXFLAGS += -g -Wall -Wextra -O0
# All tests produced by this Makefile. Remember to add new tests you
# created to the list.
TESTS = ${SRS_TRUNK_PREFIX}/${SRS_OBJS}/${APP_NAME}
TESTS = ${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/${APP_NAME}
# All Google Test headers. Usually you shouldn't change this
# definition.
... ... @@ -129,7 +130,7 @@ echo "# Depends, the depends objects" >> ${FILE}
echo -n "SRS_UTEST_DEPS = " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=${item%.*}
echo -n "${SRS_TRUNK_PREFIX}/${SRS_OBJS}/${FILE_NAME}.o " >> ${FILE}
echo -n "${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/${FILE_NAME}.o " >> ${FILE}
done
echo "" >> ${FILE}; echo "" >> ${FILE}
#
... ... @@ -169,12 +170,12 @@ echo "" >> ${FILE}; echo "" >> ${FILE}
#
echo "# generate the utest binary" >> ${FILE}
cat << END >> ${FILE}
${SRS_TRUNK_PREFIX}/${SRS_OBJS}/${APP_NAME} : \$(SRS_UTEST_DEPS) ${MODULE_OBJS} gtest_main.a
${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/${APP_NAME} : \$(SRS_UTEST_DEPS) ${MODULE_OBJS} gtest_main.a
\$(CXX) -o \$@ \$(CPPFLAGS) \$(CXXFLAGS) \$^ \$(DEPS_LIBRARIES_FILES) ${LINK_OPTIONS}
END
#####################################################################################
# parent Makefile, to create module output dir before compile it.
echo " mkdir -p ${SRS_OBJS}/utest" >> ${SRS_MAKEFILE}
echo " mkdir -p ${SRS_OBJS_DIR}/utest" >> ${SRS_MAKEFILE}
echo -n "generate utest ok"; echo '!';
... ...
... ... @@ -4,8 +4,9 @@
# the main output dir, all configure and make output are in this dir.
#####################################################################################
# create the main objs
SRS_WORKDIR="./"
SRS_OBJS="${SRS_WORKDIR}/objs"
SRS_WORKDIR="."
SRS_OBJS_DIR="objs"
SRS_OBJS="${SRS_WORKDIR}/${SRS_OBJS_DIR}"
mkdir -p ${SRS_OBJS}
#####################################################################################
... ... @@ -30,10 +31,12 @@ if [ $SRS_EXPORT_LIBRTMP != NO ]; then
exit 1
fi
# create target
SRS_WORKDIR=${SRS_EXPORT_LIBRTMP} && SRS_OBJS=${SRS_WORKDIR}/objs && mkdir -p ${SRS_OBJS} &&
SRS_WORKDIR=${SRS_EXPORT_LIBRTMP} && SRS_OBJS=${SRS_WORKDIR}/${SRS_OBJS_DIR} && mkdir -p ${SRS_OBJS} &&
# copy src to target
_CPT=${SRS_EXPORT_LIBRTMP}/3rdparty && mkdir -p ${_CPT} && cp 3rdparty/st-1.9.zip ${_CPT} &&
_CPT=${SRS_EXPORT_LIBRTMP}/3rdparty/patches && mkdir -p ${_CPT} && cp 3rdparty/patches/1.st.arm.patch ${_CPT} &&
_CPT=${SRS_EXPORT_LIBRTMP}/research/librtmp && mkdir -p ${_CPT} && cp research/librtmp/*.c ${_CPT} && cp research/librtmp/Makefile ${_CPT} &&
_CPT=${SRS_EXPORT_LIBRTMP}/src/core && mkdir -p ${_CPT} && cp src/core/* ${_CPT}
# check ret
ret=$?; if [[ $ret -ne 0 ]]; then echo "export src failed, ret=$ret"; exit $ret; fi
fi
... ... @@ -119,7 +122,7 @@ SrsLibrtmpSampleEntry="nossl"
if [ $SRS_SSL = YES ]; then SrsLibrtmpSampleEntry="ssl";fi
# utest make entry, (cd utest; make)
SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\""
if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS}/utest; \$(MAKE))"; fi
if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/utest; \$(MAKE))"; fi
#####################################################################################
# generate colorful summary script
... ... @@ -172,9 +175,9 @@ help:
@echo " uninstall uninstall srs from prefix path"
clean:
(cd ${SRS_OBJS}; rm -rf srs srs_utest)
(cd ${SRS_OBJS}; rm -rf src research include lib)
(cd ${SRS_OBJS}/utest; rm -rf *.o *.a)
(cd ${SRS_OBJS_DIR}; rm -rf srs srs_utest)
(cd ${SRS_OBJS_DIR}; rm -rf src research include lib)
(cd ${SRS_OBJS_DIR}/utest; rm -rf *.o *.a)
(cd research/librtmp; make clean)
(cd research/api-server/static-dir; rm -rf crossdomain.xml forward live players)
... ... @@ -191,7 +194,7 @@ else
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
server: _prepare_dir
@echo "build the srs(simple rtmp server) over st(state-threads)"
\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} srs
\$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} srs
END
fi
... ... @@ -269,7 +272,7 @@ if [ $SRS_LIBRTMP = YES ]; then
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
librtmp: server
@echo "build the client publish/play library."
\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} librtmp
\$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} librtmp
@echo "build the srs-librtmp sample"
(cd research/librtmp; \$(MAKE) ${SrsLibrtmpSampleEntry})
... ... @@ -301,7 +304,7 @@ fi
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
# the ./configure will generate it.
_prepare_dir:
@mkdir -p ${SRS_OBJS}
@mkdir -p ${SRS_OBJS_DIR}
END
#####################################################################################
... ... @@ -340,16 +343,16 @@ END
# library(.a): add to ModuleLibFiles if binary need the specifeid library. for example, LibSTfile
#
# st(state-threads) the basic network library for SRS.
LibSTRoot="${SRS_OBJS}/st"; LibSTfile="${LibSTRoot}/libst.a"
LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a"
# hp(http-parser) the http request/url parser, for SRS to support HTTP callback.
LibHttpParserRoot=""; LibHttpParserfile=""
if [ $SRS_HTTP_PARSER = YES ]; then LibHttpParserRoot="${SRS_OBJS}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi
if [ $SRS_HTTP_PARSER = YES ]; then LibHttpParserRoot="${SRS_OBJS_DIR}/hp"; LibHttpParserfile="${LibHttpParserRoot}/libhttp_parser.a"; fi
# openssl-1.0.1f, for the RTMP complex handshake.
LibSSLRoot="";LibSSLfile=""
if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = NO ]; then LibSSLRoot="${SRS_OBJS}/openssl/include"; LibSSLfile="${SRS_OBJS}/openssl/lib/libssl.a ${SRS_OBJS}/openssl/lib/libcrypto.a"; fi fi
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
# gperftools-2.1, for mem check and mem/cpu profile
LibGperfRoot=""; LibGperfFile=""
if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS}/gperf/include"; LibGperfFile="${SRS_OBJS}/gperf/lib/libtcmalloc_and_profiler.a"; fi
if [ $SRS_GPERF = YES ]; then LibGperfRoot="${SRS_OBJS_DIR}/gperf/include"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_and_profiler.a"; fi
# the link options, always use static link
SrsLinkOptions="-ldl";
if [ $SRS_SSL = YES ]; then if [ $SRS_USE_SYS_SSL = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lssl"; fi fi
... ... @@ -365,7 +368,7 @@ if [ $SRS_MIPS_UBUNTU12 = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lgcc_eh
#Core, depends only on system apis.
MODULE_ID="CORE"
MODULE_DEPENDS=()
ModuleLibIncs=(${SRS_OBJS})
ModuleLibIncs=(${SRS_OBJS_DIR})
MODULE_FILES=("srs_core" "srs_core_autofree")
CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}"
... ... @@ -373,7 +376,7 @@ CORE_OBJS="${MODULE_OBJS[@]}"
#Kernel, depends on core, provides error/log/config, nothing about stream information.
MODULE_ID="KERNEL"
MODULE_DEPENDS=("CORE")
ModuleLibIncs=(${SRS_OBJS})
ModuleLibIncs=(${SRS_OBJS_DIR})
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream" "srs_kernel_buffer"
"srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_file"
"srs_kernel_consts")
... ... @@ -383,7 +386,7 @@ KERNEL_OBJS="${MODULE_OBJS[@]}"
#RTMP Protocol, depends on core/kernel, provides rtmp/htttp protocol features.
MODULE_ID="RTMP"
MODULE_DEPENDS=("CORE" "KERNEL")
ModuleLibIncs=(${SRS_OBJS} ${LibSSLRoot})
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_protocol_stack" "srs_protocol_rtmp"
"srs_protocol_handshake" "srs_protocol_utility" "srs_protocol_msg_array")
RTMP_INCS="src/rtmp"; MODULE_DIR=${RTMP_INCS} . auto/modules.sh
... ... @@ -393,7 +396,7 @@ RTMP_OBJS="${MODULE_OBJS[@]}"
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
MODULE_ID="APP"
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS})
ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS_DIR})
MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_st_socket" "srs_app_source"
"srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http"
"srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
... ... @@ -407,7 +410,7 @@ fi
#LIBS Module, build libsrs.a for static link.
MODULE_ID="LIBS"
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
ModuleLibIncs=(${SRS_OBJS})
ModuleLibIncs=(${SRS_OBJS_DIR})
MODULE_FILES=("srs_librtmp" "srs_lib_simple_socket" "srs_lib_bandwidth")
LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh
LIBS_OBJS="${MODULE_OBJS[@]}"
... ... @@ -416,7 +419,7 @@ LIBS_OBJS="${MODULE_OBJS[@]}"
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
MODULE_ID="MAIN"
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS} ${LibGperfRoot})
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot})
MODULE_FILES=("srs_main_server")
MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@]}"
... ... @@ -452,7 +455,7 @@ if [ $SRS_UTEST = YES ]; then
MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol"
"srs_utest_kernel" "srs_utest_core" "srs_utest_config"
"srs_utest_reload")
ModuleLibIncs=(${SRS_OBJS} ${LibSTRoot} ${LibSSLRoot})
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile})
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${APP_OBJS[@]}"
... ...