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