libs.sh
1.6 KB
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
# 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.
FILE=${SRS_OBJS}/${SRS_MAKEFILE}
LIB_TARGET="${SRS_OBJS}/${LIB_NAME}"
LIB_TAGET_STATIC="${LIB_TARGET}.a"
echo "generate lib ${LIB_NAME} depends..."
echo "" >> ${FILE}
echo "# archive library ${LIB_TAGET_STATIC}" >> ${FILE}
echo "${BUILD_KEY}: ${LIB_TAGET_STATIC}" >> ${FILE}
# build depends
echo -n "${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}
# 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}
# 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 -n "generate lib ${LIB_NAME} ok"; echo '!';