Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit efc0b7a

Browse filesBrowse files
committed
Merge pull request markus-perl#4 from Mirabis/master
Numjobs & safety tweaks
2 parents 30cf6c4 + 997b42b commit efc0b7a
Copy full SHA for efc0b7a

File tree

Expand file treeCollapse file tree

1 file changed

+52
-42
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+52
-42
lines changed

‎build-ffmpeg

Copy file name to clipboardExpand all lines: build-ffmpeg
+52-42Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
#!/bin/bash
22

33
# https://github.com/markus-perl/ffmpeg-build-script
4-
# Version 0.3
4+
# Version 0.4
55

6-
CWD=`pwd`
6+
CWD=$(pwd)
77
PACKAGES="$CWD/packages"
88
WORKSPACE="$CWD/workspace"
99
CC=clang
1010
LDFLAGS="-L${WORKSPACE}/lib -lm"
1111
CFLAGS="-I${WORKSPACE}/include"
1212
PKG_CONFIG_PATH="${WORKSPACE}/lib/pkgconfig"
1313

14+
# Speed up the process
15+
# Env Var NUMJOBS overrides automatic detection
16+
if [[ -n $NUMJOBS ]]; then
17+
MJOBS=$NUMJOBS
18+
elif [[ -f /proc/cpuinfo ]]; then
19+
MJOBS=$(grep -c processor /proc/cpuinfo)
20+
else
21+
MJOBS=4
22+
fi
23+
echo "Using $MJOBS make jobs simultaneously."
24+
1425
make_dir () {
1526
if [ ! -d $1 ]; then
1627
if ! mkdir $1; then
17-
echo "\nFailed to create dir $1";
28+
printf "\n Failed to create dir %s" "$1";
1829
exit 1
1930
fi
2031
fi
@@ -49,13 +60,13 @@ download () {
4960
}
5061

5162
execute () {
52-
echo "$ $@"
63+
echo "$ $*"
5364
OUTPUT="$($@ 2>&1)"
5465

5566
if [ $? -ne 0 ]; then
56-
echo $OUTPUT
67+
echo "$OUTPUT"
5768
echo ""
58-
echo "Failed to Execute $@" >&2
69+
echo "Failed to Execute $*" >&2
5970
exit 1
6071
fi
6172
}
@@ -75,7 +86,7 @@ build () {
7586
}
7687

7788
command_exists() {
78-
if ! [ -x "$(command -v $1)" ]; then
89+
if ! [[ -x $(command -v "$1") ]]; then
7990
return 1
8091
fi
8192

@@ -124,120 +135,120 @@ fi
124135

125136
if build "yasm"; then
126137
download "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz" "yasm-1.3.0.tar.gz"
127-
cd $PACKAGES/yasm-1.3.0
128-
execute ./configure --prefix=${WORKSPACE}
129-
execute make -j 4
138+
cd $PACKAGES/yasm-1.3.0 || exit
139+
execute ./configure --prefix=${WORKSPACE}
140+
execute make -j $MJOBS
130141
execute make install
131142
build_done "yasm"
132143
fi
133144

134145
if build "opencore"; then
135146
download "http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Fopencore-amr%2F&ts=1442256558&use_mirror=netassist" "opencore-amr-0.1.3.tar.gz"
136-
cd $PACKAGES/opencore-amr-0.1.3
147+
cd $PACKAGES/opencore-amr-0.1.3 || exit
137148
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
138-
execute make -j 4
149+
execute make -j $MJOBS
139150
execute make install
140151
build_done "opencore"
141152
fi
142153

143154
if build "libvpx"; then
144155
download "https://github.com/webmproject/libvpx/archive/v1.5.0.tar.gz" "libvpx-1.5.0.tar.gz"
145-
cd $PACKAGES/libvpx*
156+
cd $PACKAGES/libvpx* || exit
146157
sed -e 's/cp -p/cp/' -i build/make/Makefile
147158
execute ./configure --prefix=${WORKSPACE} --disable-unit-tests --disable-shared
148-
execute make -j 4
159+
execute make -j $MJOBS
149160
execute make install
150161
build_done "libvpx"
151162
fi
152163

153164
if build "lame"; then
154165
download "http://kent.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz" "lame-3.99.5.tar.gz"
155-
cd $PACKAGES/lame-3.99.5
166+
cd $PACKAGES/lame-3.99.5 || exit
156167
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
157-
execute make -j 4
168+
execute make -j $MJOBS
158169
execute make install
159170
build_done "lame"
160171
fi
161172

162173
if build "xvidcore"; then
163174
download "http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz" "xvidcore-1.3.3.tar.gz"
164-
cd $PACKAGES/xvidcore
165-
cd build/generic
175+
cd $PACKAGES/xvidcore || exit
176+
cd build/generic || exit
166177
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
167-
execute make -j 4
178+
execute make -j $MJOBS
168179
execute make install
169180

170-
if [ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]; then
171-
execute rm ${WORKSPACE}/lib/libxvidcore.4.dylib
181+
if [[ -f ${WORKSPACE}/lib/libxvidcore.4.dylib ]]; then
182+
execute rm "${WORKSPACE}/lib/libxvidcore.4.dylib"
172183
fi
173184

174185
build_done "xvidcore"
175186
fi
176187

177188
if build "x264"; then
178189
download "ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2" "last_x264.tar.bz2"
179-
cd $PACKAGES/x264-snapshot-*
190+
cd $PACKAGES/x264-snapshot-* || exit
180191
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
181-
execute make -j 4
192+
execute make -j $MJOBS
182193
execute make install
183194
execute make install-lib-static
184195
build_done "x264"
185196
fi
186197

187198
if build "libogg"; then
188199
download "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz" "libogg-1.3.2.tar.gz"
189-
cd $PACKAGES/libogg-1.3.2
200+
cd $PACKAGES/libogg-1.3.2 || exit
190201
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
191-
execute make -j 4
202+
execute make -j $MJOBS
192203
execute make install
193204
build_done "libogg"
194205
fi
195206

196207
if build "libvorbis"; then
197208
download "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz" "libvorbis-1.3.5.tar.gz"
198-
cd $PACKAGES/libvorbis-1.3.5
209+
cd $PACKAGES/libvorbis-1.3.5 || exit
199210
execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE}/lib --with-ogg-includes=${WORKSPACE}/include/ --enable-static --disable-shared --disable-oggtest
200-
execute make -j 4
211+
execute make -j $MJOBS
201212
execute make install
202213
build_done "libvorbis"
203214
fi
204215

205216
if build "libtheora"; then
206217
download "http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz" "libtheora-1.1.1.tar.bz"
207-
cd $PACKAGES/libtheora-1.1.1
218+
cd $PACKAGES/libtheora-1.1.1 || exit
208219
sed "s/-fforce-addr//g" configure > configure.patched
209220
chmod +x configure.patched
210221
mv configure.patched configure
211222
execute ./configure --prefix=${WORKSPACE} --with-ogg-libraries=${WORKSPACE}/lib --with-ogg-includes=${WORKSPACE}/include/ --with-vorbis-libraries=${WORKSPACE}/lib --with-vorbis-includes=${WORKSPACE}/include/ --enable-static --disable-shared --disable-oggtest --disable-vorbistest --disable-examples --disable-asm
212-
execute make -j 4
223+
execute make -j $MJOBS
213224
execute make install
214225
build_done "libtheora"
215226
fi
216227

217228
if build "pkg-config"; then
218229
download "http://pkgconfig.freedesktop.org/releases/pkg-config-0.29.1.tar.gz" "pkg-config-0.29.1.tar.gz"
219-
cd $PACKAGES/pkg-config-0.29.1
230+
cd $PACKAGES/pkg-config-0.29.1 || exit
220231
execute ./configure --silent --prefix=${WORKSPACE} --with-pc-path=${WORKSPACE}/lib/pkgconfig --with-internal-glib
221-
execute make -j 4
232+
execute make -j $MJOBS
222233
execute make install
223234
build_done "pkg-config"
224235
fi
225236

226237
if build "cmake"; then
227238
download "https://cmake.org/files/v3.5/cmake-3.5.0.tar.gz" "cmake-3.5.0.tar.gz"
228-
cd $PACKAGES/cmake*
239+
cd $PACKAGES/cmake* || exit
229240
rm Modules/FindJava.cmake
230241
perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
231242
perl -p -i -e "s/get_filename_component.JNIPATH/#get_filename_component(JNIPATH/g" Tests/CMakeLists.txt
232243
execute ./configure --prefix=${WORKSPACE}
233-
execute make -j 4
244+
execute make -j $MJOBS
234245
execute make install
235246
build_done "cmake"
236247
fi
237248

238249
if build "vid_stab"; then
239250
download "https://codeload.github.com/georgmartius/vid.stab/legacy.tar.gz/release-0.98b" "vid.stab-0.98b-transcode-1.1-binary-x86_64.tgz"
240-
cd $PACKAGES/georgmartius-vid*
251+
cd $PACKAGES/georgmartius-vid* || exit
241252
perl -p -i -e "s/vidstab SHARED/vidstab STATIC/" CMakeLists.txt
242253
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} .
243254
execute make -s install
@@ -246,10 +257,10 @@ fi
246257

247258
if build "x265"; then
248259
download "https://bitbucket.org/multicoreware/x265/downloads/x265_1.9.tar.gz" "x265-1.9.tar.gz"
249-
cd $PACKAGES/x265_1.9
250-
cd source
260+
cd $PACKAGES/x265_1.9 || exit
261+
cd source || exit
251262
execute cmake -DCMAKE_INSTALL_PREFIX:PATH=${WORKSPACE} -DENABLE_SHARED:bool=off .
252-
execute make -j 4
263+
execute make -j $MJOBS
253264
execute make install
254265
sed "s/-lx265/-lx265 -lstdc++/g" "$WORKSPACE/lib/pkgconfig/x265.pc" > "$WORKSPACE/lib/pkgconfig/x265.pc.tmp"
255266
mv "$WORKSPACE/lib/pkgconfig/x265.pc.tmp" "$WORKSPACE/lib/pkgconfig/x265.pc"
@@ -258,21 +269,20 @@ fi
258269

259270
if build "fdk_aac"; then
260271
download "http://downloads.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.4.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fopencore-amr%2Ffiles%2Ffdk-aac%2F&ts=1457561564&use_mirror=kent" "fdk-aac-0.1.4.tar.gz"
261-
262-
cd $PACKAGES/fdk-aac*
272+
cd $PACKAGES/fdk-aac* || exit
263273
execute ./configure --prefix=${WORKSPACE} --disable-shared --enable-static
264-
execute make -j 4
274+
execute make -j $MJOBS
265275
execute make install
266276
build_done "fdk_aac"
267277
fi
268278

269279

270280
build "ffmpeg"
271281
download "http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 " "ffmpeg-snapshot.tar.bz2 "
272-
cd $PACKAGES/ffmpeg*
282+
cd $PACKAGES/ffmpeg* || exit
273283
CFLAGS="-I$WORKSPACE/include" LDFLAGS="-L$WORKSPACE/lib"
274284
execute ./configure --arch=64 --prefix=${WORKSPACE} --extra-cflags="-I$WORKSPACE/include" --extra-ldflags="-L$WORKSPACE/lib" --extra-version=static --disable-debug --disable-shared --enable-static --extra-cflags=--static --disable-ffplay --disable-ffserver --disable-doc --enable-version3 --enable-libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-gpl --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-nonfree --enable-filters --enable-libvidstab --enable-libx265 --enable-runtime-cpudetect --enable-libfdk-aac
275-
execute make -j 4
285+
execute make -j $MJOBS
276286
execute make install
277287

278288
INSTALL_FOLDER="/usr/bin"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.