2
0

auto_headers.sh 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #!/bin/bash
  2. # output variables:
  3. # SRS_AUTO_HEADERS_H: the auto generated header file.
  4. SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
  5. # write user options to headers
  6. echo "// auto generated by configure" > $SRS_AUTO_HEADERS_H
  7. echo "#ifndef SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
  8. echo "#define SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
  9. echo "" >> $SRS_AUTO_HEADERS_H
  10. echo "#define SRS_PACKAGER \"${SRS_AUTO_PACKAGER}\"" >> $SRS_AUTO_HEADERS_H
  11. echo "#define SRS_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
  12. echo "#define SRS_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
  13. echo "#define SRS_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
  14. echo "#define SRS_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
  15. echo "#define SRS_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
  16. echo "" >> $SRS_AUTO_HEADERS_H
  17. function srs_define_macro()
  18. {
  19. macro=$1 && file=$2
  20. echo "#define $macro" >> $file
  21. echo "#define ${macro}_BOOL true" >> $file
  22. }
  23. function srs_define_macro_value()
  24. {
  25. macro=$1 && value=$2 && file=$3
  26. echo "#define $macro $value" >> $file
  27. echo "#define ${macro}_BOOL true" >> $file
  28. }
  29. function srs_undefine_macro()
  30. {
  31. macro=$1 && file=$2
  32. echo "#undef $macro" >> $file
  33. echo "#define ${macro}_BOOL false" >> $file
  34. }
  35. #####################################################################################
  36. # generate auto headers file, depends on the finished of options.sh
  37. #####################################################################################
  38. # auto headers in depends.
  39. if [ $SRS_HDS = YES ]; then
  40. srs_define_macro "SRS_HDS" $SRS_AUTO_HEADERS_H
  41. else
  42. srs_undefine_macro "SRS_HDS" $SRS_AUTO_HEADERS_H
  43. fi
  44. if [ $SRS_SRT = YES ]; then
  45. srs_define_macro "SRS_SRT" $SRS_AUTO_HEADERS_H
  46. else
  47. srs_undefine_macro "SRS_SRT" $SRS_AUTO_HEADERS_H
  48. fi
  49. if [ $SRS_CXX11 = YES ]; then
  50. srs_define_macro "SRS_CXX11" $SRS_AUTO_HEADERS_H
  51. else
  52. srs_undefine_macro "SRS_CXX11" $SRS_AUTO_HEADERS_H
  53. fi
  54. if [ $SRS_CXX14 = YES ]; then
  55. srs_define_macro "SRS_CXX14" $SRS_AUTO_HEADERS_H
  56. else
  57. srs_undefine_macro "SRS_CXX14" $SRS_AUTO_HEADERS_H
  58. fi
  59. if [ $SRS_RTC = YES ]; then
  60. srs_define_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
  61. else
  62. srs_undefine_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
  63. fi
  64. if [ $SRS_FFMPEG_FIT = YES ]; then
  65. srs_define_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
  66. else
  67. srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
  68. fi
  69. if [ $SRS_SIMULATOR = YES ]; then
  70. srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
  71. else
  72. srs_undefine_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
  73. fi
  74. if [ $SRS_HTTPS = YES ]; then
  75. srs_define_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
  76. else
  77. srs_undefine_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
  78. fi
  79. if [ $SRS_UTEST = YES ]; then
  80. srs_define_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H
  81. else
  82. srs_undefine_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H
  83. fi
  84. # whatever the FFMPEG tools, if transcode and ingest specified,
  85. # srs always compile the FFMPEG tool stub which used to start the FFMPEG process.
  86. if [ $SRS_FFMPEG_STUB = YES ]; then
  87. srs_define_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
  88. else
  89. srs_undefine_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
  90. fi
  91. if [ $SRS_GPERF = YES ]; then
  92. srs_define_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
  93. else
  94. srs_undefine_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
  95. fi
  96. if [ $SRS_GPERF_MC = YES ]; then
  97. srs_define_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
  98. else
  99. srs_undefine_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
  100. fi
  101. if [ $SRS_GPERF_MD = YES ]; then
  102. srs_define_macro "SRS_GPERF_MD" $SRS_AUTO_HEADERS_H
  103. else
  104. srs_undefine_macro "SRS_GPERF_MD" $SRS_AUTO_HEADERS_H
  105. fi
  106. if [ $SRS_GPERF_MP = YES ]; then
  107. srs_define_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
  108. else
  109. srs_undefine_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
  110. fi
  111. if [ $SRS_GPERF_CP = YES ]; then
  112. srs_define_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
  113. else
  114. srs_undefine_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
  115. fi
  116. #####################################################################################
  117. # for embeded.
  118. #####################################################################################
  119. # for log level compile settings
  120. if [ $SRS_LOG_VERBOSE = YES ]; then
  121. srs_define_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
  122. else
  123. srs_undefine_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
  124. fi
  125. if [ $SRS_LOG_INFO = YES ]; then
  126. srs_define_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
  127. else
  128. srs_undefine_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
  129. fi
  130. if [ $SRS_LOG_TRACE = YES ]; then
  131. srs_define_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
  132. else
  133. srs_undefine_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
  134. fi
  135. if [ $SRS_CROSS_BUILD = YES ]; then
  136. srs_define_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
  137. else
  138. srs_undefine_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
  139. fi
  140. if [ $SRS_OSX = YES ]; then
  141. srs_define_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
  142. else
  143. srs_undefine_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
  144. fi
  145. if [ $SRS_DEBUG = YES ]; then
  146. srs_define_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
  147. else
  148. srs_undefine_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
  149. fi
  150. if [ $SRS_DEBUG_STATS = YES ]; then
  151. srs_define_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
  152. else
  153. srs_undefine_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
  154. fi
  155. # prefix
  156. echo "" >> $SRS_AUTO_HEADERS_H
  157. echo "#define SRS_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H
  158. echo "#define SRS_DEFAULT_CONFIG \"${SRS_DEFAULT_CONFIG}\"" >> $SRS_AUTO_HEADERS_H
  159. echo "" >> $SRS_AUTO_HEADERS_H
  160. #####################################################################################
  161. # generated the contributors from AUTHORS.txt
  162. #####################################################################################
  163. if [[ -f AUTHORS.txt ]]; then
  164. SRS_CONSTRIBUTORS=`cat AUTHORS.txt|grep "*"|awk '{print $2}'`
  165. echo "#define SRS_CONSTRIBUTORS \"\\" >> $SRS_AUTO_HEADERS_H
  166. for CONTRIBUTOR in $SRS_CONSTRIBUTORS; do
  167. CONTRIBUTOR=`echo $CONTRIBUTOR|sed 's/@users.noreply.github.com>/@github>/g'`
  168. echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
  169. done
  170. echo "\"" >> $SRS_AUTO_HEADERS_H
  171. else
  172. echo "#define SRS_CONSTRIBUTORS \"ossrs\"" >> $SRS_AUTO_HEADERS_H
  173. fi
  174. # new empty line to auto headers file.
  175. echo "" >> $SRS_AUTO_HEADERS_H
  176. #####################################################################################
  177. # auto header EOF.
  178. #####################################################################################
  179. echo "#endif" >> $SRS_AUTO_HEADERS_H
  180. echo "" >> $SRS_AUTO_HEADERS_H