-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sh
executable file
·170 lines (145 loc) · 3.61 KB
/
build.sh
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
162
163
164
165
166
167
168
169
170
#!/bin/sh
set -e
set -u
jflag=
jval=2
while getopts 'j:' OPTION
do
case $OPTION in
j) jflag=1
jval="$OPTARG"
;;
?) printf "Usage: %s: [-j concurrency_level] (hint: your cores + 20%%)\n" $(basename $0) >&2
exit 2
;;
esac
done
shift $(($OPTIND - 1))
if [ $# -gt 0 ]
then
jval="$1"
fi
if [ "$jflag" ]
then
if [ "$jval" ]
then
printf "Option -j specified (%d)\n" $jval
fi
fi
cd `dirname $0`
ENV_ROOT=`pwd`
. ./env.source
#if you want a rebuild
#rm -rf "$BUILD_DIR" "$TARGET_DIR"
mkdir -p "$BUILD_DIR" "$TARGET_DIR" "$DOWNLOAD_DIR" "$BIN_DIR"
#download and extract package
download(){
filename="$1"
if [ ! -z "$2" ];then
filename="$2"
fi
../download.pl "$DOWNLOAD_DIR" "$1" "$filename" "$3" "$4"
#disable uncompress
CACHE_DIR="$DOWNLOAD_DIR" ../fetchurl "http://cache/$filename"
}
echo "#### FFmpeg static build ####"
#this is our working directory
cd $BUILD_DIR
download \
"yasm-1.3.0.tar.gz" \
"" \
"fc9e586751ff789b34b1f21d572d96af" \
"http://www.tortall.net/projects/yasm/releases/"
download \
"last_stable_x264.tar.bz2" \
"" \
"" \
"https://download.videolan.org/pub/videolan/x264/snapshots/"
download \
"x265_1.7.tar.gz" \
"" \
"ff31a807ebc868aa59b60706e303102f" \
"https://bitbucket.org/multicoreware/x265/downloads/"
download \
"master" \
"fdk-aac.tar.gz" \
"" \
"https://github.com/mstorsjo/fdk-aac/tarball"
download \
"lame-3.99.5.tar.gz" \
"" \
"84835b313d4a8b68f5349816d33e07ce" \
"http://downloads.sourceforge.net/project/lame/lame/3.99"
download \
"opus-1.1.tar.gz" \
"" \
"c5a8cf7c0b066759542bc4ca46817ac6" \
"http://downloads.xiph.org/releases/opus"
download \
"faac-1.28.tar.bz2" \
"" \
"c5dde68840cefe46532089c9392d1df0" \
"http://downloads.sourceforge.net/faac/"
download \
"ffmpeg-3.0.tar.gz" \
"" \
"" \
"https://github.com/FFmpeg/FFmpeg/releases/download/n3.0"
echo "*** Building yasm ***"
cd $BUILD_DIR/yasm*
./configure --prefix=$TARGET_DIR --bindir=$BIN_DIR
make -j $jval
make install
echo "*** Building x264 ***"
cd $BUILD_DIR/x264*
PATH="$BIN_DIR:$PATH" ./configure --prefix=$TARGET_DIR --enable-static --disable-shared --disable-opencl
PATH="$BIN_DIR:$PATH" make -j $jval
make install
echo "*** Building x265 ***"
cd $BUILD_DIR/x265*
cd build/linux
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" -DENABLE_SHARED:bool=off ../../source
make -j $jval
make install
echo "*** Building fdk-aac ***"
cd $BUILD_DIR/mstorsjo-fdk-aac*
autoreconf -fiv
./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
make install
echo "*** Building mp3lame ***"
cd $BUILD_DIR/lame*
./configure --prefix=$TARGET_DIR --enable-nasm --disable-shared
make -j $jval
echo "*** Building opus ***"
cd $BUILD_DIR/opus*
./configure --prefix=$TARGET_DIR --disable-shared
make -j $jval
# FFMpeg
echo "*** Building FFmpeg ***"
cd $BUILD_DIR/ffmpeg*
PATH="$BIN_DIR:$PATH" \
PKG_CONFIG_PATH="$TARGET_DIR/lib/pkgconfig" ./configure \
--prefix="$TARGET_DIR" \
--pkg-config-flags="--static" \
--extra-cflags="-I$TARGET_DIR/include -I$TARGET_DIR/include/bm -std=c11" \
--extra-ldflags="-L$TARGET_DIR/lib" \
--bindir="$BIN_DIR" \
--cc=clang \
--cxx=clang++ \
--enable-static \
--enable-decklink \
--enable-gpl \
--enable-libfdk-aac \
--enable-libx264 \
--enable-nonfree \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-sdl
# Stupid hack to override ffmpeg's too-automatic build process
sed -i '' 's/CXXFLAGS += $(CPPFLAGS) $(CFLAGS)/CXXFLAGS += $(CPPFLAGS) $(CFLAGS) -std=c++03/g' $BUILD_DIR/ffmpeg-3.0/common.mak
PATH="$BIN_DIR:$PATH" make VERBOSE=1 -j $jval
make install -j $jval
make distclean
hash -r