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