~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to build_files/build_environment/install_deps.sh

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
# Parse command line!
 
23
ARGS=$( \
 
24
getopt \
 
25
-o s:i:t:h \
 
26
--long source:,install:,threads:,help,with-all,with-osl,with-opencollada,all-static,force-all,\
 
27
force-python,force-numpy,force-boost,force-ocio,force-oiio,force-llvm,force-osl,force-opencollada,\
 
28
force-ffmpeg,skip-python,skip-numpy,skip-boost,skip-ocio,skip-oiio,skip-llvm,skip-osl,skip-ffmpeg,\
 
29
skip-opencollada \
 
30
-- "$@" \
 
31
)
 
32
 
 
33
DISTRO=""
 
34
RPM=""
 
35
SRC="$HOME/src/blender-deps"
 
36
INST="/opt/lib"
 
37
CWD=$PWD
 
38
 
 
39
# Do not install some optional, potentially conflicting libs by default...
 
40
WITH_ALL=false
 
41
 
 
42
# Do not yet enable osl, use --with-osl (or --with-all) option to try it.
 
43
WITH_OSL=false
 
44
 
 
45
# Do not yet enable opencollada, use --with-opencollada (or --with-all) option to try it.
 
46
WITH_OPENCOLLADA=false
 
47
 
 
48
# Try to link everything statically. Use this to produce portable versions of blender.
 
49
ALL_STATIC=false
 
50
 
 
51
THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"`
 
52
if [ -z "$THREADS" ]; then
 
53
  THREADS=1
 
54
fi
 
55
 
 
56
COMMON_INFO="\"Source code of dependencies needed to be compiled will be downloaded and extracted into '\$SRC'.
 
57
Built libs of dependencies needed to be compiled will be installed into '\$INST'.
 
58
Please edit \\\$SRC and/or \\\$INST variables at the beginning of this script,
 
59
or use --source/--install options, if you want to use other paths!
 
60
 
 
61
Number of threads for building: \$THREADS (automatically detected, use --threads=<nbr> to override it).
 
62
Full install: \$WITH_ALL (use --with-all option to enable it).
 
63
Building OSL: \$WITH_OSL (use --with-osl option to enable it).
 
64
Building OpenCOLLADA: \$WITH_OPENCOLLADA (use --with-opencollada option to enable it).
 
65
All static linking: \$ALL_STATIC (use --all-static option to enable it).
 
66
 
 
67
Example:
 
68
Full install without OpenCOLLADA: --with-all --skip-opencollada
 
69
 
 
70
Use --help to show all available options!\""
 
71
 
 
72
ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
 
73
    -h, --help
 
74
        Show this message and exit.
 
75
 
 
76
    -s <path>, --source=<path>
 
77
        Use a specific path where to store downloaded libraries sources (defaults to '\$SRC').
 
78
 
 
79
    -i <path>, --install=<path>
 
80
        Use a specific path where to install built libraries (defaults to '\$INST').
 
81
 
 
82
    -t n, --threads=n
 
83
        Use a specific number of threads when building the libraries (auto-detected as '\$THREADS').
 
84
 
 
85
    --with-all
 
86
        By default, a number of optional and not-so-often needed libraries are not installed.
 
87
        This option will try to install them, at the cost of potential conflicts (depending on
 
88
        how your package system is set…).
 
89
        Note this option also implies all other (more specific) --with-foo options below.
 
90
 
 
91
    --with-osl
 
92
        Try to install or build the OpenShadingLanguage libraries (and their dependencies).
 
93
        Still experimental!
 
94
 
 
95
    --with-opencollada
 
96
        Build and install the OpenCOLLADA libraries.
 
97
 
 
98
    --all-static
 
99
        Build libraries as statically as possible, to create static builds of Blender.
 
100
 
 
101
    --force-all
 
102
        Force the rebuild of all built libraries.
 
103
 
 
104
    --force-python
 
105
        Force the rebuild of Python.
 
106
 
 
107
    --force-numpy
 
108
        Force the rebuild of NumPy.
 
109
 
 
110
    --force-boost
 
111
        Force the rebuild of Boost.
 
112
 
 
113
    --force-ocio
 
114
        Force the rebuild of OpenColorIO.
 
115
 
 
116
    --force-oiio
 
117
        Force the rebuild of OpenImageIO.
 
118
 
 
119
    --force-llvm
 
120
        Force the rebuild of LLVM.
 
121
 
 
122
    --force-osl
 
123
        Force the rebuild of OpenShadingLanguage.
 
124
 
 
125
    --force-opencollada
 
126
        Force the rebuild of OpenCOLLADA.
 
127
 
 
128
    --force-ffmpeg
 
129
        Force the rebuild of FFMpeg.
 
130
 
 
131
    Note about the --force-foo options:
 
132
        * They obviously only have an effect if those libraries are built by this script
 
133
          (i.e. if there is no available and satisfactory package)!
 
134
        * If the “force-rebuilt” library is a dependency of others, it will force the rebuild
 
135
          of those libraries too (e.g. --force-boost will also rebuild oiio and osl...).
 
136
        * Do not forget --with-osl if you built it and still want it!
 
137
 
 
138
    --skip-python
 
139
        Unconditionally skip Python installation/building.
 
140
 
 
141
    --skip-numpy
 
142
        Unconditionally skip NumPy installation/building.
 
143
 
 
144
    --skip-boost
 
145
        Unconditionally skip Boost installation/building.
 
146
 
 
147
    --skip-ocio
 
148
        Unconditionally skip OpenColorIO installation/building.
 
149
 
 
150
    --skip-oiio
 
151
        Unconditionally skip OpenImageIO installation/building.
 
152
 
 
153
    --skip-llvm
 
154
        Unconditionally skip LLVM installation/building.
 
155
 
 
156
    --skip-osl
 
157
        Unconditionally skip OpenShadingLanguage installation/building.
 
158
 
 
159
    --skip-opencollada
 
160
        Unconditionally skip OpenCOLLADA installation/building.
 
161
 
 
162
    --skip-ffmpeg
 
163
        Unconditionally skip FFMpeg installation/building.\""
 
164
 
 
165
PYTHON_VERSION="3.3.0"
 
166
PYTHON_VERSION_MIN="3.3"
 
167
PYTHON_SOURCE="http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.bz2"
 
168
PYTHON_FORCE_REBUILD=false
 
169
PYTHON_SKIP=false
 
170
 
 
171
#Could not get numpy-1.6.2 to compile with python-3.3
 
172
NUMPY_VERSION="1.7.0rc1"
 
173
NUMPY_VERSION_MIN="1.7"
 
174
NUMPY_SOURCE="http://sourceforge.net/projects/numpy/files/NumPy/$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz"
 
175
NUMPY_FORCE_REBUILD=false
 
176
NUMPY_SKIP=false
 
177
 
 
178
BOOST_VERSION="1.51.0"
 
179
_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
 
180
BOOST_SOURCE="http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download"
 
181
BOOST_VERSION_MIN="1.49"
 
182
BOOST_FORCE_REBUILD=false
 
183
BOOST_SKIP=false
 
184
 
 
185
OCIO_VERSION="1.0.7"
 
186
OCIO_SOURCE="https://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION"
 
187
OCIO_VERSION_MIN="1.0"
 
188
OCIO_FORCE_REBUILD=false
 
189
OCIO_SKIP=false
 
190
 
 
191
OIIO_VERSION="1.1.1"
 
192
OIIO_SOURCE="https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_VERSION"
 
193
OIIO_VERSION_MIN="1.1"
 
194
OIIO_FORCE_REBUILD=false
 
195
OIIO_SKIP=false
 
196
 
 
197
LLVM_VERSION="3.1"
 
198
LLVM_VERSION_MIN="3.0"
 
199
LLVM_VERSION_FOUND=""
 
200
LLVM_SOURCE="http://llvm.org/releases/$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.gz"
 
201
LLVM_CLANG_SOURCE="http://llvm.org/releases/$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.gz"
 
202
LLVM_FORCE_REBUILD=false
 
203
LLVM_SKIP=false
 
204
 
 
205
# OSL needs to be compiled for now!
 
206
OSL_VERSION="1.2.0"
 
207
OSL_SOURCE="https://github.com/mont29/OpenShadingLanguage/archive/blender-fixes.tar.gz"
 
208
OSL_FORCE_REBUILD=false
 
209
OSL_SKIP=false
 
210
 
 
211
# Version??
 
212
OPENCOLLADA_VERSION="1.3"
 
213
OPENCOLLADA_SOURCE="https://github.com/KhronosGroup/OpenCOLLADA.git"
 
214
OPENCOLLADA_FORCE_REBUILD=false
 
215
OPENCOLLADA_SKIP=false
 
216
 
 
217
FFMPEG_VERSION="1.0"
 
218
FFMPEG_SOURCE="http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2"
 
219
FFMPEG_VERSION_MIN="0.7.6"
 
220
FFMPEG_FORCE_REBUILD=false
 
221
FFMPEG_SKIP=false
 
222
_ffmpeg_list_sep=";"
 
223
 
 
224
# FFMPEG optional libs.
 
225
VORBIS_USE=false
 
226
VORBIS_DEV=""
 
227
SCHRO_USE=false
 
228
SCRHO_DEV=""
 
229
THEORA_USE=false
 
230
THEORA_DEV=""
 
231
XVID_USE=false
 
232
XVID_DEV=""
 
233
X264_USE=false
 
234
X264_DEV=""
 
235
X264_VERSION_MIN=0.118
 
236
VPX_USE=false
 
237
VPX_VERSION_MIN=0.9.7
 
238
VPX_DEV=""
 
239
MP3LAME_USE=false
 
240
MP3LAME_DEV=""
 
241
OPENJPEG_USE=false
 
242
OPENJPEG_DEV=""
 
243
 
 
244
# Switch to english language, else some things (like check_package_DEB()) won't work!
 
245
LANG_BACK=$LANG
 
246
LANG=""
 
247
export LANG
 
248
 
 
249
 
 
250
_echo() {
 
251
  if [ "X$1" = "X-n" ]; then
 
252
     shift; printf "%s" "$@"
 
253
  else
 
254
     printf "%s\n" "$@"
 
255
  fi
 
256
}
 
257
 
 
258
ERROR() {
 
259
  _echo "$@"
 
260
}
 
261
 
 
262
INFO() {
 
263
  _echo "$@"
 
264
}
 
265
 
 
266
# Finish parsing the commandline args.
 
267
eval set -- "$ARGS"
 
268
while true; do
 
269
  case $1 in
 
270
    -s|--source)
 
271
      SRC="$2"; shift; shift; continue
 
272
    ;;
 
273
    -i|--install)
 
274
      INST="$2"; shift; shift; continue
 
275
    ;;
 
276
    -t|--threads)
 
277
      THREADS="$2"; shift; shift; continue
 
278
    ;;
 
279
    -h|--help)
 
280
      INFO ""
 
281
      INFO "USAGE:"
 
282
      INFO ""
 
283
      INFO "`eval _echo "$COMMON_INFO"`"
 
284
      INFO ""
 
285
      INFO "`eval _echo "$ARGUMENTS_INFO"`"
 
286
      INFO ""
 
287
      exit 0
 
288
    ;;
 
289
    --with-all)
 
290
      WITH_ALL=true; shift; continue
 
291
    ;;
 
292
    --with-osl)
 
293
      WITH_OSL=true; shift; continue
 
294
    ;;
 
295
    --with-opencollada)
 
296
      WITH_OPENCOLLADA=true; shift; continue
 
297
    ;;
 
298
    --all-static)
 
299
      ALL_STATIC=true; shift; continue
 
300
    ;;
 
301
    --force-all)
 
302
      PYTHON_FORCE_REBUILD=true
 
303
      NUMPY_FORCE_REBUILD=true
 
304
      BOOST_FORCE_REBUILD=true
 
305
      OCIO_FORCE_REBUILD=true
 
306
      OIIO_FORCE_REBUILD=true
 
307
      LLVM_FORCE_REBUILD=true
 
308
      OSL_FORCE_REBUILD=true
 
309
      OPENCOLLADA_FORCE_REBUILD=true
 
310
      FFMPEG_FORCE_REBUILD=true
 
311
      shift; continue
 
312
    ;;
 
313
    --force-python)
 
314
      PYTHON_FORCE_REBUILD=true; shift; continue
 
315
    ;;
 
316
    --force-numpy)
 
317
      NUMPY_FORCE_REBUILD=true; shift; continue
 
318
    ;;
 
319
    --force-boost)
 
320
      BOOST_FORCE_REBUILD=true; shift; continue
 
321
    ;;
 
322
    --force-ocio)
 
323
      OCIO_FORCE_REBUILD=true; shift; continue
 
324
    ;;
 
325
    --force-oiio)
 
326
      OIIO_FORCE_REBUILD=true; shift; continue
 
327
    ;;
 
328
    --force-llvm)
 
329
      LLVM_FORCE_REBUILD=true; shift; continue
 
330
    ;;
 
331
    --force-osl)
 
332
      OSL_FORCE_REBUILD=true; shift; continue
 
333
    ;;
 
334
    --force-opencollada)
 
335
      OPENCOLLADA_FORCE_REBUILD=true; shift; continue
 
336
    ;;
 
337
    --force-ffmpeg)
 
338
      FFMPEG_FORCE_REBUILD=true; shift; continue
 
339
    ;;
 
340
    --skip-python)
 
341
      PYTHON_SKIP=true; shift; continue
 
342
    ;;
 
343
    --skip-numpy)
 
344
      NUMPY_SKIP=true; shift; continue
 
345
    ;;
 
346
    --skip-boost)
 
347
      BOOST_SKIP=true; shift; continue
 
348
    ;;
 
349
    --skip-ocio)
 
350
      OCIO_SKIP=true; shift; continue
 
351
    ;;
 
352
    --skip-oiio)
 
353
      OIIO_SKIP=true; shift; continue
 
354
    ;;
 
355
    --skip-llvm)
 
356
      LLVM_SKIP=true; shift; continue
 
357
    ;;
 
358
    --skip-osl)
 
359
      OSL_SKIP=true; shift; continue
 
360
    ;;
 
361
    --skip-opencollada)
 
362
      OPENCOLLADA_SKIP=true; shift; continue
 
363
    ;;
 
364
    --skip-ffmpeg)
 
365
      FFMPEG_SKIP=true; shift; continue
 
366
    ;;
 
367
    --)
 
368
      # no more arguments to parse
 
369
      break
 
370
    ;;
 
371
    *)
 
372
      INFO ""
 
373
      INFO "Wrong parameter! Usage:"
 
374
      INFO ""
 
375
      INFO "`eval _echo "$COMMON_INFO"`"
 
376
      INFO ""
 
377
      exit 1
 
378
    ;;
 
379
  esac
 
380
done
 
381
 
 
382
if $WITH_ALL; then
 
383
  WITH_OSL=true
 
384
  WITH_OPENCOLLADA=true
 
385
fi
 
386
 
 
387
# Return 0 if $1 = $2 (i.e. 1.01.0 = 1.1, but 1.1.1 != 1.1), else 1.
 
388
# $1 and $2 should be version numbers made of numbers only.
 
389
version_eq() {
 
390
  backIFS=$IFS
 
391
  IFS='.'
 
392
 
 
393
  # Split both version numbers into their numeric elements.
 
394
  arr1=( $1 )
 
395
  arr2=( $2 )
 
396
 
 
397
  ret=1
 
398
 
 
399
  count1=${#arr1[@]}
 
400
  count2=${#arr2[@]}
 
401
  if [ $count2 -ge $count1 ]; then
 
402
    _t=$count1
 
403
    count1=$count2
 
404
    count2=$_t
 
405
    arr1=( $2 )
 
406
    arr2=( $1 )
 
407
  fi
 
408
 
 
409
  ret=0
 
410
  for (( i=0; $i < $count2; i++ ))
 
411
  do
 
412
    if [ $(( 10#${arr1[$i]} )) -ne $(( 10#${arr2[$i]} )) ]; then
 
413
      ret=1
 
414
      break
 
415
    fi
 
416
  done
 
417
 
 
418
  for (( i=$count2; $i < $count1; i++ ))
 
419
  do
 
420
    if [ $(( 10#${arr1[$i]} )) -ne 0 ]; then
 
421
      ret=1
 
422
      break
 
423
    fi
 
424
  done
 
425
 
 
426
  IFS=$backIFS
 
427
  return $ret
 
428
}
 
429
 
 
430
# Return 0 if $1 >= $2, else 1.
 
431
# $1 and $2 should be version numbers made of numbers only.
 
432
version_ge() {
 
433
  version_eq $1 $2
 
434
  if [ $? -eq 1 -a $(_echo "$1" "$2" | sort --version-sort | head --lines=1) = "$1" ]; then
 
435
    return 1
 
436
  else
 
437
    return 0
 
438
  fi
 
439
}
 
440
 
 
441
# 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.
 
442
# $1 and $2 should be version numbers made of numbers only.
 
443
# $1 should be at least as long as $2!
 
444
version_match() {
 
445
  backIFS=$IFS
 
446
  IFS='.'
 
447
 
 
448
  # Split both version numbers into their numeric elements.
 
449
  arr1=( $1 )
 
450
  arr2=( $2 )
 
451
 
 
452
  ret=1
 
453
 
 
454
  count1=${#arr1[@]}
 
455
  count2=${#arr2[@]}
 
456
  if [ $count1 -ge $count2 ]; then
 
457
    ret=0
 
458
    for (( i=0; $i < $count2; i++ ))
 
459
    do
 
460
      if [ $(( 10#${arr1[$i]} )) -ne $(( 10#${arr2[$i]} )) ]; then
 
461
        ret=1
 
462
        break
 
463
      fi
 
464
    done
 
465
  fi
 
466
 
 
467
  IFS=$backIFS
 
468
  return $ret
 
469
}
 
470
 
 
471
detect_distro() {
 
472
  if [ -f /etc/debian_version ]; then
 
473
    DISTRO="DEB"
 
474
  elif [ -f /etc/redhat-release -o /etc/SuSE-release ]; then
 
475
    DISTRO="RPM"
 
476
  elif [ -f /etc/arch-release ]; then
 
477
    DISTRO="ARCH"
 
478
  fi
 
479
}
 
480
 
 
481
rpm_flavour() {
 
482
  if [ -f /etc/redhat-release ]; then
 
483
    if [ "`grep '6\.' /etc/redhat-release`" ]; then
 
484
      RPM="RHEL"
 
485
    else
 
486
      RPM="FEDORA"
 
487
    fi
 
488
  elif [ -f /etc/SuSE-release ]; then
 
489
    RPM="SUSE"
 
490
  fi
 
491
}
 
492
 
 
493
prepare_opt() {
 
494
  INFO "Ensuring $INST exists and is writable by us"
 
495
  if [ ! -d  $INST ]; then
 
496
    sudo mkdir -p $INST
 
497
  fi
 
498
 
 
499
  if [ ! -w $INST ]; then
 
500
    sudo chown $USER $INST
 
501
    sudo chmod 775 $INST
 
502
  fi
 
503
}
 
504
 
 
505
# Check whether the current package needs to be recompiled, based on a dummy file containing a magic number in its name...
 
506
magic_compile_check() {
 
507
  if [ -f $INST/.$1-magiccheck-$2 ]; then
 
508
    return 0
 
509
  else
 
510
    return 1
 
511
  fi
 
512
}
 
513
 
 
514
magic_compile_set() {
 
515
  rm -f $INST/.$1-magiccheck-*
 
516
  touch $INST/.$1-magiccheck-$2
 
517
}
 
518
 
 
519
compile_Python() {
 
520
  # To be changed each time we make edits that would modify the compiled result!
 
521
  py_magic=0
 
522
 
 
523
  _src=$SRC/Python-$PYTHON_VERSION
 
524
  _inst=$INST/python-$PYTHON_VERSION
 
525
 
 
526
  # Clean install if needed!
 
527
  magic_compile_check python-$PYTHON_VERSION $py_magic
 
528
  if [ $? -eq 1 -o $PYTHON_FORCE_REBUILD == true ]; then
 
529
    rm -rf $_inst
 
530
  fi
 
531
 
 
532
  if [ ! -d $_inst ]; then
 
533
    INFO "Building Python-$PYTHON_VERSION"
 
534
 
 
535
    prepare_opt
 
536
 
 
537
    if [ ! -d $_src ]; then
 
538
      mkdir -p $SRC
 
539
      wget -c $PYTHON_SOURCE -O $_src.tar.bz2
 
540
 
 
541
      INFO "Unpacking Python-$PYTHON_VERSION"
 
542
      tar -C $SRC -xf $_src.tar.bz2
 
543
    fi
 
544
 
 
545
    cd $_src
 
546
 
 
547
    ./configure --prefix=$_inst --enable-ipv6 \
 
548
        --enable-loadable-sqlite-extensions --with-dbmliborder=bdb \
 
549
        --with-computed-gotos --with-pymalloc
 
550
 
 
551
    make -j$THREADS && make install
 
552
    make clean
 
553
 
 
554
    if [ -d $_inst ]; then
 
555
      rm -f $INST/python-3.3
 
556
      ln -s python-$PYTHON_VERSION $INST/python-3.3
 
557
    else
 
558
      ERROR "Python--$PYTHON_VERSION failed to compile, exiting"
 
559
      exit 1
 
560
    fi
 
561
 
 
562
    magic_compile_set python-$PYTHON_VERSION $py_magic
 
563
 
 
564
    cd $CWD
 
565
    INFO "Done compiling Python-$PYTHON_VERSION!"
 
566
  else
 
567
    INFO "Own Python-$PYTHON_VERSION is up to date, nothing to do!"
 
568
    INFO "If you want to force rebuild of this lib, use the --force-python option."
 
569
  fi
 
570
}
 
571
 
 
572
compile_Numpy() {
 
573
  # To be changed each time we make edits that would modify the compiled result!
 
574
  py_magic=0
 
575
 
 
576
  _src=$SRC/numpy-$NUMPY_VERSION
 
577
  _inst=$INST/numpy-$NUMPY_VERSION
 
578
  _python=$INST/python-$PYTHON_VERSION
 
579
  _site=lib/python3.3/site-packages
 
580
 
 
581
  # Clean install if needed!
 
582
  magic_compile_check numpy-$NUMPY_VERSION $py_magic
 
583
  if [ $? -eq 1 -o $NUMPY_FORCE_REBUILD == true ]; then
 
584
    rm -rf $_inst
 
585
  fi
 
586
 
 
587
  if [ ! -d $_inst ]; then
 
588
    INFO "Building Numpy-$NUMPY_VERSION"
 
589
 
 
590
    prepare_opt
 
591
 
 
592
    if [ ! -d $_src ]; then
 
593
      mkdir -p $SRC
 
594
      wget -c $NUMPY_SOURCE -O $_src.tar.gz
 
595
 
 
596
      INFO "Unpacking Numpy-$NUMPY_VERSION"
 
597
      tar -C $SRC -xf $_src.tar.gz
 
598
    fi
 
599
 
 
600
    cd $_src
 
601
 
 
602
    $_python/bin/python3 setup.py install --prefix=$_inst
 
603
 
 
604
    if [ -d $_inst ]; then
 
605
      rm -f $_python/$_site/numpy
 
606
      ln -s $_inst/$_site/numpy $_python/$_site/numpy
 
607
    else
 
608
      ERROR "Numpy-$NUMPY_VERSION failed to compile, exiting"
 
609
      exit 1
 
610
    fi
 
611
 
 
612
    magic_compile_set numpy-$NUMPY_VERSION $py_magic
 
613
 
 
614
    cd $CWD
 
615
    INFO "Done compiling Numpy-$NUMPY_VERSION!"
 
616
  else
 
617
    INFO "Own Numpy-$NUMPY_VERSION is up to date, nothing to do!"
 
618
    INFO "If you want to force rebuild of this lib, use the --force-numpy option."
 
619
  fi
 
620
}
 
621
 
 
622
compile_Boost() {
 
623
  # To be changed each time we make edits that would modify the compiled result!
 
624
  boost_magic=7
 
625
 
 
626
  _src=$SRC/boost-$BOOST_VERSION
 
627
  _inst=$INST/boost-$BOOST_VERSION
 
628
 
 
629
  # Clean install if needed!
 
630
  magic_compile_check boost-$BOOST_VERSION $boost_magic
 
631
  if [ $? -eq 1 -o $BOOST_FORCE_REBUILD == true ]; then
 
632
    rm -rf $_inst
 
633
  fi
 
634
 
 
635
  if [ ! -d $_inst ]; then
 
636
    INFO "Building Boost-$BOOST_VERSION"
 
637
 
 
638
    prepare_opt
 
639
 
 
640
    if [ ! -d $_src ]; then
 
641
      INFO "Downloading Boost-$BOOST_VERSION"
 
642
      mkdir -p $SRC
 
643
      wget -c $BOOST_SOURCE -O $_src.tar.bz2
 
644
      tar -C $SRC --transform "s,(.*/?)boost_1_[^/]+(.*),\1boost-$BOOST_VERSION\2,x" -xf $_src.tar.bz2
 
645
    fi
 
646
 
 
647
    cd $_src
 
648
    if [ ! -f $_src/b2 ]; then
 
649
      ./bootstrap.sh
 
650
    fi
 
651
    ./b2 -j$THREADS -a --with-system --with-filesystem --with-thread --with-regex --with-locale --with-date_time \
 
652
         --prefix=$_inst --disable-icu boost.locale.icu=off install
 
653
    ./b2 --clean
 
654
 
 
655
    if [ -d $_inst ]; then
 
656
      rm -f $INST/boost
 
657
      ln -s boost-$BOOST_VERSION $INST/boost
 
658
    else
 
659
      ERROR "Boost-$BOOST_VERSION failed to compile, exiting"
 
660
      exit 1
 
661
    fi
 
662
 
 
663
    magic_compile_set boost-$BOOST_VERSION $boost_magic
 
664
 
 
665
    # Rebuild dependecies as well!
 
666
    OIIO_FORCE_REBUILD=true
 
667
    OSL_FORCE_REBUILD=true
 
668
 
 
669
    cd $CWD
 
670
    INFO "Done compiling Boost-$BOOST_VERSION!"
 
671
  else
 
672
    INFO "Own Boost-$BOOST_VERSION is up to date, nothing to do!"
 
673
    INFO "If you want to force rebuild of this lib, use the --force-boost option."
 
674
  fi
 
675
}
 
676
 
 
677
compile_OCIO() {
 
678
  # To be changed each time we make edits that would modify the compiled result!
 
679
  ocio_magic=1
 
680
 
 
681
  _src=$SRC/OpenColorIO-$OCIO_VERSION
 
682
  _inst=$INST/ocio-$OCIO_VERSION
 
683
 
 
684
  # Clean install if needed!
 
685
  magic_compile_check ocio-$OCIO_VERSION $ocio_magic
 
686
  if [ $? -eq 1 -o $OCIO_FORCE_REBUILD == true ]; then
 
687
    rm -rf $_inst
 
688
  fi
 
689
 
 
690
  if [ ! -d $_inst ]; then
 
691
    INFO "Building OpenColorIO-$OCIO_VERSION"
 
692
 
 
693
    prepare_opt
 
694
 
 
695
    if [ ! -d $_src ]; then
 
696
      INFO "Downloading OpenColorIO-$OCIO_VERSION"
 
697
      mkdir -p $SRC
 
698
      wget -c $OCIO_SOURCE -O $_src.tar.gz
 
699
 
 
700
      INFO "Unpacking OpenColorIO-$OCIO_VERSION"
 
701
      tar -C $SRC --transform "s,(.*/?)imageworks-OpenColorIO[^/]*(.*),\1OpenColorIO-$OCIO_VERSION\2,x" \
 
702
          -xf $_src.tar.gz
 
703
    fi
 
704
 
 
705
    cd $_src
 
706
    # Always refresh the whole build!
 
707
    if [ -d build ]; then
 
708
      rm -rf build
 
709
    fi    
 
710
    mkdir build
 
711
    cd build
 
712
 
 
713
    if file /bin/cp | grep -q '32-bit'; then
 
714
      cflags="-fPIC -m32 -march=i686"
 
715
    else
 
716
      cflags="-fPIC"
 
717
    fi
 
718
 
 
719
    cmake -D CMAKE_BUILD_TYPE=Release \
 
720
          -D CMAKE_PREFIX_PATH=$_inst \
 
721
          -D CMAKE_INSTALL_PREFIX=$_inst \
 
722
          -D CMAKE_CXX_FLAGS="$cflags" \
 
723
          -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \
 
724
          -D OCIO_BUILD_APPS=OFF \
 
725
          -D OCIO_BUILD_PYGLUE=OFF \
 
726
          ..
 
727
 
 
728
    make -j$THREADS && make install
 
729
 
 
730
    # Force linking against static libs
 
731
    rm -f $_inst/lib/*.so*
 
732
 
 
733
    # Additional depencencies
 
734
    cp ext/dist/lib/libtinyxml.a $_inst/lib
 
735
    cp ext/dist/lib/libyaml-cpp.a $_inst/lib
 
736
 
 
737
    make clean
 
738
 
 
739
    if [ -d $_inst ]; then
 
740
      rm -f $INST/ocio
 
741
      ln -s ocio-$OCIO_VERSION $INST/ocio
 
742
    else
 
743
      ERROR "OpenColorIO-$OCIO_VERSION failed to compile, exiting"
 
744
      exit 1
 
745
    fi
 
746
 
 
747
    magic_compile_set ocio-$OCIO_VERSION $ocio_magic
 
748
 
 
749
    cd $CWD
 
750
    INFO "Done compiling OpenColorIO-$OCIO_VERSION!"
 
751
  else
 
752
    INFO "Own OpenColorIO-$OCIO_VERSION is up to date, nothing to do!"
 
753
    INFO "If you want to force rebuild of this lib, use the --force-ocio option."
 
754
  fi
 
755
}
 
756
 
 
757
compile_OIIO() {
 
758
  # To be changed each time we make edits that would modify the compiled result!
 
759
  oiio_magic=7
 
760
 
 
761
  _src=$SRC/OpenImageIO-$OIIO_VERSION
 
762
  _inst=$INST/oiio-$OIIO_VERSION
 
763
 
 
764
  # Clean install if needed!
 
765
  magic_compile_check oiio-$OIIO_VERSION $oiio_magic
 
766
  if [ $? -eq 1 -o $OIIO_FORCE_REBUILD == true ]; then
 
767
    rm -rf $_inst
 
768
  fi
 
769
 
 
770
  if [ ! -d $_inst ]; then
 
771
    INFO "Building OpenImageIO-$OIIO_VERSION"
 
772
 
 
773
    prepare_opt
 
774
 
 
775
    if [ ! -d $_src ]; then
 
776
      mkdir -p $SRC
 
777
      wget -c $OIIO_SOURCE -O "$_src.tar.gz"
 
778
 
 
779
      INFO "Unpacking OpenImageIO-$OIIO_VERSION"
 
780
      tar -C $SRC --transform "s,(.*/?)OpenImageIO-oiio[^/]*(.*),\1OpenImageIO-$OIIO_VERSION\2,x" \
 
781
          -xf $_src.tar.gz
 
782
 
 
783
      cd $_src
 
784
 
 
785
      # XXX Ugly patching hack!
 
786
      cat << EOF | patch -p1
 
787
diff --git a/src/libutil/SHA1.cpp b/src/libutil/SHA1.cpp
 
788
index b9e6c8b..c761185 100644
 
789
--- a/src/libutil/SHA1.cpp
 
790
+++ b/src/libutil/SHA1.cpp
 
791
@@ -8,9 +8,9 @@
 
792
 
 
793
 // If compiling with MFC, you might want to add #include "StdAfx.h"
 
794
 
 
795
+#include "SHA1.h"
 
796
 #include "hash.h"
 
797
 #include "dassert.h"
 
798
-#include "SHA1.h"
 
799
 
 
800
 #ifdef SHA1_UTILITY_FUNCTIONS
 
801
 #define SHA1_MAX_FILE_BUFFER 8000
 
802
EOF
 
803
 
 
804
      cd $CWD
 
805
 
 
806
    fi
 
807
 
 
808
    cd $_src
 
809
    # Always refresh the whole build!
 
810
    if [ -d build ]; then
 
811
      rm -rf build
 
812
    fi    
 
813
    mkdir build
 
814
    cd build
 
815
 
 
816
    cmake_d="-D CMAKE_BUILD_TYPE=Release"
 
817
    cmake_d="$cmake_d -D CMAKE_PREFIX_PATH=$_inst"
 
818
    cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
 
819
    cmake_d="$cmake_d -D BUILDSTATIC=ON"
 
820
 
 
821
    # linking statically could give issues on Debian/Ubuntu (and probably other distros
 
822
    # which doesn't like static linking) when linking shared oiio library due to missing
 
823
    # text symbols (static libs should be compiled with -fPIC)
 
824
    # cmake_d="$cmake_d -D LINKSTATIC=ON"
 
825
 
 
826
    if [ -d $INST/boost ]; then
 
827
      cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost -D Boost_NO_SYSTEM_PATHS=ON"
 
828
      if $ALL_STATIC; then
 
829
        cmake_d="$cmake_d -D Boost_USE_STATIC_LIBS=ON"
 
830
      fi
 
831
    fi
 
832
 
 
833
    # Looks like we do not need ocio in oiio for now...
 
834
#    if [ -d $INST/ocio ]; then
 
835
#      cmake_d="$cmake_d -D OCIO_PATH=$INST/ocio"
 
836
#    fi
 
837
 
 
838
    if file /bin/cp | grep -q '32-bit'; then
 
839
      cflags="-fPIC -m32 -march=i686"
 
840
    else
 
841
      cflags="-fPIC"
 
842
    fi
 
843
 
 
844
    cmake $cmake_d -D CMAKE_CXX_FLAGS="$cflags" -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" ../src
 
845
 
 
846
    make -j$THREADS && make install
 
847
    make clean
 
848
 
 
849
    if [ -d $_inst ]; then
 
850
      rm -f $INST/oiio
 
851
      ln -s oiio-$OIIO_VERSION $INST/oiio
 
852
    else
 
853
      ERROR "OpenImageIO-$OIIO_VERSION failed to compile, exiting"
 
854
      exit 1
 
855
    fi
 
856
 
 
857
    magic_compile_set oiio-$OIIO_VERSION $oiio_magic
 
858
 
 
859
    # Rebuild dependecies as well!
 
860
    OSL_FORCE_REBUILD=true
 
861
 
 
862
    cd $CWD
 
863
    INFO "Done compiling OpenImageIO-$OIIO_VERSION!"
 
864
  else
 
865
    INFO "Own OpenImageIO-$OIIO_VERSION is up to date, nothing to do!"
 
866
    INFO "If you want to force rebuild of this lib, use the --force-oiio option."
 
867
  fi
 
868
}
 
869
 
 
870
compile_LLVM() {
 
871
  # To be changed each time we make edits that would modify the compiled result!
 
872
  llvm_magic=1
 
873
 
 
874
  _src=$SRC/LLVM-$LLVM_VERSION
 
875
  _inst=$INST/llvm-$LLVM_VERSION
 
876
  _src_clang=$SRC/CLANG-$LLVM_VERSION
 
877
 
 
878
  # Clean install if needed!
 
879
  magic_compile_check llvm-$LLVM_VERSION $llvm_magic
 
880
  if [ $? -eq 1 -o $LLVM_FORCE_REBUILD == true ]; then
 
881
    rm -rf $_inst
 
882
    rm -rf $_inst_clang
 
883
  fi
 
884
 
 
885
  if [ ! -d $_inst ]; then
 
886
    INFO "Building LLVM-$LLVM_VERSION (CLANG included!)"
 
887
 
 
888
    prepare_opt
 
889
 
 
890
    if [ ! -d $_src -o true ]; then
 
891
      mkdir -p $SRC
 
892
      wget -c $LLVM_SOURCE -O "$_src.tar.gz"
 
893
      wget -c $LLVM_CLANG_SOURCE -O "$_src_clang.tar.gz"
 
894
 
 
895
      INFO "Unpacking LLVM-$LLVM_VERSION"
 
896
      tar -C $SRC --transform "s,([^/]*/?)llvm-[^/]*(.*),\1LLVM-$LLVM_VERSION\2,x" \
 
897
          -xf $_src.tar.gz
 
898
      INFO "Unpacking CLANG-$LLVM_VERSION to $_src/tools/clang"
 
899
      tar -C $_src/tools \
 
900
          --transform "s,([^/]*/?)clang-[^/]*(.*),\1clang\2,x" \
 
901
          -xf $_src_clang.tar.gz
 
902
 
 
903
      cd $_src
 
904
 
 
905
      # XXX Ugly patching hack!
 
906
      cat << EOF | patch -p1
 
907
--- a/CMakeLists.txt
 
908
+++ b/CMakeLists.txt
 
909
@@ -13,7 +13,7 @@
 
910
 set(LLVM_VERSION_MAJOR 3)
 
911
 set(LLVM_VERSION_MINOR 1)
 
912
 
 
913
-set(PACKAGE_VERSION "\${LLVM_VERSION_MAJOR}.\${LLVM_VERSION_MINOR}svn")
 
914
+set(PACKAGE_VERSION "\${LLVM_VERSION_MAJOR}.\${LLVM_VERSION_MINOR}")
 
915
 
 
916
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 
917
 
 
918
EOF
 
919
 
 
920
      cd $CWD
 
921
 
 
922
    fi
 
923
 
 
924
    cd $_src
 
925
 
 
926
    # Always refresh the whole build!
 
927
    if [ -d build ]; then
 
928
      rm -rf build
 
929
    fi    
 
930
    mkdir build
 
931
    cd build
 
932
 
 
933
    cmake_d="-D CMAKE_BUILD_TYPE=Release"
 
934
    cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
 
935
    cmake_d="$cmake_d -D LLVM_ENABLE_FFI=ON"
 
936
    cmake_d="$cmake_d -D LLVM_TARGETS_TO_BUILD=X86"
 
937
 
 
938
    if [ -d $_FFI_INCLUDE_DIR ]; then
 
939
      cmake_d="$cmake_d -D FFI_INCLUDE_DIR=$_FFI_INCLUDE_DIR"
 
940
    fi
 
941
 
 
942
    cmake $cmake_d ..
 
943
 
 
944
    make -j$THREADS && make install
 
945
    make clean
 
946
 
 
947
    if [ -d $_inst ]; then
 
948
      rm -f $INST/llvm
 
949
      ln -s llvm-$LLVM_VERSION $INST/llvm
 
950
    else
 
951
      ERROR "LLVM-$LLVM_VERSION failed to compile, exiting"
 
952
      exit 1
 
953
    fi
 
954
 
 
955
    magic_compile_set llvm-$LLVM_VERSION $llvm_magic
 
956
 
 
957
    # Rebuild dependecies as well!
 
958
    OSL_FORCE_REBUILD=true
 
959
 
 
960
    cd $CWD
 
961
    INFO "Done compiling LLVM-$LLVM_VERSION (CLANG included)!"
 
962
  else
 
963
    INFO "Own LLVM-$LLVM_VERSION (CLANG included) is up to date, nothing to do!"
 
964
    INFO "If you want to force rebuild of this lib, use the --force-llvm option."
 
965
  fi
 
966
}
 
967
 
 
968
compile_OSL() {
 
969
  # To be changed each time we make edits that would modify the compiled result!
 
970
  osl_magic=7
 
971
 
 
972
  _src=$SRC/OpenShadingLanguage-$OSL_VERSION
 
973
  _inst=$INST/osl-$OSL_VERSION
 
974
 
 
975
  # Clean install if needed!
 
976
  magic_compile_check osl-$OSL_VERSION $osl_magic
 
977
  if [ $? -eq 1 -o $OSL_FORCE_REBUILD == true ]; then
 
978
    rm -rf $_inst
 
979
  fi
 
980
 
 
981
  if [ ! -d $_inst ]; then
 
982
    INFO "Building OpenShadingLanguage-$OSL_VERSION"
 
983
 
 
984
    prepare_opt
 
985
 
 
986
    if [ ! -d $_src ]; then
 
987
      mkdir -p $SRC
 
988
 
 
989
      # XXX Using git on my own repo for now, looks like archives are not updated immediately... :/
 
990
#      wget -c $OSL_SOURCE -O "$_src.tar.gz"
 
991
 
 
992
#      INFO "Unpacking OpenShadingLanguage-$OSL_VERSION"
 
993
#      tar -C $SRC --transform "s,(.*/?)OpenShadingLanguage-[^/]*(.*),\1OpenShadingLanguage-$OSL_VERSION\2,x" \
 
994
#          -xf $_src.tar.gz
 
995
      git clone https://github.com/mont29/OpenShadingLanguage.git $_src
 
996
      cd $_src
 
997
      git checkout blender-fixes
 
998
      cd $CWD
 
999
    fi
 
1000
 
 
1001
    cd $_src
 
1002
    # XXX For now, always update from latest repo...
 
1003
    git pull origin
 
1004
 
 
1005
    # Always refresh the whole build!
 
1006
    if [ -d build ]; then
 
1007
      rm -rf build
 
1008
    fi    
 
1009
    mkdir build
 
1010
    cd build
 
1011
 
 
1012
    cmake_d="-D CMAKE_BUILD_TYPE=Release"
 
1013
    cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
 
1014
    cmake_d="$cmake_d -D BUILDSTATIC=ON"
 
1015
    cmake_d="$cmake_d -D BUILD_TESTING=OFF"
 
1016
    cmake_d="$cmake_d -D STOP_ON_WARNING=OFF"
 
1017
 
 
1018
    if [ -d $INST/boost ]; then
 
1019
      cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost -D Boost_NO_SYSTEM_PATHS=ON"
 
1020
      if $ALL_STATIC; then
 
1021
        cmake_d="$cmake_d -D Boost_USE_STATIC_LIBS=ON"        
 
1022
      fi
 
1023
    fi
 
1024
 
 
1025
    if [ -d $INST/oiio ]; then
 
1026
      cmake_d="$cmake_d -D OPENIMAGEIOHOME=$INST/oiio"
 
1027
    fi
 
1028
 
 
1029
    if [ ! -z $LLVM_VERSION_FOUND ]; then
 
1030
      cmake_d="$cmake_d -D LLVM_VERSION=$LLVM_VERSION_FOUND"
 
1031
      if [ -d $INST/llvm ]; then
 
1032
        cmake_d="$cmake_d -D LLVM_DIRECTORY=$INST/llvm"
 
1033
        cmake_d="$cmake_d -D LLVM_STATIC=ON"
 
1034
      fi
 
1035
    fi
 
1036
 
 
1037
    cmake $cmake_d ../src
 
1038
 
 
1039
    make -j$THREADS && make install
 
1040
    make clean
 
1041
 
 
1042
    if [ -d $_inst ]; then
 
1043
      rm -f $INST/osl
 
1044
      ln -s osl-$OSL_VERSION $INST/osl
 
1045
    else
 
1046
      ERROR "OpenShadingLanguage-$OSL_VERSION failed to compile, exiting"
 
1047
      exit 1
 
1048
    fi
 
1049
 
 
1050
    magic_compile_set osl-$OSL_VERSION $osl_magic
 
1051
 
 
1052
    cd $CWD
 
1053
    INFO "Done compiling OpenShadingLanguage-$OSL_VERSION!"
 
1054
  else
 
1055
    INFO "Own OpenShadingLanguage-$OSL_VERSION is up to date, nothing to do!"
 
1056
    INFO "If you want to force rebuild of this lib, use the --force-osl option."
 
1057
  fi
 
1058
}
 
1059
 
 
1060
compile_OpenCOLLADA() {
 
1061
  # To be changed each time we make edits that would modify the compiled results!
 
1062
  opencollada_magic=5
 
1063
 
 
1064
  _src=$SRC/OpenCOLLADA-$OPENCOLLADA_VERSION
 
1065
  _inst=$INST/opencollada-$OPENCOLLADA_VERSION
 
1066
 
 
1067
  # Clean install if needed!
 
1068
  magic_compile_check opencollada-$OPENCOLLADA_VERSION $opencollada_magic
 
1069
  if [ $? -eq 1 -o $OPENCOLLADA_FORCE_REBUILD == true ]; then
 
1070
    rm -rf $_inst
 
1071
  fi
 
1072
 
 
1073
  if [ ! -d $_inst ]; then
 
1074
    INFO "Building OpenCOLLADA-$OPENCOLLADA_VERSION"
 
1075
 
 
1076
    prepare_opt
 
1077
 
 
1078
    if [ ! -d $_src ]; then
 
1079
      mkdir -p $SRC
 
1080
      git clone $OPENCOLLADA_SOURCE $_src
 
1081
    fi
 
1082
 
 
1083
    cd $_src
 
1084
 
 
1085
    # XXX For now, always update from latest repo...
 
1086
    git pull origin
 
1087
 
 
1088
    # Always refresh the whole build!
 
1089
    if [ -d build ]; then
 
1090
      rm -rf build
 
1091
    fi
 
1092
    mkdir build
 
1093
    cd build
 
1094
 
 
1095
    cmake_d="-D CMAKE_BUILD_TYPE=Release"
 
1096
    cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
 
1097
    cmake_d="$cmake_d -D USE_EXPAT=OFF"
 
1098
    cmake_d="$cmake_d -D USE_LIBXML=ON"
 
1099
    cmake_d="$cmake_d -D USE_STATIC=ON"
 
1100
 
 
1101
    cmake $cmake_d ../
 
1102
 
 
1103
    make -j$THREADS && make install
 
1104
    make clean
 
1105
 
 
1106
    if [ -d $_inst ]; then
 
1107
      rm -f $INST/opencollada
 
1108
      ln -s opencollada-$OPENCOLLADA_VERSION $INST/opencollada
 
1109
    else
 
1110
      ERROR "OpenCOLLADA-$OPENCOLLADA_VERSION failed to compile, exiting"
 
1111
      exit 1
 
1112
    fi
 
1113
 
 
1114
    magic_compile_set opencollada-$OPENCOLLADA_VERSION $opencollada_magic
 
1115
 
 
1116
    cd $CWD
 
1117
    INFO "Done compiling OpenCOLLADA-$OPENCOLLADA_VERSION!"
 
1118
  else
 
1119
    INFO "Own OpenCOLLADA-$OPENCOLLADA_VERSION is up to date, nothing to do!"
 
1120
    INFO "If you want to force rebuild of this lib, use the --force-opencollada option."
 
1121
  fi
 
1122
}
 
1123
 
 
1124
compile_FFmpeg() {
 
1125
  # To be changed each time we make edits that would modify the compiled result!
 
1126
  ffmpeg_magic=3
 
1127
 
 
1128
  _src=$SRC/ffmpeg-$FFMPEG_VERSION
 
1129
  _inst=$INST/ffmpeg-$FFMPEG_VERSION
 
1130
 
 
1131
  # Clean install if needed!
 
1132
  magic_compile_check ffmpeg-$FFMPEG_VERSION $ffmpeg_magic
 
1133
  if [ $? -eq 1 -o $FFMPEG_FORCE_REBUILD == true ]; then
 
1134
    rm -rf $_inst
 
1135
  fi
 
1136
 
 
1137
  if [ ! -d $_inst ]; then
 
1138
    INFO "Building ffmpeg-$FFMPEG_VERSION"
 
1139
 
 
1140
    prepare_opt
 
1141
 
 
1142
    if [ ! -d $_src ]; then
 
1143
      INFO "Downloading ffmpeg-$FFMPEG_VERSION"
 
1144
      mkdir -p $SRC
 
1145
      wget -c $FFMPEG_SOURCE -O "$_src.tar.bz2"
 
1146
 
 
1147
      INFO "Unpacking ffmpeg-$FFMPEG_VERSION"
 
1148
      tar -C $SRC -xf $_src.tar.bz2
 
1149
    fi
 
1150
 
 
1151
    cd $_src
 
1152
 
 
1153
    extra=""
 
1154
 
 
1155
    if $VORBIS_USE; then
 
1156
      extra="$extra --enable-libvorbis"
 
1157
    fi
 
1158
 
 
1159
    if $THEORA_USE; then
 
1160
      extra="$extra --enable-libtheora"
 
1161
    fi
 
1162
 
 
1163
    # XXX At least under Debian, static schro gives problem at blender linking time... :/
 
1164
    if $SCHRO_USE && ! $ALL_STATIC; then
 
1165
      extra="$extra --enable-libschroedinger"
 
1166
    fi
 
1167
 
 
1168
    if $XVID_USE; then
 
1169
      extra="$extra --enable-libxvid"
 
1170
    fi
 
1171
 
 
1172
    if $X264_USE; then
 
1173
      extra="$extra --enable-libx264"
 
1174
    fi
 
1175
 
 
1176
    if $VPX_USE; then
 
1177
      extra="$extra --enable-libvpx"
 
1178
    fi
 
1179
 
 
1180
    if $MP3LAME_USE; then
 
1181
      extra="$extra --enable-libmp3lame"
 
1182
    fi
 
1183
 
 
1184
    if $OPENJPEG_USE; then
 
1185
      extra="$extra --enable-libopenjpeg"
 
1186
    fi
 
1187
 
 
1188
    ./configure --cc="gcc -Wl,--as-needed" \
 
1189
        --extra-ldflags="-pthread -static-libgcc" \
 
1190
        --prefix=$_inst --enable-static \
 
1191
        --disable-ffplay --disable-ffserver --disable-doc \
 
1192
        --enable-gray \
 
1193
        --enable-avfilter --disable-vdpau \
 
1194
        --disable-bzlib --disable-libgsm --disable-libspeex \
 
1195
        --enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \
 
1196
        --disable-vaapi --disable-libfaac --disable-nonfree --enable-gpl \
 
1197
        --disable-postproc --disable-x11grab --disable-librtmp --disable-libopencore-amrnb \
 
1198
        --disable-libopencore-amrwb --disable-libdc1394 --disable-version3 --disable-outdev=sdl \
 
1199
        --disable-outdev=alsa --disable-indev=sdl --disable-indev=alsa --disable-indev=jack \
 
1200
        --disable-indev=lavfi $extra
 
1201
 
 
1202
    make -j$THREADS && make install
 
1203
    make clean
 
1204
 
 
1205
    if [ -d $_inst ]; then
 
1206
      rm -f $INST/ffmpeg
 
1207
      ln -s ffmpeg-$FFMPEG_VERSION $INST/ffmpeg
 
1208
    else
 
1209
      ERROR "FFmpeg-$FFMPEG_VERSION failed to compile, exiting"
 
1210
      exit 1
 
1211
    fi
 
1212
 
 
1213
    magic_compile_set ffmpeg-$FFMPEG_VERSION $ffmpeg_magic
 
1214
 
 
1215
    cd $CWD
 
1216
    INFO "Done compiling ffmpeg-$FFMPEG_VERSION!"
 
1217
  else
 
1218
    INFO "Own ffmpeg-$FFMPEG_VERSION is up to date, nothing to do!"
 
1219
    INFO "If you want to force rebuild of this lib, use the --force-ffmpeg option."
 
1220
  fi
 
1221
}
 
1222
 
 
1223
 
 
1224
 
 
1225
get_package_version_DEB() {
 
1226
    dpkg-query -W -f '${Version}' $1 | sed -r 's/.*:\s*([0-9]+:)(([0-9]+\.?)+).*/\2/'
 
1227
}
 
1228
 
 
1229
check_package_DEB() {
 
1230
  r=`apt-cache policy $1 | grep -c 'Candidate:'`
 
1231
 
 
1232
  if [ $r -ge 1 ]; then
 
1233
    return 0
 
1234
  else
 
1235
    return 1
 
1236
  fi
 
1237
}
 
1238
 
 
1239
check_package_version_match_DEB() {
 
1240
  v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*([0-9]+:)(([0-9]+\.?)+).*/\2/'`
 
1241
 
 
1242
  if [ -z "$v" ]; then
 
1243
    return 1
 
1244
  fi
 
1245
 
 
1246
  version_match $v $2
 
1247
  return $?
 
1248
}
 
1249
 
 
1250
check_package_version_ge_DEB() {
 
1251
  v=`apt-cache policy $1 | grep 'Candidate:' | sed -r 's/.*:\s*([0-9]+:)?(([0-9]+\.?)+).*/\2/'`
 
1252
 
 
1253
  if [ -z "$v" ]; then
 
1254
    return 1
 
1255
  fi
 
1256
 
 
1257
  version_ge $v $2
 
1258
  return $?
 
1259
}
 
1260
 
 
1261
install_packages_DEB() {
 
1262
  sudo apt-get install -y --force-yes $@
 
1263
  if [ $? -ge 1 ]; then
 
1264
    ERROR "apt-get failed to install requested packages, exiting."
 
1265
    exit 1
 
1266
  fi
 
1267
}
 
1268
 
 
1269
install_DEB() {
 
1270
  INFO ""
 
1271
  INFO "Installing dependencies for DEB-based distribution"
 
1272
  INFO ""
 
1273
  INFO "`eval _echo "$COMMON_INFO"`"
 
1274
  INFO ""
 
1275
 
 
1276
  read -p "Do you want to continue (Y/n)?"
 
1277
  [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" != "y" ] && exit
 
1278
 
 
1279
  if [ ! -z "`cat /etc/debian_version | grep ^6`"  ]; then
 
1280
    if [ -z "`cat /etc/apt/sources.list | grep backports.debian.org`"  ]; then
 
1281
      INFO "Looks like you're using Debian Squeeze which does have broken CMake"
 
1282
      INFO "It is highly recommended to install cmake from backports, otherwise"
 
1283
      INFO "compilation of some libraries could fail"
 
1284
      INFO ""
 
1285
      INFO "You could install newer CMake from debian-backports repository"
 
1286
      INFO "Add this this line to your /etc/apt/sources.lixt:"
 
1287
      INFO ""
 
1288
      INFO "deb http://backports.debian.org/debian-backports squeeze-backports main"
 
1289
      INFO ""
 
1290
      INFO "and then run:"
 
1291
      INFO ""
 
1292
      INFO "sudo apt-get update && sudo apt-get install cmake=2.8.7-4~bpo60+1 sudo apt-get install cmake=2.8.7-4~bpo60+1"
 
1293
      INFO ""
 
1294
      INFO "(you could also add this reporisotry using GUI like synaptic)"
 
1295
      INFO ""
 
1296
      INFO "Hit Enter to continue running the script, or hit Ctrl-C to abort the script"
 
1297
 
 
1298
      read
 
1299
      INFO ""
 
1300
    fi
 
1301
  fi
 
1302
 
 
1303
  sudo apt-get update
 
1304
 
 
1305
  # These libs should always be available in debian/ubuntu official repository...
 
1306
  OPENJPEG_DEV="libopenjpeg-dev"
 
1307
  VORBIS_DEV="libvorbis-dev"
 
1308
  THEORA_DEV="libtheora-dev"
 
1309
 
 
1310
  _packages="gawk cmake cmake-curses-gui scons build-essential libjpeg-dev libpng-dev \
 
1311
             libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev \
 
1312
             libncurses5-dev libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV \
 
1313
             libopenexr-dev libopenal-dev libglew-dev yasm $THEORA_DEV $VORBIS_DEV \
 
1314
             libsdl1.2-dev libfftw3-dev patch bzip2"
 
1315
 
 
1316
  OPENJPEG_USE=true
 
1317
  VORBIS_USE=true
 
1318
  THEORA_USE=true
 
1319
 
 
1320
  # Install newest libtiff-dev in debian/ubuntu.
 
1321
  TIFF="libtiff5"
 
1322
  check_package_DEB $TIFF
 
1323
  if [ $? -eq 0 ]; then
 
1324
    _packages="$_packages $TIFF-dev"
 
1325
  else
 
1326
    TIFF="libtiff"
 
1327
    check_package_DEB $TIFF
 
1328
    if [ $? -eq 0 ]; then
 
1329
      _packages="$_packages $TIFF-dev"
 
1330
    fi
 
1331
  fi
 
1332
 
 
1333
  if $WITH_ALL; then
 
1334
    _packages="$_packages libspnav-dev libjack-dev"
 
1335
  fi
 
1336
 
 
1337
  INFO ""
 
1338
  install_packages_DEB $_packages
 
1339
 
 
1340
  INFO ""
 
1341
  X264_DEV="libx264-dev"
 
1342
  check_package_version_ge_DEB $X264_DEV $X264_VERSION_MIN
 
1343
  if [ $? -eq 0 ]; then
 
1344
    install_packages_DEB $X264_DEV
 
1345
    X264_USE=true
 
1346
  fi
 
1347
 
 
1348
  if $WITH_ALL; then
 
1349
    INFO ""
 
1350
    # Grmpf, debian is libxvidcore-dev and ubuntu libxvidcore4-dev!
 
1351
    # Note: not since ubuntu 10.04
 
1352
    XVID_DEV="libxvidcore-dev"
 
1353
    check_package_DEB $XVID_DEV
 
1354
    if [ $? -eq 0 ]; then
 
1355
      install_packages_DEB $XVID_DEV
 
1356
      XVID_USE=true
 
1357
    else
 
1358
      XVID_DEV="libxvidcore4-dev"
 
1359
      check_package_DEB $XVID_DEV
 
1360
      if [ $? -eq 0 ]; then
 
1361
        install_packages_DEB $XVID_DEV
 
1362
        XVID_USE=true
 
1363
      fi
 
1364
    fi
 
1365
 
 
1366
    INFO ""
 
1367
    MP3LAME_DEV="libmp3lame-dev"
 
1368
    check_package_DEB $MP3LAME_DEV
 
1369
    if [ $? -eq 0 ]; then
 
1370
      install_packages_DEB $MP3LAME_DEV
 
1371
      MP3LAME_USE=true
 
1372
    fi
 
1373
 
 
1374
    INFO ""
 
1375
    VPX_DEV="libvpx-dev"
 
1376
    check_package_version_ge_DEB $VPX_DEV $VPX_VERSION_MIN
 
1377
    if [ $? -eq 0 ]; then
 
1378
      install_packages_DEB $VPX_DEV
 
1379
      VPX_USE=true
 
1380
    fi
 
1381
 
 
1382
    INFO ""
 
1383
    SCHRO_DEV="libschroedinger-dev"
 
1384
    check_package_DEB $SCHRO_DEV
 
1385
    if [ $? -eq 0 ]; then
 
1386
      install_packages_DEB $SCHRO_DEV
 
1387
      SCHRO_USE=true
 
1388
    fi
 
1389
  fi
 
1390
 
 
1391
  INFO ""
 
1392
  if $PYTHON_SKIP; then
 
1393
    INFO "WARNING! Skipping Python installation, as requested..."
 
1394
  else
 
1395
    check_package_DEB python$PYTHON_VERSION_MIN-dev
 
1396
    if [ $? -eq 0 ]; then
 
1397
      install_packages_DEB python$PYTHON_VERSION_MIN-dev
 
1398
      INFO ""
 
1399
      if $NUMPY_SKIP; then
 
1400
        INFO "WARNING! Skipping NumPy installation, as requested..."
 
1401
      else
 
1402
        check_package_DEB python$PYTHON_VERSION_MIN-numpy
 
1403
        if [ $? -eq 0 ]; then
 
1404
          install_packages_DEB python$PYTHON_VERSION_MIN-numpy
 
1405
        else
 
1406
          INFO "WARNING! Sorry, using python package but no numpy package available!"
 
1407
        fi
 
1408
      fi
 
1409
    else
 
1410
      compile_Python
 
1411
      INFO ""
 
1412
      if $NUMPY_SKIP; then
 
1413
        INFO "WARNING! Skipping NumPy installation, as requested..."
 
1414
      else
 
1415
        compile_Numpy
 
1416
      fi
 
1417
    fi
 
1418
  fi
 
1419
 
 
1420
  INFO ""
 
1421
  if $BOOST_SKIP; then
 
1422
    INFO "WARNING! Skipping Boost installation, as requested..."
 
1423
  else
 
1424
    check_package_version_ge_DEB libboost-dev $BOOST_VERSION_MIN
 
1425
    if [ $? -eq 0 ]; then
 
1426
      install_packages_DEB libboost-dev
 
1427
 
 
1428
      boost_version=$(echo `get_package_version_DEB libboost-dev` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
 
1429
 
 
1430
      check_package_DEB libboost-locale$boost_version-dev
 
1431
      if [ $? -eq 0 ]; then
 
1432
        install_packages_DEB libboost-locale$boost_version-dev libboost-filesystem$boost_version-dev \
 
1433
                             libboost-regex$boost_version-dev libboost-system$boost_version-dev \
 
1434
                             libboost-thread$boost_version-dev
 
1435
      else
 
1436
        compile_Boost
 
1437
      fi
 
1438
    else
 
1439
      compile_Boost
 
1440
    fi
 
1441
  fi
 
1442
 
 
1443
  INFO ""
 
1444
  if $OCIO_SKIP; then
 
1445
    INFO "WARNING! Skipping OpenColorIO installation, as requested..."
 
1446
  else
 
1447
    check_package_version_ge_DEB libopencolorio-dev $OCIO_VERSION_MIN
 
1448
    if [ $? -eq 0 ]; then
 
1449
      install_packages_DEB libopencolorio-dev
 
1450
    else
 
1451
      compile_OCIO
 
1452
    fi
 
1453
  fi
 
1454
 
 
1455
  INFO ""
 
1456
  if $OIIO_SKIP; then
 
1457
    INFO "WARNING! Skipping OpenImageIO installation, as requested..."
 
1458
  else
 
1459
    check_package_version_ge_DEB libopenimageio-dev $OIIO_VERSION_MIN
 
1460
    if [ $? -eq 0 ]; then
 
1461
      install_packages_DEB libopenimageio-dev
 
1462
    else
 
1463
      compile_OIIO
 
1464
    fi
 
1465
  fi
 
1466
 
 
1467
  if $WITH_OSL; then
 
1468
    have_llvm=false
 
1469
 
 
1470
    if $LLVM_SKIP; then
 
1471
      INFO "WARNING! Skipping LLVM installation, as requested (this also implies skipping OSL!)..."
 
1472
    else
 
1473
      INFO ""
 
1474
      check_package_DEB llvm-$LLVM_VERSION-dev
 
1475
      if [ $? -eq 0 ]; then
 
1476
        install_packages_DEB llvm-$LLVM_VERSION-dev clang
 
1477
        have_llvm=true
 
1478
        LLVM_VERSION_FOUND=$LLVM_VERSION
 
1479
      else
 
1480
        check_package_DEB llvm-$LLVM_VERSION_MIN-dev
 
1481
        if [ $? -eq 0 ]; then
 
1482
          install_packages_DEB llvm-$LLVM_VERSION_MIN-dev clang
 
1483
          have_llvm=true
 
1484
          LLVM_VERSION_FOUND=$LLVM_VERSION_MIN
 
1485
        else
 
1486
          install_packages_DEB libffi-dev
 
1487
          # LLVM can't find the debian ffi header dir
 
1488
          _FFI_INCLUDE_DIR=`dpkg -L libffi-dev | grep -e ".*/ffi.h" | sed -r 's/(.*)\/ffi.h/\1/'`
 
1489
          INFO ""
 
1490
          compile_LLVM
 
1491
          have_llvm=true
 
1492
          LLVM_VERSION_FOUND=$LLVM_VERSION
 
1493
        fi
 
1494
      fi
 
1495
    fi
 
1496
 
 
1497
    if $OSL_SKIP; then
 
1498
      INFO "WARNING! Skipping OpenShadingLanguage installation, as requested..."
 
1499
    else
 
1500
      if $have_llvm; then
 
1501
        INFO ""
 
1502
        install_packages_DEB flex bison libtbb-dev git
 
1503
        # No package currently!
 
1504
        INFO ""
 
1505
        compile_OSL
 
1506
      fi
 
1507
    fi
 
1508
  fi
 
1509
 
 
1510
  if $WITH_OPENCOLLADA; then
 
1511
    if $OPENCOLLADA_SKIP; then
 
1512
      INFO "WARNING! Skipping OpenCOLLADA installation, as requested..."
 
1513
    else
 
1514
      INFO ""
 
1515
      install_packages_DEB git libpcre3-dev libxml2-dev
 
1516
      # Find path to libxml shared lib...
 
1517
      _XML2_LIB=`dpkg -L libxml2-dev | grep -e ".*/libxml2.so"`
 
1518
      # No package
 
1519
      INFO ""
 
1520
      compile_OpenCOLLADA
 
1521
    fi
 
1522
  fi
 
1523
 
 
1524
  INFO ""
 
1525
  if $FFMPEG_SKIP; then
 
1526
    INFO "WARNING! Skipping FFMpeg installation, as requested..."
 
1527
  else
 
1528
#    XXX Debian features libav packages as ffmpeg, those are not really compatible with blender code currently :/
 
1529
#        So for now, always build our own ffmpeg.
 
1530
#    check_package_DEB ffmpeg
 
1531
#    if [ $? -eq 0 ]; then
 
1532
#      install_packages_DEB ffmpeg
 
1533
#      ffmpeg_version=`get_package_version_DEB ffmpeg`
 
1534
#      INFO "ffmpeg version: $ffmpeg_version"
 
1535
#      if [ ! -z "$ffmpeg_version" ]; then
 
1536
#        if  dpkg --compare-versions $ffmpeg_version gt 0.7.2; then
 
1537
#          install_packages_DEB libavfilter-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswscale-dev
 
1538
#        else
 
1539
#          compile_FFmpeg
 
1540
#        fi
 
1541
#      fi
 
1542
#    fi
 
1543
    compile_FFmpeg
 
1544
  fi
 
1545
}
 
1546
 
 
1547
 
 
1548
 
 
1549
get_package_version_RPM() {
 
1550
  rpm_flavour
 
1551
  if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
 
1552
    yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'
 
1553
  elif [ $RPM = "SUSE" ]; then
 
1554
    zypper info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+).*/\1/'
 
1555
  fi  
 
1556
}
 
1557
 
 
1558
check_package_RPM() {
 
1559
  rpm_flavour
 
1560
  if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
 
1561
    r=`yum info $1 | grep -c 'Summary'`
 
1562
  elif [ $RPM = "SUSE" ]; then
 
1563
    r=`zypper info $1 | grep -c 'Summary'`
 
1564
  fi
 
1565
 
 
1566
  if [ $r -ge 1 ]; then
 
1567
    return 0
 
1568
  else
 
1569
    return 1
 
1570
  fi
 
1571
}
 
1572
 
 
1573
check_package_version_match_RPM() {
 
1574
  v=`get_package_version_RPM $1`
 
1575
 
 
1576
  if [ -z "$v" ]; then
 
1577
    return 1
 
1578
  fi
 
1579
 
 
1580
  version_match $v $2
 
1581
  return $?
 
1582
}
 
1583
 
 
1584
check_package_version_ge_RPM() {
 
1585
  v=`get_package_version_RPM $1`
 
1586
 
 
1587
  if [ -z "$v" ]; then
 
1588
    return 1
 
1589
  fi
 
1590
 
 
1591
  version_ge $v $2
 
1592
  return $?
 
1593
}
 
1594
 
 
1595
install_packages_RPM() {
 
1596
  rpm_flavour
 
1597
  if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
 
1598
    sudo yum install -y $@
 
1599
    if [ $? -ge 1 ]; then
 
1600
      ERROR "yum failed to install requested packages, exiting."
 
1601
      exit 1
 
1602
    fi
 
1603
 
 
1604
  elif [ $RPM = "SUSE" ]; then
 
1605
    sudo zypper --non-interactive install --auto-agree-with-licenses $@
 
1606
    if [ $? -ge 1 ]; then
 
1607
      ERROR "zypper failed to install requested packages, exiting."
 
1608
      exit 1
 
1609
    fi
 
1610
  fi
 
1611
}
 
1612
 
 
1613
install_RPM() {
 
1614
  INFO ""
 
1615
  INFO "Installing dependencies for RPM-based distribution"
 
1616
  INFO ""
 
1617
  INFO "`eval _echo "$COMMON_INFO"`"
 
1618
  INFO ""
 
1619
 
 
1620
  read -p "Do you want to continue (Y/n)?"
 
1621
  [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" != "y" ] && exit
 
1622
 
 
1623
  # Enable non-free repositories for all flavours
 
1624
  rpm_flavour
 
1625
  if [ $RPM = "FEDORA" ]; then
 
1626
    sudo yum -y localinstall --nogpgcheck \
 
1627
    http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm \
 
1628
    http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
 
1629
 
 
1630
    sudo yum -y update
 
1631
 
 
1632
    # Install cmake now because of difference with RHEL
 
1633
    sudo yum -y install cmake
 
1634
 
 
1635
  elif [ $RPM = "RHEL" ]; then
 
1636
    sudo yum -y localinstall --nogpgcheck \
 
1637
    http://download.fedoraproject.org/pub/epel/6/$(uname -i)/epel-release-6-8.noarch.rpm \
 
1638
    http://download1.rpmfusion.org/free/el/updates/6/$(uname -i)/rpmfusion-free-release-6-1.noarch.rpm \
 
1639
    http://download1.rpmfusion.org/nonfree/el/updates/6/$(uname -i)/rpmfusion-nonfree-release-6-1.noarch.rpm
 
1640
 
 
1641
    sudo yum -y update
 
1642
 
 
1643
    # Install cmake 2.8 from other repo
 
1644
    mkdir -p $SRC
 
1645
    if [ -f $SRC/cmake-2.8.8-4.el6.$(uname -m).rpm ]; then
 
1646
      INFO ""
 
1647
      INFO "Special cmake already installed"
 
1648
    else
 
1649
      curl -O ftp://ftp.pbone.net/mirror/atrpms.net/el6-$(uname -i)/atrpms/testing/cmake-2.8.8-4.el6.$(uname -m).rpm
 
1650
      mv cmake-2.8.8-4.el6.$(uname -m).rpm $SRC/
 
1651
      sudo rpm -ihv $SRC/cmake-2.8.8-4.el6.$(uname -m).rpm
 
1652
    fi
 
1653
 
 
1654
  elif [ $RPM = "SUSE" ]; then
 
1655
    _suse_rel="`grep VERSION /etc/SuSE-release | gawk '{print $3}'`"
 
1656
    sudo zypper ar -f http://packman.inode.at/suse/openSUSE_$_suse_rel/ packman
 
1657
 
 
1658
    sudo zypper --non-interactive --gpg-auto-import-keys update --auto-agree-with-licenses
 
1659
  fi
 
1660
 
 
1661
  # These libs should always be available in fedora/suse official repository...
 
1662
  OPENJPEG_DEV="openjpeg-devel"
 
1663
  VORBIS_DEV="libvorbis-devel"
 
1664
  THEORA_DEV="libtheora-devel"
 
1665
 
 
1666
  _packages="gcc gcc-c++ make scons libpng-devel libtiff-devel \
 
1667
             freetype-devel libX11-devel libXi-devel wget ncurses-devel \
 
1668
             readline-devel $OPENJPEG_DEV openal-soft-devel \
 
1669
             glew-devel yasm $THEORA_DEV $VORBIS_DEV SDL-devel fftw-devel \
 
1670
             libjpeg-devel patch"
 
1671
 
 
1672
  OPENJPEG_USE=true
 
1673
  VORBIS_USE=true
 
1674
  THEORA_USE=true
 
1675
 
 
1676
  if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
 
1677
 
 
1678
    _packages="$_packages libsqlite3-devel openexr-devel"
 
1679
 
 
1680
    if $WITH_ALL; then
 
1681
      _packages="$_packages jack-audio-connection-kit-devel libspnav-devel"
 
1682
    fi
 
1683
 
 
1684
    INFO ""
 
1685
    install_packages_RPM $_packages
 
1686
 
 
1687
    INFO ""
 
1688
    X264_DEV="x264-devel"
 
1689
    check_package_version_ge_RPM $X264_DEV $X264_VERSION_MIN
 
1690
    if [ $? -eq 0 ]; then
 
1691
      install_packages_RPM $X264_DEV
 
1692
      X264_USE=true
 
1693
    fi
 
1694
 
 
1695
    if $WITH_ALL; then
 
1696
      INFO ""
 
1697
      XVID_DEV="xvidcore-devel"
 
1698
      check_package_RPM $XVID_DEV
 
1699
      if [ $? -eq 0 ]; then
 
1700
        install_packages_RPM $XVID_DEV
 
1701
        XVID_USE=true
 
1702
      fi
 
1703
 
 
1704
      INFO ""
 
1705
      MP3LAME_DEV="lame-devel"
 
1706
      check_package_RPM $MP3LAME_DEV
 
1707
      if [ $? -eq 0 ]; then
 
1708
        install_packages_RPM $MP3LAME_DEV
 
1709
        MP3LAME_USE=true
 
1710
      fi
 
1711
    fi
 
1712
 
 
1713
  elif [ $RPM = "SUSE" ]; then
 
1714
 
 
1715
    _packages="$_packages cmake sqlite3-devel libopenexr-devel"
 
1716
 
 
1717
    if $WITH_ALL; then
 
1718
      _packages="$_packages libjack-devel libspnav-devel"
 
1719
    fi
 
1720
 
 
1721
    INFO ""
 
1722
    install_packages_RPM $_packages
 
1723
 
 
1724
    INFO ""
 
1725
    X264_DEV="libx264-devel"
 
1726
    check_package_version_ge_RPM $X264_DEV $X264_VERSION_MIN
 
1727
    if [ $? -eq 0 ]; then
 
1728
      install_packages_RPM $X264_DEV
 
1729
      X264_USE=true
 
1730
    fi
 
1731
 
 
1732
    if $WITH_ALL; then
 
1733
      INFO ""
 
1734
      XVID_DEV="libxvidcore-devel"
 
1735
      check_package_RPM $XVID_DEV
 
1736
      if [ $? -eq 0 ]; then
 
1737
        install_packages_RPM $XVID_DEV
 
1738
        XVID_USE=true
 
1739
      fi
 
1740
 
 
1741
      INFO ""
 
1742
      MP3LAME_DEV="libmp3lame-devel"
 
1743
      check_package_RPM $MP3LAME_DEV
 
1744
      if [ $? -eq 0 ]; then
 
1745
        install_packages_RPM $MP3LAME_DEV
 
1746
        MP3LAME_USE=true
 
1747
      fi
 
1748
    fi
 
1749
  fi
 
1750
 
 
1751
  if $WITH_ALL; then
 
1752
    INFO ""
 
1753
    VPX_DEV="libvpx-devel"
 
1754
    check_package_version_ge_RPM $VPX_DEV $VPX_VERSION_MIN
 
1755
    if [ $? -eq 0 ]; then
 
1756
      install_packages_RPM $VPX_DEV
 
1757
      VPX_USE=true
 
1758
    fi
 
1759
 
 
1760
    INFO ""
 
1761
    SCHRO_DEV="schroedinger-devel"
 
1762
    check_package_RPM $SCHRO_DEV
 
1763
    if [ $? -eq 0 ]; then
 
1764
      install_packages_RPM $SCHRO_DEV
 
1765
      SCHRO_USE=true
 
1766
    fi
 
1767
  fi
 
1768
 
 
1769
  INFO ""
 
1770
  if $PYTHON_SKIP; then
 
1771
    INFO "WARNING! Skipping Python installation, as requested..."
 
1772
  else
 
1773
    check_package_version_match_RPM python3-devel $PYTHON_VERSION_MIN
 
1774
    if [ $? -eq 0 ]; then
 
1775
      install_packages_RPM python3-devel
 
1776
      INFO ""
 
1777
      if $NUMPY_SKIP; then
 
1778
        INFO "WARNING! Skipping NumPy installation, as requested..."
 
1779
      else
 
1780
        check_package_version_match_RPM python3-numpy $NUMPY_VERSION_MIN
 
1781
        if [ $? -eq 0 ]; then
 
1782
          install_packages_RPM python3-numpy
 
1783
        else
 
1784
          INFO "WARNING! Sorry, using python package but no numpy package available!"
 
1785
        fi
 
1786
      fi
 
1787
    else
 
1788
      compile_Python
 
1789
      INFO ""
 
1790
      if $NUMPY_SKIP; then
 
1791
        INFO "WARNING! Skipping NumPy installation, as requested..."
 
1792
      else
 
1793
        compile_Numpy
 
1794
      fi
 
1795
    fi
 
1796
  fi
 
1797
 
 
1798
  INFO ""
 
1799
  if $BOOST_SKIP; then
 
1800
    INFO "WARNING! Skipping Boost installation, as requested..."
 
1801
  else
 
1802
    check_package_version_ge_RPM boost-devel $BOOST_VERSION
 
1803
    if [ $? -eq 0 ]; then
 
1804
      install_packages_RPM boost-devel
 
1805
    else
 
1806
      compile_Boost
 
1807
    fi
 
1808
  fi
 
1809
 
 
1810
  INFO ""
 
1811
  if $OCIO_SKIP; then
 
1812
    INFO "WARNING! Skipping OpenColorIO installation, as requested..."
 
1813
  else
 
1814
    check_package_version_ge_RPM OpenColorIO-devel $OCIO_VERSION_MIN
 
1815
    if [ $? -eq 0 ]; then
 
1816
      install_packages_RPM OpenColorIO-devel
 
1817
    else
 
1818
      compile_OCIO
 
1819
    fi
 
1820
  fi
 
1821
 
 
1822
  INFO ""
 
1823
  if $OIIO_SKIP; then
 
1824
    INFO "WARNING! Skipping OpenImageIO installation, as requested..."
 
1825
  else
 
1826
    check_package_version_ge_RPM OpenImageIO-devel $OIIO_VERSION_MIN
 
1827
    if [ $? -eq 0 ]; then
 
1828
      install_packages_RPM OpenImageIO-devel
 
1829
    else
 
1830
      compile_OIIO
 
1831
    fi
 
1832
  fi
 
1833
 
 
1834
  if $WITH_OSL; then
 
1835
    have_llvm=false
 
1836
 
 
1837
    INFO ""
 
1838
    if $LLVM_SKIP; then
 
1839
      INFO "WARNING! Skipping LLVM installation, as requested (this also implies skipping OSL!)..."
 
1840
    else
 
1841
      check_package_RPM llvm-$LLVM_VERSION-devel
 
1842
      if [ $? -eq 0 ]; then
 
1843
        install_packages_RPM llvm-$LLVM_VERSION-devel clang
 
1844
        have_llvm=true
 
1845
        LLVM_VERSION_FOUND=$LLVM_VERSION
 
1846
      else
 
1847
        #
 
1848
        # Better to compile it than use minimum version from repo...
 
1849
        #
 
1850
      install_packages_RPM libffi-devel
 
1851
      # LLVM can't find the fedora ffi header dir...
 
1852
      _FFI_INCLUDE_DIR=`rpm -ql libffi-devel | grep -e ".*/ffi.h" | sed -r 's/(.*)\/ffi.h/\1/'`
 
1853
      INFO ""
 
1854
      compile_LLVM
 
1855
      have_llvm=true
 
1856
      LLVM_VERSION_FOUND=$LLVM_VERSION
 
1857
      fi
 
1858
    fi
 
1859
 
 
1860
    if $OSL_SKIP; then
 
1861
      INFO ""
 
1862
      INFO "WARNING! Skipping OpenShadingLanguage installation, as requested..."
 
1863
    else
 
1864
      if $have_llvm; then
 
1865
        # No package currently!
 
1866
        INFO ""
 
1867
        install_packages_RPM flex bison git
 
1868
        if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
 
1869
          install_packages_RPM tbb-devel
 
1870
        fi
 
1871
        INFO ""
 
1872
        compile_OSL
 
1873
      fi
 
1874
    fi
 
1875
  fi
 
1876
 
 
1877
  if $WITH_OPENCOLLADA; then
 
1878
    if $OPENCOLLADA_SKIP; then
 
1879
      INFO "WARNING! Skipping OpenCOLLADA installation, as requested..."
 
1880
    else
 
1881
      INFO ""
 
1882
      install_packages_RPM pcre-devel libxml2-devel git
 
1883
      # Find path to libxml shared lib...
 
1884
      _XML2_LIB=`rpm -ql libxml2-devel | grep -e ".*/libxml2.so"`
 
1885
      # No package...
 
1886
      INFO ""
 
1887
      compile_OpenCOLLADA
 
1888
    fi
 
1889
  fi
 
1890
 
 
1891
  INFO ""
 
1892
  if $FFMPEG_SKIP; then
 
1893
    INFO "WARNING! Skipping FFMpeg installation, as requested..."
 
1894
  else
 
1895
    # Always for now, not sure which packages should be installed
 
1896
    compile_FFmpeg
 
1897
  fi
 
1898
}
 
1899
 
 
1900
 
 
1901
 
 
1902
print_info_ffmpeglink_DEB() {
 
1903
  if $ALL_STATIC; then
 
1904
    dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.a" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", $0); nlines++ }'
 
1905
  else
 
1906
    dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
 
1907
  fi
 
1908
}
 
1909
 
 
1910
print_info_ffmpeglink_RPM() {
 
1911
#  # XXX No static libs...
 
1912
#  if $ALL_STATIC; then
 
1913
#    rpm -ql $_packages | grep -e ".*\/lib[^\/]\+\.a" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", $0); nlines++ }'
 
1914
#  else
 
1915
  rpm -ql $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
 
1916
#  fi
 
1917
}
 
1918
 
 
1919
print_info_ffmpeglink() {
 
1920
  # This func must only print a ';'-separated list of libs...
 
1921
  if [ -z "$DISTRO" ]; then
 
1922
    ERROR "Failed to detect distribution type"
 
1923
    exit 1
 
1924
  fi
 
1925
 
 
1926
  # Create list of packages from which to get libs names...
 
1927
  _packages=""
 
1928
 
 
1929
  if $THEORA_USE; then
 
1930
    _packages="$_packages $THEORA_DEV"
 
1931
  fi
 
1932
 
 
1933
  if $VORBIS_USE; then
 
1934
    _packages="$_packages $VORBIS_DEV"
 
1935
  fi
 
1936
 
 
1937
  if $XVID_USE; then
 
1938
    _packages="$_packages $XVID_DEV"
 
1939
  fi
 
1940
 
 
1941
  if $VPX_USE; then
 
1942
    _packages="$_packages $VPX_DEV"
 
1943
  fi
 
1944
 
 
1945
  if $MP3LAME_USE; then
 
1946
    _packages="$_packages $MP3LAME_DEV"
 
1947
  fi
 
1948
 
 
1949
  if $X264_USE; then
 
1950
    _packages="$_packages $X264_DEV"
 
1951
  fi
 
1952
 
 
1953
  if $OPENJPEG_USE; then
 
1954
    _packages="$_packages $OPENJPEG_DEV"
 
1955
  fi
 
1956
 
 
1957
  if $SCHRO_USE; then
 
1958
    _packages="$_packages $SCHRO_DEV"
 
1959
  fi
 
1960
 
 
1961
  if [ "$DISTRO" = "DEB" ]; then
 
1962
    print_info_ffmpeglink_DEB
 
1963
  elif [ "$DISTRO" = "RPM" ]; then
 
1964
    print_info_ffmpeglink_RPM
 
1965
#  elif [ "$DISTRO" = "ARCH" ]; then
 
1966
#    print_info_ffmpeglink_ARCH
 
1967
  # XXX TODO!
 
1968
  else INFO "<Could not determine additional link libraries needed for ffmpeg, replace this by valid list of libs...>"
 
1969
  fi
 
1970
}
 
1971
 
 
1972
print_info() {
 
1973
  INFO ""
 
1974
  INFO "If you're using CMake add this to your configuration flags:"
 
1975
 
 
1976
  _buildargs=""
 
1977
 
 
1978
  if $ALL_STATIC; then
 
1979
    _1="-D WITH_STATIC_LIBS=ON"
 
1980
    # XXX Force linking with shared SDL lib!
 
1981
    _2="-D SDL_LIBRARY='libSDL.so;-lpthread'"
 
1982
    INFO "  $_1"
 
1983
    INFO "  $_2"
 
1984
    _buildargs="$_buildargs $_1 $_2"
 
1985
  fi
 
1986
 
 
1987
  if [ -d $INST/boost ]; then
 
1988
    _1="-D BOOST_ROOT=$INST/boost"
 
1989
    _2="-D Boost_NO_SYSTEM_PATHS=ON"
 
1990
    INFO "  $_1"
 
1991
    INFO "  $_2"
 
1992
    _buildargs="$_buildargs $_1 $_2"
 
1993
  elif $ALL_STATIC; then
 
1994
    _1="-D Boost_USE_ICU=ON"
 
1995
    INFO "  $_1"
 
1996
    _buildargs="$_buildargs $_1"
 
1997
  fi
 
1998
 
 
1999
  if [ -d $INST/osl -a $WITH_OSL == true ]; then
 
2000
    _1="-D CYCLES_OSL=$INST/osl"
 
2001
    _2="-D WITH_CYCLES_OSL=ON"
 
2002
    _3="-D LLVM_VERSION=$LLVM_VERSION_FOUND"
 
2003
    INFO "  $_1"
 
2004
    INFO "  $_2"
 
2005
    INFO "  $_3"
 
2006
    _buildargs="$_buildargs $_1 $_2 $_3"
 
2007
    if [ -d $INST/llvm ]; then
 
2008
      _1="-D LLVM_DIRECTORY=$INST/llvm"
 
2009
      _2="-D LLVM_STATIC=ON"
 
2010
      INFO "  $_1"
 
2011
      INFO "  $_2"
 
2012
      _buildargs="$_buildargs $_1 $_2"
 
2013
    fi
 
2014
  fi
 
2015
 
 
2016
  if [ -d $INST/opencollada -a $WITH_OPENCOLLADA == true ]; then
 
2017
    _1="-D WITH_OPENCOLLADA=ON"
 
2018
    INFO "  $_1"
 
2019
    _buildargs="$_buildargs $_1"
 
2020
    if $ALL_STATIC; then
 
2021
      _1="-D XML2_LIBRARY=$_XML2_LIB"
 
2022
      INFO "  $_1"
 
2023
      _buildargs="$_buildargs $_1"
 
2024
    fi
 
2025
  fi
 
2026
 
 
2027
  if [ -d $INST/ffmpeg ]; then
 
2028
    _1="-D WITH_CODEC_FFMPEG=ON"
 
2029
    _2="-D FFMPEG=$INST/ffmpeg"
 
2030
    _3="-D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;rt;`print_info_ffmpeglink`'"
 
2031
    INFO "  $_1"
 
2032
    INFO "  $_2"
 
2033
    INFO "  $_3"
 
2034
    _buildargs="$_buildargs $_1 $_2 $_3"
 
2035
  fi
 
2036
 
 
2037
  INFO ""
 
2038
  INFO "Or even simpler, just run (in your blender-source dir):"
 
2039
  INFO "  make -j$THREADS BUILD_CMAKE_ARGS=\"$_buildargs\""
 
2040
 
 
2041
  INFO ""
 
2042
  INFO "If you're using SCons add this to your user-config:"
 
2043
 
 
2044
  if [ -d $INST/python-$PYTHON_VERSION_MIN ]; then
 
2045
    INFO "BF_PYTHON = '$INST/python-$PYTHON_VERSION_MIN'"
 
2046
    INFO "BF_PYTHON_ABI_FLAGS = 'm'"
 
2047
  fi
 
2048
 
 
2049
  if [ -d $INST/ocio ]; then
 
2050
    INFO "BF_OCIO = '$INST/ocio'"
 
2051
  fi
 
2052
 
 
2053
  if [ -d $INST/oiio ]; then
 
2054
    INFO "BF_OIIO = '$INST/oiio'"
 
2055
  fi
 
2056
 
 
2057
  if [ -d $INST/boost ]; then
 
2058
    INFO "BF_BOOST = '$INST/boost'"
 
2059
    INFO "WITH_BF_BOOST = True"
 
2060
  fi
 
2061
 
 
2062
  if [ -d $INST/ffmpeg ]; then
 
2063
    INFO "BF_FFMPEG = '$INST/ffmpeg'"
 
2064
    _ffmpeg_list_sep=" "
 
2065
    INFO "BF_FFMPEG_LIB = 'avformat avcodec swscale avutil avdevice `print_info_ffmpeglink`'"
 
2066
  fi
 
2067
 
 
2068
  INFO ""
 
2069
  INFO ""
 
2070
  INFO "WARNING: If this script had to build boost into $INST, and you are dynamically linking "
 
2071
  INFO "         blender against it, you will have to run those commands as root user:"
 
2072
  INFO ""
 
2073
  INFO "    echo \"$INST/boost/lib\" > /etc/ld.so.conf.d/boost.conf"
 
2074
  INFO "    ldconfig"
 
2075
  INFO ""
 
2076
}
 
2077
 
 
2078
# Detect distributive type used on this machine
 
2079
detect_distro
 
2080
 
 
2081
if [ -z "$DISTRO" ]; then
 
2082
  ERROR "Failed to detect distribution type"
 
2083
  exit 1
 
2084
elif [ "$DISTRO" = "DEB" ]; then
 
2085
  install_DEB
 
2086
elif [ "$DISTRO" = "RPM" ]; then
 
2087
  install_RPM
 
2088
#elif [ "$DISTRO" = "ARCH" ]; then
 
2089
#  install_ARCH
 
2090
fi
 
2091
 
 
2092
print_info | tee BUILD_NOTES.txt
 
2093
INFO ""
 
2094
INFO "This information has been written to BUILD_NOTES.txt"
 
2095
INFO ""
 
2096
 
 
2097
# Switch back to user language.
 
2098
LANG=LANG_BACK
 
2099
export LANG