winlin

support build with jobs

@@ -2,6 +2,11 @@ @@ -2,6 +2,11 @@
2 2
3 ff_src_dir="../../3rdparty" 3 ff_src_dir="../../3rdparty"
4 4
  5 +# the jobs to make ffmpeg
  6 +if [[ "" -eq SRS_JOBS ]]; then
  7 + export SRS_JOBS="--jobs=1"
  8 +fi
  9 +
5 ff_current_dir=$(pwd -P) 10 ff_current_dir=$(pwd -P)
6 ff_build_dir="${ff_current_dir}/_build" 11 ff_build_dir="${ff_current_dir}/_build"
7 ff_release_dir="${ff_current_dir}/_release" 12 ff_release_dir="${ff_current_dir}/_release"
@@ -9,6 +14,7 @@ echo "start to build the tools for transcode system:" @@ -9,6 +14,7 @@ echo "start to build the tools for transcode system:"
9 echo "current_dir: ${ff_current_dir}" 14 echo "current_dir: ${ff_current_dir}"
10 echo "build_dir: ${ff_build_dir}" 15 echo "build_dir: ${ff_build_dir}"
11 echo "release_dir: ${ff_release_dir}" 16 echo "release_dir: ${ff_release_dir}"
  17 +echo "SRS_JOBS: ${SRS_JOBS}"
12 18
13 mkdir -p ${ff_build_dir} 19 mkdir -p ${ff_build_dir}
14 mkdir -p ${ff_release_dir} 20 mkdir -p ${ff_release_dir}
@@ -22,7 +28,7 @@ else @@ -22,7 +28,7 @@ else
22 cd $ff_current_dir && 28 cd $ff_current_dir &&
23 rm -rf yasm-1.2.0 && unzip -q ${ff_src_dir}/yasm-1.2.0.zip && 29 rm -rf yasm-1.2.0 && unzip -q ${ff_src_dir}/yasm-1.2.0.zip &&
24 cd yasm-1.2.0 && ./configure --prefix=${ff_release_dir} && 30 cd yasm-1.2.0 && ./configure --prefix=${ff_release_dir} &&
25 - make && make install 31 + make ${SRS_JOBS} && make install
26 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build yasm-1.2.0 failed"; exit 1; fi 32 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build yasm-1.2.0 failed"; exit 1; fi
27 fi 33 fi
28 # add yasm to path, for x264 to use yasm directly. 34 # add yasm to path, for x264 to use yasm directly.
@@ -37,7 +43,7 @@ else @@ -37,7 +43,7 @@ else
37 cd $ff_current_dir && 43 cd $ff_current_dir &&
38 rm -rf libaacplus-2.0.2 && unzip -q ${ff_src_dir}/libaacplus-2.0.2.zip && 44 rm -rf libaacplus-2.0.2 && unzip -q ${ff_src_dir}/libaacplus-2.0.2.zip &&
39 cd libaacplus-2.0.2 && cp ../${ff_src_dir}/libaacplus-patch-26410-800.zip src/26410-800.zip && 45 cd libaacplus-2.0.2 && cp ../${ff_src_dir}/libaacplus-patch-26410-800.zip src/26410-800.zip &&
40 - bash autogen.sh && ./configure --prefix=${ff_release_dir} --enable-static && make && make install 46 + bash autogen.sh && ./configure --prefix=${ff_release_dir} --enable-static && make ${SRS_JOBS} && make install
41 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build libaacplus-2.0.2 failed"; exit 1; fi 47 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build libaacplus-2.0.2 failed"; exit 1; fi
42 fi 48 fi
43 49
@@ -48,7 +54,7 @@ else @@ -48,7 +54,7 @@ else
48 echo "build lame-3.99.5" 54 echo "build lame-3.99.5"
49 cd $ff_current_dir && 55 cd $ff_current_dir &&
50 rm -rf lame-3.99.5 && unzip -q ${ff_src_dir}/lame-3.99.5.zip && 56 rm -rf lame-3.99.5 && unzip -q ${ff_src_dir}/lame-3.99.5.zip &&
51 - cd lame-3.99.5 && ./configure --prefix=${ff_release_dir} --enable-static && make && make install 57 + cd lame-3.99.5 && ./configure --prefix=${ff_release_dir} --enable-static && make ${SRS_JOBS} && make install
52 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build lame-3.99.5 failed"; exit 1; fi 58 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build lame-3.99.5 failed"; exit 1; fi
53 fi 59 fi
54 60
@@ -61,7 +67,7 @@ else @@ -61,7 +67,7 @@ else
61 rm -rf x264-snapshot-20131129-2245-stable && unzip -q ${ff_src_dir}/x264-snapshot-20131129-2245-stable.zip && 67 rm -rf x264-snapshot-20131129-2245-stable && unzip -q ${ff_src_dir}/x264-snapshot-20131129-2245-stable.zip &&
62 cd x264-snapshot-20131129-2245-stable && 68 cd x264-snapshot-20131129-2245-stable &&
63 ./configure --prefix=${ff_release_dir} --disable-opencl --bit-depth=8 --enable-static && 69 ./configure --prefix=${ff_release_dir} --disable-opencl --bit-depth=8 --enable-static &&
64 - make && make install 70 + make ${SRS_JOBS} && make install
65 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build x264 failed"; exit 1; fi 71 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build x264 failed"; exit 1; fi
66 fi 72 fi
67 73
@@ -90,6 +96,6 @@ else @@ -90,6 +96,6 @@ else
90 --enable-libx264 --enable-libmp3lame --enable-libaacplus \ 96 --enable-libx264 --enable-libmp3lame --enable-libaacplus \
91 --enable-pthreads --extra-libs=-lpthread \ 97 --enable-pthreads --extra-libs=-lpthread \
92 --enable-encoders --enable-decoders --enable-avfilter --enable-muxers --enable-demuxers && 98 --enable-encoders --enable-decoders --enable-avfilter --enable-muxers --enable-demuxers &&
93 - make && make install 99 + make ${SRS_JOBS} && make install
94 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build ffmpeg failed"; exit 1; fi 100 ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build ffmpeg failed"; exit 1; fi
95 fi 101 fi
@@ -183,7 +183,7 @@ else @@ -183,7 +183,7 @@ else
183 rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} && 183 rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
184 unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && 184 unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 &&
185 patch -p1 < ../../3rdparty/1.st.arm.Makefile.patch && 185 patch -p1 < ../../3rdparty/1.st.arm.Makefile.patch &&
186 - make linux-debug && 186 + make linux-debug ${SRS_JOBS}&&
187 cd .. && rm -f st && ln -sf st-1.9/obj st 187 cd .. && rm -f st && ln -sf st-1.9/obj st
188 ) 188 )
189 fi 189 fi
@@ -205,7 +205,7 @@ if [ $SRS_HTTP = YES ]; then @@ -205,7 +205,7 @@ if [ $SRS_HTTP = YES ]; then
205 cd http-parser-2.1 && 205 cd http-parser-2.1 &&
206 sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile && 206 sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&
207 sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile && 207 sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&
208 - make package && 208 + make package ${SRS_JOBS} &&
209 cd .. && rm -f hp && ln -sf http-parser-2.1 hp 209 cd .. && rm -f hp && ln -sf http-parser-2.1 hp
210 ) 210 )
211 fi 211 fi
@@ -236,7 +236,7 @@ if [ $SRS_HLS = YES ]; then @@ -236,7 +236,7 @@ if [ $SRS_HLS = YES ]; then
236 ( 236 (
237 rm -rf ${SRS_OBJS}/nginx-1.5.7 && cd ${SRS_OBJS} && 237 rm -rf ${SRS_OBJS}/nginx-1.5.7 && cd ${SRS_OBJS} &&
238 unzip -q ../3rdparty/nginx-1.5.7.zip && cd nginx-1.5.7 && 238 unzip -q ../3rdparty/nginx-1.5.7.zip && cd nginx-1.5.7 &&
239 - ./configure --prefix=`pwd`/_release && make && make install && 239 + ./configure --prefix=`pwd`/_release && make ${SRS_JOBS} && make install &&
240 cd .. && ln -sf nginx-1.5.7/_release nginx 240 cd .. && ln -sf nginx-1.5.7/_release nginx
241 ) 241 )
242 fi 242 fi
@@ -352,7 +352,7 @@ if [ $SRS_SSL = YES ]; then @@ -352,7 +352,7 @@ if [ $SRS_SSL = YES ]; then
352 rm -rf ${SRS_OBJS}/openssl-1.0.1f && cd ${SRS_OBJS} && 352 rm -rf ${SRS_OBJS}/openssl-1.0.1f && cd ${SRS_OBJS} &&
353 unzip -q ../3rdparty/openssl-1.0.1f.zip && cd openssl-1.0.1f && 353 unzip -q ../3rdparty/openssl-1.0.1f.zip && cd openssl-1.0.1f &&
354 ./config --prefix=`pwd`/_release -no-shared && 354 ./config --prefix=`pwd`/_release -no-shared &&
355 - make && make install && 355 + make ${SRS_JOBS} && make install &&
356 cd .. && ln -sf openssl-1.0.1f/_release openssl 356 cd .. && ln -sf openssl-1.0.1f/_release openssl
357 ) 357 )
358 fi 358 fi
@@ -399,10 +399,10 @@ fi @@ -399,10 +399,10 @@ fi
399 if [ $SRS_RESEARCH = YES ]; then 399 if [ $SRS_RESEARCH = YES ]; then
400 mkdir -p ${SRS_OBJS}/research 400 mkdir -p ${SRS_OBJS}/research
401 401
402 - (cd research/hls && make && mv ts_info ../../${SRS_OBJS}/research) 402 + (cd research/hls && make ${SRS_JOBS} && mv ts_info ../../${SRS_OBJS}/research)
403 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi 403 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi
404 404
405 - (cd research/ffempty && make && mv ffempty ../../${SRS_OBJS}/research) 405 + (cd research/ffempty && make ${SRS_JOBS} && mv ffempty ../../${SRS_OBJS}/research)
406 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi 406 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi
407 fi 407 fi
408 408
@@ -412,9 +412,9 @@ fi @@ -412,9 +412,9 @@ fi
412 if [ $SRS_UTEST = YES ]; then 412 if [ $SRS_UTEST = YES ]; then
413 mkdir -p ${SRS_OBJS}/utest 413 mkdir -p ${SRS_OBJS}/utest
414 414
415 - (cd research/hls && make && mv ts_info ../../${SRS_OBJS}/research) 415 + (cd research/hls && make ${SRS_JOBS} && mv ts_info ../../${SRS_OBJS}/research)
416 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi 416 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi
417 417
418 - (cd research/ffempty && make && mv ffempty ../../${SRS_OBJS}/research) 418 + (cd research/ffempty && make ${SRS_JOBS} && mv ffempty ../../${SRS_OBJS}/research)
419 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi 419 ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi
420 fi 420 fi
@@ -17,6 +17,8 @@ SRS_FFMPEG=RESERVED @@ -17,6 +17,8 @@ SRS_FFMPEG=RESERVED
17 SRS_HTTP=RESERVED 17 SRS_HTTP=RESERVED
18 SRS_RESEARCH=RESERVED 18 SRS_RESEARCH=RESERVED
19 SRS_UTEST=RESERVED 19 SRS_UTEST=RESERVED
  20 +# arguments
  21 +SRS_JOBS=1
20 22
21 # TODO: remove the default to yes. 23 # TODO: remove the default to yes.
22 SRS_HLS=YES 24 SRS_HLS=YES
@@ -36,7 +38,10 @@ do @@ -36,7 +38,10 @@ do
36 opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`" 38 opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"
37 39
38 case "$option" in 40 case "$option" in
39 - -*=*) value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;; 41 + -*=*)
  42 + value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'`
  43 + option=`echo "$option" | sed -e 's/=[-_a-zA-Z0-9]*//'`
  44 + ;;
40 *) value="" ;; 45 *) value="" ;;
41 esac 46 esac
42 47
@@ -56,6 +61,8 @@ do @@ -56,6 +61,8 @@ do
56 --without-http) SRS_HTTP=NO ;; 61 --without-http) SRS_HTTP=NO ;;
57 --without-research) SRS_RESEARCH=NO ;; 62 --without-research) SRS_RESEARCH=NO ;;
58 --without-utest) SRS_UTEST=NO ;; 63 --without-utest) SRS_UTEST=NO ;;
  64 +
  65 + --jobs) SRS_JOBS=${value} ;;
59 66
60 *) 67 *)
61 echo "$0: error: invalid option \"$option\"" 68 echo "$0: error: invalid option \"$option\""
@@ -64,6 +71,13 @@ do @@ -64,6 +71,13 @@ do
64 esac 71 esac
65 done 72 done
66 73
  74 +# parse the jobs for make
  75 +if [[ "" -eq SRS_JOBS ]]; then
  76 + export SRS_JOBS="--jobs"
  77 +else
  78 + export SRS_JOBS="--jobs=${SRS_JOBS}"
  79 +fi
  80 +
67 # save all config options to macro to write to auto headers file 81 # save all config options to macro to write to auto headers file
68 SRS_CONFIGURE="$opt" 82 SRS_CONFIGURE="$opt"
69 83
@@ -90,6 +104,9 @@ if [ $help = yes ]; then @@ -90,6 +104,9 @@ if [ $help = yes ]; then
90 --without-ffmpeg disable the ffmpeg transcoding feature. 104 --without-ffmpeg disable the ffmpeg transcoding feature.
91 --without-research do not build the research tools. 105 --without-research do not build the research tools.
92 --without-utest do not build the utest for srs. 106 --without-utest do not build the utest for srs.
  107 +
  108 + --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
  109 + used for make in the configure, for example, to make ffmpeg.
93 110
94 END 111 END
95 exit 0 112 exit 0
@@ -49,7 +49,7 @@ echo "" >> $SRS_AUTO_HEADERS_H @@ -49,7 +49,7 @@ echo "" >> $SRS_AUTO_HEADERS_H
49 # srs-librtmp sample entry 49 # srs-librtmp sample entry
50 SrsLibrtmpSampleEntry="nossl"; if [ $SRS_SSL = YES ]; then SrsLibrtmpSampleEntry="ssl";fi 50 SrsLibrtmpSampleEntry="nossl"; if [ $SRS_SSL = YES ]; then SrsLibrtmpSampleEntry="ssl";fi
51 # utest make entry, (cd utest; make) 51 # utest make entry, (cd utest; make)
52 -SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\""; if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd utest; make)"; fi 52 +SrsUtestMakeEntry="@echo -e \"ignore utest for it's disabled\""; if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd utest; \$(MAKE))"; fi
53 53
54 ##################################################################################### 54 #####################################################################################
55 # colorful summary 55 # colorful summary
@@ -73,7 +73,7 @@ GREEN="\\${GREEN}" @@ -73,7 +73,7 @@ GREEN="\\${GREEN}"
73 YELLOW="\\${YELLOW}" 73 YELLOW="\\${YELLOW}"
74 BLACK="\\${BLACK}" 74 BLACK="\\${BLACK}"
75 75
76 -default: server bandwidth librtmp librtmp-sample utest 76 +default: bandwidth librtmp-sample utest
77 @echo -e "\$(GREEN)build summary:\$(BLACK)" 77 @echo -e "\$(GREEN)build summary:\$(BLACK)"
78 @echo -e " \$(GREEN)server: ./objs/srs, the srs server\$(BLACK)" 78 @echo -e " \$(GREEN)server: ./objs/srs, the srs server\$(BLACK)"
79 @echo -e " ${SrsHlsSummaryColor}hls: delivery HLS stream, @see: https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryHLS\$(BLACK)" 79 @echo -e " ${SrsHlsSummaryColor}hls: delivery HLS stream, @see: https://github.com/winlinvip/simple-rtmp-server/wiki/DeliveryHLS\$(BLACK)"
@@ -108,20 +108,20 @@ server: _prepare_dir @@ -108,20 +108,20 @@ server: _prepare_dir
108 @echo "build the srs(simple rtmp server) over st(state-threads)" 108 @echo "build the srs(simple rtmp server) over st(state-threads)"
109 \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} srs 109 \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} srs
110 110
111 -bandwidth: _prepare_dir 111 +bandwidth: server
112 @echo "build the bandwidth test client tool" 112 @echo "build the bandwidth test client tool"
113 \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} bandwidth 113 \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} bandwidth
114 114
115 -librtmp: _prepare_dir 115 +librtmp: server
116 @echo "build the client publish/play library." 116 @echo "build the client publish/play library."
117 \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} librtmp 117 \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} librtmp
118 118
119 -librtmp-sample: 119 +librtmp-sample: librtmp
120 @echo "build the srs-librtmp sample" 120 @echo "build the srs-librtmp sample"
121 - (cd research/librtmp; make ${SrsLibrtmpSampleEntry}) 121 + (cd research/librtmp; \$(MAKE) ${SrsLibrtmpSampleEntry})
122 @echo "srs-librtmp sample build success" 122 @echo "srs-librtmp sample build success"
123 123
124 -utest: 124 +utest: server
125 @echo "build the utest for srs" 125 @echo "build the utest for srs"
126 ${SrsUtestMakeEntry} 126 ${SrsUtestMakeEntry}
127 @echo "utest for srs build success" 127 @echo "utest for srs build success"
@@ -154,7 +154,7 @@ AR ?= ar @@ -154,7 +154,7 @@ AR ?= ar
154 CXXFLAGS = ${CXXFLAGS} 154 CXXFLAGS = ${CXXFLAGS}
155 LINK = g++ 155 LINK = g++
156 156
157 -.PHONY: default srs bandwidth 157 +.PHONY: default srs bandwidth librtmp
158 158
159 default: 159 default:
160 160