blob: 7b1ead2c28c18fdf7deaf716b7a5330cab587597 (
plain)
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
#!/bin/bash
DISTRO=""
SRC="$HOME/src/blender-deps"
CWD=$PWD
THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"`
PYTHON_VERSION="3.3.0"
BOOST_VERSION="1_51_0"
OIIO_VERSION="1.1.0"
OCIO_VERSION="1.0.7"
FFMPEG_VERSION="1.0"
HASXVID=false
HASVPX=false
HASMP3LAME=false
HASX264=false
HASOPENJPEG=false
HASSCHRO=false
ERROR() {
echo "${@}"
}
INFO() {
echo "${@}"
}
detect_distro() {
if [ -f /etc/debian_version ]; then
DISTRO="DEB"
elif [ -f /etc/redhat-release ]; then
DISTRO="RPM"
elif [ -f /etc/SuSE-release ]; then
DISTRO="SUSE"
fi
}
prepare_opt() {
INFO "Ensuring /opt/lib exists and writable by us"
sudo mkdir -p /opt/lib
sudo chown $USER /opt/lib
sudo chmod 775 /opt/lib
}
compile_Python() {
if [ ! -d /opt/lib/python-$PYTHON_VERSION ]; then
INFO "Building Python-$PYTHON_VERSION"
prepare_opt
if [ ! -d $SRC/Python-$PYTHON_VERSION ]; then
mkdir -p $SRC
wget -c http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.bz2 -P $SRC
INFO "Unpacking Python-$PYTHON_VERSION"
tar -C $SRC -xf $SRC/Python-$PYTHON_VERSION.tar.bz2
fi
cd $SRC/Python-$PYTHON_VERSION
./configure --prefix=/opt/lib/python-$PYTHON_VERSION --enable-ipv6 \
--enable-loadable-sqlite-extensions --with-dbmliborder=bdb \
--with-computed-gotos --with-pymalloc
make -j$THREADS
make install
make clean
rm -f /opt/lib/python-3.3
ln -s python-$PYTHON_VERSION /opt/lib/python-3.3
cd $CWD
fi
}
compile_Boost() {
INFO "Building boost"
version_dots=`echo "$BOOST_VERSION" | sed -r 's/_/./g'`
if [ ! -d /opt/lib/boost-$version_dots ]; then
INFO "Building Boost-$version_dots"
prepare_opt
if [ ! -d $SRC/boost_$BOOST_VERSION ]; then
INFO "Downloading Boost-$version_dots"
mkdir -p $SRC
wget -c http://sourceforge.net/projects/boost/files/boost/$version_dots/boost_$BOOST_VERSION.tar.bz2/download \
-O $SRC/boost_$BOOST_VERSION.tar.bz2
tar -C $SRC -xf $SRC/boost_$BOOST_VERSION.tar.bz2
fi
cd $SRC/boost_$BOOST_VERSION
./bootstrap.sh --with-libraries=system,filesystem,thread,regex,locale --prefix=/opt/lib/boost-$version_dots
./b2 install
./b2 --clean
rm -f /opt/lib/boost
ln -s boost-$version_dots /opt/lib/boost
cd $CWD
fi
}
compile_OCIO() {
if [ ! -d /opt/lib/ocio-$OCIO_VERSION ]; then
INFO "Building OpenColorIO-$OCIO_VERSION"
prepare_opt
if [ ! -d $SRC/OpenColorIO-$OCIO_VERSION ]; then
INFO "Downloading OpenColorIO-$OCIO_VERSION"
mkdir -p $SRC
wget -c http://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION \
-O $SRC/OpenColorIO-$OCIO_VERSION.tar.gz
INFO "Unpacking OpenColorIO-$OCIO_VERSION"
tar -C "$SRC" -xf $SRC/OpenColorIO-$OCIO_VERSION.tar.gz
mv $SRC/imageworks-OpenColorIO* $SRC/OpenColorIO-$OCIO_VERSION
fi
cd $SRC/OpenColorIO-$OCIO_VERSION
mkdir build
cd build
if file /bin/cp | grep -q '32-bit'; then
cflags="-fPIC -m32 -march=i686"
else
cflags="-fPIC"
fi
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_PREFIX_PATH=/opt/lib/ocio-$OCIO_VERSION \
-D CMAKE_INSTALL_PREFIX=/opt/lib/ocio-$OCIO_VERSION \
-D CMAKE_CXX_FLAGS="$cflags" \
-D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \
..
make -j$THREADS
make install
# Force linking against sttaic libs
rm -f /opt/lib/ocio-$OCIO_VERSION/lib/*.so*
# Additional depencencies
cp ext/dist/lib/libtinyxml.a /opt/lib/ocio-$OCIO_VERSION/lib
cp ext/dist/lib/libyaml-cpp.a /opt/lib/ocio-$OCIO_VERSION/lib
make clean
rm -f /opt/lib/ocio
ln -s ocio-$OCIO_VERSION /opt/lib/ocio
cd $CWD
fi
}
compile_OIIO() {
if [ ! -d /opt/lib/oiio-$OIIO_VERSION ]; then
INFO "Building OpenImageIO-$OIIO_VERSION"
prepare_opt
if [ ! -d $SRC/OpenImageIO-$OIIO_VERSION ]; then
wget -c https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_VERSION \
-O "$SRC/OpenImageIO-$OIIO_VERSION.tar.gz"
INFO "Unpacking OpenImageIO-$OIIO_VERSION"
tar -C $SRC -xf $SRC/OpenImageIO-$OIIO_VERSION.tar.gz
mv $SRC/OpenImageIO-oiio* $SRC/OpenImageIO-$OIIO_VERSION
fi
cd $SRC/OpenImageIO-$OIIO_VERSION
mkdir build
cd build
if [ -d /opt/lib/boost ]; then
boost_root="/opt/lib/boost"
else
boost_root="/usr"
fi
if file /bin/cp | grep -q '32-bit'; then
cflags="-fPIC -m32 -march=i686"
else
cflags="-fPIC"
fi
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_PREFIX_PATH=/opt/lib/oiio-$OIIO_VERSION \
-D CMAKE_INSTALL_PREFIX=/opt/lib/oiio-$OIIO_VERSION \
-D BUILDSTATIC=ON \
-D CMAKE_CXX_FLAGS="$cflags" \
-D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \
-D BOOST_ROOT="$boost_root" \
../src
make -j$THREADS
make install
make clean
rm -f /opt/lib/oiio
ln -s oiio-$OIIO_VERSION /opt/lib/oiio
cd $CWD
fi
}
compile_FFmpeg() {
if [ ! -d /opt/lib/ffmpeg-$FFMPEG_VERSION ]; then
INFO "Building FFmpeg-$FFMPEG_VERSION"
prepare_opt
if [ ! -d $SRC/ffmpeg-$FFMPEG_VERSION ]; then
INFO "Downloading FFmpeg-$FFMPEG_VERSION"
wget -c http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 -P $SRC
INFO "Unpacking FFmpeg-$FFMPEG_VERSION"
tar -C $SRC -xf $SRC/ffmpeg-$FFMPEG_VERSION.tar.bz2
fi
cd $SRC/ffmpeg-$FFMPEG_VERSION
extra=""
if $HASXVID; then
extra="$extra --enable-libxvid"
fi
if $HASVPX; then
extra="$extra --enable-libvpx"
fi
if $HASMP3LAME; then
extra="$extra --enable-libmp3lame"
fi
if $HASX264; then
extra="$extra --enable-libx264"
fi
if $HASOPENJPEG; then
extra="$extra --enable-libopenjpeg"
fi
if $HASSCHRO; then
extra="$extra --enable-libschroedinger"
fi
./configure --cc="gcc -Wl,--as-needed" --extra-ldflags="-pthread -static-libgcc" \
--prefix=/opt/lib/ffmpeg-$FFMPEG_VERSION --enable-static --enable-avfilter --disable-vdpau \
--disable-bzlib --disable-libgsm --disable-libspeex --enable-libtheora \
--enable-libvorbis --enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \
--disable-vaapi --disable-libfaac --disable-nonfree --enable-gpl \
--disable-postproc --disable-x11grab --disable-librtmp --disable-libopencore-amrnb \
--disable-libopencore-amrwb --disable-libdc1394 --disable-version3 --disable-outdev=sdl \
--disable-outdev=alsa --disable-indev=sdl --disable-indev=alsa --disable-indev=jack \
--disable-indev=lavfi $extra
make -j$THERADS
make install
make clean
rm -f /opt/lib/ffmpeg
ln -s ffmpeg-$FFMPEG_VERSION /opt/lib/ffmpeg
cd $CWD
fi
}
deb_version() {
dpkg-query -W -f '${Version}' $1 | sed -r 's/^([0-9]\.[0-9]+).*/\1/'
}
check_package_DEB() {
r=`apt-cache policy $1 | grep -c 'Candidate:'`
if [ $r -ge 1 ]; then
return 0
else
return 1
fi
}
install_DEB() {
INFO "Installing dependencies for DEB-based distributive"
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \
libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \
libssl-dev liblzma-dev libreadline-dev libopenjpeg-dev libopenexr-dev libopenal-dev \
libglew-dev yasm libschroedinger-dev libtheora-dev libvorbis-dev libsdl1.2-dev \
libfftw3-dev libjack-dev python-dev patch
HASOPENJPEG=true
HASSCHRO=true
check_package_DEB libxvidcore4-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libxvidcore4-dev
HASXVID=true
fi
check_package_DEB libmp3lame-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libmp3lame-dev
HASMP3LAME=true
fi
check_package_DEB libx264-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libx264-dev
HASX264=true
fi
check_package_DEB libvpx-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libvpx-dev
vpx_version=`deb_version libvpx-dev`
if [ ! -z "$vpx_version" ]; then
if dpkg --compare-versions $vpx_version gt 0.9.7; then
HASVPX=true
fi
fi
fi
check_package_DEB libspnav-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libspnav-dev
fi
check_package_DEB python3.3-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y python3.3-dev
else
compile_Python
fi
check_package_DEB libboost-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libboost-dev
boost_version=`deb_version libboost-dev`
check_package_DEB libboost-locale$boost_version-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libboost-locale$boost_version-dev libboost-filesystem$boost_version-dev \
libboost-regex$boost_version-dev libboost-system$boost_version-dev libboost-thread$boost_version-dev
else
compile_Boost
fi
else
compile_Boost
fi
check_package_DEB libopencolorio-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libopencolorio-dev
else
compile_OCIO
fi
check_package_DEB libopenimageio-dev
if [ $? -eq 0 ]; then
sudo apt-get install -y libopenimageio-dev
else
compile_OIIO
fi
check_package_DEB ffmpeg
if [ $? -eq 0 ]; then
sudo apt-get install -y ffmpeg
ffmpeg_version=`deb_version ffmpeg`
if [ ! -z "$ffmpeg_version" ]; then
if dpkg --compare-versions $ffmpeg_version gt 0.7.2; then
sudo apt-get install -y libavfilter-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswscale-dev
else
compile_FFmpeg
fi
fi
fi
}
check_package_RPM() {
r=`yum info $1 | grep -c 'Summary'`
if [ $r -ge 1 ]; then
return 0
else
return 1
fi
}
check_package_version_RPM() {
v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'`
# for now major and minor versions only (as if x.y, not x.y.z)
r=`echo $v | grep -c $2`
if [ $r -ge 1 ]; then
return 0
else
return 1
fi
}
install_RPM() {
INFO "Installing dependencies for RPM-based distributive"
sudo yum -y update
sudo yum -y install gcc gcc-c++ cmake scons libpng-devel libtiff-devel \
freetype-devel libX11-devel libXi-devel wget libsqlite3x-devel ncurses-devel \
readline-devel openjpeg-devel openexr-devel openal-soft-devel \
glew-devel yasm schroedinger-devel libtheora-devel libvorbis-devel SDL-devel \
fftw-devel lame-libs jack-audio-connection-kit-devel x264-devel libspnav-devel \
libjpeg-devel patch python-devel
HASOPENJPEG=true
HASSCHRO=true
check_package_version_RPM python-devel 3.3.
if [ $? -eq 0 ]; then
sudo yum install -y python-devel
else
compile_Python
fi
check_package_RPM boost-devel
if [ $? -eq 0 ]; then
sudo yum install -y boost-devel
else
compile_Boost
fi
check_package_RPM OpenColorIO-devel
if [ $? -eq 0 ]; then
sudo yum install -y OpenColorIO-devel
else
compile_OCIO
fi
check_package_RPM OpenImageIO-devel
if [ $? -eq 0 ]; then
sudo yum install -y OpenImageIO-devel
else
compile_OIIO
fi
# Always for now, not sure which packages should be installed
compile_FFmpeg
}
check_package_SUSE() {
r=`zypper info $1 | grep -c 'Summary'`
if [ $r -ge 1 ]; then
return 0
else
return 1
fi
}
check_package_version_SUSE() {
v=`zypper info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'`
# for now major and minor versions only (as if x.y, not x.y.z)
r=`echo $v | grep -c $2`
if [ $r -ge 1 ]; then
return 0
else
return 1
fi
}
install_SUSE() {
INFO "Installing dependencies for SuSE-based distributive"
sudo zypper --non-interactive update --auto-agree-with-licenses
sudo zypper --non-interactive install --auto-agree-with-licenses \
gcc gcc-c++ libSDL-devel openal-soft-devel libpng12-devel libjpeg62-devel \
libtiff-devel OpenEXR-devel yasm libtheora-devel libvorbis-devel cmake \
scons patch
check_package_version_SUSE python3-devel 3.3.
if [ $? -eq 0 ]; then
sudo zypper --non-interactive install --auto-agree-with-licenses python3-devel
else
compile_Python
fi
# can not see boost_locale in repo, so let's build own boost
compile_Boost
# this libraries are also missing in the repo
compile_OCIO
compile_OIIO
compile_FFmpeg
}
print_info() {
INFO ""
INFO "If you're using CMake add this to your configuration flags:"
if [ -d /opt/lib/boost ]; then
INFO " -D BOOST_ROOT=/opt/lib/boost"
INFO " -D Boost_NO_SYSTEM_PATHS=ON"
fi
if [ -d /opt/lib/ffmpeg ]; then
INFO " -D FFMPEG=/opt/lib/ffmpeg"
fi
INFO ""
INFO "If you're using SCons add this to your user-config:"
if [ -d /opt/lib/python3.3 ]; then
INFO "BF_PYTHON='/opt/lib/puthon-3.3'"
INFO "BF_PYTHON_ABI_FLAGS='m'"
fi
if [ -d /opt/lib/ocio ]; then
INFO "BF_OCIO='/opt/lib/ocio'"
fi
if [ -d /opt/lib/oiio ]; then
INFO "BF_OCIO='/opt/lib/oiio'"
fi
if [ -d /opt/lib/boost ]; then
INFO "BF_BOOST='/opt/lib/boost'"
fi
if [ -d /opt/lib/ffmpeg ]; then
INFO "BF_FFMPEG='/opt/lib/ffmpeg'"
fi
}
# Detect distributive type used on this machine
detect_distro
if [ -z "$DISTRO" ]; then
ERROR "Failed to detect distribytive type"
exit 1
elif [ "$DISTRO" = "DEB" ]; then
install_DEB
elif [ "$DISTRO" = "RPM" ]; then
install_RPM
elif [ "$DISTRO" = "SUSE" ]; then
install_SUSE
fi
print_info
|