winlin

refine build for modules, add defines.

@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 # $MODULE_DEPENDS array, the denpend MODULEs id. ie. (CORE OS) 10 # $MODULE_DEPENDS array, the denpend MODULEs id. ie. (CORE OS)
11 # $ModuleLibIncs array, the depend 3rdpart library includes. ie. (objs/st-1.9/obj objs/libx264/obj) 11 # $ModuleLibIncs array, the depend 3rdpart library includes. ie. (objs/st-1.9/obj objs/libx264/obj)
12 # $MODULE_FILES array, the head/cpp files of modules. ie. (public log) 12 # $MODULE_FILES array, the head/cpp files of modules. ie. (public log)
  13 +# $DEFINES string, the build macro defines. ie. "-DMY_SRS"
13 # 14 #
14 # returns: 15 # returns:
15 # $MODULE_OBJS array, the objects of the modules, used for link the binary 16 # $MODULE_OBJS array, the objects of the modules, used for link the binary
@@ -78,7 +79,7 @@ for item in ${MODULE_FILES[*]}; do @@ -78,7 +79,7 @@ for item in ${MODULE_FILES[*]}; do
78 MODULE_OBJS="${MODULE_OBJS[@]} ${CPP_FILE}" 79 MODULE_OBJS="${MODULE_OBJS[@]} ${CPP_FILE}"
79 if [ -f ${CPP_FILE} ]; then 80 if [ -f ${CPP_FILE} ]; then
80 echo "${OBJ_FILE}: \$(${DEPS_NAME}) ${CPP_FILE} " >> ${FILE} 81 echo "${OBJ_FILE}: \$(${DEPS_NAME}) ${CPP_FILE} " >> ${FILE}
81 - echo " \$(CXX) -c \$(CXXFLAGS) \$(${INCS_NAME})\\" >> ${FILE} 82 + echo " \$(CXX) -c \$(CXXFLAGS) ${DEFINES} \$(${INCS_NAME})\\" >> ${FILE}
82 echo " -o ${OBJ_FILE} ${CPP_FILE}" >> ${FILE} 83 echo " -o ${OBJ_FILE} ${CPP_FILE}" >> ${FILE}
83 fi 84 fi
84 done 85 done
@@ -175,10 +175,12 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then @@ -175,10 +175,12 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
175 "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" 175 "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client"
176 "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds" 176 "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds"
177 "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener") 177 "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener")
  178 + DEFINES=""
178 # add each modules for app 179 # add each modules for app
179 for SRS_MODULE in $SRS_MODULES; do 180 for SRS_MODULE in $SRS_MODULES; do
180 . $SRS_MODULE/config 181 . $SRS_MODULE/config
181 MODULE_FILES+=($SRS_MODULE_APP) 182 MODULE_FILES+=($SRS_MODULE_APP)
  183 + DEFINES="${DEFINES} ${SRS_MODULE_DEFINES}"
182 done 184 done
183 APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh 185 APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
184 APP_OBJS="${MODULE_OBJS[@]}" 186 APP_OBJS="${MODULE_OBJS[@]}"
@@ -7,5 +7,6 @@ SRS模块规则: @@ -7,5 +7,6 @@ SRS模块规则:
7 1. SRS_MODULE_NAME:模块名称,用来做Makefile的phony以及执行binary文件名。 7 1. SRS_MODULE_NAME:模块名称,用来做Makefile的phony以及执行binary文件名。
8 2. SRS_MODULE_MAIN:模块的main函数所在的cpp文件,在src/main目录。 8 2. SRS_MODULE_MAIN:模块的main函数所在的cpp文件,在src/main目录。
9 3. SRS_MODULE_APP:模块在src/app目录的源文件列表。 9 3. SRS_MODULE_APP:模块在src/app目录的源文件列表。
  10 +4. SRS_MODULE_DEFINES: 模块编译时的额外宏定义。
10 11
11 winlin, 2015.3 12 winlin, 2015.3