winlin

osx support build nginx and ffmpeg

  1 +*** configure Sat Nov 30 05:45:08 2013
  2 +--- ../x264-snapshot-20131129-2245-stable-patch/configure Tue Mar 17 21:42:24 2015
  3 +***************
  4 +*** 466,472 ****
  5 + ;;
  6 + darwin*)
  7 + SYS="MACOSX"
  8 +! CFLAGS="$CFLAGS -falign-loops=16"
  9 + libm="-lm"
  10 + if [ "$pic" = "no" ]; then
  11 + cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
  12 +--- 466,472 ----
  13 + ;;
  14 + darwin*)
  15 + SYS="MACOSX"
  16 +! CFLAGS="$CFLAGS"
  17 + libm="-lm"
  18 + if [ "$pic" = "no" ]; then
  19 + cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
@@ -79,6 +79,7 @@ else @@ -79,6 +79,7 @@ else
79 cd $ff_current_dir && 79 cd $ff_current_dir &&
80 rm -rf x264-snapshot-20131129-2245-stable && unzip -q ${ff_src_dir}/x264-snapshot-20131129-2245-stable.zip && 80 rm -rf x264-snapshot-20131129-2245-stable && unzip -q ${ff_src_dir}/x264-snapshot-20131129-2245-stable.zip &&
81 cd x264-snapshot-20131129-2245-stable && 81 cd x264-snapshot-20131129-2245-stable &&
  82 + chmod +w configure && patch -p0 <../../../3rdparty/patches/5.x264.osx.gcc.patch &&
82 ./configure --prefix=${ff_release_dir} --disable-opencl --bit-depth=8 \ 83 ./configure --prefix=${ff_release_dir} --disable-opencl --bit-depth=8 \
83 --enable-static --disable-avs --disable-swscale --disable-lavf \ 84 --enable-static --disable-avs --disable-swscale --disable-lavf \
84 --disable-ffms --disable-gpac && 85 --disable-ffms --disable-gpac &&
@@ -98,6 +98,15 @@ function Ubuntu_prepare() @@ -98,6 +98,15 @@ function Ubuntu_prepare()
98 echo "install unzip success" 98 echo "install unzip success"
99 fi 99 fi
100 100
  101 + if [ $SRS_NGINX = YES ]; then
  102 + if [[ ! -f /usr/include/pcre.h ]]; then
  103 + echo "install libpcre3-dev"
  104 + require_sudoer "sudo apt-get install -y --force-yes libpcre3-dev"
  105 + sudo apt-get install -y --force-yes libpcre3-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
  106 + echo "install libpcre3-dev success"
  107 + fi
  108 + fi
  109 +
101 if [ $SRS_FFMPEG_TOOL = YES ]; then 110 if [ $SRS_FFMPEG_TOOL = YES ]; then
102 autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then 111 autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
103 echo "install autoconf" 112 echo "install autoconf"
@@ -113,13 +122,6 @@ function Ubuntu_prepare() @@ -113,13 +122,6 @@ function Ubuntu_prepare()
113 echo "install libtool success" 122 echo "install libtool success"
114 fi 123 fi
115 124
116 - if [[ ! -f /usr/include/pcre.h ]]; then  
117 - echo "install libpcre3-dev"  
118 - require_sudoer "sudo apt-get install -y --force-yes libpcre3-dev"  
119 - sudo apt-get install -y --force-yes libpcre3-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi  
120 - echo "install libpcre3-dev success"  
121 - fi  
122 -  
123 if [[ ! -f /usr/include/zlib.h ]]; then 125 if [[ ! -f /usr/include/zlib.h ]]; then
124 echo "install zlib1g-dev" 126 echo "install zlib1g-dev"
125 require_sudoer "sudo apt-get install -y --force-yes zlib1g-dev" 127 require_sudoer "sudo apt-get install -y --force-yes zlib1g-dev"
@@ -189,6 +191,15 @@ function Centos_prepare() @@ -189,6 +191,15 @@ function Centos_prepare()
189 echo "install unzip success" 191 echo "install unzip success"
190 fi 192 fi
191 193
  194 + if [ $SRS_NGINX = YES ]; then
  195 + if [[ ! -f /usr/include/pcre.h ]]; then
  196 + echo "install pcre-devel"
  197 + require_sudoer "sudo yum install -y pcre-devel"
  198 + sudo yum install -y pcre-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
  199 + echo "install pcre-devel success"
  200 + fi
  201 + fi
  202 +
192 if [ $SRS_FFMPEG_TOOL = YES ]; then 203 if [ $SRS_FFMPEG_TOOL = YES ]; then
193 automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then 204 automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
194 echo "install automake" 205 echo "install automake"
@@ -211,13 +222,6 @@ function Centos_prepare() @@ -211,13 +222,6 @@ function Centos_prepare()
211 echo "install libtool success" 222 echo "install libtool success"
212 fi 223 fi
213 224
214 - if [[ ! -f /usr/include/pcre.h ]]; then  
215 - echo "install pcre-devel"  
216 - require_sudoer "sudo yum install -y pcre-devel"  
217 - sudo yum install -y pcre-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi  
218 - echo "install pcre-devel success"  
219 - fi  
220 -  
221 if [[ ! -f /usr/include/zlib.h ]]; then 225 if [[ ! -f /usr/include/zlib.h ]]; then
222 echo "install zlib-devel" 226 echo "install zlib-devel"
223 require_sudoer "sudo yum install -y zlib-devel" 227 require_sudoer "sudo yum install -y zlib-devel"
@@ -271,14 +275,6 @@ function OSX_prepare() @@ -271,14 +275,6 @@ function OSX_prepare()
271 echo "OSX does not support stat, use --without-stat" 275 echo "OSX does not support stat, use --without-stat"
272 exit 1 276 exit 1
273 fi 277 fi
274 - if [ $SRS_FFMPEG_TOOL = YES ]; then  
275 - echo "OSX does not support ffmpeg, use --without-ffmpeg"  
276 - exit 1  
277 - fi  
278 - if [ $SRS_NGINX = YES ]; then  
279 - echo "OSX does not support nginx, use --without-nginx"  
280 - exit 1  
281 - fi  
282 fi 278 fi
283 279
284 brew --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then 280 brew --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
@@ -323,6 +319,15 @@ function OSX_prepare() @@ -323,6 +319,15 @@ function OSX_prepare()
323 echo "install unzip success" 319 echo "install unzip success"
324 fi 320 fi
325 321
  322 + if [ $SRS_NGINX = YES ]; then
  323 + if [[ ! -f /usr/local/include/pcre.h ]]; then
  324 + echo "install pcre"
  325 + echo "brew install pcre"
  326 + brew install pcre; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
  327 + echo "install pcre success"
  328 + fi
  329 + fi
  330 +
326 if [ $SRS_FFMPEG_TOOL = YES ]; then 331 if [ $SRS_FFMPEG_TOOL = YES ]; then
327 automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then 332 automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
328 echo "install automake" 333 echo "install automake"
@@ -338,25 +343,18 @@ function OSX_prepare() @@ -338,25 +343,18 @@ function OSX_prepare()
338 echo "install autoconf success" 343 echo "install autoconf success"
339 fi 344 fi
340 345
341 - libtool --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then 346 + which libtool >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
342 echo "install libtool" 347 echo "install libtool"
343 echo "brew install libtool" 348 echo "brew install libtool"
344 brew install libtool; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi 349 brew install libtool; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
345 echo "install libtool success" 350 echo "install libtool success"
346 fi 351 fi
347 352
348 - if [[ ! -f /usr/include/pcre.h ]]; then  
349 - echo "install pcre-devel"  
350 - echo "brew install pcre-devel"  
351 - brew install pcre-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi  
352 - echo "install pcre-devel success"  
353 - fi  
354 -  
355 - if [[ ! -f /usr/include/zlib.h ]]; then  
356 - echo "install zlib-devel"  
357 - echo "brew install zlib-devel"  
358 - brew install zlib-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi  
359 - echo "install zlib-devel success" 353 + brew info zlib >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
  354 + echo "install zlib"
  355 + echo "brew install zlib"
  356 + brew install zlib; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
  357 + echo "install zlib success"
360 fi 358 fi
361 fi 359 fi
362 360
@@ -448,8 +446,6 @@ if [ $SRS_HTTP_PARSER = YES ]; then @@ -448,8 +446,6 @@ if [ $SRS_HTTP_PARSER = YES ]; then
448 rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip && 446 rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
449 cd http-parser-2.1 && 447 cd http-parser-2.1 &&
450 patch -p0 < ../../3rdparty/patches/2.http.parser.patch && 448 patch -p0 < ../../3rdparty/patches/2.http.parser.patch &&
451 - sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&  
452 - sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&  
453 make CC=${SrsArmCC} AR=${SrsArmAR} package && 449 make CC=${SrsArmCC} AR=${SrsArmAR} package &&
454 cd .. && rm -rf hp && ln -sf http-parser-2.1 hp && 450 cd .. && rm -rf hp && ln -sf http-parser-2.1 hp &&
455 cd .. && touch ${SRS_OBJS}/_flag.st.hp.tmp 451 cd .. && touch ${SRS_OBJS}/_flag.st.hp.tmp
@@ -517,7 +513,11 @@ if [ $__SRS_BUILD_NGINX = YES ]; then @@ -517,7 +513,11 @@ if [ $__SRS_BUILD_NGINX = YES ]; then
517 # srs will write ts/m3u8 file use current user, 513 # srs will write ts/m3u8 file use current user,
518 # nginx default use nobody, so cannot read the ts/m3u8 created by srs. 514 # nginx default use nobody, so cannot read the ts/m3u8 created by srs.
519 cp ${SRS_OBJS}/nginx/conf/nginx.conf ${SRS_OBJS}/nginx/conf/nginx.conf.bk 515 cp ${SRS_OBJS}/nginx/conf/nginx.conf ${SRS_OBJS}/nginx/conf/nginx.conf.bk
  516 + if [ $OS_IS_OSX = YES ]; then
  517 + sed -i '' "s/^.user nobody;/user `whoami`;/g" ${SRS_OBJS}/nginx/conf/nginx.conf
  518 + else
520 sed -i "s/^.user nobody;/user `whoami`;/g" ${SRS_OBJS}/nginx/conf/nginx.conf 519 sed -i "s/^.user nobody;/user `whoami`;/g" ${SRS_OBJS}/nginx/conf/nginx.conf
  520 + fi
521 fi 521 fi
522 522
523 # the demo dir. 523 # the demo dir.