libs.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # generate the library for static link.
  2. #
  3. # params:
  4. # $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
  5. # $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
  6. # $SRS_MAKEFILE the makefile name. ie. Makefile
  7. #
  8. # $BUILD_KEY a string indicates the build key for Makefile. ie. dump
  9. # $LIB_NAME the app name to output. ie. smart_server
  10. # $MODULE_OBJS array, the objects to compile the app.
  11. FILE=${SRS_OBJS}/${SRS_MAKEFILE}
  12. LIB_TARGET="${SRS_OBJS_DIR}/${LIB_NAME}"
  13. LIB_TAGET_STATIC="${LIB_TARGET}.a"
  14. echo "generate lib ${LIB_NAME} depends..."
  15. echo "" >> ${FILE}
  16. echo "# archive library ${LIB_TAGET_STATIC}" >> ${FILE}
  17. echo "${BUILD_KEY}: ${LIB_TAGET_STATIC}" >> ${FILE}
  18. # build depends
  19. echo -n "${LIB_TAGET_STATIC}: " >> ${FILE}
  20. for item in ${MODULE_OBJS[*]}; do
  21. FILE_NAME=`basename $item`
  22. FILE_NAME=${FILE_NAME%.*}
  23. if [ ! -f ${item} ]; then
  24. continue;
  25. fi
  26. OBJ_FILE=${SRS_OBJS_DIR}/$item
  27. OBJ_FILE="${OBJ_FILE%.*}.o"
  28. echo -n "${OBJ_FILE} " >> ${FILE}
  29. done
  30. echo "" >> ${FILE}
  31. # build header file
  32. echo -n " @bash auto/generate_header.sh ${SRS_OBJS_DIR}" >> ${FILE}
  33. echo "" >> ${FILE}
  34. # archive librtmp.a
  35. echo -n " \$(AR) -rs ${LIB_TAGET_STATIC} " >> ${FILE}
  36. for item in ${MODULE_OBJS[*]}; do
  37. FILE_NAME=`basename $item`
  38. FILE_NAME=${FILE_NAME%.*}
  39. if [ ! -f ${item} ]; then
  40. continue;
  41. fi
  42. OBJ_FILE=${SRS_OBJS_DIR}/$item
  43. OBJ_FILE="${OBJ_FILE%.*}.o"
  44. echo -n "${OBJ_FILE} " >> ${FILE}
  45. done
  46. echo "" >> ${FILE}
  47. # parent Makefile, to create module output dir before compile it.
  48. echo " @mkdir -p ${SRS_OBJS_DIR}/include" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  49. echo " @mkdir -p ${SRS_OBJS_DIR}/lib" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  50. echo -n "generate lib ${LIB_NAME} ok"; echo '!';