winlin

add library

#!/bin/bash
# genereate the library header file.
objs=$1
... ...
# generate the library for static link.
#
# params:
# $SRS_OBJS the objs directory. ie. objs
# $SRS_MAKEFILE the makefile name. ie. Makefile
#
# $BUILD_KEY a string indicates the build key for Makefile. ie. dump
# $LIB_NAME the app name to output. ie. smart_server
# $MODULE_OBJS array, the objects to compile the app.
# $LINK_OPTIONS the linker options to generate the so(shared library).
FILE=${SRS_OBJS}/${SRS_MAKEFILE}
LIB_TARGET="${SRS_OBJS}/${LIB_NAME}"
LIB_TAGET_STATIC="${LIB_TARGET}.a"
LIB_TAGET_SHARED="${LIB_TARGET}.so"
echo "generate lib ${LIB_NAME} depends..."
echo "" >> ${FILE}
echo "# archive library ${LIB_TAGET_STATIC}" >> ${FILE}
echo "${BUILD_KEY}: ${LIB_TAGET_SHARED}" >> ${FILE}
# build depends
echo -n "${LIB_TAGET_SHARED}: " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=`basename $item`
FILE_NAME=${FILE_NAME%.*}
if [ ! -f ${item} ]; then
continue;
fi
OBJ_FILE=${SRS_OBJS}/$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 "" >> ${FILE}
# archive librtmp.a
echo -n " \$(AR) -rs ${LIB_TAGET_STATIC} " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=`basename $item`
FILE_NAME=${FILE_NAME%.*}
if [ ! -f ${item} ]; then
continue;
fi
OBJ_FILE=${SRS_OBJS}/$item
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
echo "" >> ${FILE}
echo "generate lib ${LIB_NAME} link...";
# archive librtmp.so
echo -n " \$(GCC) -shared -o ${LIB_TAGET_SHARED} " >> ${FILE}
for item in ${MODULE_OBJS[*]}; do
FILE_NAME=`basename $item`
FILE_NAME=${FILE_NAME%.*}
if [ ! -f ${item} ]; then
continue;
fi
OBJ_FILE=${SRS_OBJS}/$item
OBJ_FILE="${OBJ_FILE%.*}.o"
echo -n "${OBJ_FILE} " >> ${FILE}
done
echo -n "${LINK_OPTIONS} " >> ${FILE}
echo "" >> ${FILE}
echo -n "generate lib ${LIB_NAME} ok"; echo '!';
... ...
... ... @@ -42,15 +42,16 @@ echo "" >> $SRS_AUTO_HEADERS_H
echo "generate Makefile"
SRS_MAKEFILE="Makefile"
cat << END > ${SRS_MAKEFILE}
.PHONY: default help clean server bandwidth _prepare_dir
default: server bandwidth
.PHONY: default help clean server bandwidth librtmp _prepare_dir
default: server bandwidth librtmp
help:
@echo "Usage: make <help>|<clean>|<server>|<bandwidth>"
@echo "Usage: make <help>|<clean>|<server>|<bandwidth>|<librtmp>"
@echo " help display this help menu"
@echo " clean cleanup project"
@echo " server build the srs(simple rtmp server) over st(state-threads)"
@echo " bandwidth build the bandwidth test client tool."
@echo " librtmp build the client publish/play library."
clean:
(rm -f Makefile; cd ${SRS_OBJS}; rm -rf srs bandwidth Makefile *.hpp src st_*_load research)
... ... @@ -63,6 +64,10 @@ bandwidth: _prepare_dir
@echo "build the bandwidth test client tool"
\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} bandwidth
librtmp: _prepare_dir
@echo "build the client publish/play library."
\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} librtmp
# the ./configure will generate it.
_prepare_dir:
@mkdir -p ${SRS_OBJS}
... ... @@ -158,6 +163,14 @@ MODULE_FILES=("srs_core_server" "srs_core_conn" "srs_core_client" "srs_core_sock
MODULE_DIR="src/app" . auto/modules.sh
APP_OBJS="${MODULE_OBJS[@]}"
#
#LIBS Module, build libsrs.a for static link.
MODULE_ID="LIBS"
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
ModuleLibIncs=()
MODULE_FILES=("srs_librtmp")
MODULE_DIR="src/libs" . auto/modules.sh
LIBS_OBJS="${MODULE_OBJS[@]}"
#
#Main Module
MODULE_ID="MAIN"
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
... ... @@ -186,6 +199,10 @@ BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
# bandwidth
# bandwidth test tool, to test the bandwidth to server
BUILD_KEY="bandwidth" APP_MAIN="srs_main_bandcheck" APP_NAME="bandwidth" . auto/apps.sh
#
# srs librtmp
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${LIBS_OBJS[@]}"
BUILD_KEY="librtmp" LIB_NAME="srs_librtmp" LINK_OPTIONS="" . auto/libs.sh
echo 'configure ok! '
... ...
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_librtmp.hpp>
... ...
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_LIB_RTMP_HPP
#define SRS_LIB_RTMP_HPP
/*
#include <srs_librtmp.hpp>
*/
#endif
... ...
... ... @@ -4,6 +4,9 @@ file
..\main\srs_main_bandcheck.cpp,
auto readonly separator,
..\..\objs\srs_auto_headers.hpp,
libs readonly separator,
..\libs\srs_librtmp.hpp,
..\libs\srs_librtmp.cpp,
core readonly separator,
..\core\srs_core.hpp,
..\core\srs_core.cpp,
... ...