Merge branch 'master' into blender2.8
[blender.git] / build_files / build_environment / install_deps.sh
1 #!/usr/bin/env bash
2 # ##### BEGIN GPL LICENSE BLOCK #####
3 #
4 #  This program is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU General Public License
6 #  as published by the Free Software Foundation; either version 2
7 #  of the License, or (at your option) any later version.
8 #
9 #  This program is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #  GNU General Public License for more details.
13 #
14 #  You should have received a copy of the GNU General Public License
15 #  along with this program; if not, write to the Free Software Foundation,
16 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # ##### END GPL LICENSE BLOCK #####
19
20 # A shell script installing/building all needed dependencies to build Blender, for some Linux distributions.
21
22 ##### Args and Help Handling #####
23
24 # Parse command line!
25 ARGS=$( \
26 getopt \
27 -o s:i:t:h \
28 --long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
29 with-all,with-opencollada,with-jack,\
30 ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
31 force-all,force-python,force-numpy,force-boost,\
32 force-ocio,force-openexr,force-oiio,force-llvm,force-osl,force-osd,force-openvdb,\
33 force-ffmpeg,force-opencollada,force-alembic,\
34 build-all,build-python,build-numpy,build-boost,\
35 build-ocio,build-openexr,build-oiio,build-llvm,build-osl,build-osd,build-openvdb,\
36 build-ffmpeg,build-opencollada,build-alembic,\
37 skip-python,skip-numpy,skip-boost,\
38 skip-ocio,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-osd,skip-openvdb,\
39 skip-ffmpeg,skip-opencollada,skip-alembic \
40 -- "$@" \
41 )
42
43 COMMANDLINE=$@
44
45 DISTRO=""
46 RPM=""
47 SRC="$HOME/src/blender-deps"
48 INST="/opt/lib"
49 TMP="/tmp"
50 CWD=$PWD
51 INFO_PATH=$CWD
52 SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
53
54 # Do not install some optional, potentially conflicting libs by default...
55 WITH_ALL=false
56
57 # Do not yet enable opencollada, use --with-opencollada (or --with-all) option to try it.
58 WITH_OPENCOLLADA=false
59
60 THREADS=$(nproc)
61
62 COMMON_INFO="\"Source code of dependencies needed to be compiled will be downloaded and extracted into '\$SRC'.
63 Built libs of dependencies needed to be compiled will be installed into '\$INST'.
64 Please edit \\\$SRC and/or \\\$INST variables at the beginning of this script,
65 or use --source/--install options, if you want to use other paths!
66
67 Number of threads for building: \$THREADS (automatically detected, use --threads=<nbr> to override it).
68 Full install: \$WITH_ALL (use --with-all option to enable it).
69 Building OpenCOLLADA: \$WITH_OPENCOLLADA (use --with-opencollada option to enable it).
70
71 Example:
72 Full install without OpenCOLLADA: --with-all --skip-opencollada
73
74 Use --help to show all available options!\""
75
76 ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
77     -h, --help
78         Show this message and exit.
79
80     --show-deps
81         Show main dependencies of Blender (including officially supported versions) and exit.
82
83     -s <path>, --source=<path>
84         Use a specific path where to store downloaded libraries sources (defaults to '\$SRC').
85
86     -i <path>, --install=<path>
87         Use a specific path where to install built libraries (defaults to '\$INST').
88
89     --tmp=<path>
90         Use a specific temp path (defaults to '\$TMP').
91
92     --info=<path>
93         Use a specific info path (to store BUILD_NOTES.txt, defaults to '\$INFO_PATH').
94
95     -t n, --threads=n
96         Use a specific number of threads when building the libraries (auto-detected as '\$THREADS').
97
98     --no-sudo
99         Disable use of sudo (this script won't be able to do much though, will just print needed packages...).
100
101     --no-build
102         Do not build (compile) anything, dependencies not installable with the package manager will remain missing.
103
104     --no-confirm
105         Disable any interaction with user (suitable for automated run).
106
107     --with-all
108         By default, a number of optional and not-so-often needed libraries are not installed.
109         This option will try to install them, at the cost of potential conflicts (depending on
110         how your package system is set…).
111         Note this option also implies all other (more specific) --with-foo options below.
112
113     --with-opencollada
114         Build and install the OpenCOLLADA libraries.
115
116     --with-jack
117         Install the jack libraries.
118
119     --ver-ocio=<ver>
120         Force version of OCIO library.
121
122     --ver-oiio=<ver>
123         Force version of OIIO library.
124
125     --ver-llvm=<ver>
126         Force version of LLVM library.
127
128     --ver-osl=<ver>
129         Force version of OSL library.
130
131     --ver-osd=<ver>
132         Force version of OSD library.
133
134     --ver-openvdb=<ver>
135         Force version of OpenVDB library.
136
137     Note about the --ver-foo options:
138         It may not always work as expected (some libs are actually checked out from a git rev...), yet it might help
139         to fix some build issues (like LLVM mismatch with the version used by your graphic system).
140
141     --build-all
142         Force the build of all possible libraries.
143
144     --build-python
145         Force the build of Python.
146
147     --build-numpy
148         Force the build of NumPy.
149
150     --build-boost
151         Force the build of Boost.
152
153     --build-ocio
154         Force the build of OpenColorIO.
155
156     --build-openexr
157         Force the build of OpenEXR.
158
159     --build-oiio
160         Force the build of OpenImageIO.
161
162     --build-llvm
163         Force the build of LLVM.
164
165     --build-osl
166         Force the build of OpenShadingLanguage.
167
168     --build-osd
169         Force the build of OpenSubdiv.
170
171     --build-openvdb
172         Force the build of OpenVDB.
173
174     --build-alembic
175         Force the build of Alembic.
176
177     --build-opencollada
178         Force the build of OpenCOLLADA.
179
180     --build-ffmpeg
181         Force the build of FFMpeg.
182
183     Note about the --build-foo options:
184         * They force the script to prefer building dependencies rather than using available packages.
185           This may make things simpler and allow working around some distribution bugs, but on the other hand it will
186           use much more space on your hard drive.
187         * Please be careful with the Blender building options if you have both 'official' dev packages and
188           install_deps' built ones on your system, by default CMake will prefer official packages, which may lead to
189           linking issues. Please ensure your CMake configuration always uses all correct library paths.
190         * If the “force-built” library is a dependency of others, it will force the build
191           of those libraries as well (e.g. --build-boost also implies --build-oiio and --build-osl...).
192
193     --force-all
194         Force the rebuild of all built libraries.
195
196     --force-python
197         Force the rebuild of Python.
198
199     --force-numpy
200         Force the rebuild of NumPy.
201
202     --force-boost
203         Force the rebuild of Boost.
204
205     --force-ocio
206         Force the rebuild of OpenColorIO.
207
208     --force-openexr
209         Force the rebuild of OpenEXR.
210
211     --force-oiio
212         Force the rebuild of OpenImageIO.
213
214     --force-llvm
215         Force the rebuild of LLVM.
216
217     --force-osl
218         Force the rebuild of OpenShadingLanguage.
219
220     --force-osd
221         Force the rebuild of OpenSubdiv.
222
223     --force-openvdb
224         Force the rebuild of OpenVDB.
225
226     --force-alembic
227         Force the rebuild of Alembic.
228
229     --force-opencollada
230         Force the rebuild of OpenCOLLADA.
231
232     --force-ffmpeg
233         Force the rebuild of FFMpeg.
234
235     Note about the --force-foo options:
236         * They obviously only have an effect if those libraries are built by this script
237           (i.e. if there is no available and satisfactory package)!
238         * If the “force-rebuilt” library is a dependency of others, it will force the rebuild
239           of those libraries too (e.g. --force-boost will also rebuild oiio and osl...).
240
241     --skip-python
242         Unconditionally skip Python installation/building.
243
244     --skip-numpy
245         Unconditionally skip NumPy installation/building.
246
247     --skip-boost
248         Unconditionally skip Boost installation/building.
249
250     --skip-ocio
251         Unconditionally skip OpenColorIO installation/building.
252
253     --skip-openexr
254         Unconditionally skip OpenEXR installation/building.
255
256     --skip-oiio
257         Unconditionally skip OpenImageIO installation/building.
258
259     --skip-llvm
260         Unconditionally skip LLVM installation/building.
261
262     --skip-osl
263         Unconditionally skip OpenShadingLanguage installation/building.
264
265     --skip-osd
266         Unconditionally skip OpenSubdiv installation/building.
267
268     --skip-openvdb
269         Unconditionally skip OpenVDB installation/building.
270
271     --skip-alembic
272         Unconditionally skip Alembic installation/building.
273
274     --skip-opencollada
275         Unconditionally skip OpenCOLLADA installation/building.
276
277     --skip-ffmpeg
278         Unconditionally skip FFMpeg installation/building.\""
279
280 ##### Main Vars #####
281
282 DO_SHOW_DEPS=false
283
284 SUDO="sudo"
285
286 NO_BUILD=false
287 NO_CONFIRM=false
288 USE_CXX11=true
289
290 PYTHON_VERSION="3.7.0"
291 PYTHON_VERSION_MIN="3.7"
292 PYTHON_FORCE_BUILD=false
293 PYTHON_FORCE_REBUILD=false
294 PYTHON_SKIP=false
295
296 NUMPY_VERSION="1.15.0"
297 NUMPY_VERSION_MIN="1.8"
298 NUMPY_FORCE_BUILD=false
299 NUMPY_FORCE_REBUILD=false
300 NUMPY_SKIP=false
301
302 BOOST_VERSION="1.68.0"
303 BOOST_VERSION_MIN="1.49"
304 BOOST_FORCE_BUILD=false
305 BOOST_FORCE_REBUILD=false
306 BOOST_SKIP=false
307
308 OCIO_VERSION="1.1.0"
309 OCIO_VERSION_MIN="1.0"
310 OCIO_FORCE_BUILD=false
311 OCIO_FORCE_REBUILD=false
312 OCIO_SKIP=false
313
314 OPENEXR_VERSION="2.3.0"
315 OPENEXR_VERSION_MIN="2.0.1"
316 ILMBASE_VERSION="2.3.0"
317 ILMBASE_VERSION_MIN="2.3"
318 OPENEXR_FORCE_BUILD=false
319 OPENEXR_FORCE_REBUILD=false
320 OPENEXR_SKIP=false
321 _with_built_openexr=false
322
323 OIIO_VERSION="1.8.13"
324 OIIO_VERSION_MIN="1.8.13"
325 OIIO_VERSION_MAX="99.99.0"  # UNKNOWN currently # Not supported by current OSL...
326 OIIO_FORCE_BUILD=false
327 OIIO_FORCE_REBUILD=false
328 OIIO_SKIP=false
329
330 LLVM_VERSION="6.0.1"
331 LLVM_VERSION_MIN="6.0"
332 LLVM_VERSION_FOUND=""
333 LLVM_FORCE_BUILD=false
334 LLVM_FORCE_REBUILD=false
335 LLVM_SKIP=false
336
337 # OSL needs to be compiled for now!
338 OSL_VERSION="1.9.9"
339 OSL_VERSION_MIN=$OSL_VERSION
340 OSL_FORCE_BUILD=false
341 OSL_FORCE_REBUILD=false
342 OSL_SKIP=false
343
344 # OpenSubdiv needs to be compiled for now
345 OSD_VERSION="3.3.3"
346 OSD_VERSION_MIN=$OSD_VERSION
347 OSD_FORCE_BUILD=false
348 OSD_FORCE_REBUILD=false
349 OSD_SKIP=false
350
351 # OpenVDB needs to be compiled for now
352 OPENVDB_BLOSC_VERSION="1.14.4"
353
354 OPENVDB_VERSION="5.1.0"
355 OPENVDB_VERSION_MIN=$OPENVDB_VERSION
356 OPENVDB_FORCE_BUILD=false
357 OPENVDB_FORCE_REBUILD=false
358 OPENVDB_SKIP=false
359
360 # Alembic needs to be compiled for now
361 ALEMBIC_VERSION="1.7.8"
362 ALEMBIC_VERSION_MIN=$ALEMBIC_VERSION
363 ALEMBIC_FORCE_BUILD=false
364 ALEMBIC_FORCE_REBUILD=false
365 ALEMBIC_SKIP=false
366
367 OPENCOLLADA_VERSION="1.6.63"
368 OPENCOLLADA_FORCE_BUILD=false
369 OPENCOLLADA_FORCE_REBUILD=false
370 OPENCOLLADA_SKIP=false
371
372 FFMPEG_VERSION="4.0.2"
373 FFMPEG_VERSION_MIN="2.8.4"
374 FFMPEG_FORCE_BUILD=false
375 FFMPEG_FORCE_REBUILD=false
376 FFMPEG_SKIP=false
377 _ffmpeg_list_sep=";"
378
379 # FFMPEG optional libs.
380 VORBIS_USE=false
381 VORBIS_DEV=""
382 OGG_USE=false
383 OGG_DEV=""
384 THEORA_USE=false
385 THEORA_DEV=""
386 XVID_USE=false
387 XVID_DEV=""
388 X264_USE=false
389 X264_DEV=""
390 X264_VERSION_MIN=0.118
391 VPX_USE=false
392 VPX_VERSION_MIN=0.9.7
393 VPX_DEV=""
394 MP3LAME_USE=false
395 MP3LAME_DEV=""
396 OPENJPEG_USE=false
397 OPENJPEG_DEV=""
398
399 # Whether to use system GLEW or not (OpenSubDiv needs recent glew to work).
400 NO_SYSTEM_GLEW=false
401
402 # Switch to english language, else some things (like check_package_DEB()) won't work!
403 LANG_BACK=$LANG
404 LANG=""
405 export LANG
406
407 ##### Generic Helpers #####
408
409 BLACK=$(tput setaf 0)
410 RED=$(tput setaf 1)
411 GREEN=$(tput setaf 2)
412 YELLOW=$(tput setaf 3)
413 LIME_YELLOW=$(tput setaf 190)
414 POWDER_BLUE=$(tput setaf 153)
415 BLUE=$(tput setaf 4)
416 MAGENTA=$(tput setaf 5)
417 CYAN=$(tput setaf 6)
418 WHITE=$(tput setaf 7)
419 BRIGHT=$(tput bold)
420 NORMAL=$(tput sgr0)
421 BLINK=$(tput blink)
422 REVERSE=$(tput smso)
423 UNDERLINE=$(tput smul)
424
425 _echo() {
426   if [ "X$1" = "X-n" ]; then
427      shift; printf "%s" "$@"
428   else
429      printf "%s\n" "$@"
430   fi
431 }
432
433 ERROR() {
434   _echo "${BRIGHT}${RED}ERROR! ${NORMAL}${RED}$@${NORMAL}"
435 }
436
437 WARNING() {
438   _echo "${BRIGHT}${YELLOW}WARNING! ${NORMAL}${YELLOW}$@${NORMAL}"
439 }
440
441 INFO() {
442   _echo "${GREEN}$@${NORMAL}"
443 }
444
445 PRINT() {
446   _echo "$@"
447 }
448
449 ##### Args Handling #####
450
451 # Finish parsing the commandline args.
452 eval set -- "$ARGS"
453 while true; do
454   case $1 in
455     -s|--source)
456       SRC="$2"; shift; shift; continue
457     ;;
458     -i|--install)
459       INST="$2"; shift; shift; continue
460     ;;
461     --tmp)
462       TMP="$2"; shift; shift; continue
463     ;;
464     --info)
465       INFO_PATH="$2"; shift; shift; continue
466     ;;
467     -t|--threads)
468       THREADS="$2"; shift; shift; continue
469     ;;
470     -h|--help)
471       PRINT ""
472       PRINT "USAGE:"
473       PRINT ""
474       PRINT "`eval _echo "$COMMON_INFO"`"
475       PRINT ""
476       PRINT "`eval _echo "$ARGUMENTS_INFO"`"
477       PRINT ""
478       exit 0
479     ;;
480     --show-deps)
481       # We have to defer...
482       DO_SHOW_DEPS=true; shift; continue
483     ;;
484     --no-sudo)
485       PRINT ""
486       WARNING "--no-sudo enabled, this script might not be able to do much..."
487       PRINT ""
488       SUDO=""; shift; continue
489     ;;
490     --no-build)
491       PRINT ""
492       WARNING "--no-build enabled, this script will not be able to install all dependencies..."
493       PRINT ""
494       NO_BUILD=true; shift; continue
495     ;;
496     --no-confirm)
497       NO_CONFIRM=true; shift; continue
498     ;;
499     --with-all)
500       WITH_ALL=true; shift; continue
501     ;;
502     --with-opencollada)
503       WITH_OPENCOLLADA=true; shift; continue
504     ;;
505     --with-jack)
506       WITH_JACK=true; shift; continue;
507     ;;
508     --ver-ocio)
509       OCIO_VERSION="$2"
510       OCIO_VERSION_MIN=$OCIO_VERSION
511       shift; shift; continue
512     ;;
513     --ver-oiio)
514       OIIO_VERSION="$2"
515       OIIO_VERSION_MIN=$OIIO_VERSION
516       shift; shift; continue
517     ;;
518     --ver-llvm)
519       LLVM_VERSION="$2"
520       LLVM_VERSION_MIN=$LLVM_VERSION
521       shift; shift; continue
522     ;;
523     --ver-osl)
524       OSL_VERSION="$2"
525       OSL_VERSION_MIN=$OSL_VERSION
526       shift; shift; continue
527     ;;
528     --ver-osd)
529       OSD_VERSION="$2"
530       OSD_VERSION_MIN=$OSD_VERSION
531       shift; shift; continue
532     ;;
533     --ver-openvdb)
534       OPENVDB_VERSION="$2"
535       OPENVDB_VERSION_MIN=$OPENVDB_VERSION
536       shift; shift; continue
537     ;;
538     --build-all)
539       PYTHON_FORCE_BUILD=true
540       NUMPY_FORCE_BUILD=true
541       BOOST_FORCE_BUILD=true
542       OCIO_FORCE_BUILD=true
543       OPENEXR_FORCE_BUILD=true
544       OIIO_FORCE_BUILD=true
545       LLVM_FORCE_BUILD=true
546       OSL_FORCE_BUILD=true
547       OSD_FORCE_BUILD=true
548       OPENVDB_FORCE_BUILD=true
549       OPENCOLLADA_FORCE_BUILD=true
550       FFMPEG_FORCE_BUILD=true
551       ALEMBIC_FORCE_BUILD=true
552       shift; continue
553     ;;
554     --build-python)
555       PYTHON_FORCE_BUILD=true
556       NUMPY_FORCE_BUILD=true
557       shift; continue
558     ;;
559     --build-numpy)
560       PYTHON_FORCE_BUILD=true
561       NUMPY_FORCE_BUILD=true
562       shift; continue
563     ;;
564     --build-boost)
565       BOOST_FORCE_BUILD=true; shift; continue
566     ;;
567     --build-ocio)
568       OCIO_FORCE_BUILD=true; shift; continue
569     ;;
570     --build-openexr)
571       OPENEXR_FORCE_BUILD=true; shift; continue
572     ;;
573     --build-oiio)
574       OIIO_FORCE_BUILD=true; shift; continue
575     ;;
576     --build-llvm)
577       LLVM_FORCE_BUILD=true; shift; continue
578     ;;
579     --build-osl)
580       OSL_FORCE_BUILD=true; shift; continue
581     ;;
582     --build-osd)
583       OSD_FORCE_BUILD=true; shift; continue
584     ;;
585     --build-openvdb)
586       OPENVDB_FORCE_BUILD=true; shift; continue
587     ;;
588     --build-opencollada)
589       OPENCOLLADA_FORCE_BUILD=true; shift; continue
590     ;;
591     --build-ffmpeg)
592       FFMPEG_FORCE_BUILD=true; shift; continue
593     ;;
594     --build-alembic)
595       ALEMBIC_FORCE_BUILD=true; shift; continue
596     ;;
597     --force-all)
598       PYTHON_FORCE_REBUILD=true
599       NUMPY_FORCE_REBUILD=true
600       BOOST_FORCE_REBUILD=true
601       OCIO_FORCE_REBUILD=true
602       OPENEXR_FORCE_REBUILD=true
603       OIIO_FORCE_REBUILD=true
604       LLVM_FORCE_REBUILD=true
605       OSL_FORCE_REBUILD=true
606       OSD_FORCE_REBUILD=true
607       OPENVDB_FORCE_REBUILD=true
608       OPENCOLLADA_FORCE_REBUILD=true
609       FFMPEG_FORCE_REBUILD=true
610       ALEMBIC_FORCE_REBUILD=true
611       shift; continue
612     ;;
613     --force-python)
614       PYTHON_FORCE_REBUILD=true
615       NUMPY_FORCE_REBUILD=true
616       shift; continue
617     ;;
618     --force-numpy)
619       NUMPY_FORCE_REBUILD=true; shift; continue
620     ;;
621     --force-boost)
622       BOOST_FORCE_REBUILD=true; shift; continue
623     ;;
624     --force-ocio)
625       OCIO_FORCE_REBUILD=true; shift; continue
626     ;;
627     --force-openexr)
628       OPENEXR_FORCE_REBUILD=true; shift; continue
629     ;;
630     --force-oiio)
631       OIIO_FORCE_REBUILD=true; shift; continue
632     ;;
633     --force-llvm)
634       LLVM_FORCE_REBUILD=true; shift; continue
635     ;;
636     --force-osl)
637       OSL_FORCE_REBUILD=true; shift; continue
638     ;;
639     --force-osd)
640       OSD_FORCE_REBUILD=true; shift; continue
641     ;;
642     --force-openvdb)
643       OPENVDB_FORCE_REBUILD=true; shift; continue
644     ;;
645     --force-opencollada)
646       OPENCOLLADA_FORCE_REBUILD=true; shift; continue
647     ;;
648     --force-ffmpeg)
649       FFMPEG_FORCE_REBUILD=true; shift; continue
650     ;;
651     --force-alembic)
652       ALEMBIC_FORCE_REBUILD=true; shift; continue
653     ;;
654     --skip-python)
655       PYTHON_SKIP=true; shift; continue
656     ;;
657     --skip-numpy)
658       NUMPY_SKIP=true; shift; continue
659     ;;
660     --skip-boost)
661       BOOST_SKIP=true; shift; continue
662     ;;
663     --skip-ocio)
664       OCIO_SKIP=true; shift; continue
665     ;;
666     --skip-openexr)
667       OPENEXR_SKIP=true; shift; continue
668     ;;
669     --skip-oiio)
670       OIIO_SKIP=true; shift; continue
671     ;;
672     --skip-llvm)
673       LLVM_SKIP=true; shift; continue
674     ;;
675     --skip-osl)
676       OSL_SKIP=true; shift; continue
677     ;;
678     --skip-osd)
679       OSD_SKIP=true; shift; continue
680     ;;
681     --skip-openvdb)
682       OPENVDB_SKIP=true; shift; continue
683     ;;
684     --skip-opencollada)
685       OPENCOLLADA_SKIP=true; shift; continue
686     ;;
687     --skip-ffmpeg)
688       FFMPEG_SKIP=true; shift; continue
689     ;;
690     --skip-alembic)
691       ALEMBIC_SKIP=true; shift; continue
692     ;;
693     --)
694       # no more arguments to parse
695       break
696     ;;
697     *)
698       PRINT ""
699       ERROR "Wrong parameter! Usage:"
700       PRINT ""
701       PRINT "`eval _echo "$COMMON_INFO"`"
702       PRINT ""
703       exit 1
704     ;;
705   esac
706 done
707
708 if [ "$WITH_ALL" = true -a "$OPENCOLLADA_SKIP" = false ]; then
709   WITH_OPENCOLLADA=true
710 fi
711 if [ "$WITH_ALL" = true ]; then
712   WITH_JACK=true
713 fi
714
715
716 WARNING "****WARNING****"
717 PRINT "If you are experiencing issues building Blender, _*TRY A FRESH, CLEAN BUILD FIRST*_!"
718 PRINT "The same goes for install_deps itself, if you encounter issues, please first erase everything in $SRC and $INST"
719 PRINT "(provided obviously you did not add anything yourself in those dirs!), and run install_deps.sh again!"
720 PRINT "Often, changes in the libs built by this script, or in your distro package, cannot be handled simply, so..."
721 PRINT ""
722 PRINT "You may also try to use the '--build-foo' options to bypass your distribution's packages"
723 PRINT "for some troublesome/buggy libraries..."
724 PRINT ""
725 PRINT ""
726 PRINT "Ran with:"
727 PRINT "    install_deps.sh $COMMANDLINE"
728 PRINT ""
729 PRINT ""
730
731
732 # This has to be done here, because user might force some versions...
733 PYTHON_SOURCE=( "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz" )
734 NUMPY_SOURCE=( "https://github.com/numpy/numpy/releases/download/v$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz" )
735
736 _boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
737 BOOST_SOURCE=( "http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download" )
738 BOOST_BUILD_MODULES="--with-system --with-filesystem --with-thread --with-regex --with-locale --with-date_time --with-wave --with-iostreams --with-python --with-program_options"
739
740 OCIO_USE_REPO=false
741 OCIO_SOURCE=( "https://github.com/imageworks/OpenColorIO/archive/v$OCIO_VERSION.tar.gz")
742 #~ OCIO_SOURCE_REPO=( "https://github.com/imageworks/OpenColorIO.git" )
743 #~ OCIO_SOURCE_REPO_UID="6de971097c7f552300f669ed69ca0b6cf5a70843"
744
745 OPENEXR_USE_REPO=false
746 OPENEXR_SOURCE=( "http://download.savannah.nongnu.org/releases/openexr/openexr-$OPENEXR_VERSION.tar.gz" )
747 #~ OPENEXR_SOURCE_REPO=( "https://github.com/mont29/openexr.git" )
748 #~ OPENEXR_SOURCE_REPO_UID="2787aa1cf652d244ed45ae124eb1553f6cff11ee"
749 ILMBASE_SOURCE=( "http://download.savannah.nongnu.org/releases/openexr/ilmbase-$ILMBASE_VERSION.tar.gz" )
750
751 OIIO_USE_REPO=false
752 OIIO_SOURCE=( "https://github.com/OpenImageIO/oiio/archive/Release-$OIIO_VERSION.tar.gz" )
753 #~ OIIO_SOURCE_REPO=( "https://github.com/OpenImageIO/oiio.git" )
754 #~ OIIO_SOURCE_REPO_UID="c9e67275a0b248ead96152f6d2221cc0c0f278a4"
755
756 LLVM_SOURCE=( "http://releases.llvm.org/$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.xz" )
757 LLVM_CLANG_SOURCE=( "http://releases.llvm.org/$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.xz" "http://llvm.org/releases/$LLVM_VERSION/cfe-$LLVM_VERSION.src.tar.xz" )
758
759 OSL_USE_REPO=false
760 OSL_SOURCE=( "https://github.com/imageworks/OpenShadingLanguage/archive/Release-$OSL_VERSION.tar.gz" )
761 #~ OSL_SOURCE_REPO=( "https://github.com/imageworks/OpenShadingLanguage.git" )
762 #~ OSL_SOURCE_REPO_BRANCH="master"
763 #~ OSL_SOURCE_REPO_UID="85179714e1bc69cd25ecb6bb711c1a156685d395"
764 #~ OSL_SOURCE=( "https://github.com/Nazg-Gul/OpenShadingLanguage/archive/Release-1.5.11.tar.gz" )
765 #~ OSL_SOURCE_REPO=( "https://github.com/mont29/OpenShadingLanguage.git" )
766 #~ OSL_SOURCE_REPO_UID="85179714e1bc69cd25ecb6bb711c1a156685d395"
767 #~ OSL_SOURCE_REPO=( "https://github.com/Nazg-Gul/OpenShadingLanguage.git" )
768 #~ OSL_SOURCE_REPO_UID="7d40ff5fe8e47b030042afb92d0e955f5aa96f48"
769 #~ OSL_SOURCE_REPO_BRANCH="blender-fixes"
770
771 OSD_USE_REPO=false
772 # Script foo to make the version string compliant with the archive name:
773 # ${Varname//SearchForThisChar/ReplaceWithThisChar}
774 OSD_SOURCE=( "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${OSD_VERSION//./_}.tar.gz" )
775 #~ OSD_SOURCE_REPO=( "https://github.com/PixarAnimationStudios/OpenSubdiv.git" )
776 #~ OSD_SOURCE_REPO_UID="404659fffa659da075d1c9416e4fc939139a84ee"
777 #~ OSD_SOURCE_REPO_BRANCH="dev"
778
779 OPENVDB_USE_REPO=false
780 OPENVDB_BLOSC_SOURCE=( "https://github.com/Blosc/c-blosc/archive/v${OPENVDB_BLOSC_VERSION}.tar.gz" )
781 OPENVDB_SOURCE=( "https://github.com/dreamworksanimation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz" )
782 #~ OPENVDB_SOURCE_REPO=( "https:///dreamworksanimation/openvdb.git" )
783 #~ OPENVDB_SOURCE_REPO_UID="404659fffa659da075d1c9416e4fc939139a84ee"
784 #~ OPENVDB_SOURCE_REPO_BRANCH="dev"
785
786 ALEMBIC_USE_REPO=false
787 ALEMBIC_SOURCE=( "https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.tar.gz" )
788 # ALEMBIC_SOURCE_REPO=( "https://github.com/alembic/alembic.git" )
789 # ALEMBIC_SOURCE_REPO_UID="e6c90d4faa32c4550adeaaf3f556dad4b73a92bb"
790 # ALEMBIC_SOURCE_REPO_BRANCH="master"
791
792 OPENCOLLADA_USE_REPO=false
793 OPENCOLLADA_SOURCE=( "https://github.com/KhronosGroup/OpenCOLLADA/archive/v${OPENCOLLADA_VERSION}.tar.gz" )
794 #~ OPENCOLLADA_SOURCE_REPO=( "https://github.com/KhronosGroup/OpenCOLLADA.git" )
795 #~ OPENCOLLADA_REPO_UID="e937c3897b86fc0da53cde97257f5156"
796 #~ OPENCOLLADA_REPO_BRANCH="master"
797
798 FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
799
800 # C++11 is required now
801 CXXFLAGS_BACK=$CXXFLAGS
802 CXXFLAGS="$CXXFLAGS -std=c++11"
803 export CXXFLAGS
804
805 #### Show Dependencies ####
806
807 # Need those to be after we defined versions...
808 DEPS_COMMON_INFO="\"COMMON DEPENDENCIES:
809
810 Those libraries should be available as packages in all recent distributions (optional ones are [between brackets]):
811
812     * Basics of dev environment (cmake, gcc, svn , git, ...).
813     * libjpeg, libpng, libtiff, [libopenjpeg], [libopenal].
814     * libx11, libxcursor, libxi, libxrandr, libxinerama (and other libx... as needed).
815     * libsqlite3, libbz2, libssl, libfftw3, libxml2, libtinyxml, yasm, libyaml-cpp.
816     * libsdl1.2, libglew, [libglewmx].\""
817
818 DEPS_SPECIFIC_INFO="\"BUILDABLE DEPENDENCIES:
819
820 The following libraries will probably not all be available as packages in your distribution
821 (install_deps will by default try to install packages, and fall back to building missing ones).
822 You can force install_deps to build those with '--build-all' or relevant 'build-foo' options, see '--help' message.
823 You may also want to build them yourself (optional ones are [between brackets]):
824
825     * Python $PYTHON_VERSION_MIN (from $PYTHON_SOURCE).
826     * [NumPy $NUMPY_VERSION_MIN] (from $NUMPY_SOURCE).
827     * Boost $BOOST_VERSION_MIN (from $BOOST_SOURCE, modules: $BOOST_BUILD_MODULES).
828     * [FFMpeg $FFMPEG_VERSION_MIN (needs libvorbis, libogg, libtheora, libx264, libmp3lame, libxvidcore, libvpx, ...)] (from $FFMPEG_SOURCE).
829     * [OpenColorIO $OCIO_VERSION_MIN] (from $OCIO_SOURCE).
830     * ILMBase $ILMBASE_VERSION_MIN (from $ILMBASE_SOURCE).
831     * OpenEXR $OPENEXR_VERSION_MIN (from $OPENEXR_SOURCE).
832     * OpenImageIO $OIIO_VERSION_MIN (from $OIIO_SOURCE).
833     * [LLVM $LLVM_VERSION_MIN (with clang)] (from $LLVM_SOURCE, and $LLVM_CLANG_SOURCE).
834     * [OpenShadingLanguage $OSL_VERSION_MIN] (from $OSL_SOURCE_REPO, branch $OSL_SOURCE_REPO_BRANCH, commit $OSL_SOURCE_REPO_UID).
835     * [OpenSubDiv $OSD_VERSION_MIN] (from $OSD_SOURCE_REPO, branch $OSD_SOURCE_REPO_BRANCH, commit $OSD_SOURCE_REPO_UID).
836     * [OpenVDB $OPENVDB_VERSION_MIN] (from $OPENVDB_SOURCE), [Blosc $OPENVDB_BLOSC_VERSION] (from $OPENVDB_BLOSC_SOURCE).
837     * [OpenCollada $OPENCOLLADA_VERSION] (from $OPENCOLLADA_SOURCE).
838     * [Alembic $ALEMBIC_VERSION] (from $ALEMBIC_SOURCE).\""
839
840 if [ "$DO_SHOW_DEPS" = true ]; then
841   PRINT ""
842   PRINT "Blender dependencies (libraries needed to build it):"
843   PRINT ""
844   PRINT "`eval _echo "$DEPS_COMMON_INFO"`"
845   PRINT ""
846   PRINT "`eval _echo "$DEPS_SPECIFIC_INFO"`"
847   PRINT ""
848   exit 0
849 fi
850
851
852
853 ##### Generic Helpers #####
854
855 # Check return code of wget for success...
856 download() {
857   declare -a sources=("${!1}")
858   sources_count=${#sources[@]}
859   error=1
860
861   for (( i=0; $i < $sources_count; i++ ))
862   do
863     wget -c ${sources[$i]} -O $2
864     if [ $? -eq 0 ]; then
865       error=0
866       break
867     fi
868   done
869
870   if [ $error -eq 1 ]; then
871     ERROR "wget could not find ${sources[@]}, or could not write it to $2, exiting"
872     exit 1
873   fi
874 }
875
876 # Return 0 if $1 = $2 (i.e. 1.01.0 = 1.1, but 1.1.1 != 1.1), else 1.
877 # $1 and $2 should be version numbers made of numbers only.
878 version_eq() {
879   backIFS=$IFS
880   IFS='.'
881
882   # Split both version numbers into their numeric elements.
883   arr1=( $1 )
884   arr2=( $2 )
885
886   ret=1
887
888   count1=${#arr1[@]}
889   count2=${#arr2[@]}
890   if [ $count2 -ge $count1 ]; then
891     _t=$count1
892     count1=$count2
893     count2=$_t
894     arr1=( $2 )
895     arr2=( $1 )
896   fi
897
898   ret=0
899   for (( i=0; $i < $count2; i++ ))
900   do
901     if [ $(( 10#${arr1[$i]} )) -ne $(( 10#${arr2[$i]} )) ]; then
902       ret=1
903       break
904     fi
905   done
906
907   for (( i=$count2; $i < $count1; i++ ))
908   do
909     if [ $(( 10#${arr1[$i]} )) -ne 0 ]; then
910       ret=1
911       break
912     fi
913   done
914
915   IFS=$backIFS
916   return $ret
917 }
918
919 # Return 0 if $1 >= $2, else 1.
920 # $1 and $2 should be version numbers made of numbers only.
921 version_ge() {
922   version_eq $1 $2
923   if [ $? -eq 1 -a $(_echo "$1" "$2" | sort --version-sort | head --lines=1) = "$1" ]; then
924     return 1
925   else
926     return 0
927   fi
928 }
929
930 # Return 0 if $3 > $1 >= $2, else 1.
931 # $1 and $2 should be version numbers made of numbers only.
932 version_ge_lt() {
933   version_ge $1 $3
934   if [ $? -eq 0 ]; then
935     return 1
936   else
937     version_ge $1 $2
938     return $?
939   fi
940 }
941
942 # Return 0 if $1 is into $2 (e.g. 3.3.2 is into 3.3, but not 3.3.0 or 3.3.5), else 1.
943 # $1 and $2 should be version numbers made of numbers only.
944 # $1 should be at least as long as $2!
945 version_match() {
946   backIFS=$IFS
947   IFS='.'
948
949   # Split both version numbers into their numeric elements.
950   arr1=( $1 )
951   arr2=( $2 )
952
953   ret=1
954
955   count1=${#arr1[@]}
956   count2=${#arr2[@]}
957   if [ $count1 -ge $count2 ]; then
958     ret=0
959     for (( i=0; $i < $count2; i++ ))
960     do
961       if [ $(( 10#${arr1[$i]} )) -ne $(( 10#${arr2[$i]} )) ]; then
962         ret=1
963         break
964       fi
965     done
966   fi
967
968   IFS=$backIFS
969   return $ret
970 }
971
972 ##### Generic compile helpers #####
973 prepare_opt() {
974   INFO "Ensuring $INST exists and is writable by us"
975   if [ ! $SUDO ]; then
976     WARNING "--no-sudo enabled, might be impossible to create install dir..."
977   fi
978   if [ ! -d  $INST ]; then
979     $SUDO mkdir -p $INST
980   fi
981
982   if [ ! -w $INST ]; then
983     $SUDO chown $USER $INST
984     $SUDO chmod 775 $INST
985   fi
986 }
987
988 # Check whether the current package needs to be recompiled, based on a dummy file containing a magic number in its name...
989 magic_compile_check() {
990   if [ -f $INST/.$1-magiccheck-$2-$USE_CXX11 ]; then
991     return 0
992   else
993     return 1
994   fi
995 }
996
997 magic_compile_set() {
998   rm -f $INST/.$1-magiccheck-*
999   touch $INST/.$1-magiccheck-$2-$USE_CXX11
1000 }
1001
1002 # Note: should clean nicely in $INST, but not in $SRC, when we switch to a new version of a lib...
1003 _clean() {
1004   rm -rf `readlink -f $_inst_shortcut`
1005   # Only remove $_src dir when not using git repo (avoids to re-clone the whole repo every time!!!).
1006   if [ $_git == false ]; then
1007     rm -rf $_src
1008   fi
1009   rm -rf $_inst
1010   rm -rf $_inst_shortcut
1011 }
1012
1013 _create_inst_shortcut() {
1014   rm -f $_inst_shortcut
1015   ln -s $_inst $_inst_shortcut
1016 }
1017
1018 # ldconfig
1019 run_ldconfig() {
1020   _lib_path="$INST/$1/lib"
1021   _ldconf_path="/etc/ld.so.conf.d/$1.conf"
1022   PRINT ""
1023   if [ ! $SUDO ]; then
1024     WARNING "--no-sudo enabled, impossible to run ldconfig for $1, you'll have to do it yourself..."
1025   else
1026     INFO "Running ldconfig for $1..."
1027     $SUDO sh -c "echo \"$_lib_path\" > $_ldconf_path"
1028     $SUDO /sbin/ldconfig  # XXX OpenSuse does not include sbin in command path with sudo!!!
1029   fi
1030   PRINT ""
1031 }
1032
1033 #### Build Python ####
1034 _init_python() {
1035   _src=$SRC/Python-$PYTHON_VERSION
1036   _git=false
1037   _inst=$INST/python-$PYTHON_VERSION
1038   _inst_shortcut=$INST/python-$PYTHON_VERSION_MIN
1039 }
1040
1041 clean_Python() {
1042   clean_Numpy
1043   _init_python
1044   _clean
1045 }
1046
1047 compile_Python() {
1048   if [ "$NO_BUILD" = true ]; then
1049     WARNING "--no-build enabled, Python will not be compiled!"
1050     return
1051   fi
1052
1053   # To be changed each time we make edits that would modify the compiled result!
1054   py_magic=1
1055   _init_python
1056
1057   # Clean install if needed!
1058   magic_compile_check python-$PYTHON_VERSION $py_magic
1059   if [ $? -eq 1 -o "$PYTHON_FORCE_REBUILD" = true ]; then
1060     clean_Python
1061   fi
1062
1063   if [ ! -d $_inst ]; then
1064     INFO "Building Python-$PYTHON_VERSION"
1065
1066     prepare_opt
1067
1068     if [ ! -d $_src ]; then
1069       mkdir -p $SRC
1070       download PYTHON_SOURCE[@] $_src.tgz
1071
1072       INFO "Unpacking Python-$PYTHON_VERSION"
1073       tar -C $SRC -xf $_src.tgz
1074     fi
1075
1076     cd $_src
1077
1078     ./configure --prefix=$_inst --libdir=$_inst/lib --enable-ipv6 \
1079         --enable-loadable-sqlite-extensions --with-dbmliborder=bdb \
1080         --with-computed-gotos --with-pymalloc
1081
1082     make -j$THREADS && make install
1083     make clean
1084
1085     if [ -d $_inst ]; then
1086       _create_inst_shortcut
1087     else
1088       ERROR "Python--$PYTHON_VERSION failed to compile, exiting"
1089       exit 1
1090     fi
1091
1092     magic_compile_set python-$PYTHON_VERSION $py_magic
1093
1094     cd $CWD
1095     INFO "Done compiling Python-$PYTHON_VERSION!"
1096   else
1097     INFO "Own Python-$PYTHON_VERSION is up to date, nothing to do!"
1098     INFO "If you want to force rebuild of this lib, use the --force-python option."
1099   fi
1100 }
1101
1102 ##### Build Numpy #####
1103 _init_numpy() {
1104   _src=$SRC/numpy-$NUMPY_VERSION
1105   _git=false
1106   _inst=$INST/numpy-$NUMPY_VERSION
1107   _python=$INST/python-$PYTHON_VERSION
1108   _site=lib/python$PYTHON_VERSION_MIN/site-packages
1109   _inst_shortcut=$_python/$_site/numpy
1110 }
1111
1112 clean_Numpy() {
1113   _init_numpy
1114   _clean
1115 }
1116
1117 compile_Numpy() {
1118   if [ "$NO_BUILD" = true ]; then
1119     WARNING "--no-build enabled, Numpy will not be compiled!"
1120     return
1121   fi
1122
1123   # To be changed each time we make edits that would modify the compiled result!
1124   numpy_magic=0
1125   _init_numpy
1126
1127   # Clean install if needed!
1128   magic_compile_check numpy-$NUMPY_VERSION $numpy_magic
1129   if [ $? -eq 1 -o "$NUMPY_FORCE_REBUILD" = true ]; then
1130     clean_Numpy
1131   fi
1132
1133   if [ ! -d $_inst ]; then
1134     INFO "Building Numpy-$NUMPY_VERSION"
1135
1136     prepare_opt
1137
1138     if [ ! -d $_src ]; then
1139       mkdir -p $SRC
1140       download NUMPY_SOURCE[@] $_src.tar.gz
1141
1142       INFO "Unpacking Numpy-$NUMPY_VERSION"
1143       tar -C $SRC -xf $_src.tar.gz
1144     fi
1145
1146     cd $_src
1147
1148     $_python/bin/python3 setup.py install --old-and-unmanageable --prefix=$_inst
1149
1150     if [ -d $_inst ]; then
1151       # Can't use _create_inst_shortcut here...
1152       rm -f $_inst_shortcut
1153       ln -s $_inst/$_site/numpy $_inst_shortcut
1154     else
1155       ERROR "Numpy-$NUMPY_VERSION failed to compile, exiting"
1156       exit 1
1157     fi
1158
1159     magic_compile_set numpy-$NUMPY_VERSION $numpy_magic
1160
1161     cd $CWD
1162     INFO "Done compiling Numpy-$NUMPY_VERSION!"
1163   else
1164     INFO "Own Numpy-$NUMPY_VERSION is up to date, nothing to do!"
1165     INFO "If you want to force rebuild of this lib, use the --force-numpy option."
1166   fi
1167 }
1168
1169 #### Build Boost ####
1170 _init_boost() {
1171   _src=$SRC/boost-$BOOST_VERSION
1172   _git=false
1173   _inst=$INST/boost-$BOOST_VERSION
1174   _inst_shortcut=$INST/boost
1175 }
1176
1177 clean_Boost() {
1178   _init_boost
1179   _clean
1180 }
1181
1182 compile_Boost() {
1183   if [ "$NO_BUILD" = true ]; then
1184     WARNING "--no-build enabled, Boost will not be compiled!"
1185     return
1186   fi
1187
1188   # To be changed each time we make edits that would modify the compiled result!
1189   boost_magic=11
1190
1191   _init_boost
1192
1193   # Clean install if needed!
1194   magic_compile_check boost-$BOOST_VERSION $boost_magic
1195   if [ $? -eq 1 -o "$BOOST_FORCE_REBUILD" = true ]; then
1196     clean_Boost
1197   fi
1198
1199   if [ ! -d $_inst ]; then
1200     INFO "Building Boost-$BOOST_VERSION"
1201
1202     # Rebuild dependecies as well!
1203     OIIO_FORCE_BUILD=true
1204     OIIO_FORCE_REBUILD=true
1205     OSL_FORCE_BUILD=true
1206     OSL_FORCE_REBUILD=true
1207     OPENVDB_FORCE_BUILD=true
1208     OPENVDB_FORCE_REBUILD=true
1209
1210     prepare_opt
1211
1212     if [ ! -d $_src ]; then
1213       INFO "Downloading Boost-$BOOST_VERSION"
1214       mkdir -p $SRC
1215       download BOOST_SOURCE[@] $_src.tar.bz2
1216       tar -C $SRC --transform "s,\w*,boost-$BOOST_VERSION,x" -xf $_src.tar.bz2
1217     fi
1218
1219     cd $_src
1220     if [ ! -f $_src/b2 ]; then
1221       ./bootstrap.sh
1222     fi
1223     ./b2 -j$THREADS -a $BOOST_BUILD_MODULES \
1224          --prefix=$_inst --disable-icu boost.locale.icu=off install
1225     ./b2 --clean
1226
1227     if [ -d $_inst ]; then
1228       _create_inst_shortcut
1229     else
1230       ERROR "Boost-$BOOST_VERSION failed to compile, exiting"
1231       exit 1
1232     fi
1233
1234     magic_compile_set boost-$BOOST_VERSION $boost_magic
1235
1236     cd $CWD
1237     INFO "Done compiling Boost-$BOOST_VERSION!"
1238   else
1239     INFO "Own Boost-$BOOST_VERSION is up to date, nothing to do!"
1240     INFO "If you want to force rebuild of this lib, use the --force-boost option."
1241   fi
1242
1243   # Just always run it, much simpler this way!
1244   run_ldconfig "boost"
1245 }
1246
1247 #### Build OCIO ####
1248 _init_ocio() {
1249   _src=$SRC/OpenColorIO-$OCIO_VERSION
1250   if [ "$OCIO_USE_REPO" = true ]; then
1251     _git=true
1252   else
1253     _git=false
1254   fi
1255   _inst=$INST/ocio-$OCIO_VERSION
1256   _inst_shortcut=$INST/ocio
1257 }
1258
1259 clean_OCIO() {
1260   _init_ocio
1261   _clean
1262 }
1263
1264 compile_OCIO() {
1265   if [ "$NO_BUILD" = true ]; then
1266     WARNING "--no-build enabled, OpenColorIO will not be compiled!"
1267     return
1268   fi
1269
1270   # To be changed each time we make edits that would modify the compiled result!
1271   ocio_magic=2
1272   _init_ocio
1273
1274   # Clean install if needed!
1275   magic_compile_check ocio-$OCIO_VERSION $ocio_magic
1276   if [ $? -eq 1 -o "$OCIO_FORCE_REBUILD" = true ]; then
1277     clean_OCIO
1278   fi
1279
1280   if [ ! -d $_inst ]; then
1281     INFO "Building OpenColorIO-$OCIO_VERSION"
1282
1283     prepare_opt
1284
1285     if [ ! -d $_src ]; then
1286       INFO "Downloading OpenColorIO-$OCIO_VERSION"
1287       mkdir -p $SRC
1288
1289       if [ "$OCIO_USE_REPO" = true ]; then
1290         git clone ${OCIO_SOURCE_REPO[0]} $_src
1291       else
1292         download OCIO_SOURCE[@] $_src.tar.gz
1293         INFO "Unpacking OpenColorIO-$OCIO_VERSION"
1294         tar -C $SRC --transform "s,(.*/?)imageworks-OpenColorIO[^/]*(.*),\1OpenColorIO-$OCIO_VERSION\2,x" \
1295             -xf $_src.tar.gz
1296       fi
1297
1298     fi
1299
1300     cd $_src
1301
1302     if [ "$OCIO_USE_REPO" = true ]; then
1303       # XXX For now, always update from latest repo...
1304       git pull origin master
1305       git checkout $OCIO_SOURCE_REPO_UID
1306       git reset --hard
1307     fi
1308
1309     # Always refresh the whole build!
1310     if [ -d build ]; then
1311       rm -rf build
1312     fi
1313     mkdir build
1314     cd build
1315
1316     cmake_d="-D CMAKE_BUILD_TYPE=Release"
1317     cmake_d="$cmake_d -D CMAKE_PREFIX_PATH=$_inst"
1318     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
1319     cmake_d="$cmake_d -D OCIO_BUILD_APPS=OFF"
1320     cmake_d="$cmake_d -D OCIO_BUILD_PYGLUE=OFF"
1321     cmake_d="$cmake_d -D STOP_ON_WARNING=OFF"
1322
1323     if file /bin/cp | grep -q '32-bit'; then
1324       cflags="-fPIC -m32 -march=i686"
1325     else
1326       cflags="-fPIC"
1327     fi
1328     cflags="$cflags -Wno-error=unused-function -Wno-error=deprecated-declarations"
1329
1330     cmake $cmake_d -D CMAKE_CXX_FLAGS="$cflags" -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" ..
1331
1332     make -j$THREADS && make install
1333
1334     # Force linking against static libs
1335     rm -f $_inst/lib/*.so*
1336
1337     # Additional depencencies
1338     cp ext/dist/lib/libtinyxml.a $_inst/lib
1339     cp ext/dist/lib/libyaml-cpp.a $_inst/lib
1340
1341     make clean
1342
1343     if [ -d $_inst ]; then
1344       _create_inst_shortcut
1345     else
1346       ERROR "OpenColorIO-$OCIO_VERSION failed to compile, exiting"
1347       exit 1
1348     fi
1349
1350     magic_compile_set ocio-$OCIO_VERSION $ocio_magic
1351
1352     cd $CWD
1353     INFO "Done compiling OpenColorIO-$OCIO_VERSION!"
1354   else
1355     INFO "Own OpenColorIO-$OCIO_VERSION is up to date, nothing to do!"
1356     INFO "If you want to force rebuild of this lib, use the --force-ocio option."
1357   fi
1358
1359   run_ldconfig "ocio"
1360 }
1361
1362 #### Build ILMBase ####
1363 _init_ilmbase() {
1364   _src=$SRC/ILMBase-$ILMBASE_VERSION
1365   _git=false
1366   _inst=$TMP/ilmbase-$ILMBASE_VERSION
1367   _inst_shortcut=$TMP/ilmbase
1368 }
1369
1370 clean_ILMBASE() {
1371   _init_ilmbase
1372   _clean
1373 }
1374
1375 compile_ILMBASE() {
1376   if [ "$NO_BUILD" = true ]; then
1377     WARNING "--no-build enabled, ILMBase will not be compiled!"
1378     return
1379   fi
1380
1381   # To be changed each time we make edits that would modify the compiled result!
1382   ilmbase_magic=10
1383   _init_ilmbase
1384
1385   # Clean install if needed!
1386   magic_compile_check ilmbase-$ILMBASE_VERSION $ilmbase_magic
1387   if [ $? -eq 1 -o "$OPENEXR_FORCE_REBUILD" = true ]; then
1388     clean_ILMBASE
1389     rm -rf $_openexr_inst
1390   fi
1391
1392   if [ ! -d $_openexr_inst ]; then
1393     INFO "Building ILMBase-$ILMBASE_VERSION"
1394
1395     # Rebuild dependecies as well!
1396     OPENEXR_FORCE_BUILD=true
1397     OPENEXR_FORCE_REBUILD=true
1398
1399     prepare_opt
1400
1401     if [ ! -d $_src ]; then
1402       INFO "Downloading ILMBase-$ILMBASE_VERSION"
1403       mkdir -p $SRC
1404       download ILMBASE_SOURCE[@] $_src.tar.gz
1405
1406       INFO "Unpacking ILMBase-$ILMBASE_VERSION"
1407       tar -C $SRC --transform "s,(.*/?)ilmbase-[^/]*(.*),\1ILMBase-$ILMBASE_VERSION\2,x" -xf $_src.tar.gz
1408
1409     fi
1410
1411     cd $_src
1412     # Always refresh the whole build!
1413     if [ -d build ]; then
1414       rm -rf build
1415     fi
1416     mkdir build
1417     cd build
1418
1419     cmake_d="-D CMAKE_BUILD_TYPE=Release"
1420     cmake_d="$cmake_d -D CMAKE_PREFIX_PATH=$_inst"
1421     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
1422     cmake_d="$cmake_d -D BUILD_SHARED_LIBS=ON"
1423     cmake_d="$cmake_d -D NAMESPACE_VERSIONING=OFF"  # VERY IMPORTANT!!!
1424
1425     if file /bin/cp | grep -q '32-bit'; then
1426       cflags="-fPIC -m32 -march=i686"
1427     else
1428       cflags="-fPIC"
1429     fi
1430
1431     cmake $cmake_d -D CMAKE_CXX_FLAGS="$cflags" -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" ..
1432
1433     make -j$THREADS && make install
1434
1435     make clean
1436
1437     if [ -d $_inst ]; then
1438       _create_inst_shortcut
1439     else
1440       ERROR "ILMBase-$ILMBASE_VERSION failed to compile, exiting"
1441       exit 1
1442     fi
1443     cd $CWD
1444     INFO "Done compiling ILMBase-$ILMBASE_VERSION!"
1445   else
1446     INFO "Own ILMBase-$ILMBASE_VERSION is up to date, nothing to do!"
1447     INFO "If you want to force rebuild of this lib (and openexr), use the --force-openexr option."
1448   fi
1449
1450   magic_compile_set ilmbase-$ILMBASE_VERSION $ilmbase_magic
1451 }
1452
1453 #### Build OpenEXR ####
1454 _init_openexr() {
1455   _src=$SRC/OpenEXR-$OPENEXR_VERSION
1456   _git=true
1457   _inst=$_openexr_inst
1458   _inst_shortcut=$INST/openexr
1459 }
1460
1461 clean_OPENEXR() {
1462   clean_ILMBASE
1463   _init_openexr
1464   _clean
1465 }
1466
1467 compile_OPENEXR() {
1468   if [ "$NO_BUILD" = true ]; then
1469     WARNING "--no-build enabled, OpenEXR will not be compiled!"
1470     return
1471   fi
1472
1473   # To be changed each time we make edits that would modify the compiled result!
1474   openexr_magic=14
1475
1476   # Clean install if needed!
1477   magic_compile_check openexr-$OPENEXR_VERSION $openexr_magic
1478   if [ $? -eq 1 -o "$OPENEXR_FORCE_REBUILD" = true ]; then
1479     clean_OPENEXR
1480   fi
1481
1482   _openexr_inst=$INST/openexr-$OPENEXR_VERSION
1483   compile_ILMBASE
1484   PRINT ""
1485   _ilmbase_inst=$_inst_shortcut
1486   _init_openexr
1487
1488   if [ ! -d $_inst ]; then
1489     INFO "Building OpenEXR-$OPENEXR_VERSION"
1490
1491     # Rebuild dependecies as well!
1492     OIIO_FORCE_BUILD=true
1493     OIIO_FORCE_REBUILD=true
1494
1495     prepare_opt
1496
1497     if [ ! -d $_src ]; then
1498       INFO "Downloading OpenEXR-$OPENEXR_VERSION"
1499       mkdir -p $SRC
1500
1501       if [ "$OPENEXR_USE_REPO" = true ]; then
1502         git clone ${OPENEXR_SOURCE_REPO[0]} $_src
1503       else
1504         download OPENEXR_SOURCE[@] $_src.tar.gz
1505         INFO "Unpacking OpenEXR-$OPENEXR_VERSION"
1506         tar -C $SRC --transform "s,(.*/?)openexr[^/]*(.*),\1OpenEXR-$OPENEXR_VERSION\2,x" -xf $_src.tar.gz
1507       fi
1508
1509     fi
1510
1511     cd $_src
1512
1513     if [ "$OPENEXR_USE_REPO" = true ]; then
1514       # XXX For now, always update from latest repo...
1515       git pull origin master
1516       git checkout $OPENEXR_SOURCE_REPO_UID
1517       git reset --hard
1518       oiio_src_path="../OpenEXR"
1519     else
1520       oiio_src_path=".."
1521     fi
1522
1523     # Always refresh the whole build!
1524     if [ -d build ]; then
1525       rm -rf build
1526     fi
1527     mkdir build
1528     cd build
1529
1530     cmake_d="-D CMAKE_BUILD_TYPE=Release"
1531     cmake_d="$cmake_d -D CMAKE_PREFIX_PATH=$_inst"
1532     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
1533     cmake_d="$cmake_d -D ILMBASE_PACKAGE_PREFIX=$_ilmbase_inst"
1534     cmake_d="$cmake_d -D BUILD_SHARED_LIBS=ON"
1535     cmake_d="$cmake_d -D NAMESPACE_VERSIONING=OFF"  # VERY IMPORTANT!!!
1536
1537     if file /bin/cp | grep -q '32-bit'; then
1538       cflags="-fPIC -m32 -march=i686"
1539     else
1540       cflags="-fPIC"
1541     fi
1542
1543     cmake $cmake_d -D CMAKE_CXX_FLAGS="$cflags" -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" $oiio_src_path
1544
1545     make -j$THREADS && make install
1546
1547     make clean
1548
1549     if [ -d $_inst ]; then
1550       _create_inst_shortcut
1551       # Copy ilmbase files here (blender expects same dir for ilmbase and openexr :/).
1552       cp -an $_ilmbase_inst/* $_inst_shortcut
1553     else
1554       ERROR "OpenEXR-$OPENEXR_VERSION failed to compile, exiting"
1555       exit 1
1556     fi
1557
1558     magic_compile_set openexr-$OPENEXR_VERSION $openexr_magic
1559
1560     cd $CWD
1561     INFO "Done compiling OpenEXR-$OPENEXR_VERSION!"
1562   else
1563     INFO "Own OpenEXR-$OPENEXR_VERSION is up to date, nothing to do!"
1564     INFO "If you want to force rebuild of this lib, use the --force-openexr option."
1565   fi
1566
1567   _with_built_openexr=true
1568
1569   # Just always run it, much simpler this way!
1570   run_ldconfig "openexr"
1571 }
1572
1573 #### Build OIIO ####
1574 _init_oiio() {
1575   _src=$SRC/OpenImageIO-$OIIO_VERSION
1576   _git=true
1577   _inst=$INST/oiio-$OIIO_VERSION
1578   _inst_shortcut=$INST/oiio
1579 }
1580
1581 clean_OIIO() {
1582   _init_oiio
1583   _clean
1584 }
1585
1586 compile_OIIO() {
1587   if [ "$NO_BUILD" = true ]; then
1588     WARNING "--no-build enabled, OpenImageIO will not be compiled!"
1589     return
1590   fi
1591
1592   # To be changed each time we make edits that would modify the compiled result!
1593   oiio_magic=17
1594   _init_oiio
1595
1596   # Clean install if needed!
1597   magic_compile_check oiio-$OIIO_VERSION $oiio_magic
1598   if [ $? -eq 1 -o "$OIIO_FORCE_REBUILD" = true ]; then
1599     clean_OIIO
1600   fi
1601
1602   if [ ! -d $_inst ]; then
1603     INFO "Building OpenImageIO-$OIIO_VERSION"
1604
1605     # Rebuild dependecies as well!
1606     OSL_FORCE_BUILD=true
1607     OSL_FORCE_REBUILD=true
1608
1609     prepare_opt
1610
1611     if [ ! -d $_src ]; then
1612       mkdir -p $SRC
1613
1614       if [ "$OIIO_USE_REPO" = true ]; then
1615         git clone ${OIIO_SOURCE_REPO[0]} $_src
1616       else
1617         download OIIO_SOURCE[@] "$_src.tar.gz"
1618         INFO "Unpacking OpenImageIO-$OIIO_VERSION"
1619         tar -C $SRC --transform "s,(.*/?)oiio-Release-[^/]*(.*),\1OpenImageIO-$OIIO_VERSION\2,x" -xf $_src.tar.gz
1620       fi
1621     fi
1622
1623     cd $_src
1624
1625     if [ "$OIIO_USE_REPO" = true ]; then
1626       # XXX For now, always update from latest repo...
1627       git pull origin master
1628       # Stick to same rev as windows' libs...
1629       git checkout $OIIO_SOURCE_REPO_UID
1630       git reset --hard
1631     fi
1632
1633     # Always refresh the whole build!
1634     if [ -d build ]; then
1635       rm -rf build
1636     fi
1637     mkdir build
1638     cd build
1639
1640     cmake_d="-D CMAKE_BUILD_TYPE=Release"
1641     cmake_d="$cmake_d -D CMAKE_PREFIX_PATH=$_inst"
1642     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
1643     cmake_d="$cmake_d -D STOP_ON_WARNING=OFF"
1644     cmake_d="$cmake_d -D BUILDSTATIC=OFF"
1645     cmake_d="$cmake_d -D LINKSTATIC=OFF"
1646     cmake_d="$cmake_d -D USE_SIMD=sse2"
1647
1648     cmake_d="$cmake_d -D OPENEXR_VERSION=$OPENEXR_VERSION"
1649
1650     if [ "$_with_built_openexr" = true ]; then
1651       cmake_d="$cmake_d -D ILMBASE_HOME=$INST/openexr"
1652       cmake_d="$cmake_d -D OPENEXR_HOME=$INST/openexr"
1653       INFO "ILMBASE_HOME=$INST/openexr"
1654     fi
1655
1656     # ptex is only needed when nicholas bishop is ready
1657     cmake_d="$cmake_d -D USE_PTEX=OFF"
1658
1659     # Optional tests and cmd tools
1660     cmake_d="$cmake_d -D USE_QT=OFF"
1661     cmake_d="$cmake_d -D USE_PYTHON=OFF"
1662     cmake_d="$cmake_d -D USE_FFMPEG=OFF"
1663     cmake_d="$cmake_d -D BUILD_TESTING=OFF"
1664     cmake_d="$cmake_d -D OIIO_BUILD_TESTS=OFF"
1665     cmake_d="$cmake_d -D OIIO_BUILD_TOOLS=OFF"
1666     cmake_d="$cmake_d -D TXT2MAN="
1667     #cmake_d="$cmake_d -D CMAKE_EXPORT_COMPILE_COMMANDS=ON"
1668     #cmake_d="$cmake_d -D CMAKE_VERBOSE_MAKEFILE=ON"
1669
1670     if [ -d $INST/boost ]; then
1671       cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost -D Boost_NO_SYSTEM_PATHS=ON"
1672     fi
1673
1674     # Looks like we do not need ocio in oiio for now...
1675 #    if [ -d $INST/ocio ]; then
1676 #      cmake_d="$cmake_d -D OCIO_PATH=$INST/ocio"
1677 #    fi
1678     cmake_d="$cmake_d -D USE_OCIO=OFF"
1679
1680     cmake_d="$cmake_d -D OIIO_BUILD_CPP11=ON"
1681
1682     if file /bin/cp | grep -q '32-bit'; then
1683       cflags="-fPIC -m32 -march=i686"
1684     else
1685       cflags="-fPIC"
1686     fi
1687
1688     cmake $cmake_d -D CMAKE_CXX_FLAGS="$cflags" -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" ..
1689
1690     make -j$THREADS && make install
1691     make clean
1692
1693     if [ -d $_inst ]; then
1694       _create_inst_shortcut
1695     else
1696       ERROR "OpenImageIO-$OIIO_VERSION failed to compile, exiting"
1697       exit 1
1698     fi
1699
1700     magic_compile_set oiio-$OIIO_VERSION $oiio_magic
1701
1702     cd $CWD
1703     INFO "Done compiling OpenImageIO-$OIIO_VERSION!"
1704   else
1705     INFO "Own OpenImageIO-$OIIO_VERSION is up to date, nothing to do!"
1706     INFO "If you want to force rebuild of this lib, use the --force-oiio option."
1707   fi
1708
1709   # Just always run it, much simpler this way!
1710   run_ldconfig "oiio"
1711 }
1712
1713 #### Build LLVM ####
1714 _init_llvm() {
1715   _src=$SRC/LLVM-$LLVM_VERSION
1716   _src_clang=$SRC/CLANG-$LLVM_VERSION
1717   _git=false
1718   _inst=$INST/llvm-$LLVM_VERSION
1719   _inst_shortcut=$INST/llvm
1720 }
1721
1722 clean_LLVM() {
1723   _init_llvm
1724   _clean
1725 }
1726
1727 compile_LLVM() {
1728   if [ "$NO_BUILD" = true ]; then
1729     WARNING "--no-build enabled, LLVM will not be compiled!"
1730     return
1731   fi
1732
1733   # To be changed each time we make edits that would modify the compiled result!
1734   llvm_magic=3
1735   _init_llvm
1736
1737   # Clean install if needed!
1738   magic_compile_check llvm-$LLVM_VERSION $llvm_magic
1739   if [ $? -eq 1 -o "$LLVM_FORCE_REBUILD" = true ]; then
1740     clean_LLVM
1741   fi
1742
1743   if [ ! -d $_inst ]; then
1744     INFO "Building LLVM-$LLVM_VERSION (CLANG included!)"
1745
1746     # Rebuild dependecies as well!
1747     OSL_FORCE_BUILD=true
1748     OSL_FORCE_REBUILD=true
1749
1750     prepare_opt
1751
1752     if [ ! -d $_src -o true ]; then
1753       mkdir -p $SRC
1754       download LLVM_SOURCE[@] "$_src.tar.xz"
1755       download LLVM_CLANG_SOURCE[@] "$_src_clang.tar.xz"
1756
1757       INFO "Unpacking LLVM-$LLVM_VERSION"
1758       tar -C $SRC --transform "s,([^/]*/?)llvm-[^/]*(.*),\1LLVM-$LLVM_VERSION\2,x" \
1759           -xf $_src.tar.xz
1760       INFO "Unpacking CLANG-$LLVM_VERSION to $_src/tools/clang"
1761       # Stupid clang guys renamed 'clang' to 'cfe' for now handle both cases... :(
1762       tar -C $_src/tools \
1763           --transform "s,([^/]*/?)(clang|cfe)-[^/]*(.*),\1clang\3,x" \
1764           -xf $_src_clang.tar.xz
1765
1766       cd $_src
1767
1768       cd $CWD
1769
1770     fi
1771
1772     cd $_src
1773
1774     # Always refresh the whole build!
1775     if [ -d build ]; then
1776       rm -rf build
1777     fi
1778     mkdir build
1779     cd build
1780
1781     cmake_d="-D CMAKE_BUILD_TYPE=Release"
1782     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
1783     cmake_d="$cmake_d -D LLVM_ENABLE_FFI=ON"
1784     cmake_d="$cmake_d -D LLVM_TARGETS_TO_BUILD=X86"
1785     cmake_d="$cmake_d -D LLVM_ENABLE_TERMINFO=OFF"
1786
1787     if [ -d $_FFI_INCLUDE_DIR ]; then
1788       cmake_d="$cmake_d -D FFI_INCLUDE_DIR=$_FFI_INCLUDE_DIR"
1789     fi
1790
1791     cmake $cmake_d ..
1792
1793     make -j$THREADS && make install
1794     make clean
1795
1796     if [ -d $_inst ]; then
1797       _create_inst_shortcut
1798     else
1799       ERROR "LLVM-$LLVM_VERSION failed to compile, exiting"
1800       exit 1
1801     fi
1802
1803     magic_compile_set llvm-$LLVM_VERSION $llvm_magic
1804
1805     cd $CWD
1806     INFO "Done compiling LLVM-$LLVM_VERSION (CLANG included)!"
1807   else
1808     INFO "Own LLVM-$LLVM_VERSION (CLANG included) is up to date, nothing to do!"
1809     INFO "If you want to force rebuild of this lib, use the --force-llvm option."
1810   fi
1811 }
1812
1813 #### Build OSL ####
1814 _init_osl() {
1815   _src=$SRC/OpenShadingLanguage-$OSL_VERSION
1816   _git=true
1817   _inst=$INST/osl-$OSL_VERSION
1818   _inst_shortcut=$INST/osl
1819 }
1820
1821 clean_OSL() {
1822   _init_osl
1823   _clean
1824 }
1825
1826 compile_OSL() {
1827   if [ "$NO_BUILD" = true ]; then
1828     WARNING "--no-build enabled, OpenShadingLanguage will not be compiled!"
1829     return
1830   fi
1831
1832   # To be changed each time we make edits that would modify the compiled result!
1833   osl_magic=21
1834   _init_osl
1835
1836   # Clean install if needed!
1837   magic_compile_check osl-$OSL_VERSION $osl_magic
1838   if [ $? -eq 1 -o "$OSL_FORCE_REBUILD" = true ]; then
1839     #~ rm -Rf $_src  # XXX Radical, but not easy to change remote repo fully automatically
1840     clean_OSL
1841   fi
1842
1843   if [ ! -d $_inst ]; then
1844     INFO "Building OpenShadingLanguage-$OSL_VERSION"
1845
1846     prepare_opt
1847
1848     if [ ! -d $_src ]; then
1849       mkdir -p $SRC
1850
1851       if [ "$OSL_USE_REPO" = true ]; then
1852         git clone ${OSL_SOURCE_REPO[0]} $_src
1853       else
1854         download OSL_SOURCE[@] "$_src.tar.gz"
1855         INFO "Unpacking OpenShadingLanguage-$OSL_VERSION"
1856         tar -C $SRC --transform "s,(.*/?)OpenShadingLanguage-[^/]*(.*),\1OpenShadingLanguage-$OSL_VERSION\2,x" \
1857             -xf $_src.tar.gz
1858       fi
1859     fi
1860
1861     cd $_src
1862
1863     if [ "$OSL_USE_REPO" = true ]; then
1864       git remote set-url origin ${OSL_SOURCE_REPO[0]}
1865       # XXX For now, always update from latest repo...
1866       git pull --no-edit -X theirs origin $OSL_SOURCE_REPO_BRANCH
1867       # Stick to same rev as windows' libs...
1868       git checkout $OSL_SOURCE_REPO_UID
1869       git reset --hard
1870     fi
1871
1872     # Always refresh the whole build!
1873     if [ -d build ]; then
1874       rm -rf build
1875     fi
1876     mkdir build
1877     cd build
1878
1879     cmake_d="-D CMAKE_BUILD_TYPE=Release"
1880     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
1881     cmake_d="$cmake_d -D BUILD_TESTING=OFF"
1882     cmake_d="$cmake_d -D STOP_ON_WARNING=OFF"
1883     cmake_d="$cmake_d -D BUILDSTATIC=OFF"
1884     cmake_d="$cmake_d -D OSL_BUILD_PLUGINS=OFF"
1885     cmake_d="$cmake_d -D OSL_BUILD_TESTS=OFF"
1886     cmake_d="$cmake_d -D USE_SIMD=sse2"
1887     cmake_d="$cmake_d -D OSL_BUILD_CPP11=1"
1888
1889     #~ cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION"
1890
1891     if [ "$_with_built_openexr" = true ]; then
1892       INFO "ILMBASE_HOME=$INST/openexr"
1893       cmake_d="$cmake_d -D ILMBASE_HOME=$INST/openexr"
1894       # XXX Temp workaround... sigh, ILMBase really messed the things up by defining their custom names ON by default :(
1895       cmake_d="$cmake_d -D ILMBASE_CUSTOM=ON"
1896       cmake_d="$cmake_d -D ILMBASE_CUSTOM_LIBRARIES='Half;Iex;Imath;IlmThread'"
1897     fi
1898
1899     if [ -d $INST/boost ]; then
1900       cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost -D Boost_NO_SYSTEM_PATHS=ON"
1901     fi
1902
1903     if [ -d $INST/oiio ]; then
1904       cmake_d="$cmake_d -D OPENIMAGEIOHOME=$INST/oiio"
1905     fi
1906
1907     if [ ! -z $LLVM_VERSION_FOUND ]; then
1908       cmake_d="$cmake_d -D LLVM_VERSION=$LLVM_VERSION_FOUND"
1909       if [ -d $INST/llvm ]; then
1910         cmake_d="$cmake_d -D LLVM_DIRECTORY=$INST/llvm"
1911         cmake_d="$cmake_d -D LLVM_STATIC=ON"
1912       fi
1913     fi
1914
1915     #~ cmake_d="$cmake_d -D CMAKE_EXPORT_COMPILE_COMMANDS=ON"
1916     #~ cmake_d="$cmake_d -D CMAKE_VERBOSE_MAKEFILE=ON"
1917
1918     cmake $cmake_d ..
1919
1920     make -j$THREADS && make install
1921     make clean
1922
1923     if [ -d $_inst ]; then
1924       _create_inst_shortcut
1925     else
1926       ERROR "OpenShadingLanguage-$OSL_VERSION failed to compile, exiting"
1927       exit 1
1928     fi
1929
1930     magic_compile_set osl-$OSL_VERSION $osl_magic
1931
1932     cd $CWD
1933     INFO "Done compiling OpenShadingLanguage-$OSL_VERSION!"
1934   else
1935     INFO "Own OpenShadingLanguage-$OSL_VERSION is up to date, nothing to do!"
1936     INFO "If you want to force rebuild of this lib, use the --force-osl option."
1937   fi
1938
1939   run_ldconfig "osl"
1940 }
1941
1942 #### Build OSD ####
1943 _init_osd() {
1944   _src=$SRC/OpenSubdiv-$OSD_VERSION
1945   _git=true
1946   _inst=$INST/osd-$OSD_VERSION
1947   _inst_shortcut=$INST/osd
1948 }
1949
1950 clean_OSD() {
1951   _init_osd
1952   _clean
1953 }
1954
1955 compile_OSD() {
1956   if [ "$NO_BUILD" = true ]; then
1957     WARNING "--no-build enabled, OpenSubdiv will not be compiled!"
1958     return
1959   fi
1960
1961   # To be changed each time we make edits that would modify the compiled result!
1962   osd_magic=2
1963   _init_osd
1964
1965   # Clean install if needed!
1966   magic_compile_check osd-$OSD_VERSION $osd_magic
1967   if [ $? -eq 1 -o "$OSD_FORCE_REBUILD" = true ]; then
1968     clean_OSD
1969   fi
1970
1971   if [ ! -d $_inst ]; then
1972     INFO "Building OpenSubdiv-$OSD_VERSION"
1973
1974     prepare_opt
1975
1976     if [ ! -d $_src ]; then
1977       mkdir -p $SRC
1978
1979       if [ "$OSD_USE_REPO" = true ]; then
1980         git clone ${OSD_SOURCE_REPO[0]} $_src
1981       else
1982         download OSD_SOURCE[@] "$_src.tar.gz"
1983         INFO "Unpacking OpenSubdiv-$OSD_VERSION"
1984         tar -C $SRC --transform "s,(.*/?)OpenSubdiv-[^/]*(.*),\1OpenSubdiv-$OSD_VERSION\2,x" \
1985             -xf $_src.tar.gz
1986       fi
1987     fi
1988
1989     cd $_src
1990
1991     if [ "$OSD_USE_REPO" = true ]; then
1992       git remote set-url origin ${OSD_SOURCE_REPO[0]}
1993       # XXX For now, always update from latest repo...
1994       git pull --no-edit -X theirs origin $OSD_SOURCE_REPO_BRANCH
1995       # Stick to same rev as windows' libs...
1996       git checkout $OSD_SOURCE_REPO_UID
1997       git reset --hard
1998     fi
1999
2000     # Always refresh the whole build!
2001     if [ -d build ]; then
2002       rm -rf build
2003     fi
2004     mkdir build
2005     cd build
2006
2007     cmake_d="-D CMAKE_BUILD_TYPE=Release"
2008     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
2009     # ptex is only needed when nicholas bishop is ready
2010     cmake_d="$cmake_d -D NO_PTEX=1"
2011     cmake_d="$cmake_d -D NO_CLEW=1 -D NO_CUDA=1 -D NO_OPENCL=1"
2012     # maya plugin, docs, tutorials, regression tests and examples are not needed
2013     cmake_d="$cmake_d -D NO_MAYA=1 -D NO_DOC=1 -D NO_TUTORIALS=1 -D NO_REGRESSION=1 -DNO_EXAMPLES=1"
2014
2015     cmake $cmake_d ..
2016
2017     make -j$THREADS && make install
2018     make clean
2019
2020     if [ -d $_inst ]; then
2021       _create_inst_shortcut
2022     else
2023       ERROR "OpenSubdiv-$OSD_VERSION failed to compile, exiting"
2024       exit 1
2025     fi
2026
2027     magic_compile_set osd-$OSD_VERSION $osd_magic
2028
2029     cd $CWD
2030     INFO "Done compiling OpenSubdiv-$OSD_VERSION!"
2031   else
2032     INFO "Own OpenSubdiv-$OSD_VERSION is up to date, nothing to do!"
2033     INFO "If you want to force rebuild of this lib, use the --force-osd option."
2034   fi
2035
2036   run_ldconfig "osd"
2037 }
2038
2039 #### Build Blosc ####
2040 _init_blosc() {
2041   _src=$SRC/c-blosc-$OPENVDB_BLOSC_VERSION
2042   _git=false
2043   _inst=$INST/blosc-$OPENVDB_BLOSC_VERSION
2044   _inst_shortcut=$INST/blosc
2045 }
2046
2047 clean_BLOSC() {
2048   _init_blosc
2049   _clean
2050 }
2051
2052 compile_BLOSC() {
2053   if [ "$NO_BUILD" = true ]; then
2054     WARNING "--no-build enabled, Blosc will not be compiled!"
2055     return
2056   fi
2057
2058   # To be changed each time we make edits that would modify the compiled result!
2059   blosc_magic=0
2060   _init_blosc
2061
2062   # Clean install if needed!
2063   magic_compile_check blosc-$OPENVDB_BLOSC_VERSION $blosc_magic
2064   if [ $? -eq 1 -o "$OPENVDB_FORCE_REBUILD" = true ]; then
2065     clean_BLOSC
2066     rm -rf $_inst
2067   fi
2068
2069   if [ ! -d $_inst ]; then
2070     INFO "Building Blosc-$OPENVDB_BLOSC_VERSION"
2071
2072     # Rebuild dependecies as well!
2073     OPENVDB_FORCE_BUILD=true
2074     OPENVDB_FORCE_REBUILD=true
2075
2076     prepare_opt
2077
2078     if [ ! -d $_src ]; then
2079       INFO "Downloading Blosc-$OPENVDB_BLOSC_VERSION"
2080       mkdir -p $SRC
2081       download OPENVDB_BLOSC_SOURCE[@] $_src.tar.gz
2082
2083       INFO "Unpacking Blosc-$OPENVDB_BLOSC_VERSION"
2084       tar -C $SRC -xf $_src.tar.gz
2085     fi
2086
2087     cd $_src
2088     # Always refresh the whole build!
2089     if [ -d build ]; then
2090       rm -rf build
2091     fi
2092     mkdir build
2093     cd build
2094
2095     cmake_d="-D CMAKE_BUILD_TYPE=Release"
2096     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
2097     cmake_d="$cmake_d -D BUILD_STATIC=OFF"
2098     cmake_d="$cmake_d -D BUILD_TESTS=OFF"
2099     cmake_d="$cmake_d -D BUILD_BENCHMARKS=OFF"
2100     INFO "$cmake_d"
2101
2102     cmake $cmake_d ..
2103
2104     make -j$THREADS && make install
2105
2106     make clean
2107
2108     if [ -d $_inst ]; then
2109       _create_inst_shortcut
2110     else
2111       ERROR "Blosc-$OPENVDB_BLOSC_VERSION failed to compile, exiting"
2112       exit 1
2113     fi
2114     cd $CWD
2115     INFO "Done compiling Blosc-$OPENVDB_BLOSC_VERSION!"
2116   else
2117     INFO "Own Blosc-$OPENVDB_BLOSC_VERSION is up to date, nothing to do!"
2118     INFO "If you want to force rebuild of this lib (and openvdb), use the --force-openvdb option."
2119   fi
2120
2121   magic_compile_set blosc-$OPENVDB_BLOSC_VERSION $blosc_magic
2122
2123   run_ldconfig "blosc"
2124 }
2125
2126 #### Build OpenVDB ####
2127 _init_openvdb() {
2128   _src=$SRC/openvdb-$OPENVDB_VERSION
2129   _git=false
2130   _inst=$INST/openvdb-$OPENVDB_VERSION
2131   _inst_shortcut=$INST/openvdb
2132 }
2133
2134 clean_OPENVDB() {
2135   _init_openvdb
2136   _clean
2137 }
2138
2139 compile_OPENVDB() {
2140   if [ "$NO_BUILD" = true ]; then
2141     WARNING "--no-build enabled, OpenVDB will not be compiled!"
2142     return
2143   fi
2144
2145   compile_BLOSC
2146   PRINT ""
2147
2148   # To be changed each time we make edits that would modify the compiled result!
2149   openvdb_magic=1
2150   _init_openvdb
2151
2152   # Clean install if needed!
2153   magic_compile_check openvdb-$OPENVDB_VERSION $openvdb_magic
2154   if [ $? -eq 1 -o "$OPENVDB_FORCE_REBUILD" = true ]; then
2155     clean_OPENVDB
2156   fi
2157
2158   if [ ! -d $_inst ]; then
2159     INFO "Building OpenVDB-$OPENVDB_VERSION"
2160
2161     prepare_opt
2162
2163     if [ ! -d $_src -o true ]; then
2164       mkdir -p $SRC
2165       download OPENVDB_SOURCE[@] "$_src.tar.gz"
2166
2167       INFO "Unpacking OpenVDB-$OPENVDB_VERSION"
2168       tar -C $SRC -xf $_src.tar.gz
2169     fi
2170
2171     cd $_src
2172
2173     #~ if [ "$OPENVDB_USE_REPO" = true ]; then
2174       #~ git remote set-url origin ${OPENVDB_SOURCE_REPO[0]}
2175       #~ # XXX For now, always update from latest repo...
2176       #~ git pull --no-edit -X theirs origin $OPENVDB_SOURCE_REPO_BRANCH
2177       #~ # Stick to same rev as windows' libs...
2178       #~ git checkout $OPENVDB_SOURCE_REPO_UID
2179       #~ git reset --hard
2180     #~ fi
2181
2182     # Source builds here
2183     cd openvdb
2184
2185     make_d="DESTDIR=$_inst"
2186     make_d="$make_d HDSO=/usr"
2187
2188     if [ -d $INST/boost ]; then
2189       make_d="$make_d BOOST_INCL_DIR=$INST/boost/include BOOST_LIB_DIR=$INST/boost/lib"
2190     fi
2191
2192     if [ "$_with_built_openexr" = true ]; then
2193       make_d="$make_d ILMBASE_INCL_DIR=$INST/openexr/include ILMBASE_LIB_DIR=$INST/openexr/lib"
2194       make_d="$make_d EXR_INCL_DIR=$INST/openexr/include EXR_LIB_DIR=$INST/openexr/lib"
2195       INFO "ILMBASE_HOME=$INST/openexr"
2196     fi
2197
2198     if [ -d $INST/blosc ]; then
2199       make_d="$make_d BLOSC_INCL_DIR=$INST/blosc/include BLOSC_LIB_DIR=$INST/blosc/lib"
2200     fi
2201
2202     # Build without log4cplus, glfw, python module & docs
2203     make_d="$make_d LOG4CPLUS_INCL_DIR= GLFW_INCL_DIR= PYTHON_VERSION= DOXYGEN="
2204
2205     make -j$THREADS lib $make_d install
2206     make clean
2207
2208     if [ -d $_inst ]; then
2209       _create_inst_shortcut
2210     else
2211       ERROR "OpenVDB-$OPENVDB_VERSION failed to compile, exiting"
2212       exit 1
2213     fi
2214
2215     magic_compile_set openvdb-$OPENVDB_VERSION $openvdb_magic
2216
2217     cd $CWD
2218     INFO "Done compiling OpenVDB-$OPENVDB_VERSION!"
2219   else
2220     INFO "Own OpenVDB-$OPENVDB_VERSION is up to date, nothing to do!"
2221     INFO "If you want to force rebuild of this lib, use the --force-openvdb option."
2222   fi
2223
2224   run_ldconfig "openvdb"
2225 }
2226
2227 #### Build Alembic ####
2228 _init_alembic() {
2229   _src=$SRC/alembic-$ALEMBIC_VERSION
2230   _git=false
2231   _inst=$INST/alembic-$ALEMBIC_VERSION
2232   _inst_shortcut=$INST/alembic
2233 }
2234
2235 clean_ALEMBIC() {
2236   _init_alembic
2237   _clean
2238 }
2239
2240 compile_ALEMBIC() {
2241   if [ "$NO_BUILD" = true ]; then
2242     WARNING "--no-build enabled, Alembic will not be compiled!"
2243     return
2244   fi
2245
2246   # To be changed each time we make edits that would modify the compiled result!
2247   alembic_magic=2
2248   _init_alembic
2249
2250   # Clean install if needed!
2251   magic_compile_check alembic-$ALEMBIC_VERSION $alembic_magic
2252   if [ $? -eq 1 -o "$ALEMBIC_FORCE_REBUILD" = true ]; then
2253     clean_ALEMBIC
2254   fi
2255
2256   if [ ! -d $_inst ]; then
2257     INFO "Building Alembic-$ALEMBIC_VERSION"
2258
2259     prepare_opt
2260
2261     if [ ! -d $_src -o true ]; then
2262       mkdir -p $SRC
2263       download ALEMBIC_SOURCE[@] "$_src.tar.gz"
2264
2265       INFO "Unpacking Alembic-$ALEMBIC_VERSION"
2266       tar -C $SRC -xf $_src.tar.gz
2267     fi
2268
2269     cd $_src
2270
2271     cmake_d="-D CMAKE_INSTALL_PREFIX=$_inst"
2272
2273     if [ -d $INST/boost ]; then
2274       if [ -d $INST/boost ]; then
2275         cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost"
2276       fi
2277       cmake_d="$cmake_d -D USE_STATIC_BOOST=ON"
2278     else
2279       cmake_d="$cmake_d -D USE_STATIC_BOOST=OFF"
2280     fi
2281
2282     if [ "$_with_built_openexr" = true ]; then
2283       cmake_d="$cmake_d -D ILMBASE_ROOT=$INST/openexr"
2284       cmake_d="$cmake_d -D USE_ARNOLD=OFF"
2285       cmake_d="$cmake_d -D USE_BINARIES=OFF"
2286       cmake_d="$cmake_d -D USE_EXAMPLES=OFF"
2287       cmake_d="$cmake_d -D USE_HDF5=OFF"
2288       cmake_d="$cmake_d -D USE_MAYA=OFF"
2289       cmake_d="$cmake_d -D USE_PRMAN=OFF"
2290       cmake_d="$cmake_d -D USE_PYALEMBIC=OFF"
2291       cmake_d="$cmake_d -D USE_STATIC_HDF5=OFF"
2292       cmake_d="$cmake_d -D ALEMBIC_ILMBASE_LINK_STATIC=OFF"
2293       cmake_d="$cmake_d -D ALEMBIC_SHARED_LIBS=OFF"
2294       INFO "ILMBASE_ROOT=$INST/openexr"
2295     fi
2296
2297     cmake $cmake_d ./
2298     make -j$THREADS install
2299     make clean
2300
2301     if [ -d $_inst ]; then
2302       _create_inst_shortcut
2303     else
2304       ERROR "Alembic-$ALEMBIC_VERSION failed to compile, exiting"
2305       exit 1
2306     fi
2307
2308     magic_compile_set alembic-$ALEMBIC_VERSION $alembic_magic
2309
2310     cd $CWD
2311     INFO "Done compiling Alembic-$ALEMBIC_VERSION!"
2312   else
2313     INFO "Own Alembic-$ALEMBIC_VERSION is up to date, nothing to do!"
2314     INFO "If you want to force rebuild of this lib, use the --force-alembic option."
2315   fi
2316
2317   run_ldconfig "alembic"
2318 }
2319
2320 #### Build OpenCOLLADA ####
2321 _init_opencollada() {
2322   _src=$SRC/OpenCOLLADA-$OPENCOLLADA_VERSION
2323   _git=true
2324   _inst=$INST/opencollada-$OPENCOLLADA_VERSION
2325   _inst_shortcut=$INST/opencollada
2326 }
2327
2328 clean_OpenCOLLADA() {
2329   _init_opencollada
2330   _clean
2331 }
2332
2333 compile_OpenCOLLADA() {
2334   if [ "$NO_BUILD" = true ]; then
2335     WARNING "--no-build enabled, OpenCOLLADA will not be compiled!"
2336     return
2337   fi
2338
2339   # To be changed each time we make edits that would modify the compiled results!
2340   opencollada_magic=9
2341   _init_opencollada
2342
2343   # Clean install if needed!
2344   magic_compile_check opencollada-$OPENCOLLADA_VERSION $opencollada_magic
2345   if [ $? -eq 1 -o "$OPENCOLLADA_FORCE_REBUILD" = true ]; then
2346     clean_OpenCOLLADA
2347   fi
2348
2349   if [ ! -d $_inst ]; then
2350     INFO "Building OpenCOLLADA-$OPENCOLLADA_VERSION"
2351
2352     prepare_opt
2353
2354     if [ ! -d $_src ]; then
2355       mkdir -p $SRC
2356       if [ "$OPENCOLLADA_USE_REPO" = true ]; then
2357         git clone $OPENCOLLADA_SOURCE_REPO $_src
2358       else
2359         download OPENCOLLADA_SOURCE[@] "$_src.tar.gz"
2360         INFO "Unpacking OpenCOLLADA-$OPENCOLLADA_VERSION"
2361         tar -C $SRC -xf $_src.tar.gz
2362       fi
2363     fi
2364
2365     cd $_src
2366
2367     if [ "$OPENCOLLADA_USE_REPO" = true ]; then
2368       git pull origin $OPENCOLLADA_REPO_BRANCH
2369
2370       # Stick to same rev as windows' libs...
2371       git checkout $OPENCOLLADA_REPO_UID
2372       git reset --hard
2373     fi
2374
2375     # Always refresh the whole build!
2376     if [ -d build ]; then
2377       rm -rf build
2378     fi
2379     mkdir build
2380     cd build
2381
2382     cmake_d="-D CMAKE_BUILD_TYPE=Release"
2383     cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
2384     cmake_d="$cmake_d -D USE_EXPAT=OFF"
2385     cmake_d="$cmake_d -D USE_LIBXML=ON"
2386     # XXX Does not work!
2387 #    cmake_d="$cmake_d -D USE_STATIC=OFF"
2388     cmake_d="$cmake_d -D USE_STATIC=ON"
2389
2390     cmake $cmake_d ../
2391
2392     make -j$THREADS && make install
2393     make clean
2394
2395     if [ -d $_inst ]; then
2396       _create_inst_shortcut
2397     else
2398       ERROR "OpenCOLLADA-$OPENCOLLADA_VERSION failed to compile, exiting"
2399       exit 1
2400     fi
2401
2402     magic_compile_set opencollada-$OPENCOLLADA_VERSION $opencollada_magic
2403
2404     cd $CWD
2405     INFO "Done compiling OpenCOLLADA-$OPENCOLLADA_VERSION!"
2406   else
2407     INFO "Own OpenCOLLADA-$OPENCOLLADA_VERSION is up to date, nothing to do!"
2408     INFO "If you want to force rebuild of this lib, use the --force-opencollada option."
2409   fi
2410 }
2411
2412 #### Build FFMPEG ####
2413 _init_ffmpeg() {
2414   _src=$SRC/ffmpeg-$FFMPEG_VERSION
2415   _inst=$INST/ffmpeg-$FFMPEG_VERSION
2416   _inst_shortcut=$INST/ffmpeg
2417 }
2418
2419 clean_FFmpeg() {
2420   _init_ffmpeg
2421   _clean
2422 }
2423
2424 compile_FFmpeg() {
2425   if [ "$NO_BUILD" = true ]; then
2426     WARNING "--no-build enabled, ffmpeg will not be compiled!"
2427     return
2428   fi
2429
2430   # To be changed each time we make edits that would modify the compiled result!
2431   ffmpeg_magic=5
2432   _init_ffmpeg
2433
2434   # Clean install if needed!
2435   magic_compile_check ffmpeg-$FFMPEG_VERSION $ffmpeg_magic
2436   if [ $? -eq 1 -o "$FFMPEG_FORCE_REBUILD" = true ]; then
2437     clean_FFmpeg
2438   fi
2439
2440   if [ ! -d $_inst ]; then
2441     INFO "Building ffmpeg-$FFMPEG_VERSION"
2442
2443     prepare_opt
2444
2445     if [ ! -d $_src ]; then
2446       INFO "Downloading ffmpeg-$FFMPEG_VERSION"
2447       mkdir -p $SRC
2448       download FFMPEG_SOURCE[@] "$_src.tar.bz2"
2449
2450       INFO "Unpacking ffmpeg-$FFMPEG_VERSION"
2451       tar -C $SRC -xf $_src.tar.bz2
2452     fi
2453
2454     cd $_src
2455
2456     extra=""
2457
2458     if [ "$VORBIS_USE" = true ]; then
2459       extra="$extra --enable-libvorbis"
2460     fi
2461
2462     if [ "$THEORA_USE" = true ]; then
2463       extra="$extra --enable-libtheora"
2464     fi
2465
2466     if [ "$XVID_USE" = true ]; then
2467       extra="$extra --enable-libxvid"
2468     fi
2469
2470     if [ "$X264_USE" = true ]; then
2471       extra="$extra --enable-libx264"
2472     fi
2473
2474     if [ "$VPX_USE" = true ]; then
2475       extra="$extra --enable-libvpx"
2476     fi
2477
2478     if [ "$MP3LAME_USE" = true ]; then
2479       extra="$extra --enable-libmp3lame"
2480     fi
2481
2482     if [ "$OPENJPEG_USE" = true ]; then
2483       extra="$extra --enable-libopenjpeg"
2484     fi
2485
2486     ./configure --cc="gcc -Wl,--as-needed" \
2487         --extra-ldflags="-pthread -static-libgcc" \
2488         --prefix=$_inst --enable-static \
2489         --disable-ffplay --disable-ffserver --disable-doc \
2490         --enable-gray \
2491         --enable-avfilter --disable-vdpau \
2492         --disable-bzlib --disable-libgsm --disable-libspeex \
2493         --enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \
2494         --disable-vaapi --disable-nonfree --enable-gpl \
2495         --disable-postproc --disable-librtmp --disable-libopencore-amrnb \
2496         --disable-libopencore-amrwb --disable-libdc1394 --disable-version3 --disable-outdev=sdl \
2497         --disable-libxcb \
2498         --disable-outdev=xv --disable-indev=sndio --disable-outdev=sndio \
2499         --disable-outdev=alsa --disable-indev=sdl --disable-indev=alsa --disable-indev=jack \
2500         --disable-indev=lavfi $extra
2501
2502     make -j$THREADS && make install
2503     make clean
2504
2505     if [ -d $_inst ]; then
2506       _create_inst_shortcut
2507     else
2508       ERROR "FFmpeg-$FFMPEG_VERSION failed to compile, exiting"
2509       exit 1
2510     fi
2511
2512     magic_compile_set ffmpeg-$FFMPEG_VERSION $ffmpeg_magic
2513
2514     cd $CWD
2515     INFO "Done compiling ffmpeg-$FFMPEG_VERSION!"
2516   else
2517     INFO "Own ffmpeg-$FFMPEG_VERSION is up to date, nothing to do!"
2518     INFO "If you want to force rebuild of this lib, use the --force-ffmpeg option."
2519   fi
2520 }
2521
2522
2523 #### Install on DEB-like ####
2524 get_package_version_DEB() {
2525     dpkg-query -W -f '${Version}' $1 | sed -r 's/([0-9]+:)?(([0-9]+\.?)+([0-9]+)).*/\2/'
2526 }
2527
2528 check_package_DEB() {
2529   r=`apt-cache show $1 | grep -c 'Package:'`
2530
2531   if [ $r -ge 1 ]; then
2532     return 0
2533   else
2534     return 1
2535   fi
2536 }
2537
2538 check_package_installed_DEB() {
2539   r=`dpkg-query -W -f='${Status}' $1 | grep -c "install ok"`
2540
2541   if [ $r -ge 1 ]; then
2542     return 0
2543   else
2544     return 1
2545   fi
2546 }
2547
2548 check_package_version_match_DEB() {
2549   v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*([0-9]+:)(([0-9]+\.?)+).*/\2/'`
2550
2551   if [ -z "$v" ]; then
2552     return 1
2553   fi
2554
2555   version_match $v $2
2556   return $?
2557 }
2558
2559 check_package_version_ge_DEB() {
2560   v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*([0-9]+:)?(([0-9]+\.?)+).*/\2/'`
2561
2562   if [ -z "$v" ]; then
2563     return 1
2564   fi
2565
2566   version_ge $v $2
2567   return $?
2568 }
2569
2570 check_package_version_ge_lt_DEB() {
2571   v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*([0-9]+:)?(([0-9]+\.?)+).*/\2/'`
2572
2573   if [ -z "$v" ]; then
2574     return 1
2575   fi
2576
2577   version_ge_lt $v $2 $3
2578   return $?
2579 }
2580
2581 install_packages_DEB() {
2582   if [ ! $SUDO ]; then
2583     WARNING "--no-sudo enabled, impossible to run apt-get install for $@, you'll have to do it yourself..."
2584   else
2585     $SUDO apt-get install -y $@
2586     if [ $? -ge 1 ]; then
2587       ERROR "apt-get failed to install requested packages, exiting."
2588       exit 1
2589     fi
2590   fi
2591 }
2592
2593 install_DEB() {
2594   PRINT ""
2595   INFO "Installing dependencies for DEB-based distribution"
2596   PRINT ""
2597   PRINT "`eval _echo "$COMMON_INFO"`"
2598   PRINT ""
2599
2600   if [ "$NO_CONFIRM" = false ]; then
2601     read -p "Do you want to continue (Y/n)?"
2602     [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" != "y" ] && exit
2603   fi
2604
2605   if [ ! $SUDO ]; then
2606     WARNING "--no-sudo enabled, impossible to run apt-get update, you'll have to do it yourself..."
2607   else
2608     $SUDO apt-get update
2609   fi
2610
2611   # These libs should always be available in debian/ubuntu official repository...
2612   VORBIS_DEV="libvorbis-dev"
2613   OGG_DEV="libogg-dev"
2614   THEORA_DEV="libtheora-dev"
2615
2616   _packages="gawk cmake cmake-curses-gui build-essential libjpeg-dev libpng-dev libtiff-dev \
2617              git libfreetype6-dev libx11-dev flex bison libtbb-dev libxxf86vm-dev \
2618              libxcursor-dev libxi-dev wget libsqlite3-dev libxrandr-dev libxinerama-dev \
2619              libbz2-dev libncurses5-dev libssl-dev liblzma-dev libreadline-dev \
2620              libopenal-dev libglew-dev yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV \
2621              libsdl1.2-dev libfftw3-dev patch bzip2 libxml2-dev libtinyxml-dev libjemalloc-dev"
2622              # libglewmx-dev  (broken in deb testing currently...)
2623
2624   VORBIS_USE=true
2625   OGG_USE=true
2626   THEORA_USE=true
2627
2628   PRINT ""
2629   # New Ubuntu crap (17.04 and more) have no openjpeg lib!
2630   OPENJPEG_DEV="libopenjpeg-dev"
2631   check_package_DEB $OPENJPEG_DEV
2632   if [ $? -eq 0 ]; then
2633     _packages="$_packages $OPENJPEG_DEV"
2634     OPENJPEG_USE=true
2635   fi
2636
2637   PRINT ""
2638   # Some not-so-old distro (ubuntu 12.4) do not have it, do not fail in this case, just warn.
2639   YAMLCPP_DEV="libyaml-cpp-dev"
2640   check_package_DEB $YAMLCPP_DEV
2641   if [ $? -eq 0 ]; then
2642     _packages="$_packages $YAMLCPP_DEV"
2643   else
2644     PRINT ""
2645     WARNING "libyaml-cpp-dev not found, you may have to install it by hand to get Blender compiling..."
2646     PRINT ""
2647   fi
2648
2649   if [ "$WITH_JACK" = true ]; then
2650     _packages="$_packages libspnav-dev"
2651     # Only install jack if jack2 is not already installed!
2652     JACK="libjack-dev"
2653     JACK2="libjack-jackd2-dev"
2654     check_package_installed_DEB $JACK2
2655     if [ $? -eq 0 ]; then
2656       _packages="$_packages $JACK2"
2657     else
2658       _packages="$_packages $JACK"
2659     fi
2660   fi
2661
2662   PRINT ""
2663   install_packages_DEB $_packages
2664
2665   PRINT""
2666   LIBSNDFILE_DEV="libsndfile1-dev"
2667   check_package_DEB $LIBSNDFILE_DEV
2668   if [ $? -eq 0 ]; then
2669     install_packages_DEB $LIBSNDFILE_DEV
2670   fi
2671
2672   PRINT ""
2673   X264_DEV="libx264-dev"
2674   check_package_version_ge_DEB $X264_DEV $X264_VERSION_MIN
2675   if [ $? -eq 0 ]; then
2676     install_packages_DEB $X264_DEV
2677     X264_USE=true
2678   fi
2679
2680   if [ "$WITH_ALL" = true ]; then
2681     PRINT ""
2682     XVID_DEV="libxvidcore-dev"
2683     check_package_DEB $XVID_DEV
2684     if [ $? -eq 0 ]; then
2685       install_packages_DEB $XVID_DEV
2686       XVID_USE=true
2687     fi
2688
2689     PRINT ""
2690     MP3LAME_DEV="libmp3lame-dev"
2691     check_package_DEB $MP3LAME_DEV
2692     if [ $? -eq 0 ]; then
2693       install_packages_DEB $MP3LAME_DEV
2694       MP3LAME_USE=true
2695     fi
2696
2697     PRINT ""
2698     VPX_DEV="libvpx-dev"
2699     check_package_version_ge_DEB $VPX_DEV $VPX_VERSION_MIN
2700     if [ $? -eq 0 ]; then
2701       install_packages_DEB $VPX_DEV
2702       VPX_USE=true
2703     fi
2704   fi
2705
2706   # Check cmake/glew versions and disable features for older distros.
2707   # This is so Blender can at least compile.
2708   PRINT ""
2709   _cmake=`get_package_version_DEB cmake`
2710   version_ge $_cmake "2.8.10"
2711   if [ $? -eq 1 ]; then
2712     version_ge $_cmake "2.8.8"
2713     if [ $? -eq 1 ]; then
2714       WARNING "OpenVDB and OpenCOLLADA disabled because cmake-$_cmake is not enough"
2715       OPENVDB_SKIP=true
2716       OPENCOLLADA_SKIP=true
2717     else
2718       WARNING "OpenVDB disabled because cmake-$_cmake is not enough"
2719       OPENVDB_SKIP=true
2720     fi
2721   fi
2722
2723   PRINT ""
2724   _glew=`get_package_version_DEB libglew-dev`
2725   if [ -z $_glew ]; then
2726     # Stupid virtual package in Ubuntu 12.04 doesn't show version number...
2727     _glew=`apt-cache showpkg libglew-dev|tail -n1|awk '{print $2}'|sed 's/-.*//'`
2728   fi
2729   version_ge $_glew "1.9.0"
2730   if [ $? -eq 1 ]; then
2731     version_ge $_glew "1.7.0"
2732     if [ $? -eq 1 ]; then
2733       WARNING "OpenSubdiv disabled because GLEW-$_glew is not enough"
2734       WARNING "Blender will not use system GLEW library"
2735       OSD_SKIP=true
2736       NO_SYSTEM_GLEW=true
2737     else
2738       WARNING "OpenSubdiv will compile with GLEW-$_glew but with limited capability"
2739       WARNING "Blender will not use system GLEW library"
2740       NO_SYSTEM_GLEW=true
2741     fi
2742   fi
2743
2744
2745   PRINT ""
2746   _do_compile_python=false
2747   if [ "$PYTHON_SKIP" = true ]; then
2748     WARNING "Skipping Python/NumPy installation, as requested..."
2749   elif [ "$PYTHON_FORCE_BUILD" = true ]; then
2750     INFO "Forced Python/NumPy building, as requested..."
2751     _do_compile_python=true
2752   else
2753     check_package_DEB python$PYTHON_VERSION_MIN-dev
2754     if [ $? -eq 0 ]; then
2755       install_packages_DEB python$PYTHON_VERSION_MIN-dev
2756       clean_Python
2757       PRINT ""
2758       if [ "$NUMPY_SKIP" = true ]; then
2759         WARNING "Skipping NumPy installation, as requested..."
2760       else
2761         check_package_DEB python3-numpy
2762         if [ $? -eq 0 ]; then
2763           install_packages_DEB python3-numpy
2764         else
2765           WARNING "Sorry, using python package but no valid numpy package available!" \
2766                   "    Use --build-numpy to force building of both Python and NumPy."
2767         fi
2768       fi
2769     else
2770       _do_compile_python=true
2771     fi
2772   fi
2773
2774   if $_do_compile_python; then
2775     install_packages_DEB libffi-dev
2776     compile_Python
2777     PRINT ""
2778     if [ "$NUMPY_SKIP" = true ]; then
2779       WARNING "Skipping NumPy installation, as requested..."
2780     else
2781       compile_Numpy
2782     fi
2783   fi
2784
2785
2786   PRINT ""
2787   if [ "$BOOST_SKIP" = true ]; then
2788     WARNING "Skipping Boost installation, as requested..."
2789   elif [ "$BOOST_FORCE_BUILD" = true ]; then
2790     INFO "Forced Boost building, as requested..."
2791     compile_Boost
2792   else
2793     check_package_version_ge_DEB libboost-dev $BOOST_VERSION_MIN
2794     if [ $? -eq 0 ]; then
2795       install_packages_DEB libboost-dev
2796
2797       boost_version=$(echo `get_package_version_DEB libboost-dev` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
2798
2799       install_packages_DEB libboost-{filesystem,iostreams,locale,regex,system,thread,wave,program-options}$boost_version-dev
2800       clean_Boost
2801     else
2802       compile_Boost
2803     fi
2804   fi
2805
2806
2807   PRINT ""
2808   if [ "$OCIO_SKIP" = true ]; then
2809     WARNING "Skipping OpenColorIO installation, as requested..."
2810   elif [ "$OCIO_FORCE_BUILD" = true ]; then
2811     INFO "Forced OpenColorIO building, as requested..."
2812     compile_OCIO
2813   else
2814     # XXX Always force build of own OCIO, until linux distro guys update their package to default libyaml-cpp ver (0.5)!
2815     #check_package_version_ge_DEB libopencolorio-dev $OCIO_VERSION_MIN
2816     #if [ $? -eq 0 ]; then
2817       #install_packages_DEB libopencolorio-dev
2818       #clean_OCIO
2819     #else
2820       compile_OCIO
2821     #fi
2822   fi
2823
2824
2825   PRINT ""
2826   if [ "$OPENEXR_SKIP" = true ]; then
2827     WARNING "Skipping ILMBase/OpenEXR installation, as requested..."
2828   elif [ "$OPENEXR_FORCE_BUILD" = true ]; then
2829     INFO "Forced ILMBase/OpenEXR building, as requested..."
2830     compile_OPENEXR
2831   else
2832     check_package_version_ge_DEB libopenexr-dev $OPENEXR_VERSION_MIN
2833     if [ $? -eq 0 ]; then
2834       install_packages_DEB libopenexr-dev
2835       OPENEXR_VERSION=`get_package_version_DEB libopenexr-dev`
2836       ILMBASE_VERSION=$OPENEXR_VERSION
2837       clean_OPENEXR
2838     else
2839       compile_OPENEXR
2840     fi
2841   fi
2842
2843
2844   PRINT ""
2845   if [ "$OIIO_SKIP" = true ]; then
2846     WARNING "Skipping OpenImageIO installation, as requested..."
2847   elif [ "$OIIO_FORCE_BUILD" = true ]; then
2848     INFO "Forced OpenImageIO building, as requested..."
2849     compile_OIIO
2850   else
2851     # XXX Debian Testing / Ubuntu 16.04 pulls in WAY too many deps (gtk2/opencv ?!) incl. OCIO build against libyaml-cpp0.3 so build for now...
2852     #check_package_version_ge_lt_DEB libopenimageio-dev $OIIO_VERSION_MIN $OIIO_VERSION_MAX
2853     #if [ $? -eq 0 -a "$_with_built_openexr" = false ]; then
2854     #  install_packages_DEB libopenimageio-dev
2855     #  clean_OIIO
2856     #else
2857       compile_OIIO
2858     #fi
2859   fi
2860
2861
2862   PRINT ""
2863   have_llvm=false
2864   _do_compile_llvm=false
2865   if [ "$LLVM_SKIP" = true ]; then
2866     WARNING "Skipping LLVM installation, as requested (this also implies skipping OSL!)..."
2867     OSL_SKIP=true
2868   elif [ "$LLVM_FORCE_BUILD" = true ]; then
2869     INFO "Forced LLVM building, as requested..."
2870     _do_compile_llvm=true
2871   else
2872     check_package_DEB clang-$LLVM_VERSION_MIN
2873     if [ $? -eq 0 ]; then
2874       install_packages_DEB llvm-$LLVM_VERSION_MIN-dev clang-$LLVM_VERSION_MIN
2875       have_llvm=true
2876       LLVM_VERSION_FOUND=$LLVM_VERSION_MIN
2877       clean_LLVM
2878     else
2879       _do_compile_llvm=true
2880     fi
2881   fi
2882
2883   if [ "$_do_compile_llvm" = true ]; then
2884     install_packages_DEB libffi-dev
2885     # LLVM can't find the debian ffi header dir
2886     _FFI_INCLUDE_DIR=`dpkg -L libffi-dev | grep -e ".*/ffi.h" | sed -r 's/(.*)\/ffi.h/\1/'`
2887     PRINT ""
2888     compile_LLVM
2889     have_llvm=true
2890     LLVM_VERSION_FOUND=$LLVM_VERSION
2891   fi
2892
2893
2894   PRINT ""
2895   _do_compile_osl=false
2896   if [ "$OSL_SKIP" = true ]; then
2897     WARNING "Skipping OpenShadingLanguage installation, as requested..."
2898   elif [ "$OSL_FORCE_BUILD" = true ]; then
2899     INFO "Forced OpenShadingLanguage building, as requested..."
2900     _do_compile_osl=true
2901   else
2902     # No package currently!
2903     _do_compile_osl=true
2904   fi
2905
2906   if [ "$_do_compile_osl" = true ]; then
2907     if [ "$have_llvm" = true ]; then
2908       PRINT ""
2909       compile_OSL
2910     else
2911       WARNING "No LLVM available, cannot build OSL!"
2912     fi
2913   fi
2914
2915
2916   PRINT ""
2917   if [ "$OSD_SKIP" = true ]; then
2918     WARNING "Skipping OpenSubdiv installation, as requested..."
2919   elif [ "$OSD_FORCE_BUILD" = true ]; then
2920     INFO "Forced OpenSubdiv building, as requested..."
2921     compile_OSD
2922   else
2923     # No package currently!
2924     PRINT ""
2925     compile_OSD
2926   fi
2927
2928   PRINT ""
2929   if [ "$OPENVDB_SKIP" = true ]; then
2930     WARNING "Skipping OpenVDB installation, as requested..."
2931   elif [ "$OPENVDB_FORCE_BUILD" = true ]; then
2932     INFO "Forced OpenVDB building, as requested..."
2933     compile_OPENVDB
2934   else
2935     check_package_version_ge_DEB libopenvdb-dev $OPENVDB_VERSION_MIN
2936     if [ $? -eq 0 ]; then
2937       install_packages_DEB libopenvdb-dev libblosc-dev
2938       clean_OPENVDB
2939     else
2940       compile_OPENVDB
2941     fi
2942   fi
2943
2944   PRINT ""
2945   if [ "$ALEMBIC_SKIP" = true ]; then
2946     WARNING "Skipping Alembic installation, as requested..."
2947   elif [ "$ALEMBIC_FORCE_BUILD" = true ]; then
2948     INFO "Forced Alembic building, as requested..."
2949     compile_ALEMBIC
2950   else
2951     # No package currently, only HDF5!
2952     compile_ALEMBIC
2953   fi
2954
2955
2956   if [ "$WITH_OPENCOLLADA" = true ]; then
2957     _do_compile_collada=false
2958     PRINT ""
2959     if [ "$OPENCOLLADA_SKIP" = true ]; then
2960       WARNING "Skipping OpenCOLLADA installation, as requested..."
2961     elif [ "$OPENCOLLADA_FORCE_BUILD" = true ]; then
2962       INFO "Forced OpenCollada building, as requested..."
2963       _do_compile_collada=true
2964     else
2965       # No package currently!
2966       _do_compile_collada=true
2967     fi
2968
2969     if [ "$_do_compile_collada" = true ]; then
2970       install_packages_DEB libpcre3-dev
2971       # Find path to libxml shared lib...
2972       _XML2_LIB=`dpkg -L libxml2-dev | grep -e ".*/libxml2.so"`
2973       # No package
2974       PRINT ""
2975       compile_OpenCOLLADA
2976     fi
2977   fi
2978
2979
2980   PRINT ""
2981   if [ "$FFMPEG_SKIP" = true ]; then
2982     WARNING "Skipping FFMpeg installation, as requested..."
2983   elif [ "$FFMPEG_FORCE_BUILD" = true ]; then
2984     INFO "Forced FFMpeg building, as requested..."
2985     compile_FFmpeg
2986   else
2987     # XXX Debian Testing / Ubuntu 16.04 finally includes FFmpeg, so check as usual
2988     check_package_DEB ffmpeg
2989     if [ $? -eq 0 ]; then
2990       check_package_version_ge_DEB ffmpeg $FFMPEG_VERSION_MIN
2991       if [ $? -eq 0 ]; then
2992         install_packages_DEB libavdevice-dev
2993         clean_FFmpeg
2994       else
2995         compile_FFmpeg
2996       fi
2997     else
2998       compile_FFmpeg
2999     fi
3000   fi
3001 }
3002
3003
3004 #### Install on RPM-like ####
3005 rpm_flavour() {
3006   if [ -f /etc/redhat-release ]; then
3007     if [ "`grep '[6-7]\.' /etc/redhat-release`" ]; then
3008       RPM="RHEL"
3009     else
3010       RPM="FEDORA"
3011     fi
3012   elif [ -f /etc/SuSE-release ]; then
3013     RPM="SUSE"
3014   fi
3015 }
3016
3017 get_package_version_RPM() {
3018   rpm_flavour
3019   if [ "$RPM" = "RHEL" ]; then
3020     yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'
3021   elif [ "$RPM" = "FEDORA" ]; then
3022     dnf info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'
3023   elif [ "$RPM" = "SUSE" ]; then
3024     zypper info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'
3025   fi
3026 }
3027
3028 check_package_RPM() {
3029   rpm_flavour
3030   if [ "$RPM" = "RHEL" ]; then
3031     r=`yum info $1 | grep -c 'Summary'`
3032   elif [ "$RPM" = "FEDORA" ]; then
3033     r=`dnf info $1 | grep -c 'Summary'`
3034   elif [ "$RPM" = "SUSE" ]; then
3035     r=`zypper info $1 | grep -c 'Summary'`
3036   fi
3037
3038   if [ $r -ge 1 ]; then
3039     return 0
3040   else
3041     return 1
3042   fi
3043 }
3044
3045 check_package_version_match_RPM() {
3046   v=`get_package_version_RPM $1`
3047
3048   if [ -z "$v" ]; then
3049     return 1
3050   fi
3051
3052   version_match $v $2
3053   return $?
3054 }
3055
3056 check_package_version_ge_RPM() {
3057   v=`get_package_version_RPM $1`
3058
3059   if [ -z "$v" ]; then
3060     return 1
3061   fi
3062
3063   version_ge $v $2
3064   return $?
3065 }
3066
3067 check_package_version_ge_lt_RPM() {
3068   v=`get_package_version_RPM $1`
3069
3070   if [ -z "$v" ]; then
3071     return 1
3072   fi
3073
3074   version_ge_lt $v $2 $3
3075   return $?
3076 }
3077
3078 install_packages_RPM() {
3079   rpm_flavour
3080   if [ ! $SUDO ]; then
3081     WARNING "--no-sudo enabled, impossible to install $@, you'll have to do it yourself..."
3082   fi
3083   if [ "$RPM" = "RHEL" ]; then
3084     $SUDO yum install -y $@
3085     if [ $? -ge 1 ]; then
3086       ERROR "yum failed to install requested packages, exiting."
3087       exit 1
3088     fi
3089
3090   elif [ "$RPM" = "FEDORA" ]; then
3091     $SUDO dnf install -y $@
3092     if [ $? -ge 1 ]; then
3093       ERROR "dnf failed to install requested packages, exiting."
3094       exit 1
3095     fi
3096
3097   elif [ "$RPM" = "SUSE" ]; then
3098     $SUDO zypper --non-interactive install --auto-agree-with-licenses $@
3099     if [ $? -ge 1 ]; then
3100       ERROR "zypper failed to install requested packages, exiting."
3101       exit 1
3102     fi
3103   fi
3104 }
3105
3106 install_RPM() {
3107   PRINT ""
3108   INFO "Installing dependencies for RPM-based distribution"
3109   PRINT ""
3110   PRINT "`eval _echo "$COMMON_INFO"`"
3111   PRINT ""
3112
3113   if [ "$NO_CONFIRM" = false ]; then
3114     read -p "Do you want to continue (Y/n)?"
3115     [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" != "y" ] && exit
3116   fi
3117
3118   # Enable non-free repositories for all flavours
3119   if [ ! $SUDO ]; then
3120     WARNING "--no-sudo enabled, impossible to install third party repositories, you'll have to do it yourself..."
3121   else
3122     rpm_flavour
3123     if [ "$RPM" = "FEDORA" ]; then
3124       _fedora_rel="`egrep "[0-9]{1,}" /etc/fedora-release -o`"
3125       $SUDO dnf -y install --nogpgcheck \
3126       http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$_fedora_rel.noarch.rpm \
3127       http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$_fedora_rel.noarch.rpm
3128
3129       $SUDO dnf -y update
3130
3131     elif [ "$RPM" = "RHEL" ]; then
3132       if [ "`grep '6\.' /etc/redhat-release`" ]; then
3133         ERROR "Building with GCC 4.4 is not supported!"
3134         exit 1
3135       else
3136         $SUDO yum -y install --nogpgcheck \
3137         http://download.fedoraproject.org/pub/epel/7/$(uname -i)/e/epel-release-7-6.noarch.rpm \
3138         http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
3139
3140         $SUDO yum -y update
3141       fi
3142
3143     elif [ "$RPM" = "SUSE" ]; then
3144       # Packman repo now includes name in link...
3145       _suse_rel="`grep -w VERSION /etc/os-release | sed 's/[^0-9.]*//g'`"
3146       _suse_name="`grep -w NAME /etc/os-release | gawk '{print $2}' | sed 's/\"//'`"
3147       if [ $_suse_name ]; then
3148         _suse_rel="${_suse_name}_${_suse_rel}"
3149       fi
3150
3151       PRINT ""
3152       INFO "About to add 'packman' repository from http://packman.inode.at/suse/openSUSE_$_suse_rel/"
3153       INFO "This is only needed if you do not already have a packman repository enabled..."
3154       read -p "Do you want to add this repo (Y/n)?"
3155       if [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" == "y" ]; then
3156         INFO "    Installing packman..."
3157         $SUDO zypper ar -f -n packman http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_$_suse_rel/ packman
3158         INFO "    Done."
3159       else
3160         INFO "    Skipping packman installation."
3161       fi
3162       $SUDO zypper --non-interactive --gpg-auto-import-keys update --auto-agree-with-licenses
3163     fi
3164   fi
3165
3166   # These libs should always be available in fedora/suse official repository...
3167   OPENJPEG_DEV="openjpeg-devel"
3168   VORBIS_DEV="libvorbis-devel"
3169   OGG_DEV="libogg-devel"
3170   THEORA_DEV="libtheora-devel"
3171
3172   _packages="gcc gcc-c++ git make cmake tar bzip2 xz findutils flex bison \
3173              libtiff-devel libjpeg-devel libpng-devel sqlite-devel fftw-devel SDL-devel \
3174              libX11-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel \
3175              wget ncurses-devel readline-devel $OPENJPEG_DEV openal-soft-devel \
3176              glew-devel yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV patch \
3177              libxml2-devel yaml-cpp-devel tinyxml-devel jemalloc-devel"
3178
3179   OPENJPEG_USE=true
3180   VORBIS_USE=true
3181   OGG_USE=true
3182   THEORA_USE=true
3183
3184   if [ "$RPM" = "FEDORA" -o "$RPM" = "RHEL" ]; then
3185     _packages="$_packages freetype-devel tbb-devel"
3186
3187     if [ "$WITH_JACK" = true ]; then
3188       _packages="$_packages jack-audio-connection-kit-devel"
3189     fi
3190
3191     PRINT ""
3192     install_packages_RPM $_packages
3193
3194     PRINT ""
3195     X264_DEV="x264-devel"
3196     check_package_version_ge_RPM $X264_DEV $X264_VERSION_MIN
3197     if [ $? -eq 0 ]; then
3198       install_packages_RPM $X264_DEV
3199       X264_USE=true
3200     fi
3201
3202     if [ "$WITH_ALL" = true ]; then
3203       PRINT ""
3204       XVID_DEV="xvidcore-devel"
3205       check_package_RPM $XVID_DEV
3206       if [ $? -eq 0 ]; then
3207         install_packages_RPM $XVID_DEV
3208         XVID_USE=true
3209       fi
3210
3211       PRINT ""
3212       MP3LAME_DEV="lame-devel"
3213       check_package_RPM $MP3LAME_DEV
3214       if [ $? -eq 0 ]; then
3215         install_packages_RPM $MP3LAME_DEV
3216         MP3LAME_USE=true
3217       fi
3218     fi
3219
3220   elif [ "$RPM" = "SUSE" ]; then
3221     _packages="$_packages freetype2-devel"
3222
3223     PRINT ""
3224     install_packages_RPM $_packages
3225
3226     PRINT ""
3227     # Install TBB on openSUSE, from temporary repo
3228     check_package_RPM tbb-devel
3229     if [ $? -eq 0 ]; then
3230       install_packages_RPM tbb-devel
3231     else
3232       $SUDO zypper ar -f http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_$_suse_rel/devel:libraries:c_c++.repo
3233       $SUDO zypper -n --gpg-auto-import-keys install tbb-devel
3234       $SUDO zypper rr devel_libraries_c_c++
3235     fi
3236
3237     PRINT ""
3238     X264_DEV="libx264-devel"
3239     check_package_version_ge_RPM $X264_DEV $X264_VERSION_MIN
3240     if [ $? -eq 0 ]; then
3241       install_packages_RPM $X264_DEV
3242       X264_USE=true
3243     fi
3244
3245     if [ "$WITH_ALL" = true ]; then
3246       PRINT ""
3247       XVID_DEV="libxvidcore-devel"
3248       check_package_RPM $XVID_DEV
3249       if [ $? -eq 0 ]; then
3250         install_packages_RPM $XVID_DEV
3251         XVID_USE=true
3252       fi
3253
3254       PRINT ""
3255       MP3LAME_DEV="libmp3lame-devel"
3256       check_package_RPM $MP3LAME_DEV
3257       if [ $? -eq 0 ]; then
3258         install_packages_RPM $MP3LAME_DEV
3259         MP3LAME_USE=true
3260       fi
3261     fi
3262   fi
3263
3264   PRINT""
3265   LIBSNDFILE_DEV="libsndfile-devel"
3266   check_package_RPM $LIBSNDFILE_DEV
3267   if [ $? -eq 0 ]; then
3268     install_packages_RPM $LIBSNDFILE_DEV
3269   fi
3270
3271   if [ "$WITH_ALL" = true ]; then
3272     PRINT ""
3273     VPX_DEV="libvpx-devel"
3274     check_package_version_ge_RPM $VPX_DEV $VPX_VERSION_MIN
3275     if [ $? -eq 0 ]; then
3276       install_packages_RPM $VPX_DEV
3277       VPX_USE=true
3278     fi
3279     PRINT ""
3280     install_packages_RPM libspnav-devel
3281   fi
3282
3283
3284   PRINT ""
3285   _do_compile_python=false
3286   if [ "$PYTHON_SKIP" = true ]; then
3287     WARNING "Skipping Python installation, as requested..."
3288   elif [ "$PYTHON_FORCE_BUILD" = true ]; then
3289     INFO "Forced Python/NumPy building, as requested..."
3290     _do_compile_python=true
3291   else
3292     check_package_version_match_RPM python3-devel $PYTHON_VERSION_MIN
3293     if [ $? -eq 0 ]; then
3294       install_packages_RPM python3-devel
3295       clean_Python
3296       PRINT ""
3297       if [ "$NUMPY_SKIP" = true ]; then
3298         WARNING "Skipping NumPy installation, as requested..."
3299       else
3300         check_package_version_ge_RPM python3-numpy $NUMPY_VERSION_MIN
3301         if [ $? -eq 0 ]; then
3302           install_packages_RPM python3-numpy
3303         else
3304           WARNING "Sorry, using python package but no valid numpy package available!" \
3305                   "    Use --build-numpy to force building of both Python and NumPy."
3306         fi
3307       fi
3308     else
3309       _do_compile_python=true
3310     fi
3311   fi
3312
3313   if [ "$_do_compile_python" = true ]; then
3314     install_packages_RPM libffi-devel
3315     compile_Python
3316     PRINT ""
3317     if [ "$NUMPY_SKIP" = true ]; then
3318       WARNING "Skipping NumPy installation, as requested..."
3319     else
3320       compile_Numpy
3321     fi
3322   fi
3323
3324
3325   PRINT ""
3326   _do_compile_boost=false
3327   if [ "$BOOST_SKIP" = true ]; then
3328     WARNING "Skipping Boost installation, as requested..."
3329   elif [ "$BOOST_FORCE_BUILD" = true ]; then
3330     INFO "Forced Boost building, as requested..."
3331     _do_compile_boost=true
3332   else
3333     check_package_version_ge_RPM boost-devel $BOOST_VERSION_MIN
3334     if [ $? -eq 0 ]; then
3335       install_packages_RPM boost-devel
3336       clean_Boost
3337     else
3338       _do_compile_boost=true
3339     fi
3340   fi
3341
3342   if [ "$_do_compile_boost" = true ]; then
3343     if [ "$RPM" = "SUSE" ]; then
3344       install_packages_RPM gcc-fortran
3345     else
3346       install_packages_RPM libquadmath-devel bzip2-devel
3347     fi
3348     PRINT ""
3349     compile_Boost
3350   fi
3351
3352
3353   PRINT ""
3354   if [ "$OCIO_SKIP" = true ]; then
3355     WARNING "Skipping OpenColorIO installation, as requested..."
3356   elif [ "$OCIO_FORCE_BUILD" = true ]; then
3357     INFO "Forced OpenColorIO building, as requested..."
3358     compile_OCIO
3359   else
3360     if [ "$RPM" = "SUSE" ]; then
3361       check_package_version_ge_RPM OpenColorIO-devel $OCIO_VERSION_MIN
3362       if [ $? -eq 0 ]; then
3363         install_packages_RPM OpenColorIO-devel
3364         clean_OCIO
3365       else
3366         compile_OCIO
3367       fi
3368     # XXX Fedora/RHEL OCIO still depends on libyaml-cpp v0.3 even when system default is v0.5!
3369     else
3370       compile_OCIO
3371     fi
3372   fi
3373
3374   PRINT ""
3375   if [ "$OPENEXR_SKIP" = true ]; then
3376     WARNING "Skipping ILMBase/OpenEXR installation, as requested..."
3377   elif [ "$OPENEXR_FORCE_BUILD" = true ]; then
3378     INFO "Forced ILMBase/OpenEXR building, as requested..."
3379     compile_OPENEXR
3380   else
3381     check_package_version_ge_RPM openexr-devel $OPENEXR_VERSION_MIN
3382     if [ $? -eq 0 ]; then
3383       install_packages_RPM openexr-devel
3384       OPENEXR_VERSION=`get_package_version_RPM openexr-devel`
3385       ILMBASE_VERSION=$OPENEXR_VERSION
3386       clean_OPENEXR
3387     else
3388       compile_OPENEXR
3389     fi
3390   fi
3391
3392   PRINT ""
3393   if [ "$OIIO_SKIP" = true ]; then
3394     WARNING "Skipping OpenImageIO installation, as requested..."
3395   elif [ "$OIIO_FORCE_BUILD" = true ]; then
3396     INFO "Forced OpenImageIO building, as requested..."
3397     compile_OIIO
3398   else
3399     # XXX RPM distros pulls in too much and depends on old libs, so better to build for now...
3400     #check_package_version_ge_lt_RPM OpenImageIO-devel $OIIO_VERSION_MIN $OIIO_VERSION_MAX
3401     #if [ $? -eq 0 -a $_with_built_openexr == false ]; then
3402     #  install_packages_RPM OpenImageIO-devel
3403     #  clean_OIIO
3404     #else
3405       compile_OIIO
3406     #fi
3407   fi
3408
3409
3410   PRINT ""
3411   have_llvm=false
3412   _do_compile_llvm=false
3413   if [ "$LLVM_SKIP" = true ]; then
3414     WARNING "Skipping LLVM installation, as requested (this also implies skipping OSL!)..."
3415     OSL_SKIP=true
3416   elif [ "$LLVM_FORCE_BUILD" = true ]; then
3417     INFO "Forced LLVM building, as requested..."
3418     _do_compile_llvm=true
3419   else
3420     if [ "$RPM" = "SUSE" ]; then
3421       CLANG_DEV="llvm-clang-devel"
3422     else
3423       CLANG_DEV="clang-devel"
3424     fi
3425     # XXX RHEL has 3.4 in repo but OSL complains about not finding MCJIT_LIBRARY, so compile for now...
3426     #check_package_version_match_RPM $CLANG_DEV $LLVM_VERSION
3427     #if [ $? -eq 0 ]; then
3428     #  install_packages_RPM llvm-devel $CLANG_DEV
3429     #  have_llvm=true
3430     #  LLVM_VERSION_FOUND=$LLVM_VERSION
3431     #  clean_LLVM
3432     #else
3433       _do_compile_llvm=true
3434     #fi
3435   fi
3436
3437   if [ "$_do_compile_llvm" = true ]; then
3438     install_packages_RPM libffi-devel
3439     # LLVM can't find the fedora ffi header dir...
3440     _FFI_INCLUDE_DIR=`rpm -ql libffi-devel | grep -e ".*/ffi.h" | sed -r 's/(.*)\/ffi.h/\1/'`
3441     PRINT ""
3442     compile_LLVM
3443     have_llvm=true
3444     LLVM_VERSION_FOUND=$LLVM_VERSION
3445   fi
3446
3447
3448   PRINT ""
3449   _do_compile_osl=false
3450   if [ "$OSL_SKIP" = true ]; then
3451     WARNING "Skipping OpenShadingLanguage installation, as requested..."
3452   elif [ "$OSL_FORCE_BUILD" = true ]; then
3453     INFO "Forced OpenShadingLanguage building, as requested..."
3454     _do_compile_osl=true
3455   else
3456     # No package currently!
3457     _do_compile_osl=true
3458   fi
3459
3460   if [ "$_do_compile_osl" = true ]; then
3461     if [ "$have_llvm" = true ]; then
3462       PRINT ""
3463       compile_OSL
3464     else
3465       WARNING "No LLVM available, cannot build OSL!"
3466     fi
3467   fi
3468
3469
3470   PRINT ""
3471   if [ "$OSD_SKIP" = true ]; then
3472     WARNING "Skipping OpenSubdiv installation, as requested..."
3473   elif [ "$OSD_FORCE_BUILD" = true ]; then
3474     INFO "Forced OpenSubdiv building, as requested..."
3475     compile_OSD
3476   else
3477     # No package currently!
3478     compile_OSD
3479   fi
3480
3481
3482   PRINT ""
3483   if [ "$OPENVDB_SKIP" = true ]; then
3484     WARNING "Skipping OpenVDB installation, as requested..."
3485   elif [ "$OPENVDB_FORCE_BUILD" = true ]; then
3486     INFO "Forced OpenVDB building, as requested..."
3487     compile_OPENVDB
3488   else
3489     # No package currently!
3490     compile_OPENVDB
3491   fi
3492
3493   PRINT ""
3494   if [ "$ALEMBIC_SKIP" = true ]; then
3495     WARNING "Skipping Alembic installation, as requested..."
3496   elif [ "$ALEMBIC_FORCE_BUILD" = true ]; then
3497     INFO "Forced Alembic building, as requested..."
3498     compile_ALEMBIC
3499   else
3500     # No package currently!
3501     compile_ALEMBIC
3502   fi
3503
3504
3505   if [ "$WITH_OPENCOLLADA" = true ]; then
3506     PRINT ""
3507     _do_compile_collada=false
3508     if [ "$OPENCOLLADA_SKIP" = true ]; then
3509       WARNING "Skipping OpenCOLLADA installation, as requested..."
3510     elif [ "$OPENCOLLADA_FORCE_BUILD" = true ]; then
3511       INFO "Forced OpenCollada building, as requested..."
3512       _do_compile_collada=true
3513     else
3514       # No package...
3515       _do_compile_collada=true
3516     fi
3517
3518     if [ "$_do_compile_collada" = true ]; then
3519       install_packages_RPM pcre-devel
3520       # Find path to libxml shared lib...
3521       _XML2_LIB=`rpm -ql libxml2-devel | grep -e ".*/libxml2.so"`
3522       PRINT ""
3523       compile_OpenCOLLADA
3524     fi
3525   fi
3526
3527
3528   PRINT ""
3529   if [ "$FFMPEG_SKIP" = true ]; then
3530     WARNING "Skipping FFMpeg installation, as requested..."
3531   elif [ "$FFMPEG_FORCE_BUILD" = true ]; then
3532     INFO "Forced FFMpeg building, as requested..."
3533     compile_FFmpeg
3534   else
3535     check_package_version_ge_RPM ffmpeg-devel $FFMPEG_VERSION_MIN
3536     if [ $? -eq 0 ]; then
3537       install_packages_RPM ffmpeg ffmpeg-devel
3538       clean_FFmpeg
3539     else
3540       compile_FFmpeg
3541     fi
3542   fi
3543 }
3544
3545
3546 #### Install on ARCH-like ####
3547 get_package_version_ARCH() {
3548   pacman -Si $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+?(([0-9]+\.?)+).*/\1/'
3549 }
3550
3551 check_package_ARCH() {
3552   r=`pacman -Si $1 | grep -c 'Description'`
3553
3554   if [ $r -ge 1 ]; then
3555     return 0
3556   else
3557     return 1
3558   fi
3559 }
3560
3561 check_package_version_match_ARCH() {
3562   v=`get_package_version_ARCH $1`
3563
3564   if [ -z "$v" ]; then
3565     return 1
3566   fi
3567
3568   version_match $v $2
3569   return $?
3570 }
3571
3572 check_package_version_ge_ARCH() {
3573   v=`get_package_version_ARCH $1`
3574
3575   if [ -z "$v" ]; then
3576     return 1
3577   fi
3578
3579   version_ge $v $2
3580   return $?
3581 }
3582
3583 check_package_version_ge_lt_ARCH() {
3584   v=`get_package_version_ARCH $1`
3585
3586   if [ -z "$v" ]; then
3587     return 1
3588   fi
3589
3590   version_ge_lt $v $2 $3
3591   return $?
3592 }
3593
3594 install_packages_ARCH() {
3595   if [ ! $SUDO ]; then
3596     WARNING "--no-sudo enabled, impossible to run pacman for $@, you'll have to do it yourself..."
3597   else
3598     $SUDO pacman -S --needed --noconfirm $@
3599     if [ $? -ge 1 ]; then
3600       ERROR "pacman failed to install requested packages, exiting."
3601       exit 1
3602     fi
3603   fi
3604 }
3605
3606 install_ARCH() {
3607   PRINT ""
3608   INFO "Installing dependencies for ARCH-based distribution"
3609   PRINT ""
3610   PRINT "`eval _echo "$COMMON_INFO"`"
3611   PRINT ""
3612
3613   if [ "$NO_CONFIRM" = false ]; then
3614     read -p "Do you want to continue (Y/n)?"
3615     [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" != "y" ] && exit
3616   fi
3617
3618   # Check for sudo...
3619   if [ $SUDO ]; then
3620     if [ ! -x "/usr/bin/sudo" ]; then
3621       PRINT ""
3622       ERROR "This script requires sudo but it is not installed."
3623       PRINT "Please setup sudo according to:"
3624       PRINT "https://wiki.archlinux.org/index.php/Sudo"
3625       PRINT "and try again."
3626       PRINT ""
3627       exit
3628     fi
3629   fi
3630
3631   if [ ! $SUDO ]; then
3632     WARNING "--no-sudo enabled, impossible to run pacman -Sy, you'll have to do it yourself..."
3633   else
3634     $SUDO pacman -Sy
3635   fi
3636
3637   # These libs should always be available in arch official repository...
3638   OPENJPEG_DEV="openjpeg"
3639   VORBIS_DEV="libvorbis"
3640   OGG_DEV="libogg"
3641   THEORA_DEV="libtheora"
3642
3643   BASE_DEVEL="base-devel"
3644
3645   # Avoid conflicts when gcc-multilib is installed
3646   pacman -Qi gcc-multilib &>/dev/null
3647   if [ $? -eq 0 ]; then
3648     BASE_DEVEL=`pacman -Sgq base-devel | sed -e 's/^gcc$/gcc-multilib/g' | paste -s -d' '`
3649   fi
3650
3651   _packages="$BASE_DEVEL git cmake \
3652              libxi libxcursor libxrandr libxinerama glew libpng libtiff wget openal \
3653              $OPENJPEG_DEV $VORBIS_DEV $OGG_DEV $THEORA_DEV yasm sdl fftw intel-tbb \
3654              libxml2 yaml-cpp tinyxml python-requests jemalloc"
3655
3656   OPENJPEG_USE=true
3657   VORBIS_USE=true
3658   OGG_USE=true
3659   THEORA_USE=true
3660
3661   if [ "$WITH_ALL" = true ]; then
3662     _packages="$_packages libspnav"
3663   fi
3664
3665   if [ "$WITH_JACK" = true ]; then
3666     _packages="$_packages jack"
3667   fi
3668
3669   PRINT ""
3670   install_packages_ARCH $_packages
3671
3672   PRINT""
3673   LIBSNDFILE_DEV="libsndfile"
3674   check_package_ARCH $LIBSNDFILE_DEV
3675   if [ $? -eq 0 ]; then
3676     install_packages_ARCH $LIBSNDFILE_DEV
3677   fi
3678
3679   PRINT ""
3680   X264_DEV="x264"
3681   check_package_version_ge_ARCH $X264_DEV $X264_VERSION_MIN
3682   if [ $? -eq 0 ]; then
3683     install_packages_ARCH $X264_DEV
3684     X264_USE=true
3685   fi
3686
3687   if [ "$WITH_ALL" = true ]; then
3688     PRINT ""
3689     XVID_DEV="xvidcore"
3690     check_package_ARCH $XVID_DEV
3691     if [ $? -eq 0 ]; then
3692       install_packages_ARCH $XVID_DEV
3693       XVID_USE=true
3694     fi
3695
3696     PRINT ""
3697     MP3LAME_DEV="lame"
3698     check_package_ARCH $MP3LAME_DEV
3699     if [ $? -eq 0 ]; then
3700       install_packages_ARCH $MP3LAME_DEV
3701       MP3LAME_USE=true
3702     fi
3703
3704     PRINT ""
3705     VPX_DEV="libvpx"
3706     check_package_version_ge_ARCH $VPX_DEV $VPX_VERSION_MIN
3707     if [ $? -eq 0 ]; then
3708       install_packages_ARCH $VPX_DEV
3709       VPX_USE=true
3710     fi
3711   fi
3712
3713
3714   PRINT ""
3715   _do_compile_python=false
3716   if [ "$PYTHON_SKIP" = true ]; then
3717     WARNING "Skipping Python installation, as requested..."
3718   elif [ "$PYTHON_FORCE_BUILD" = true ]; then
3719     INFO "Forced Python/NumPy building, as requested..."
3720     _do_compile_python=true
3721   else
3722     check_package_version_ge_ARCH python $PYTHON_VERSION_MIN
3723     if [ $? -eq 0 ]; then
3724       install_packages_ARCH python
3725       clean_Python
3726       PRINT ""
3727       if [ "$NUMPY_SKIP" = true ]; then
3728         WARNING "Skipping NumPy installation, as requested..."
3729       else
3730         check_package_version_ge_ARCH python-numpy $NUMPY_VERSION_MIN
3731         if [ $? -eq 0 ]; then
3732           install_packages_ARCH python-numpy
3733         else
3734           WARNING "Sorry, using python package but no valid numpy package available!" \
3735                   "Use --build-numpy to force building of both Python and NumPy."
3736         fi
3737       fi
3738     else
3739       _do_compile_python=true
3740     fi
3741   fi
3742
3743   if [ "$_do_compile_python" = true ]; then
3744     install_packages_ARCH libffi
3745     compile_Python
3746     PRINT ""
3747     if [ "$NUMPY_SKIP" = true ]; then
3748       WARNING "Skipping NumPy installation, as requested..."
3749     else
3750       compile_Numpy
3751     fi
3752   fi
3753
3754
3755   PRINT ""
3756   if [ "$BOOST_SKIP" = true ]; then
3757     WARNING "Skipping Boost installation, as requested..."
3758   elif [ "$BOOST_FORCE_BUILD" = true ]; then
3759     INFO "Forced Boost building, as requested..."
3760     compile_Boost
3761   else
3762     check_package_version_ge_ARCH boost $BOOST_VERSION_MIN
3763     if [ $? -eq 0 ]; then
3764       install_packages_ARCH boost
3765       clean_Boost
3766     else
3767       compile_Boost
3768     fi
3769   fi
3770
3771
3772   PRINT ""
3773   if [ "$OCIO_SKIP" = true ]; then
3774     WARNING "Skipping OpenColorIO installation, as requested..."
3775   elif [ "$OCIO_FORCE_BUILD" = true ]; then
3776     INFO "Forced OpenColorIO building, as requested..."
3777     compile_OCIO
3778   else
3779     check_package_version_ge_ARCH opencolorio $OCIO_VERSION_MIN
3780     if [ $? -eq 0 ]; then
3781       install_packages_ARCH opencolorio
3782       clean_OCIO
3783     else
3784       compile_OCIO
3785     fi
3786   fi
3787
3788
3789   PRINT ""
3790   if [ "$OPENEXR_SKIP" = true ]; then
3791     WARNING "Skipping ILMBase/OpenEXR installation, as requested..."
3792   elif [ "$OPENEXR_FORCE_BUILD" = true ]; then
3793     INFO "Forced ILMBase/OpenEXR building, as requested..."
3794     compile_OPENEXR
3795   else
3796     check_package_version_ge_ARCH openexr $OPENEXR_VERSION_MIN
3797     if [ $? -eq 0 ]; then
3798       install_packages_ARCH openexr