summaryrefslogtreecommitdiff
path: root/pcr/mitsuba/PKGBUILD
blob: c0116cd216755d149830cad0d406f5ced0576809 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Maintainer: Márcio Silva <coadde@parabola.nu>

_build_pkg=yes
_build_add=yes

[[ $_build_pkg != yes && $_build_pkg != no ]] && _build_pkg=yes
[[ $_build_add != yes && $_build_add != no ]] && _build_add=yes
[[ $_build_pkg == no  && $_build_add == no ]] && _build_add=yes

_pkgname=mitsuba
_pkgver=0.5.0
_pkgdat=20140225
_pkgrev=2030
_pkgrel=5
_bldname=blender
_bldver=2.71
_bldep=14
_addname=$_bldname-addon-$_pkgname
_addver=0.3.0 # __init__.py:bl_info>version
_adddat=20140722
_addrev=61
_addrel=4
_pyver=3.4

pkgbase=$_pkgname
[[ $_build_pkg == yes ]] && pkgname+=("$_pkgname")
[[ $_build_add == yes ]] && pkgname+=("$_bldname-addon-$_pkgname")
pkgver=$_pkgver.$_pkgdat
pkgrel=$_pkgrel
arch=('i686' 'x86_64' 'mips64el')
url="https://www.$_pkgname-renderer.org"
[[ $_build_pkg == yes ]] && depends=('boost-libs' 'collada-dom' 'glew' 'libxxf86vm' 'openexr' 'qt4' 'xerces-c')
[[ $_build_pkg == yes ]] && makedepends=('boost' 'cmake' 'eigen3' 'mercurial' 'python')
[[ $_build_pkg == yes ]] && source+=("$_pkgname-$_pkgver.$_pkgrev.tar.bz2::${url}/repos/$_pkgname/archive/$_pkgrev.tar.bz2")
[[ $_build_add == yes ]] && source+=("$_addname-$_addver.$_addrev.tar.bz2::${url}/repos/exporters/$_pkgname-$_bldname/archive/$_addrev.tar.bz2"
                                     'http://www.gnu.org/licenses/gpl-2.0.txt')
[[ $_build_pkg == yes ]] && sha512sums+=('cb30ca95ada36bec56aca3af55af19511ae64f05631d3e221308dee6fe04a1de08daab6e89c9025c8f6492731ed586d40d92f2168c5d49a060f31cd0afc7d0a7')
[[ $_build_add == yes ]] && sha512sums+=('cd812c46ccfb4673a5d170c96e4aa8275d136ef4ae300b50944aac69ff646e9118afa78a9a1f22e7b03fcc1e4fa496c889f59d8bf40836e27d023548061a4491'
                                         'aee80b1f9f7f4a8a00dcf6e6ce6c41988dcaedc4de19d9d04460cbfb05d99829ffe8f9d038468eabbfba4d65b38e8dbef5ecf5eb8a1b891d9839cda6c48ee957')

_prepare_mitsuba() {
  msg 'Renaming source dir'
  mv -v $srcdir/$_pkgname-???????????? $srcdir/$_pkgname-$_pkgver.$_pkgrev

  cd $srcdir/$_pkgname-$_pkgver.$_pkgrev

  msg 'renaming wrong OS name'
  _OS=$(uname -o)
  [[ $_OS == GNU ]] && sed -i 's|Linux|GNU|I' src/libcore/plugin.cpp
  [[ $_OS == GNU/Linux ]] && sed -i 's|Linux,|GNU/Linux,|' src/libcore/plugin.cpp
  [[ $_OS == GNU/kFreeBSD ]] && sed -i 's|Linux,|GNU/kFreeBSD,|' src/libcore/plugin.cpp
  sed -i 's|Linux/|Linux,|
          s|Linux|GNU/Linux|
         ' include/$_pkgname/core/{atomic,fstream,random,thread}.h

  msg 'removing Open Source term'
  sed -i 's|free-software/open-source|free-software|
         ' include/$_pkgname/core/quad.h

  [[ -d build ]] && rm -vr build
  mkdir -v build
}

_prepare_blender-addon-mitsuba() {
  msg 'Renaming addon dir'
  mv -v $srcdir/$_pkgname-$_bldname-???????????? $srcdir/$_addname-$_addver.$_addrev
}

prepare() {
  [[ $_build_pkg == yes ]] && _prepare_mitsuba
  [[ $_build_add == yes ]] && _prepare_blender-addon-mitsuba
}

_build_mitsuba() {
  cd $srcdir/$_pkgname-$_pkgver.$_pkgrev/build

  [[ $CARCH == x86_64 ]] && _SSE=ON || _SSE=OFF
  # i686: MTS_SSE disabled

  cmake .. -DCMAKE_INSTALL_PREFIX=/usr\
    -DBoost_PYTHON_LIBRARY=/usr/lib/libboost_python${_pyver::1}.so\
    -DMTS_SSE=$_SSE\
    -DPYTHON_INCLUDE_DIR=/usr/include/python${_pyver}m\
    -DPYTHON_LIBRARY=/usr/lib/libpython${_pyver}m.so
  make
}
[[ $_build_pkg == yes ]] && build() { _build_mitsuba; }

package_mitsuba() {
  pkgdesc='A physically based renderer'
  license=('GPL3')
  optdepends=('python: Python bindings'
              "$_addname: ${_bldname^} addon exporter and renderer")
  install="$_pkgname.install"

  cd $srcdir/$_pkgname-$_pkgver.$_pkgrev/build
  make DESTDIR=$pkgdir install

  b=$pkgdir/usr/share/licenses/$pkgname

  install -vd $b && install -m644 ../doc/license.txt $b/GPL-v3.0

  msg 'fixing files and folders location'
  a=$pkgdir/usr
  b=$srcdir/$_pkgname-$_pkgver.$_pkgrev
  install -vd $a/{bin,lib/python$_pyver/lib-dynload,share/{applications,$_pkgname,pixmaps}}
  install -vm644 $b/data/linux/$_pkgname.desktop           $a/share/applications
  install -vm644 $b/src/mtsgui/resources/${_pkgname}48.png $a/share/pixmaps
  mv -v $a/{m{itsuba,ts{gui,import,srv,util}},bin}
  mv -v $a/lib{$pkgname-{bidir,core,hw,render}.so,}
  mv -v $a/{{data,plugins},share/$_pkgname}
  mv -v $a/{python/mitsuba.so,lib/python$_pyver/lib-dynload}
  mv -v $a/{sdk/include,}
  rmdir -v $a/{python,sdk}
}

package_blender-addon-mitsuba() {
  pkgver=$_addver.$_addrev.v$_bldver
  pkgrel=$_addrel
  pkgdesc="A addon for the ${_bldname^} which allows render and export with Mitsuba (built for the $_bldname package)"
  arch=('any')
  license=('GPL2')
  depends=("$_pkgname>=$_pkgver" "$_pkgname<${_pkgver::1}.$((${_pkgver:2:1}+1)).$((${_pkgver:4}==0))" "$_bldname>=$_bldep:$_bldver" "$_bldname<$(($_bldep+1)):${_bldver::1}.$((${_bldver:2}+1))")
  makedepends=()

  cd $srcdir/$_addname-$_addver.$_addrev

  msg 'fixing binary path'
  sed -i 's|'"'default'"': efutil.find_config_value('"'mitsuba', 'defaults', 'binary_path', ''"')|'"'default'"': '"'/usr/bin'"'|
         ' mtsblend/properties/engine.py

  a=$pkgdir/usr/share/$_bldname/$_bldver/scripts/addons
  b=$pkgdir/usr/share/licenses/$pkgname

  install -vd $a && cp -a mtsblend $a/$_pkgname
  install -vd $b && install -m644 $startdir/gpl-2.0.txt $b/GPL-v2.0
}

# vim:set ts=2 sw=2 et: