4 SRC="$HOME/src/blender-deps"
7 THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"`
10 BOOST_VERSION="1_51_0"
24 # Switch to english language, else some things (like check_package_DEB()) won't work!
38 if [ -f /etc/debian_version ]; then
40 elif [ -f /etc/redhat-release ]; then
42 elif [ -f /etc/SuSE-release ]; then
48 INFO "Ensuring /opt/lib exists and writable by us"
49 sudo mkdir -p /opt/lib
50 sudo chown $USER /opt/lib
51 sudo chmod 775 /opt/lib
55 if [ ! -d /opt/lib/python-$PYTHON_VERSION ]; then
56 INFO "Building Python-$PYTHON_VERSION"
60 if [ ! -d $SRC/Python-$PYTHON_VERSION ]; then
62 wget -c http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.bz2 -P $SRC
64 INFO "Unpacking Python-$PYTHON_VERSION"
65 tar -C $SRC -xf $SRC/Python-$PYTHON_VERSION.tar.bz2
68 cd $SRC/Python-$PYTHON_VERSION
70 ./configure --prefix=/opt/lib/python-$PYTHON_VERSION --enable-ipv6 \
71 --enable-loadable-sqlite-extensions --with-dbmliborder=bdb \
72 --with-computed-gotos --with-pymalloc
78 rm -f /opt/lib/python-3.3
79 ln -s python-$PYTHON_VERSION /opt/lib/python-3.3
88 version_dots=`echo "$BOOST_VERSION" | sed -r 's/_/./g'`
90 if [ ! -d /opt/lib/boost-$version_dots ]; then
91 INFO "Building Boost-$version_dots"
95 if [ ! -d $SRC/boost_$BOOST_VERSION ]; then
96 INFO "Downloading Boost-$version_dots"
98 wget -c http://sourceforge.net/projects/boost/files/boost/$version_dots/boost_$BOOST_VERSION.tar.bz2/download \
99 -O $SRC/boost_$BOOST_VERSION.tar.bz2
100 tar -C $SRC -xf $SRC/boost_$BOOST_VERSION.tar.bz2
103 cd $SRC/boost_$BOOST_VERSION
104 ./bootstrap.sh --with-libraries=system,filesystem,thread,regex,locale --prefix=/opt/lib/boost-$version_dots
109 ln -s boost-$version_dots /opt/lib/boost
116 if [ ! -d /opt/lib/ocio-$OCIO_VERSION ]; then
117 INFO "Building OpenColorIO-$OCIO_VERSION"
121 if [ ! -d $SRC/OpenColorIO-$OCIO_VERSION ]; then
122 INFO "Downloading OpenColorIO-$OCIO_VERSION"
124 wget -c http://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION \
125 -O $SRC/OpenColorIO-$OCIO_VERSION.tar.gz
127 INFO "Unpacking OpenColorIO-$OCIO_VERSION"
128 tar -C "$SRC" -xf $SRC/OpenColorIO-$OCIO_VERSION.tar.gz
129 mv $SRC/imageworks-OpenColorIO* $SRC/OpenColorIO-$OCIO_VERSION
132 cd $SRC/OpenColorIO-$OCIO_VERSION
136 if file /bin/cp | grep -q '32-bit'; then
137 cflags="-fPIC -m32 -march=i686"
142 cmake -D CMAKE_BUILD_TYPE=Release \
143 -D CMAKE_PREFIX_PATH=/opt/lib/ocio-$OCIO_VERSION \
144 -D CMAKE_INSTALL_PREFIX=/opt/lib/ocio-$OCIO_VERSION \
145 -D CMAKE_CXX_FLAGS="$cflags" \
146 -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \
152 # Force linking against sttaic libs
153 rm -f /opt/lib/ocio-$OCIO_VERSION/lib/*.so*
155 # Additional depencencies
156 cp ext/dist/lib/libtinyxml.a /opt/lib/ocio-$OCIO_VERSION/lib
157 cp ext/dist/lib/libyaml-cpp.a /opt/lib/ocio-$OCIO_VERSION/lib
162 ln -s ocio-$OCIO_VERSION /opt/lib/ocio
169 if [ ! -d /opt/lib/oiio-$OIIO_VERSION ]; then
170 INFO "Building OpenImageIO-$OIIO_VERSION"
174 if [ ! -d $SRC/OpenImageIO-$OIIO_VERSION ]; then
175 wget -c https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_VERSION \
176 -O "$SRC/OpenImageIO-$OIIO_VERSION.tar.gz"
178 INFO "Unpacking OpenImageIO-$OIIO_VERSION"
179 tar -C $SRC -xf $SRC/OpenImageIO-$OIIO_VERSION.tar.gz
180 mv $SRC/OpenImageIO-oiio* $SRC/OpenImageIO-$OIIO_VERSION
183 cd $SRC/OpenImageIO-$OIIO_VERSION
187 if [ -d /opt/lib/boost ]; then
188 boost_root="/opt/lib/boost"
193 if file /bin/cp | grep -q '32-bit'; then
194 cflags="-fPIC -m32 -march=i686"
199 cmake -D CMAKE_BUILD_TYPE=Release \
200 -D CMAKE_PREFIX_PATH=/opt/lib/oiio-$OIIO_VERSION \
201 -D CMAKE_INSTALL_PREFIX=/opt/lib/oiio-$OIIO_VERSION \
203 -D CMAKE_CXX_FLAGS="$cflags" \
204 -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \
205 -D BOOST_ROOT="$boost_root" \
213 ln -s oiio-$OIIO_VERSION /opt/lib/oiio
220 if [ ! -d /opt/lib/ffmpeg-$FFMPEG_VERSION ]; then
221 INFO "Building FFmpeg-$FFMPEG_VERSION"
225 if [ ! -d $SRC/ffmpeg-$FFMPEG_VERSION ]; then
226 INFO "Downloading FFmpeg-$FFMPEG_VERSION"
227 wget -c http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 -P $SRC
229 INFO "Unpacking FFmpeg-$FFMPEG_VERSION"
230 tar -C $SRC -xf $SRC/ffmpeg-$FFMPEG_VERSION.tar.bz2
233 cd $SRC/ffmpeg-$FFMPEG_VERSION
238 extra="$extra --enable-libxvid"
242 extra="$extra --enable-libvpx"
246 extra="$extra --enable-libmp3lame"
250 extra="$extra --enable-libx264"
253 if $HASOPENJPEG; then
254 extra="$extra --enable-libopenjpeg"
258 extra="$extra --enable-libschroedinger"
261 ./configure --cc="gcc -Wl,--as-needed" --extra-ldflags="-pthread -static-libgcc" \
262 --prefix=/opt/lib/ffmpeg-$FFMPEG_VERSION --enable-static --enable-avfilter --disable-vdpau \
263 --disable-bzlib --disable-libgsm --disable-libspeex --enable-libtheora \
264 --enable-libvorbis --enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \
265 --disable-vaapi --disable-libfaac --disable-nonfree --enable-gpl \
266 --disable-postproc --disable-x11grab --disable-librtmp --disable-libopencore-amrnb \
267 --disable-libopencore-amrwb --disable-libdc1394 --disable-version3 --disable-outdev=sdl \
268 --disable-outdev=alsa --disable-indev=sdl --disable-indev=alsa --disable-indev=jack \
269 --disable-indev=lavfi $extra
275 rm -f /opt/lib/ffmpeg
276 ln -s ffmpeg-$FFMPEG_VERSION /opt/lib/ffmpeg
283 dpkg-query -W -f '${Version}' $1 | sed -r 's/^([0-9]\.[0-9]+).*/\1/'
286 check_package_DEB() {
287 r=`apt-cache policy $1 | grep -c 'Candidate:'`
289 if [ $r -ge 1 ]; then
297 INFO "Installing dependencies for DEB-based distributive"
300 sudo apt-get -y upgrade
302 sudo apt-get install -y cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \
303 libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \
304 libssl-dev liblzma-dev libreadline-dev libopenjpeg-dev libopenexr-dev libopenal-dev \
305 libglew-dev yasm libschroedinger-dev libtheora-dev libvorbis-dev libsdl1.2-dev \
306 libfftw3-dev libjack-dev python-dev patch
311 check_package_DEB libxvidcore-dev
312 if [ $? -eq 0 ]; then
313 sudo apt-get install -y libxvidcore-dev
315 XVIDDEV="libxvidcore-dev"
318 check_package_DEB libxvidcore4-dev
319 if [ $? -eq 0 ]; then
320 sudo apt-get install -y libxvidcore4-dev
322 XVIDDEV="libxvidcore4-dev"
325 check_package_DEB libmp3lame-dev
326 if [ $? -eq 0 ]; then
327 sudo apt-get install -y libmp3lame-dev
331 check_package_DEB libx264-dev
332 if [ $? -eq 0 ]; then
333 sudo apt-get install -y libx264-dev
337 check_package_DEB libvpx-dev
338 if [ $? -eq 0 ]; then
339 sudo apt-get install -y libvpx-dev
340 vpx_version=`deb_version libvpx-dev`
341 if [ ! -z "$vpx_version" ]; then
342 if dpkg --compare-versions $vpx_version gt 0.9.7; then
348 check_package_DEB libspnav-dev
349 if [ $? -eq 0 ]; then
350 sudo apt-get install -y libspnav-dev
353 check_package_DEB python3.3-dev
354 if [ $? -eq 0 ]; then
355 sudo apt-get install -y python3.3-dev
360 check_package_DEB libboost-dev
361 if [ $? -eq 0 ]; then
362 sudo apt-get install -y libboost-dev
364 boost_version=`deb_version libboost-dev`
366 check_package_DEB libboost-locale$boost_version-dev
367 if [ $? -eq 0 ]; then
368 sudo apt-get install -y libboost-locale$boost_version-dev libboost-filesystem$boost_version-dev \
369 libboost-regex$boost_version-dev libboost-system$boost_version-dev libboost-thread$boost_version-dev
377 check_package_DEB libopencolorio-dev
378 if [ $? -eq 0 ]; then
379 sudo apt-get install -y libopencolorio-dev
384 check_package_DEB libopenimageio-dev
385 if [ $? -eq 0 ]; then
386 sudo apt-get install -y libopenimageio-dev
391 # XXX Debian features libav packages as ffmpeg, those are not really compatible with blender code currently :/
392 # So for now, always build our own ffmpeg.
393 # check_package_DEB ffmpeg
394 # if [ $? -eq 0 ]; then
395 # sudo apt-get install -y ffmpeg
396 # ffmpeg_version=`deb_version ffmpeg`
397 # INFO "ffmpeg version: $ffmpeg_version"
398 # if [ ! -z "$ffmpeg_version" ]; then
399 # if dpkg --compare-versions $ffmpeg_version gt 0.7.2; then
400 # sudo apt-get install -y libavfilter-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswscale-dev
409 check_package_RPM() {
410 r=`yum info $1 | grep -c 'Summary'`
412 if [ $r -ge 1 ]; then
419 check_package_version_RPM() {
420 v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'`
422 # for now major and minor versions only (as if x.y, not x.y.z)
423 r=`echo $v | grep -c $2`
425 if [ $r -ge 1 ]; then
433 INFO "Installing dependencies for RPM-based distributive"
437 sudo yum -y install gcc gcc-c++ cmake scons libpng-devel libtiff-devel \
438 freetype-devel libX11-devel libXi-devel wget libsqlite3x-devel ncurses-devel \
439 readline-devel openjpeg-devel openexr-devel openal-soft-devel \
440 glew-devel yasm schroedinger-devel libtheora-devel libvorbis-devel SDL-devel \
441 fftw-devel lame-libs jack-audio-connection-kit-devel x264-devel libspnav-devel \
442 libjpeg-devel patch python-devel
447 check_package_version_RPM python-devel 3.3.
448 if [ $? -eq 0 ]; then
449 sudo yum install -y python-devel
454 check_package_RPM boost-devel
455 if [ $? -eq 0 ]; then
456 sudo yum install -y boost-devel
461 check_package_RPM OpenColorIO-devel
462 if [ $? -eq 0 ]; then
463 sudo yum install -y OpenColorIO-devel
468 check_package_RPM OpenImageIO-devel
469 if [ $? -eq 0 ]; then
470 sudo yum install -y OpenImageIO-devel
475 # Always for now, not sure which packages should be installed
479 check_package_SUSE() {
480 r=`zypper info $1 | grep -c 'Summary'`
482 if [ $r -ge 1 ]; then
489 check_package_version_SUSE() {
490 v=`zypper info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'`
492 # for now major and minor versions only (as if x.y, not x.y.z)
493 r=`echo $v | grep -c $2`
495 if [ $r -ge 1 ]; then
503 INFO "Installing dependencies for SuSE-based distributive"
505 sudo zypper --non-interactive update --auto-agree-with-licenses
507 sudo zypper --non-interactive install --auto-agree-with-licenses \
508 gcc gcc-c++ libSDL-devel openal-soft-devel libpng12-devel libjpeg62-devel \
509 libtiff-devel OpenEXR-devel yasm libtheora-devel libvorbis-devel cmake \
512 check_package_version_SUSE python3-devel 3.3.
513 if [ $? -eq 0 ]; then
514 sudo zypper --non-interactive install --auto-agree-with-licenses python3-devel
519 # can not see boost_locale in repo, so let's build own boost
522 # this libraries are also missing in the repo
528 print_info_ffmpeglink_DEB() {
529 _packages="libtheora-dev"
532 _packages="$_packages $XVIDDEV"
536 _packages="$_packages libvpx-dev"
540 _packages="$_packages libmp3lame-dev"
544 _packages="$_packages libx264-dev"
547 if $HASOPENJPEG; then
548 _packages="$_packages libopenjpeg-dev"
552 _packages="$_packages libschroedinger-dev"
555 dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.so" | awk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^/]+)\.so/, "\\1", "g", $0)); nlines++ }'
558 print_info_ffmpeglink() {
559 # This func must only print a ';'-separated list of libs...
560 if [ -z "$DISTRO" ]; then
561 ERROR "Failed to detect distribution type"
563 elif [ "$DISTRO" = "DEB" ]; then
564 print_info_ffmpeglink_DEB
566 else INFO "<Could not determine additional link libraries needed for ffmpeg, replace this by valid list of libs...>"
567 # elif [ "$DISTRO" = "RPM" ]; then
568 # print_info_ffmpeglink_RPM
569 # elif [ "$DISTRO" = "SUSE" ]; then
570 # print_info_ffmpeglink_SUSE
576 INFO "If you're using CMake add this to your configuration flags:"
578 if [ -d /opt/lib/boost ]; then
579 INFO " -D BOOST_ROOT=/opt/lib/boost"
580 INFO " -D Boost_NO_SYSTEM_PATHS=ON"
583 if [ -d /opt/lib/ffmpeg ]; then
584 INFO " -D WITH_CODEC_FFMPEG=ON"
585 INFO " -D FFMPEG=/opt/lib/ffmpeg"
586 INFO " -D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;`print_info_ffmpeglink`'"
590 INFO "If you're using SCons add this to your user-config:"
592 if [ -d /opt/lib/python3.3 ]; then
593 INFO "BF_PYTHON='/opt/lib/puthon-3.3'"
594 INFO "BF_PYTHON_ABI_FLAGS='m'"
597 if [ -d /opt/lib/ocio ]; then
598 INFO "BF_OCIO='/opt/lib/ocio'"
601 if [ -d /opt/lib/oiio ]; then
602 INFO "BF_OIIO='/opt/lib/oiio'"
605 if [ -d /opt/lib/boost ]; then
606 INFO "BF_BOOST='/opt/lib/boost'"
609 if [ -d /opt/lib/ffmpeg ]; then
610 INFO "BF_FFMPEG='/opt/lib/ffmpeg'"
612 INFO "BF_FFMPEG_LIB='avformat avcodec swscale avutil avdevice `print_info_ffmpeglink`'"
616 # Detect distributive type used on this machine
619 if [ -z "$DISTRO" ]; then
620 ERROR "Failed to detect distribution type"
622 elif [ "$DISTRO" = "DEB" ]; then
624 elif [ "$DISTRO" = "RPM" ]; then
626 elif [ "$DISTRO" = "SUSE" ]; then
632 # Switch back to user language.