depends.sh
5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# TODO: check gcc/g++
echo "check gcc/g++/gdb/make/openssl-devel"
echo "depends tools are ok"
#####################################################################################
# st-1.9
#####################################################################################
if [[ -f ${SRS_OBJS}/st-1.9/obj/libst.a && -f ${SRS_OBJS}/st-1.9/obj/libst.so ]]; then
echo "st-1.9t is ok.";
else
echo "build st-1.9t";
(
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && make linux-debug &&
cd .. && rm -f st && ln -sf st-1.9/obj st
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build st-1.9 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/st-1.9/obj/libst.a ]; then echo "build st-1.9 failed."; exit -1; fi
if [ ! -f ${SRS_OBJS}/st-1.9/obj/libst.so ]; then echo "build st-1.9 failed."; exit -1; fi
#####################################################################################
# http-parser-2.1
#####################################################################################
if [[ -f ${SRS_OBJS}/http-parser-2.1/http_parser.h && -f ${SRS_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then
echo "http-parser-2.1 is ok.";
else
echo "build http-parser-2.1";
(
rm -rf ${SRS_OBJS}/http-parser-2.1 && cd ${SRS_OBJS} && unzip -q ../3rdparty/http-parser-2.1.zip &&
cd http-parser-2.1 &&
sed -i "s/CPPFLAGS_FAST +=.*$/CPPFLAGS_FAST = \$\(CPPFLAGS_DEBUG\)/g" Makefile &&
sed -i "s/CFLAGS_FAST =.*$/CFLAGS_FAST = \$\(CFLAGS_DEBUG\)/g" Makefile &&
make package &&
cd .. && rm -f hp && ln -sf http-parser-2.1 hp
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build http-parser-2.1 failed, ret=$ret"; exit $ret; fi
if [[ ! -f ${SRS_OBJS}/http-parser-2.1/http_parser.h ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
if [[ ! -f ${SRS_OBJS}/http-parser-2.1/libhttp_parser.a ]]; then echo "build http-parser-2.1 failed"; exit -1; fi
#####################################################################################
# nginx for HLS, nginx-1.5.0
#####################################################################################
if [ $SRS_HLS = YES ]; then
if [[ -f ${SRS_OBJS}/nginx/sbin/nginx ]]; then
echo "nginx-1.5.7 is ok.";
else
echo "build nginx-1.5.7";
(
rm -rf ${SRS_OBJS}/nginx-1.5.7 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/nginx-1.5.7.zip && cd nginx-1.5.7 &&
./configure --prefix=`pwd`/_release && make && make install &&
cd .. && ln -sf nginx-1.5.7/_release nginx
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build nginx-1.5.7 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/nginx/sbin/nginx ]; then echo "build nginx-1.5.7 failed."; exit -1; fi
# use current user to config nginx,
# srs will write ts/m3u8 file use current user,
# nginx default use nobody, so cannot read the ts/m3u8 created by srs.
cp ${SRS_OBJS}/nginx/conf/nginx.conf ${SRS_OBJS}/nginx/conf/nginx.conf.bk
sed -i "s/^.user nobody;/user `whoami`;/g" ${SRS_OBJS}/nginx/conf/nginx.conf
fi
if [ $SRS_HLS = YES ]; then
echo "#define SRS_HLS" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_HLS" >> $SRS_AUTO_HEADERS_H
fi
#####################################################################################
# openssl, for rtmp complex handshake
#####################################################################################
if [ $SRS_SSL = YES ]; then
echo "#define SRS_SSL" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_SSL" >> $SRS_AUTO_HEADERS_H
fi
#####################################################################################
# live transcoding, ffmpeg-2.1, x264-core138, lame-3.99.5, libaacplus-2.0.2.
#####################################################################################
if [ $SRS_FFMPEG = YES ]; then
if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then
echo "ffmpeg-2.1 is ok.";
else
echo "build ffmpeg-2.1";
(
cd ${SRS_OBJS} && pwd_dir=`pwd` &&
rm -rf ffmepg.src && mkdir -p ffmpeg.src && cd ffmpeg.src &&
rm -f build_ffmpeg.sh && ln -sf ../../auto/build_ffmpeg.sh && . build_ffmpeg.sh &&
cd ${pwd_dir} && ln -sf ffmpeg.src/_release ffmpeg
)
fi
# check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "build ffmpeg-2.1 failed, ret=$ret"; exit $ret; fi
if [ ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]; then echo "build ffmpeg-2.1 failed."; exit -1; fi
fi
if [ $SRS_FFMPEG = YES ]; then
echo "#define SRS_FFMPEG" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_FFMPEG" >> $SRS_AUTO_HEADERS_H
fi
#####################################################################################
# build research code
#####################################################################################
(cd research/hls && make)
ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/hls failed, ret=$ret"; exit $ret; fi
(cd research/ffempty && make)
ret=$?; if [[ $ret -ne 0 ]]; then echo "build research/ffempty failed, ret=$ret"; exit $ret; fi