forked from pyke369/sffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_all
executable file
·161 lines (161 loc) · 3.36 KB
/
build_all
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
HD=`cd "${0%/*}" 2> /dev/null; echo $PWD`
#
os() {
case `uname` in
Linux )
# CentOS, RHEL, Ubuntu, Debian, openSUSE, SLES, SciL, Amazon
awk '{
if (length($0) == 0) next;
sub("Welcome to",""); # Appears in openSUSE and SLES
if (match($0, "Red Hat Enterprise Linux")) { print "RHEL"; }
else if (match($0, "SUSE Linux Enterprise Server")) { print "SLES"; }
else if (match($0, "Scientific Linux")) { print "SciL"; }
else { print $1; }
exit 0
}' /etc/issue
[ $? -ne 0 ] && return 1
;;
Darwin )
echo MacOS
;;
* )
uname
;;
esac
return 0
}
#
os_ver() {
case `uname` in
Linux )
# CentOS, RHEL, Ubuntu, Debian, openSUSE, SLES, SciL, Amazon
lsb_release -sd | awk '{
if (length($0) == 0) next;
sub("^[^0-9.]*", "");
sub("\\(.*$", "");
sub("[^0-9.]*$", "");
print $0;
exit 0
}'
[ ${PIPESTATUS[0]} -ne 0 -o ${PIPESTATUS[1]} -ne 0 ] && return 1
;;
Darwin )
sw_vers | awk '/^ProductVersion:/ {
sub("^[^0-9.]*", ""); sub("[^0-9.]*$", "");
print $0;
exit 0
}'
[ ${PIPESTATUS[0]} -ne 0 -o ${PIPESTATUS[1]} -ne 0 ] && return 1
;;
* )
return 1
;;
esac
return 0
}
#
arch() {
case `uname -m` in
i386 | i486 | i586 | i686 )
echo i386
;;
x86_64 | x64 )
echo x86_64
;;
* )
uname -m
;;
esac
return 0
}
#
# Main
#
cd "$HD"
[ $? -ne 0 ] && exit 1
#
unset JAVA_HOME
case `os` in
CentOS | RHEL | SciL )
./centos-prereq
[ $? -ne 0 ] && exit 1
touch .prereq_done
;;
Ubuntu )
./enable-source
[ $? -ne 0 ] && exit 1
./ubuntu-prereq
[ $? -ne 0 ] && exit 1
if [ ! -f .prereq_done ]; then
# patch ffmpeg's CMakeLists.txt for udev
patch -N -p0 < vendor/cmake-udev.patch
[ $? -ne 0 ] && exit 1
apt-get -y install libudev-dev
[ $? -ne 0 ] && exit 1
if [ ! -s /lib/`arch`-linux-gnu/libudev.a ]; then
# Build static libudev
cd udev
[ $? -ne 0 ] && exit 1
./build_udev
[ $? -ne 0 ] && exit 1
cd ..
[ $? -ne 0 ] && exit 1
fi
fi
touch .prereq_done
;;
Debian )
./debian-prereq
[ $? -ne 0 ] && exit 1
if [ ! -f .prereq_done ]; then
patch -N -p0 < vendor/cmake-udev.patch
[ $? -ne 0 ] && exit 1
case `os_ver` in
7.* )
if [ ! -s /lib/`arch`-linux-gnu/libudev.a ]; then
# Build static libudev
cd udev
[ $? -ne 0 ] && exit 1
./build_udev
[ $? -ne 0 ] && exit 1
cd ..
[ $? -ne 0 ] && exit 1
fi
;;
esac
fi
touch .prereq_done
;;
* )
echo "Unsupported operating system: `os`" 1>&2
exit 1
;;
esac
#
cmake_ver=`cmake --version 2> /dev/null | awk '{split($3, a, "."); printf("%02d%02d%02d", a[1], a[2], a[3]); exit}'`
if [ "$cmake_ver" -lt "030200" ]; then
# Build latest cmake
cd cmake
[ $? -ne 0 ] && exit 1
./build_cmake
[ $? -ne 0 ] && exit 1
cd ..
[ $? -ne 0 ] && exit 1
fi
make 2>&1 | tee make.log
[ $? -ne 0 ] && exit 1
tail -1 make.log | grep -q 'Error [12]'
[ ${PIPESTATUS[0]} -ne 0 -o ${PIPESTATUS[1]} -eq 0 ] && exit 1
cd package
[ $? -ne 0 ] && exit 1
./build_package
[ $? -ne 0 ] && exit 1
case `os` in
Ubuntu | Debian )
./build_debian_package
[ $? -ne 0 ] && exit 1
;;
esac
#
exit 0