summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7b0ff954fef0d8963e5ea9a4096616a5c1af9ab1 (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
# Maintainer: Andrew Sun <adsun701 at gmail dot com>
# Contributor: Florian Pritz <bluewind at xinu dot at>
# Contributor: Jelle van der Waa <jelle@ at vdwaa dot nl>
# Contributor: Hugo Osvaldo Barrera <hugo at barrera dot io>
# Contributor: Matthias Maennich <arch at maennich dot net>

pkgbase=shiboken
pkgname=(python{2,}-shiboken shiboken)
pkgver=1.2.4
pkgrel=8
arch=('x86_64')
license=('LGPL')
url="http://www.pyside.org"
makedepends=('cmake' 'python2' 'python' 'qt4' 'libxslt')
source=("$pkgbase-$pkgver.tar.gz::https://github.com/PySide/Shiboken/archive/$pkgver.tar.gz"
        support-new-python.diff)
md5sums=('c284197d06ad25d78009ff55f18dd512'
         '84844a6459a5fccb3ec2d6418a1af3fd')

prepare(){
    cd "$srcdir/Shiboken-$pkgver"
    patch -p1 -i "$srcdir/support-new-python.diff"
}

build(){
    cd "$srcdir/Shiboken-$pkgver"
    # build python2
    mkdir -p build-py2 && cd build-py2
    _ver2=$(python2 -c "import platform; print(platform.python_version())")
    cmake ../ -DCMAKE_INSTALL_PREFIX=/usr  \
              -DBUILD_TESTS=OFF            \
              -DPYTHON_EXECUTABLE=/usr/bin/python2 \
              -DQT_QMAKE_EXECUTABLE=qmake-qt4
    make

    # build python3
    cd "$srcdir/Shiboken-$pkgver"
    mkdir -p build-py3 && cd build-py3

    _ver3=$(python -c "import platform; print(platform.python_version())")
    declare -a _extra_library_opt
    declare -a _extra_include_opt
    if [[ ${_ver3//./} -lt 380 ]]; then
        _includedir=/usr/include/python${_ver3%.*}m
        _library=/usr/lib/libpython${_ver3%.*}m.so
        _extra_library_opt+=("-DPYTHON3_LIBRARIES=${_library}")
        _extra_include_opt+=("-DPYTHON3_INCLUDE_DIRS=${_includedir}")
    else
        _includedir=/usr/include/python${_ver3%.*}
        _library=/usr/lib/libpython${_ver3%.*}.so
        _extra_library_opt+=("-DPYTHON3_LIBRARY=${_library}")
        _extra_include_opt+=("-DPYTHON3_INCLUDE_DIR=${_includedir}")
    fi

    cmake     -DCMAKE_INSTALL_PREFIX=/usr  \
              -DBUILD_TESTS=OFF            \
              -DUSE_PYTHON3=yes            \
              "${_extra_library_opt[@]}"   \
              "${_extra_include_opt[@]}"   \
              -DQT_QMAKE_EXECUTABLE=qmake-qt4 \
              ..
    make
}

package_shiboken() {
  pkgdesc="CPython bindings generator for C++ libraries"
  depends=(python qt4 libxslt)
  optdepends=("python2-shiboken: for compilation against python2"
              "python-shiboken: for compilation against python")

  # Header files, /usr/bin/shiboken, pkgconfig, man page
  cd "$srcdir/Shiboken-$pkgver/build-py3"
  make DESTDIR="$pkgdir" install

  cd "$srcdir/Shiboken-$pkgver/build-py2"
  cd data
  install -Dm 644 ShibokenConfig-python2.7.cmake "$pkgdir/usr/lib/cmake/Shiboken-$pkgver/"
  install -Dm 644 shiboken.pc "$pkgdir/usr/lib/pkgconfig/shiboken-py2.pc"

  rm -rf "$pkgdir/usr/lib/python"*
  rm -rf "$pkgdir/usr/lib/libshiboken"*
  rm -rf "$pkgdir/usr/lib/pkgconfig/"
  rm "$pkgdir"/usr/lib/cmake/Shiboken-$pkgver/ShibokenConfig*python*.cmake
}
package_python2-shiboken() {
  pkgdesc="Support library for Python2 bindings"
  depends=("qt4>=4.8" "libxslt" "python2" "shiboken")

  cd "$srcdir/Shiboken-$pkgver/build-py2"
  make DESTDIR="$pkgdir" install

  cd "$srcdir/Shiboken-$pkgver/build-py2"
  cd data
  install -Dm 644 ShibokenConfig-python2.7.cmake "$pkgdir/usr/lib/cmake/Shiboken-$pkgver/"
  mv "$pkgdir"/usr/lib/pkgconfig/shiboken{,-py2}.pc

  rm -rf "$pkgdir"/usr/{include,bin,share}
  rm "$pkgdir/usr/lib/cmake/Shiboken-$pkgver/ShibokenConfigVersion.cmake"
  rm "$pkgdir/usr/lib/cmake/Shiboken-$pkgver/ShibokenConfig.cmake"
}

package_python-shiboken() {
  pkgdesc="Support library for Python bindings"
  depends=("qt4>=4.8" "libxslt" "python" "shiboken")

  cd "$srcdir/Shiboken-$pkgver/build-py3"
  make DESTDIR="$pkgdir" install

  rm -rf "$pkgdir"/usr/{include,bin,share}
  rm "$pkgdir/usr/lib/cmake/Shiboken-$pkgver/ShibokenConfigVersion.cmake"
  rm "$pkgdir/usr/lib/cmake/Shiboken-$pkgver/ShibokenConfig.cmake"
}