winlin

refine configure, move auto headers to script.

@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 # variables, parent script must set it: 3 # variables, parent script must set it:
4 # SRS_JOBS: the build jobs. 4 # SRS_JOBS: the build jobs.
5 # SrsArmMakeOptions: the arm make options for ubuntu12(armhf, v7cpu) 5 # SrsArmMakeOptions: the arm make options for ubuntu12(armhf, v7cpu)
6 -# SRS_AUTO_HEADERS_H: the auto generated header file.  
7 6
8 ##################################################################################### 7 #####################################################################################
9 ##################################################################################### 8 #####################################################################################
@@ -325,30 +324,6 @@ if [ $SRS_HTTP_PARSER = YES ]; then @@ -325,30 +324,6 @@ if [ $SRS_HTTP_PARSER = YES ]; then
325 if [[ ! -f ${SRS_OBJS}/hp/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi 324 if [[ ! -f ${SRS_OBJS}/hp/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
326 fi 325 fi
327 326
328 -if [ $SRS_HTTP_PARSER = YES ]; then  
329 - echo "#define SRS_AUTO_HTTP_PARSER" >> $SRS_AUTO_HEADERS_H  
330 -else  
331 - echo "#undef SRS_AUTO_HTTP_PARSER" >> $SRS_AUTO_HEADERS_H  
332 -fi  
333 -  
334 -if [ $SRS_HTTP_SERVER = YES ]; then  
335 - echo "#define SRS_AUTO_HTTP_SERVER" >> $SRS_AUTO_HEADERS_H  
336 -else  
337 - echo "#undef SRS_AUTO_HTTP_SERVER" >> $SRS_AUTO_HEADERS_H  
338 -fi  
339 -  
340 -if [ $SRS_STREAM_CASTER = YES ]; then  
341 - echo "#define SRS_AUTO_STREAM_CASTER" >> $SRS_AUTO_HEADERS_H  
342 -else  
343 - echo "#undef SRS_AUTO_STREAM_CASTER" >> $SRS_AUTO_HEADERS_H  
344 -fi  
345 -  
346 -if [ $SRS_HTTP_API = YES ]; then  
347 - echo "#define SRS_AUTO_HTTP_API" >> $SRS_AUTO_HEADERS_H  
348 -else  
349 - echo "#undef SRS_AUTO_HTTP_API" >> $SRS_AUTO_HEADERS_H  
350 -fi  
351 -  
352 ##################################################################################### 327 #####################################################################################
353 # nginx for HLS, nginx-1.5.0 328 # nginx for HLS, nginx-1.5.0
354 ##################################################################################### 329 #####################################################################################
@@ -420,24 +395,6 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then @@ -420,24 +395,6 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
420 echo "nginx is ok" > ${SRS_OBJS}/nginx/html/nginx.html 395 echo "nginx is ok" > ${SRS_OBJS}/nginx/html/nginx.html
421 fi 396 fi
422 397
423 -if [ $SRS_NGINX = YES ]; then  
424 - echo "#define SRS_AUTO_NGINX" >> $SRS_AUTO_HEADERS_H  
425 -else  
426 - echo "#undef SRS_AUTO_NGINX" >> $SRS_AUTO_HEADERS_H  
427 -fi  
428 -  
429 -if [ $SRS_DVR = YES ]; then  
430 - echo "#define SRS_AUTO_DVR" >> $SRS_AUTO_HEADERS_H  
431 -else  
432 - echo "#undef SRS_AUTO_DVR" >> $SRS_AUTO_HEADERS_H  
433 -fi  
434 -  
435 -if [ $SRS_HLS = YES ]; then  
436 - echo "#define SRS_AUTO_HLS" >> $SRS_AUTO_HEADERS_H  
437 -else  
438 - echo "#undef SRS_AUTO_HLS" >> $SRS_AUTO_HEADERS_H  
439 -fi  
440 -  
441 ##################################################################################### 398 #####################################################################################
442 # cherrypy for http hooks callback, CherryPy-3.2.4 399 # cherrypy for http hooks callback, CherryPy-3.2.4
443 ##################################################################################### 400 #####################################################################################
@@ -458,12 +415,6 @@ if [ $SRS_HTTP_CALLBACK = YES ]; then @@ -458,12 +415,6 @@ if [ $SRS_HTTP_CALLBACK = YES ]; then
458 if [ ! -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi 415 if [ ! -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi
459 fi 416 fi
460 417
461 -if [ $SRS_HTTP_CALLBACK = YES ]; then  
462 - echo "#define SRS_AUTO_HTTP_CALLBACK" >> $SRS_AUTO_HEADERS_H  
463 -else  
464 - echo "#undef SRS_AUTO_HTTP_CALLBACK" >> $SRS_AUTO_HEADERS_H  
465 -fi  
466 -  
467 if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then 418 if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
468 echo "link players to cherrypy static-dir" 419 echo "link players to cherrypy static-dir"
469 rm -rf research/api-server/static-dir/players && 420 rm -rf research/api-server/static-dir/players &&
@@ -554,12 +505,6 @@ if [ $SRS_SSL = YES ]; then @@ -554,12 +505,6 @@ if [ $SRS_SSL = YES ]; then
554 fi 505 fi
555 fi 506 fi
556 507
557 -if [ $SRS_SSL = YES ]; then  
558 - echo "#define SRS_AUTO_SSL" >> $SRS_AUTO_HEADERS_H  
559 -else  
560 - echo "#undef SRS_AUTO_SSL" >> $SRS_AUTO_HEADERS_H  
561 -fi  
562 -  
563 ##################################################################################### 508 #####################################################################################
564 # live transcoding, ffmpeg-2.1, x264-core138, lame-3.99.5, libaacplus-2.0.2. 509 # live transcoding, ffmpeg-2.1, x264-core138, lame-3.99.5, libaacplus-2.0.2.
565 ##################################################################################### 510 #####################################################################################
@@ -580,40 +525,6 @@ if [ $SRS_FFMPEG_TOOL = YES ]; then @@ -580,40 +525,6 @@ if [ $SRS_FFMPEG_TOOL = YES ]; then
580 if [ ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]; then echo "build ffmpeg-2.1 failed."; exit -1; fi 525 if [ ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]; then echo "build ffmpeg-2.1 failed."; exit -1; fi
581 fi 526 fi
582 527
583 -# whether compile ffmpeg tool  
584 -if [ $SRS_FFMPEG_TOOL = YES ]; then  
585 - echo "#define SRS_AUTO_FFMPEG_TOOL" >> $SRS_AUTO_HEADERS_H  
586 -else  
587 - echo "#undef SRS_AUTO_FFMPEG_TOOL" >> $SRS_AUTO_HEADERS_H  
588 -fi  
589 -  
590 -# whatever the FFMPEG tools, if transcode and ingest specified,  
591 -# srs always compile the FFMPEG tool stub which used to start the FFMPEG process.  
592 -if [ $SRS_FFMPEG_STUB = YES ]; then  
593 - echo "#define SRS_AUTO_FFMPEG_STUB" >> $SRS_AUTO_HEADERS_H  
594 -else  
595 - echo "#undef SRS_AUTO_FFMPEG_STUB" >> $SRS_AUTO_HEADERS_H  
596 -fi  
597 -  
598 -if [ $SRS_TRANSCODE = YES ]; then  
599 - echo "#define SRS_AUTO_TRANSCODE" >> $SRS_AUTO_HEADERS_H  
600 -else  
601 - echo "#undef SRS_AUTO_TRANSCODE" >> $SRS_AUTO_HEADERS_H  
602 -fi  
603 -  
604 -if [ $SRS_INGEST = YES ]; then  
605 - echo "#define SRS_AUTO_INGEST" >> $SRS_AUTO_HEADERS_H  
606 -else  
607 - echo "#undef SRS_AUTO_INGEST" >> $SRS_AUTO_HEADERS_H  
608 -fi  
609 -  
610 -# for statistic.  
611 -if [ $SRS_STAT = YES ]; then  
612 - echo "#define SRS_AUTO_STAT" >> $SRS_AUTO_HEADERS_H  
613 -else  
614 - echo "#undef SRS_AUTO_STAT" >> $SRS_AUTO_HEADERS_H  
615 -fi  
616 -  
617 ##################################################################################### 528 #####################################################################################
618 # build research code, librtmp 529 # build research code, librtmp
619 ##################################################################################### 530 #####################################################################################
@@ -677,88 +588,6 @@ if [ $SRS_GPERF = YES ]; then @@ -677,88 +588,6 @@ if [ $SRS_GPERF = YES ]; then
677 if [ ! -f ${SRS_OBJS}/gperf/bin/pprof ]; then echo "build gperftools-2.1 failed."; exit -1; fi 588 if [ ! -f ${SRS_OBJS}/gperf/bin/pprof ]; then echo "build gperftools-2.1 failed."; exit -1; fi
678 fi 589 fi
679 590
680 -if [ $SRS_GPERF = YES ]; then  
681 - echo "#define SRS_AUTO_GPERF" >> $SRS_AUTO_HEADERS_H  
682 -else  
683 - echo "#undef SRS_AUTO_GPERF" >> $SRS_AUTO_HEADERS_H  
684 -fi  
685 -if [ $SRS_GPERF_MC = YES ]; then  
686 - echo "#define SRS_AUTO_GPERF_MC" >> $SRS_AUTO_HEADERS_H  
687 -else  
688 - echo "#undef SRS_AUTO_GPERF_MC" >> $SRS_AUTO_HEADERS_H  
689 -fi  
690 -if [ $SRS_GPERF_MP = YES ]; then  
691 - echo "#define SRS_AUTO_GPERF_MP" >> $SRS_AUTO_HEADERS_H  
692 -else  
693 - echo "#undef SRS_AUTO_GPERF_MP" >> $SRS_AUTO_HEADERS_H  
694 -fi  
695 -if [ $SRS_GPERF_CP = YES ]; then  
696 - echo "#define SRS_AUTO_GPERF_CP" >> $SRS_AUTO_HEADERS_H  
697 -else  
698 - echo "#undef SRS_AUTO_GPERF_CP" >> $SRS_AUTO_HEADERS_H  
699 -fi  
700 -  
701 -#####################################################################################  
702 -# for embeded.  
703 -#####################################################################################  
704 -if [ $SRS_EMBEDED_CPU = YES ]; then  
705 - echo "#define SRS_AUTO_EMBEDED_CPU" >> $SRS_AUTO_HEADERS_H  
706 -else  
707 - echo "#undef SRS_AUTO_EMBEDED_CPU" >> $SRS_AUTO_HEADERS_H  
708 -fi  
709 -  
710 -# arm  
711 -if [ $SRS_ARM_UBUNTU12 = YES ]; then  
712 - echo "#define SRS_AUTO_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H  
713 -else  
714 - echo "#undef SRS_AUTO_ARM_UBUNTU12" >> $SRS_AUTO_HEADERS_H  
715 -fi  
716 -  
717 -# mips  
718 -if [ $SRS_MIPS_UBUNTU12 = YES ]; then  
719 - echo "#define SRS_AUTO_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H  
720 -else  
721 - echo "#undef SRS_AUTO_MIPS_UBUNTU12" >> $SRS_AUTO_HEADERS_H  
722 -fi  
723 -  
724 -echo "" >> $SRS_AUTO_HEADERS_H  
725 -  
726 -# for log level compile settings  
727 -if [ $SRS_LOG_VERBOSE = YES ]; then  
728 - echo "#define SRS_AUTO_VERBOSE" >> $SRS_AUTO_HEADERS_H  
729 -else  
730 - echo "#undef SRS_AUTO_VERBOSE" >> $SRS_AUTO_HEADERS_H  
731 -fi  
732 -if [ $SRS_LOG_INFO = YES ]; then  
733 - echo "#define SRS_AUTO_INFO" >> $SRS_AUTO_HEADERS_H  
734 -else  
735 - echo "#undef SRS_AUTO_INFO" >> $SRS_AUTO_HEADERS_H  
736 -fi  
737 -if [ $SRS_LOG_TRACE = YES ]; then  
738 - echo "#define SRS_AUTO_TRACE" >> $SRS_AUTO_HEADERS_H  
739 -else  
740 - echo "#undef SRS_AUTO_TRACE" >> $SRS_AUTO_HEADERS_H  
741 -fi  
742 -  
743 -# prefix  
744 -echo "" >> $SRS_AUTO_HEADERS_H  
745 -echo "#define SRS_AUTO_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H  
746 -  
747 -echo "" >> $SRS_AUTO_HEADERS_H  
748 -  
749 -#####################################################################################  
750 -# generated the contributors from AUTHORS.txt  
751 -#####################################################################################  
752 -SRS_CONSTRIBUTORS=`cat ../AUTHORS.txt|grep "*"|awk '{print $2}'`  
753 -echo "#define SRS_AUTO_CONSTRIBUTORS \"\\" >> $SRS_AUTO_HEADERS_H  
754 -for CONTRIBUTOR in $SRS_CONSTRIBUTORS; do  
755 - echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H  
756 -done  
757 -echo "\"" >> $SRS_AUTO_HEADERS_H  
758 -  
759 -# new empty line to auto headers file.  
760 -echo "" >> $SRS_AUTO_HEADERS_H  
761 -  
762 ##################################################################################### 591 #####################################################################################
763 # generated the test script 592 # generated the test script
764 ##################################################################################### 593 #####################################################################################
@@ -57,7 +57,7 @@ done @@ -57,7 +57,7 @@ done
57 echo "" >> ${FILE} 57 echo "" >> ${FILE}
58 58
59 # parent Makefile, to create module output dir before compile it. 59 # parent Makefile, to create module output dir before compile it.
60 -echo " mkdir -p ${SRS_OBJS_DIR}/include" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}  
61 -echo " mkdir -p ${SRS_OBJS_DIR}/lib" >> ${SRS_WORKDIR}/${SRS_MAKEFILE} 60 +echo " @mkdir -p ${SRS_OBJS_DIR}/include" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
  61 +echo " @mkdir -p ${SRS_OBJS_DIR}/lib" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
62 62
63 echo -n "generate lib ${LIB_NAME} ok"; echo '!'; 63 echo -n "generate lib ${LIB_NAME} ok"; echo '!';
@@ -85,6 +85,6 @@ done @@ -85,6 +85,6 @@ done
85 echo "" >> ${FILE} 85 echo "" >> ${FILE}
86 86
87 # parent Makefile, to create module output dir before compile it. 87 # parent Makefile, to create module output dir before compile it.
88 -echo " mkdir -p ${SRS_OBJS_DIR}/${MODULE_DIR}" >> ${SRS_WORKDIR}/${SRS_MAKEFILE} 88 +echo " @mkdir -p ${SRS_OBJS_DIR}/${MODULE_DIR}" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
89 89
90 echo -n "generate module ${MODULE_ID} ok"; echo '!'; 90 echo -n "generate module ${MODULE_ID} ok"; echo '!';
@@ -176,6 +176,6 @@ END @@ -176,6 +176,6 @@ END
176 176
177 ##################################################################################### 177 #####################################################################################
178 # parent Makefile, to create module output dir before compile it. 178 # parent Makefile, to create module output dir before compile it.
179 -echo " mkdir -p ${SRS_OBJS_DIR}/utest" >> ${SRS_WORKDIR}/${SRS_MAKEFILE} 179 +echo " @mkdir -p ${SRS_OBJS_DIR}/utest" >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
180 180
181 echo -n "generate utest ok"; echo '!'; 181 echo -n "generate utest ok"; echo '!';
@@ -27,73 +27,11 @@ BLACK="\\e[0m" @@ -27,73 +27,11 @@ BLACK="\\e[0m"
27 # for export srs-librtmp, change target to it. 27 # for export srs-librtmp, change target to it.
28 . auto/generate-srs-librtmp-project.sh 28 . auto/generate-srs-librtmp-project.sh
29 29
30 -# the auto generated variables.  
31 -SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"  
32 -  
33 -# clean the exists, when not export srs-librtmp.  
34 -# do this only when the options is ok.  
35 -if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then  
36 - if [[ -f Makefile ]]; then  
37 - make clean  
38 - fi  
39 -fi  
40 -  
41 -# write user options to headers  
42 -echo "// auto generated by configure" > $SRS_AUTO_HEADERS_H  
43 -echo "#ifndef SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H  
44 -echo "#define SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H  
45 -echo "" >> $SRS_AUTO_HEADERS_H  
46 -  
47 -echo "#define SRS_AUTO_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H  
48 -echo "#define SRS_AUTO_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H  
49 -echo "#define SRS_AUTO_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H  
50 -echo "#define SRS_AUTO_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H  
51 -echo "#define SRS_AUTO_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H  
52 -  
53 -# new empty line to auto headers file.  
54 -echo "" >> $SRS_AUTO_HEADERS_H  
55 -  
56 -#####################################################################################  
57 -# generate auto headers file, depends on the finished of options.sh  
58 -#####################################################################################  
59 -if [ $SRS_ARM_UBUNTU12 = YES ]; then  
60 - __SrsArmCC="arm-linux-gnueabi-gcc";  
61 - __SrsArmGCC="arm-linux-gnueabi-gcc";  
62 - __SrsArmCXX="arm-linux-gnueabi-g++";  
63 - __SrsArmAR="arm-linux-gnueabi-ar";  
64 - __SrsArmLD="arm-linux-gnueabi-ld";  
65 - __SrsArmRANDLIB="arm-linux-gnueabi-ranlib";  
66 -fi  
67 -if [ $SRS_MIPS_UBUNTU12 = YES ]; then  
68 - __SrsArmCC="mipsel-openwrt-linux-gcc";  
69 - __SrsArmGCC="mipsel-openwrt-linux-gcc";  
70 - __SrsArmCXX="mipsel-openwrt-linux-g++";  
71 - __SrsArmAR="mipsel-openwrt-linux-ar";  
72 - __SrsArmLD="mipsel-openwrt-linux-ld";  
73 - __SrsArmRANDLIB="mipsel-openwrt-linux-ranlib";  
74 -fi  
75 -# the arm-ubuntu12 options for make for depends  
76 -if [[ -z $SrsArmCC ]]; then SrsArmCC=$__SrsArmCC; fi  
77 -if [[ -z $SrsArmGCC ]]; then SrsArmGCC=$__SrsArmGCC; fi  
78 -if [[ -z $SrsArmCXX ]]; then SrsArmCXX=$__SrsArmCXX; fi  
79 -if [[ -z $SrsArmAR ]]; then SrsArmAR=$__SrsArmAR; fi  
80 -if [[ -z $SrsArmLD ]]; then SrsArmLD=$__SrsArmLD; fi  
81 -if [[ -z $SrsArmRANDLIB ]]; then SrsArmRANDLIB=$__SrsArmRANDLIB; fi  
82 -# write to source file  
83 -if [ $SRS_EMBEDED_CPU = YES ]; then  
84 - echo "cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB"  
85 - echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"cc=$SrsArmCC gcc=$SrsArmGCC g++=$SrsArmCXX ar=$SrsArmAR ld=$SrsArmLD randlib=$SrsArmRANDLIB\"" >> $SRS_AUTO_HEADERS_H  
86 -else  
87 - echo "#define SRS_AUTO_EMBEDED_TOOL_CHAIN \"normal x86/x64 gcc\"" >> $SRS_AUTO_HEADERS_H  
88 -fi  
89 -echo "" >> $SRS_AUTO_HEADERS_H  
90 -  
91 # apply user options. 30 # apply user options.
92 . auto/depends.sh 31 . auto/depends.sh
93 32
94 -# auto header EOF.  
95 -echo "#endif" >> $SRS_AUTO_HEADERS_H  
96 -echo "" >> $SRS_AUTO_HEADERS_H 33 +# the auto generated variables.
  34 +. auto/auto_headers.sh
97 35
98 ##################################################################################### 36 #####################################################################################
99 # generate Makefile. 37 # generate Makefile.