auto_headers.sh 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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_AUTO_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
  11. echo "#define SRS_AUTO_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
  12. echo "#define SRS_AUTO_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
  13. echo "#define SRS_AUTO_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
  14. echo "#define SRS_AUTO_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
  15. echo "" >> $SRS_AUTO_HEADERS_H
  16. # export the preset.
  17. if [ $SRS_OSX = YES ]; then
  18. echo "#define SRS_OSX" >> $SRS_AUTO_HEADERS_H
  19. fi
  20. if [ $SRS_X86_X64 = YES ]; then
  21. echo "#define SRS_X86_X64" >> $SRS_AUTO_HEADERS_H
  22. fi
  23. if [ $SRS_ARM_UBUNTU12 = YES ]; then
  24. echo "#define SRS_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
  25. fi
  26. if [ $SRS_MIPS_UBUNTU12 = YES ]; then
  27. echo "#define SRS_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
  28. fi
  29. if [ $SRS_PI = YES ]; then
  30. echo "#define SRS_PI" >> $SRS_AUTO_HEADERS_H
  31. fi
  32. if [ $SRS_CUBIE = YES ]; then
  33. echo "#define SRS_CUBIE" >> $SRS_AUTO_HEADERS_H
  34. fi
  35. if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
  36. echo "#define SRS_EXPORT_LIBRTMP" >> $SRS_AUTO_HEADERS_H
  37. else
  38. echo "#undef SRS_EXPORT_LIBRTMP" >> $SRS_AUTO_HEADERS_H
  39. fi
  40. echo "" >> $SRS_AUTO_HEADERS_H
  41. #####################################################################################
  42. # generate auto headers file, depends on the finished of options.sh
  43. #####################################################################################
  44. # write to source file
  45. if [ $SRS_CROSS_BUILD = YES ]; then
  46. echo "cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB"
  47. echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB\"" >> $SRS_AUTO_HEADERS_H
  48. else
  49. echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"normal x86/x64 gcc\"" >> $SRS_AUTO_HEADERS_H
  50. fi
  51. echo "" >> $SRS_AUTO_HEADERS_H
  52. # auto headers in depends.
  53. if [ $SRS_HTTP_CORE = YES ]; then
  54. echo "#define SRS_AUTO_HTTP_CORE" >> $SRS_AUTO_HEADERS_H
  55. else
  56. echo "#undef SRS_AUTO_HTTP_CORE" >> $SRS_AUTO_HEADERS_H
  57. fi
  58. if [ $SRS_HTTP_SERVER = YES ]; then
  59. echo "#define SRS_AUTO_HTTP_SERVER" >> $SRS_AUTO_HEADERS_H
  60. else
  61. echo "#undef SRS_AUTO_HTTP_SERVER" >> $SRS_AUTO_HEADERS_H
  62. fi
  63. if [ $SRS_STREAM_CASTER = YES ]; then
  64. echo "#define SRS_AUTO_STREAM_CASTER" >> $SRS_AUTO_HEADERS_H
  65. else
  66. echo "#undef SRS_AUTO_STREAM_CASTER" >> $SRS_AUTO_HEADERS_H
  67. fi
  68. if [ $SRS_HTTP_API = YES ]; then
  69. echo "#define SRS_AUTO_HTTP_API" >> $SRS_AUTO_HEADERS_H
  70. else
  71. echo "#undef SRS_AUTO_HTTP_API" >> $SRS_AUTO_HEADERS_H
  72. fi
  73. if [ $SRS_NGINX = YES ]; then
  74. echo "#define SRS_AUTO_NGINX" >> $SRS_AUTO_HEADERS_H
  75. else
  76. echo "#undef SRS_AUTO_NGINX" >> $SRS_AUTO_HEADERS_H
  77. fi
  78. if [ $SRS_DVR = YES ]; then
  79. echo "#define SRS_AUTO_DVR" >> $SRS_AUTO_HEADERS_H
  80. else
  81. echo "#undef SRS_AUTO_DVR" >> $SRS_AUTO_HEADERS_H
  82. fi
  83. if [ $SRS_HLS = YES ]; then
  84. echo "#define SRS_AUTO_HLS" >> $SRS_AUTO_HEADERS_H
  85. else
  86. echo "#undef SRS_AUTO_HLS" >> $SRS_AUTO_HEADERS_H
  87. fi
  88. if [ $SRS_HDS = YES ]; then
  89. echo "#define SRS_AUTO_HDS" >> $SRS_AUTO_HEADERS_H
  90. else
  91. echo "#undef SRS_AUTO_HDS" >> $SRS_AUTO_HEADERS_H
  92. fi
  93. if [ $SRS_HTTP_CALLBACK = YES ]; then
  94. echo "#define SRS_AUTO_HTTP_CALLBACK" >> $SRS_AUTO_HEADERS_H
  95. else
  96. echo "#undef SRS_AUTO_HTTP_CALLBACK" >> $SRS_AUTO_HEADERS_H
  97. fi
  98. if [ $SRS_SSL = YES ]; then
  99. echo "#define SRS_AUTO_SSL" >> $SRS_AUTO_HEADERS_H
  100. else
  101. echo "#undef SRS_AUTO_SSL" >> $SRS_AUTO_HEADERS_H
  102. fi
  103. if [ $SRS_MEM_WATCH = YES ]; then
  104. echo "#define SRS_AUTO_MEM_WATCH" >> $SRS_AUTO_HEADERS_H
  105. else
  106. echo "#undef SRS_AUTO_MEM_WATCH" >> $SRS_AUTO_HEADERS_H
  107. fi
  108. # whether compile ffmpeg tool
  109. if [ $SRS_FFMPEG_TOOL = YES ]; then
  110. echo "#define SRS_AUTO_FFMPEG_TOOL" >> $SRS_AUTO_HEADERS_H
  111. else
  112. echo "#undef SRS_AUTO_FFMPEG_TOOL" >> $SRS_AUTO_HEADERS_H
  113. fi
  114. # whatever the FFMPEG tools, if transcode and ingest specified,
  115. # srs always compile the FFMPEG tool stub which used to start the FFMPEG process.
  116. if [ $SRS_FFMPEG_STUB = YES ]; then
  117. echo "#define SRS_AUTO_FFMPEG_STUB" >> $SRS_AUTO_HEADERS_H
  118. else
  119. echo "#undef SRS_AUTO_FFMPEG_STUB" >> $SRS_AUTO_HEADERS_H
  120. fi
  121. if [ $SRS_TRANSCODE = YES ]; then
  122. echo "#define SRS_AUTO_TRANSCODE" >> $SRS_AUTO_HEADERS_H
  123. else
  124. echo "#undef SRS_AUTO_TRANSCODE" >> $SRS_AUTO_HEADERS_H
  125. fi
  126. if [ $SRS_INGEST = YES ]; then
  127. echo "#define SRS_AUTO_INGEST" >> $SRS_AUTO_HEADERS_H
  128. else
  129. echo "#undef SRS_AUTO_INGEST" >> $SRS_AUTO_HEADERS_H
  130. fi
  131. # for statistic.
  132. if [ $SRS_STAT = YES ]; then
  133. echo "#define SRS_AUTO_STAT" >> $SRS_AUTO_HEADERS_H
  134. else
  135. echo "#undef SRS_AUTO_STAT" >> $SRS_AUTO_HEADERS_H
  136. fi
  137. if [ $SRS_GPERF = YES ]; then
  138. echo "#define SRS_AUTO_GPERF" >> $SRS_AUTO_HEADERS_H
  139. else
  140. echo "#undef SRS_AUTO_GPERF" >> $SRS_AUTO_HEADERS_H
  141. fi
  142. if [ $SRS_GPERF_MC = YES ]; then
  143. echo "#define SRS_AUTO_GPERF_MC" >> $SRS_AUTO_HEADERS_H
  144. else
  145. echo "#undef SRS_AUTO_GPERF_MC" >> $SRS_AUTO_HEADERS_H
  146. fi
  147. if [ $SRS_GPERF_MP = YES ]; then
  148. echo "#define SRS_AUTO_GPERF_MP" >> $SRS_AUTO_HEADERS_H
  149. else
  150. echo "#undef SRS_AUTO_GPERF_MP" >> $SRS_AUTO_HEADERS_H
  151. fi
  152. if [ $SRS_GPERF_CP = YES ]; then
  153. echo "#define SRS_AUTO_GPERF_CP" >> $SRS_AUTO_HEADERS_H
  154. else
  155. echo "#undef SRS_AUTO_GPERF_CP" >> $SRS_AUTO_HEADERS_H
  156. fi
  157. #####################################################################################
  158. # for embeded.
  159. #####################################################################################
  160. if [ $SRS_CROSS_BUILD = YES ]; then
  161. echo "#define SRS_AUTO_EMBEDED_CPU" >> $SRS_AUTO_HEADERS_H
  162. else
  163. echo "#undef SRS_AUTO_EMBEDED_CPU" >> $SRS_AUTO_HEADERS_H
  164. fi
  165. # arm
  166. if [ $SRS_ARM_UBUNTU12 = YES ]; then
  167. echo "#define SRS_AUTO_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
  168. else
  169. echo "#undef SRS_AUTO_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H
  170. fi
  171. # mips
  172. if [ $SRS_MIPS_UBUNTU12 = YES ]; then
  173. echo "#define SRS_AUTO_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
  174. else
  175. echo "#undef SRS_AUTO_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H
  176. fi
  177. echo "" >> $SRS_AUTO_HEADERS_H
  178. # for log level compile settings
  179. if [ $SRS_LOG_VERBOSE = YES ]; then
  180. echo "#define SRS_AUTO_VERBOSE" >> $SRS_AUTO_HEADERS_H
  181. else
  182. echo "#undef SRS_AUTO_VERBOSE" >> $SRS_AUTO_HEADERS_H
  183. fi
  184. if [ $SRS_LOG_INFO = YES ]; then
  185. echo "#define SRS_AUTO_INFO" >> $SRS_AUTO_HEADERS_H
  186. else
  187. echo "#undef SRS_AUTO_INFO" >> $SRS_AUTO_HEADERS_H
  188. fi
  189. if [ $SRS_LOG_TRACE = YES ]; then
  190. echo "#define SRS_AUTO_TRACE" >> $SRS_AUTO_HEADERS_H
  191. else
  192. echo "#undef SRS_AUTO_TRACE" >> $SRS_AUTO_HEADERS_H
  193. fi
  194. # prefix
  195. echo "" >> $SRS_AUTO_HEADERS_H
  196. echo "#define SRS_AUTO_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H
  197. echo "" >> $SRS_AUTO_HEADERS_H
  198. #####################################################################################
  199. # generated the contributors from AUTHORS.txt
  200. #####################################################################################
  201. SRS_CONSTRIBUTORS=`cat ../AUTHORS.txt|grep "*"|awk '{print $2}'`
  202. echo "#define SRS_AUTO_CONSTRIBUTORS \"\\" >> $SRS_AUTO_HEADERS_H
  203. for CONTRIBUTOR in $SRS_CONSTRIBUTORS; do
  204. echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
  205. done
  206. echo "\"" >> $SRS_AUTO_HEADERS_H
  207. # new empty line to auto headers file.
  208. echo "" >> $SRS_AUTO_HEADERS_H
  209. # auto header EOF.
  210. echo "#endif" >> $SRS_AUTO_HEADERS_H
  211. echo "" >> $SRS_AUTO_HEADERS_H