summaryrefslogtreecommitdiff
path: root/libre/openshadinglanguage/PKGBUILD
blob: f5d2a43b87a5eac48cd14106b79e7d5147dbf45d (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
# Maintainer: Márcio Silva <coadde@parabola.nu>
# based of Arch pkg

pkgname=openshadinglanguage
pkgver=1.3.3
pkgrel=1
pkgdesc="Advanced shading language for production GI renderers (built for the blender-libre package)"
arch=(
  mips64el
  x86_64
  i686
)
url=https://github.com/imageworks/OpenShadingLanguage
license=custom
depends=(
  openimageio
  openexr
  freetype2
  libpng
  libtiff
  boost-libs
  llvm
  zlib
)
makedepends=(
  boost
  clang
  cmake
)
source=(
  https://github.com/imageworks/OpenShadingLanguage/archive/Release-${pkgver}.tar.gz
  llvm.patch
)
md5sums=(
  77e2261b6b4e0aabdc13b3bb58caeae1a603dbd6a674048631284e150795ecdc4c0d6fd50e7898bda835024bcfeba3da5d89dea8b1ceb3f8fd893087001cc756
  8d62aa04426cb93c9239845a6eb685081a8760a1731cffb9f075cc294ab8b426c369347ae90a473b0dfbcf4d04a2be44e786792c8ce79fe82c11dc81acf6b3a2
)

prepare() {
  cd OpenShadingLanguage-Release-$pkgver

  msg 'renaming wrong OS name'
  _OS=$(uname -o)
  [[ $_OS == GNU ]] &&\
    sed -i 's|linux|GNU|i;
           ' src/{cmake/platform.cmake,make/detectplatform.mk}
  [[ $_OS == GNU/Linux ]] &&\
    sed -i 's|[{]uname[}][,]linux]|{uname -o},GNU/Linux|;\|platform| s|linux|GNU/Linux|i
           ' src/{cmake/platform.cmake,make/detectplatform.mk}
  [[ $_OS == GNU/kFreeBSD ]] &&\
    sed -i '\|STREQUAL| s|FreeBSD|kFreeBSD|;\|platform| s|freebsd|GNU/kFreeBSD|i
           ' src/cmake/platform.cmake
    sed -i 's|[{]uname[}][,]linux]|{uname -o},GNU/kFreeBSD|;\|platform| s|linux|GNU/kFreeBSD|i
           ' src/make/detectplatform.mk
  sed -i 's|Linux/OSX|GNU/BSD|' src/include/export.h
  
  # LLVM 3.4 build fix
  # based of "https://github.com/imageworks/OpenShadingLanguage/pull/320.patch"
  patch -Np1 < $srcdir/llvm.patch

  # fix include paths
  sed -i 's|oslconfig.h|../include/oslconfig.h|
          s|dual.h|../include/dual.h|
          s|dual_vec.h|../include/dual_vec.h|
         ' src/liboslexec/llvm_ops.cpp
  sed -i 's|oslexec.h|../include/oslexec.h|
          s|oslclosure.h|../include/oslclosure.h|
          s|osl_pvt.h|../include/osl_pvt.h|
         ' src/liboslexec/oslexec_pvt.h

  cd src

  [[ -d build ]] && rm -r build
  mkdir build
}

build() {
  cd OpenShadingLanguage-Release-$pkgver/src/build

  cmake .. \
    -DCMAKE_BUILD_TYPE=Release\
    -DCMAKE_INSTALL_PREFIX=/usr\
    -DLLVM_STATIC=OFF
  make
}

package() {
  cd OpenShadingLanguage-Release-$pkgver/src/build

  make DESTDIR=$pkgdir install

  mkdir -p $pkgdir/usr/share/OSL/
  mkdir -p $pkgdir/usr/share/licenses/$pkgname
  mv $pkgdir/usr/{CHANGES,README.md,INSTALL} $pkgdir/usr/share/OSL
  mv $pkgdir/usr/doc                         $pkgdir/usr/share/OSL/doc
  mv $pkgdir/usr/shaders                     $pkgdir/usr/share/OSL/shaders
  mv $pkgdir/usr/LICENSE                     $pkgdir/usr/share/licenses/$pkgname
}

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