1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 20:01:56 +00:00
srs/trunk/auto/apps.sh

92 lines
2.5 KiB
Bash
Raw Normal View History

# generate the binary
#
2013-10-17 12:58:04 +00:00
# params:
# $SRS_OBJS the objs directory. 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"]
# $APP_MAIN the object file that contains main function. ie. srs_main_server
# $BUILD_KEY a string indicates the build key for Makefile. ie. srs
# $APP_NAME the app name to output. ie. srs
# $MODULE_OBJS array, the objects to compile the app.
# $ModuleLibFiles array, the 3rdpart library file to link with. ie. [objs/st-1.9/obj/libst.a objs/libx264/obj/libx264.a]
# $LINK_OPTIONS the linker options. ie. -ldl
2013-10-17 12:58:04 +00:00
2013-11-27 14:41:58 +00:00
FILE=${SRS_OBJS}/${SRS_MAKEFILE}
2013-10-17 12:58:04 +00:00
2013-11-27 14:41:58 +00:00
APP_TARGET="${SRS_OBJS}/${APP_NAME}"
2013-10-17 12:58:04 +00:00
echo "generate app ${APP_NAME} depends...";
echo "# build ${APP_TARGET}" >> ${FILE}
# generate the binary depends, for example:
# srs: objs/srs
2013-10-17 12:58:04 +00:00
echo "${BUILD_KEY}: ${APP_TARGET}" >> ${FILE}
# the link commands, for example:
# objs/srs: objs/src/core/srs_core.o
2013-10-17 12:58:04 +00:00
echo -n "${APP_TARGET}: " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=`basename $item`
FILE_NAME=${FILE_NAME%.*}
ignored=0
for disabled_item in ${MAIN_ENTRANCES[*]}; do
if [[ ${FILE_NAME} == ${disabled_item} && ${FILE_NAME} != ${APP_MAIN} ]]; then
ignored=1
continue;
fi
done
if [ ! -f ${item} ]; then
ignored=1
fi
if [ ${ignored} == 1 ]; then
continue;
fi
2013-11-27 14:41:58 +00:00
OBJ_FILE=${SRS_OBJS}/$item
2013-10-17 12:58:04 +00:00
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
echo "" >> ${FILE}
echo "generate app ${APP_NAME} link...";
# genereate the actual link command, for example:
# $(LINK) -o objs/srs objs/src/core/srs_core.o -ldl
echo -n " \$(LINK) -o ${APP_TARGET} " >> ${FILE}
2013-10-17 12:58:04 +00:00
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=`basename $item`
FILE_NAME=${FILE_NAME%.*}
ignored=0
for disabled_item in ${MAIN_ENTRANCES[*]}; do
if [[ ${FILE_NAME} == ${disabled_item} && ${FILE_NAME} != ${APP_MAIN} ]]; then
ignored=1
continue;
fi
done
if [ ! -f ${item} ]; then
ignored=1
fi
if [ ${ignored} == 1 ]; then
continue;
fi
2013-11-27 14:41:58 +00:00
OBJ_FILE=${SRS_OBJS}/$item
2013-10-17 12:58:04 +00:00
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
# 3rdpart library static link.
for item in ${ModuleLibFiles[*]}; do
echo -n "$item " >> ${FILE}
done
# link options.
echo -n "${LINK_OPTIONS}" >> ${FILE}
echo "" >> ${FILE}
echo -n "generate app ${APP_NAME} ok"; echo '!';