winlin

refine the configure, add comments

1 #!/bin/bash 1 #!/bin/bash
2 2
  3 +function require_sudoer()
  4 +{
  5 + sudo echo "" >/dev/null 2>&1
  6 +
  7 + ret=$?; if [[ 0 -ne $ret ]]; then
  8 + echo "\"$1\" require sudoer failed. ret=$ret";
  9 + exit $ret;
  10 + fi
  11 +}
  12 +
3 # TODO: check gcc/g++ 13 # TODO: check gcc/g++
4 echo "check gcc/g++/gdb/make/openssl-devel" 14 echo "check gcc/g++/gdb/make/openssl-devel"
5 echo "depends tools are ok" 15 echo "depends tools are ok"
1 #!/bin/bash 1 #!/bin/bash
2 2
3 -SRS_MAKEFILE="Makefile" 3 +#####################################################################################
  4 +# the main output dir, all configure and make output are in this dir.
  5 +#####################################################################################
  6 +# create the main objs
4 SRS_OBJS="objs" 7 SRS_OBJS="objs"
5 -SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"  
6 -  
7 mkdir -p ${SRS_OBJS} 8 mkdir -p ${SRS_OBJS}
8 9
9 -# linux shell color support.  
10 -RED="\\e[31m"  
11 -GREEN="\\e[32m"  
12 -YELLOW="\\e[33m"  
13 -BLACK="\\e[0m"  
14 -  
15 -# parse user options. 10 +#####################################################################################
  11 +# parse user options, set the variables like SRS_SSL/SRS_HLS/SRS_FFMPEG/SRS_HTTP
  12 +#####################################################################################
  13 +# parse options, exit with error when parse options invalid.
16 . auto/options.sh 14 . auto/options.sh
17 15
18 -function require_sudoer()  
19 -{  
20 - sudo echo "" >/dev/null 2>&1  
21 -  
22 - ret=$?; if [[ 0 -ne $ret ]]; then  
23 - echo "\"$1\" require sudoer failed. ret=$ret";  
24 - exit $ret;  
25 - fi  
26 -}  
27 -  
28 # clean the exists 16 # clean the exists
  17 +# do this only when the options is ok.
29 if [[ -f Makefile ]]; then 18 if [[ -f Makefile ]]; then
30 make clean 19 make clean
31 fi 20 fi
32 21
33 -# generate the audo headers file. 22 +#####################################################################################
  23 +# generate auto headers file, depends on the finished of options.sh
  24 +#####################################################################################
  25 +# write user options to headers
  26 +SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
34 echo "#define SRS_CONFIGURE \"${SRS_CONFIGURE}\"" > $SRS_AUTO_HEADERS_H 27 echo "#define SRS_CONFIGURE \"${SRS_CONFIGURE}\"" > $SRS_AUTO_HEADERS_H
35 echo "#define SRS_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H 28 echo "#define SRS_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
36 echo "#define SRS_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H 29 echo "#define SRS_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
@@ -46,6 +39,7 @@ echo "" >> $SRS_AUTO_HEADERS_H @@ -46,6 +39,7 @@ echo "" >> $SRS_AUTO_HEADERS_H
46 ##################################################################################### 39 #####################################################################################
47 echo "generate Makefile" 40 echo "generate Makefile"
48 41
  42 +SRS_MAKEFILE="Makefile"
49 cat << END > ${SRS_MAKEFILE} 43 cat << END > ${SRS_MAKEFILE}
50 .PHONY: default help clean server bandwidth _prepare_dir 44 .PHONY: default help clean server bandwidth _prepare_dir
51 default: server bandwidth 45 default: server bandwidth
@@ -152,6 +146,11 @@ BUILD_KEY="bandwidth" APP_MAIN="srs_main_bandcheck" APP_NAME="bandwidth" SO_PATH @@ -152,6 +146,11 @@ BUILD_KEY="bandwidth" APP_MAIN="srs_main_bandcheck" APP_NAME="bandwidth" SO_PATH
152 146
153 echo 'configure ok! ' 147 echo 'configure ok! '
154 148
  149 +# linux shell color support.
  150 +RED="\\e[31m"
  151 +GREEN="\\e[32m"
  152 +YELLOW="\\e[33m"
  153 +BLACK="\\e[0m"
155 # summary 154 # summary
156 echo "" 155 echo ""
157 echo "configure summary:" 156 echo "configure summary:"