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