summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c5f36026060b3ad77680f49bb3403ca6edb94ae1 (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
# Maintainer: Alex Sarum <rum.274.4 at gmail dot com>
# Contributor: Levente Polyak <anthraxx[at]archlinux[dot]org>

pkgbase=unicorn-git
pkgname=('unicorn-git' 'python-unicorn-git' 'python2-unicorn-git' 'ruby-unicorn-git')
pkgver=1.0.2.rc3.r54.g94c94cdf
pkgrel=1
pkgdesc='Lightweight, multi-platform, multi-architecture CPU emulator framework based on QEMU'
url='http://www.unicorn-engine.org'
arch=('i686' 'x86_64')
license=('GPL2')
makedepends=('git' 'python' 'python2' 'python-setuptools' 'python2-setuptools' 'ruby')
options=('staticlibs' '!emptydirs')
source=(${pkgbase}::git+https://github.com/unicorn-engine/unicorn)
sha512sums=('SKIP')

pkgver() {
  cd ${pkgname}
  git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd ${pkgbase}
  sed 's|-O3|-O2|g' -i Makefile qemu/configure
  sed 's|-g ||g' -i qemu/configure
  sed 's|UNICORN_DEBUG ?= yes|UNICORN_DEBUG ?= no|g' -i config.mk
  cp -ra bindings/python{,2}
  sed -r 's|(python)$|\12|' -i bindings/python2/*.py
}

build() {
  cd ${pkgbase}
  make
  (cd bindings
    python const_generator.py python
    python const_generator.py ruby
  )
  (cd bindings/python
    python setup.py build
  )
  (cd bindings/python2
    python2 setup.py build
  )
  (cd bindings/ruby/unicorn_gem
    gem build unicorn-engine.gemspec
  )
}

check() {
  cd ${pkgbase}
  # Tests are not supported right now, hope they get some love soon
  # checkdepends=('cmocka')
  # make test
}

package_unicorn-git() {
  depends=('glibc')
  provides=('unicorn')
  conflicts=('unicorn')
  cd ${pkgbase}
  make DESTDIR="${pkgdir}" install
  install -Dm 644 samples/*.c -t "${pkgdir}/usr/share/doc/${pkgname}/samples"
}

package_python-unicorn-git() {
  depends=('python' 'unicorn' 'python-setuptools')
  provides=('python-unicorn')
  conflicts=('python-unicorn')
  cd ${pkgbase}/bindings/python
  python setup.py install --root="${pkgdir}" -O1 --skip-build
  install -Dm 644 sample* shellcode.py -t "${pkgdir}/usr/share/doc/${pkgname}/samples"
}

package_python2-unicorn-git() {
  depends=('python2' 'unicorn' 'python2-setuptools')
  provides=('python2-unicorn')
  conflicts=('python2-unicorn')
  cd ${pkgbase}/bindings/python2
  python2 setup.py install --root="${pkgdir}" -O1 --skip-build
  install -Dm 644 sample* shellcode.py -t "${pkgdir}/usr/share/doc/${pkgname}/samples"
}

package_ruby-unicorn-git() {
  depends=('ruby' 'unicorn')
  provides=('ruby-unicorn')
  conflicts=('ruby-unicorn')
  cd ${pkgbase}/bindings/ruby/unicorn_gem
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" \
    -n "${pkgdir}/usr/bin" unicorn-*.gem -- --with-opt-include="${srcdir}/${pkgbase}/include"
  rm -r "${pkgdir}/${_gemdir}"/{cache/unicorn-*.gem,build_info}
  find "${pkgdir}/${_gemdir}" \( -name 'mkmf.log' -or -name 'gem_make.out' \) -delete
  install -Dm 644 ../sample* -t "${pkgdir}/usr/share/doc/${pkgname}/samples"
}

# vim: ts=2 sw=2 et: