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