libs.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "Generating lib ${LIB_NAME} depends."
  15. echo "" >> ${FILE}
  16. echo "# archive library ${LIB_TAGET_STATIC}" >> ${FILE}
  17. echo "${BUILD_KEY}: ${LIB_TAGET_STATIC}" >> ${FILE}
  18. echo "" >> ${FILE}
  19. # build depends
  20. echo -n "${LIB_TAGET_STATIC}: " >> ${FILE}
  21. for item in ${MODULE_OBJS[*]}; do
  22. FILE_NAME=`basename $item`
  23. FILE_NAME=${FILE_NAME%.*}
  24. if [ ! -f ${item} ]; then
  25. continue;
  26. fi
  27. OBJ_FILE=${SRS_OBJS_DIR}/$item
  28. OBJ_FILE="${OBJ_FILE%.*}.o"
  29. echo -n "${OBJ_FILE} " >> ${FILE}
  30. done
  31. echo "" >> ${FILE}
  32. # build header file
  33. echo -n " @bash auto/generate_header.sh ${SRS_OBJS_DIR}" >> ${FILE}
  34. echo "" >> ${FILE}
  35. # archive librtmp.a
  36. echo -n " \$(AR) \$(ARFLAGS) ${LIB_TAGET_STATIC} " >> ${FILE}
  37. for item in ${MODULE_OBJS[*]}; do
  38. FILE_NAME=`basename $item`
  39. FILE_NAME=${FILE_NAME%.*}
  40. if [ ! -f ${item} ]; then
  41. continue;
  42. fi
  43. OBJ_FILE=${SRS_OBJS_DIR}/$item
  44. OBJ_FILE="${OBJ_FILE%.*}.o"
  45. echo -n "${OBJ_FILE} " >> ${FILE}
  46. done
  47. echo "" >> ${FILE}
  48. # parent Makefile, to create module output dir before compile it.
  49. echo " @mkdir -p ${SRS_OBJS_DIR}/include" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  50. echo " @mkdir -p ${SRS_OBJS_DIR}/lib" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  51. echo -n "Generate lib ${LIB_NAME} ok"; echo '!';