auto_headers.sh 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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_PACKAGER \"${SRS_AUTO_PACKAGER}\"" >> $SRS_AUTO_HEADERS_H
  11. echo "#define SRS_AUTO_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
  12. echo "#define SRS_AUTO_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
  13. echo "#define SRS_AUTO_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
  14. echo "#define SRS_AUTO_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
  15. echo "#define SRS_AUTO_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. # export the preset.
  36. if [ $SRS_X86_X64 = YES ]; then
  37. srs_define_macro "SRS_X86_X64" $SRS_AUTO_HEADERS_H
  38. fi
  39. if [ $SRS_PI = YES ]; then
  40. srs_define_macro "SRS_PI" $SRS_AUTO_HEADERS_H
  41. fi
  42. if [ $SRS_CUBIE = YES ]; then
  43. srs_define_macro "SRS_CUBIE" $SRS_AUTO_HEADERS_H
  44. fi
  45. if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
  46. echo "#define SRS_EXPORT_LIBRTMP" >> $SRS_AUTO_HEADERS_H
  47. else
  48. echo "#undef SRS_EXPORT_LIBRTMP" >> $SRS_AUTO_HEADERS_H
  49. fi
  50. echo "" >> $SRS_AUTO_HEADERS_H
  51. #####################################################################################
  52. # generate auto headers file, depends on the finished of options.sh
  53. #####################################################################################
  54. # auto headers in depends.
  55. if [ $SRS_HDS = YES ]; then
  56. srs_define_macro "SRS_AUTO_HDS" $SRS_AUTO_HEADERS_H
  57. else
  58. srs_undefine_macro "SRS_AUTO_HDS" $SRS_AUTO_HEADERS_H
  59. fi
  60. if [ $SRS_MEM_WATCH = YES ]; then
  61. srs_define_macro "SRS_AUTO_MEM_WATCH" $SRS_AUTO_HEADERS_H
  62. else
  63. srs_undefine_macro "SRS_AUTO_MEM_WATCH" $SRS_AUTO_HEADERS_H
  64. fi
  65. if [ $SRS_UTEST = YES ]; then
  66. srs_define_macro "SRS_AUTO_UTEST" $SRS_AUTO_HEADERS_H
  67. else
  68. srs_undefine_macro "SRS_AUTO_UTEST" $SRS_AUTO_HEADERS_H
  69. fi
  70. # whatever the FFMPEG tools, if transcode and ingest specified,
  71. # srs always compile the FFMPEG tool stub which used to start the FFMPEG process.
  72. if [ $SRS_FFMPEG_STUB = YES ]; then
  73. srs_define_macro "SRS_AUTO_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
  74. else
  75. srs_undefine_macro "SRS_AUTO_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
  76. fi
  77. if [ $SRS_GPERF = YES ]; then
  78. srs_define_macro "SRS_AUTO_GPERF" $SRS_AUTO_HEADERS_H
  79. else
  80. srs_undefine_macro "SRS_AUTO_GPERF" $SRS_AUTO_HEADERS_H
  81. fi
  82. if [ $SRS_GPERF_MC = YES ]; then
  83. srs_define_macro "SRS_AUTO_GPERF_MC" $SRS_AUTO_HEADERS_H
  84. else
  85. srs_undefine_macro "SRS_AUTO_GPERF_MC" $SRS_AUTO_HEADERS_H
  86. fi
  87. if [ $SRS_GPERF_MD = YES ]; then
  88. srs_define_macro "SRS_AUTO_GPERF_MD" $SRS_AUTO_HEADERS_H
  89. else
  90. srs_undefine_macro "SRS_AUTO_GPERF_MD" $SRS_AUTO_HEADERS_H
  91. fi
  92. if [ $SRS_GPERF_MP = YES ]; then
  93. srs_define_macro "SRS_AUTO_GPERF_MP" $SRS_AUTO_HEADERS_H
  94. else
  95. srs_undefine_macro "SRS_AUTO_GPERF_MP" $SRS_AUTO_HEADERS_H
  96. fi
  97. if [ $SRS_GPERF_CP = YES ]; then
  98. srs_define_macro "SRS_AUTO_GPERF_CP" $SRS_AUTO_HEADERS_H
  99. else
  100. srs_undefine_macro "SRS_AUTO_GPERF_CP" $SRS_AUTO_HEADERS_H
  101. fi
  102. #####################################################################################
  103. # for embeded.
  104. #####################################################################################
  105. # for log level compile settings
  106. if [ $SRS_LOG_VERBOSE = YES ]; then
  107. srs_define_macro "SRS_AUTO_VERBOSE" $SRS_AUTO_HEADERS_H
  108. else
  109. srs_undefine_macro "SRS_AUTO_VERBOSE" $SRS_AUTO_HEADERS_H
  110. fi
  111. if [ $SRS_LOG_INFO = YES ]; then
  112. srs_define_macro "SRS_AUTO_INFO" $SRS_AUTO_HEADERS_H
  113. else
  114. srs_undefine_macro "SRS_AUTO_INFO" $SRS_AUTO_HEADERS_H
  115. fi
  116. if [ $SRS_LOG_TRACE = YES ]; then
  117. srs_define_macro "SRS_AUTO_TRACE" $SRS_AUTO_HEADERS_H
  118. else
  119. srs_undefine_macro "SRS_AUTO_TRACE" $SRS_AUTO_HEADERS_H
  120. fi
  121. if [ $SRS_CROSS_BUILD = YES ]; then
  122. srs_define_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H
  123. else
  124. srs_undefine_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H
  125. fi
  126. if [ $SRS_OSX = YES ]; then
  127. srs_define_macro "SRS_AUTO_OSX" $SRS_AUTO_HEADERS_H
  128. else
  129. srs_undefine_macro "SRS_AUTO_OSX" $SRS_AUTO_HEADERS_H
  130. fi
  131. # prefix
  132. echo "" >> $SRS_AUTO_HEADERS_H
  133. echo "#define SRS_AUTO_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H
  134. echo "" >> $SRS_AUTO_HEADERS_H
  135. #####################################################################################
  136. # generated the contributors from AUTHORS.txt
  137. #####################################################################################
  138. if [[ -f ../AUTHORS.txt ]]; then
  139. SRS_CONSTRIBUTORS=`cat ../AUTHORS.txt|grep "*"|awk '{print $2}'`
  140. echo "#define SRS_AUTO_CONSTRIBUTORS \"\\" >> $SRS_AUTO_HEADERS_H
  141. for CONTRIBUTOR in $SRS_CONSTRIBUTORS; do
  142. echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
  143. done
  144. echo "\"" >> $SRS_AUTO_HEADERS_H
  145. else
  146. echo "#define SRS_AUTO_CONSTRIBUTORS \"ossrs\"" >> $SRS_AUTO_HEADERS_H
  147. fi
  148. # new empty line to auto headers file.
  149. echo "" >> $SRS_AUTO_HEADERS_H
  150. #####################################################################################
  151. # auto header EOF.
  152. #####################################################################################
  153. echo "#endif" >> $SRS_AUTO_HEADERS_H
  154. echo "" >> $SRS_AUTO_HEADERS_H