2
0

auto_headers.sh 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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_BACKTRACE == YES ]]; then
  60. srs_define_macro "SRS_BACKTRACE" $SRS_AUTO_HEADERS_H
  61. else
  62. srs_undefine_macro "SRS_BACKTRACE" $SRS_AUTO_HEADERS_H
  63. fi
  64. if [[ $SRS_RTC == YES ]]; then
  65. srs_define_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
  66. else
  67. srs_undefine_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
  68. fi
  69. if [[ $SRS_FFMPEG_FIT == YES ]]; then
  70. srs_define_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
  71. else
  72. srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
  73. fi
  74. if [[ $SRS_FFMPEG_OPUS == YES ]]; then
  75. srs_define_macro "SRS_FFMPEG_OPUS" $SRS_AUTO_HEADERS_H
  76. else
  77. srs_undefine_macro "SRS_FFMPEG_OPUS" $SRS_AUTO_HEADERS_H
  78. fi
  79. if [[ $SRS_SIMULATOR == YES ]]; then
  80. srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
  81. else
  82. srs_undefine_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
  83. fi
  84. if [[ $SRS_HTTPS == YES ]]; then
  85. srs_define_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
  86. else
  87. srs_undefine_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
  88. fi
  89. if [[ $SRS_GB28181 == YES ]]; then
  90. srs_define_macro "SRS_GB28181" $SRS_AUTO_HEADERS_H
  91. else
  92. srs_undefine_macro "SRS_GB28181" $SRS_AUTO_HEADERS_H
  93. fi
  94. if [[ $SRS_APM == YES ]]; then
  95. srs_define_macro "SRS_APM" $SRS_AUTO_HEADERS_H
  96. else
  97. srs_undefine_macro "SRS_APM" $SRS_AUTO_HEADERS_H
  98. fi
  99. if [[ $SRS_UTEST == YES ]]; then
  100. srs_define_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H
  101. else
  102. srs_undefine_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H
  103. fi
  104. # whatever the FFMPEG tools, if transcode and ingest specified,
  105. # srs always compile the FFMPEG tool stub which used to start the FFMPEG process.
  106. if [[ $SRS_FFMPEG_STUB == YES ]]; then
  107. srs_define_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
  108. else
  109. srs_undefine_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
  110. fi
  111. if [[ $SRS_GPERF == YES ]]; then
  112. srs_define_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
  113. else
  114. srs_undefine_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
  115. fi
  116. if [[ $SRS_GPERF_MC == YES ]]; then
  117. srs_define_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
  118. else
  119. srs_undefine_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
  120. fi
  121. if [[ $SRS_GPERF_MD == YES ]]; then
  122. srs_define_macro "SRS_GPERF_MD" $SRS_AUTO_HEADERS_H
  123. else
  124. srs_undefine_macro "SRS_GPERF_MD" $SRS_AUTO_HEADERS_H
  125. fi
  126. if [[ $SRS_GPERF_MP == YES ]]; then
  127. srs_define_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
  128. else
  129. srs_undefine_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
  130. fi
  131. if [[ $SRS_GPERF_CP == YES ]]; then
  132. srs_define_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
  133. else
  134. srs_undefine_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
  135. fi
  136. if [ $SRS_SANITIZER == YES ]; then
  137. srs_define_macro "SRS_SANITIZER" $SRS_AUTO_HEADERS_H
  138. else
  139. srs_undefine_macro "SRS_SANITIZER" $SRS_AUTO_HEADERS_H
  140. fi
  141. if [ $SRS_SANITIZER_LOG == YES ]; then
  142. srs_define_macro "SRS_SANITIZER_LOG" $SRS_AUTO_HEADERS_H
  143. else
  144. srs_undefine_macro "SRS_SANITIZER_LOG" $SRS_AUTO_HEADERS_H
  145. fi
  146. #####################################################################################
  147. # for embeded.
  148. #####################################################################################
  149. # for log level compile settings
  150. if [[ $SRS_LOG_VERBOSE == YES ]]; then
  151. srs_define_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
  152. else
  153. srs_undefine_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
  154. fi
  155. if [[ $SRS_LOG_INFO == YES ]]; then
  156. srs_define_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
  157. else
  158. srs_undefine_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
  159. fi
  160. if [[ $SRS_LOG_TRACE == YES ]]; then
  161. srs_define_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
  162. else
  163. srs_undefine_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
  164. fi
  165. if [[ $SRS_SINGLE_THREAD == YES ]]; then
  166. srs_define_macro "SRS_SINGLE_THREAD" $SRS_AUTO_HEADERS_H
  167. else
  168. srs_undefine_macro "SRS_SINGLE_THREAD" $SRS_AUTO_HEADERS_H
  169. fi
  170. if [[ $SRS_LOG_LEVEL_V2 == YES ]]; then
  171. srs_define_macro "SRS_LOG_LEVEL_V2" $SRS_AUTO_HEADERS_H
  172. else
  173. srs_undefine_macro "SRS_LOG_LEVEL_V2" $SRS_AUTO_HEADERS_H
  174. fi
  175. if [[ $SRS_CROSS_BUILD == YES ]]; then
  176. srs_define_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
  177. else
  178. srs_undefine_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
  179. fi
  180. if [[ $SRS_CYGWIN64 == YES ]]; then
  181. srs_define_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
  182. else
  183. srs_undefine_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
  184. fi
  185. if [[ $SRS_OSX == YES ]]; then
  186. srs_define_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
  187. else
  188. srs_undefine_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
  189. fi
  190. if [[ $SRS_DEBUG == YES ]]; then
  191. srs_define_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
  192. else
  193. srs_undefine_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
  194. fi
  195. if [[ $SRS_DEBUG_STATS == YES ]]; then
  196. srs_define_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
  197. else
  198. srs_undefine_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
  199. fi
  200. # prefix
  201. echo "" >> $SRS_AUTO_HEADERS_H
  202. echo "#define SRS_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H
  203. echo "#define SRS_DEFAULT_CONFIG \"${SRS_DEFAULT_CONFIG}\"" >> $SRS_AUTO_HEADERS_H
  204. echo "" >> $SRS_AUTO_HEADERS_H
  205. #####################################################################################
  206. # generated the contributors from AUTHORS.txt
  207. #####################################################################################
  208. if [[ -f AUTHORS.md ]]; then
  209. RTMP_SIG_SRS_AUTHORS=$(cat AUTHORS.md|grep "^-"|awk -F '`' '{print $2}')
  210. echo "#define RTMP_SIG_SRS_AUTHORS \"\\" >> $SRS_AUTO_HEADERS_H
  211. for CONTRIBUTOR in $RTMP_SIG_SRS_AUTHORS; do
  212. echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
  213. done
  214. echo "\"" >> $SRS_AUTO_HEADERS_H
  215. else
  216. echo "#define RTMP_SIG_SRS_AUTHORS \"ossrs\"" >> $SRS_AUTO_HEADERS_H
  217. fi
  218. # new empty line to auto headers file.
  219. echo "" >> $SRS_AUTO_HEADERS_H
  220. #####################################################################################
  221. # auto header EOF.
  222. #####################################################################################
  223. echo "#endif" >> $SRS_AUTO_HEADERS_H
  224. echo "" >> $SRS_AUTO_HEADERS_H