archrelease: copy trunk to community-any
[ArchLinux/community.git] / unicorn / repos / community-x86_64 / PKGBUILD
blobe1df73d003d1ee419231eabcd20dcf98d3a6d8be
1 # Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
2 # Maintainer: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>
4 pkgbase=unicorn
5 pkgname=('unicorn' 'python-unicorn' 'ruby-unicorn-engine')
6 pkgver=2.0.1
7 pkgrel=2
8 pkgdesc='Lightweight, multi-platform, multi-architecture CPU emulator framework based on QEMU'
9 url='https://www.unicorn-engine.org'
10 arch=('x86_64')
11 license=('GPL2')
12 makedepends=('cmake' 'python' 'python-setuptools' 'ruby' 'ruby-rdoc')
13 checkdepends=('cmocka')
14 options=('!emptydirs')
15 source=(https://github.com/unicorn-engine/unicorn/archive/${pkgver}/${pkgbase}-${pkgver}.tar.gz)
16 sha512sums=('4249d33d38614ea1ca51e38c7838cb276306100aa44c65ad1b3e39304e4b856ac643a9c6f9d13678fc07bea58989a08b64653d17afe9e62bcef2936ba63e1b1f')
17 b2sums=('4ab8f92367e7df5762d29ed58dfff524f59053e28548b170b982d16988eea16df46851d2ea559d8beabb4f1315e5ee627f9ded755a4f3b1cfd6d863a50c633b6')
19 build() {
20   cd ${pkgbase}-${pkgver}
21   export UNICORN_CFLAGS="${CFLAGS} -ffat-lto-objects"
22   export UNICORN_QEMU_FLAGS="--extra-ldflags=\"$LDFLAGS\""
23   export QEMU_CXXFLAGS="${CXXFLAGS}"
24   export QEMU_LDFLAGS="${LDFLAGS}"
25   cmake -B build \
26       -DCMAKE_BUILD_TYPE=None \
27       -DCMAKE_INSTALL_PREFIX=/usr \
28       -Wno-dev
29   cmake --build build
30   (cd bindings
31     python const_generator.py python
32     python const_generator.py ruby
33   )
34   (cd bindings/python
35     python setup.py build
36   )
37   (cd bindings/ruby/unicorn_gem
38     gem build unicorn-engine.gemspec
39   )
42 check() {
43   cd ${pkgbase}-${pkgver}
44   ctest --test-dir build --output-on-failure
47 package_unicorn() {
48   depends=('glibc')
49   provides=('libunicorn.so')
50   cd ${pkgbase}-${pkgver}
51   DESTDIR="${pkgdir}" cmake --install build
52   install -Dm 644 samples/*.c -t "${pkgdir}/usr/share/doc/${pkgname}/samples"
55 package_python-unicorn() {
56   depends=('python' 'unicorn' 'python-setuptools')
57   cd ${pkgbase}-${pkgver}/bindings/python
58   python setup.py install --root="${pkgdir}" -O1 --skip-build
59   rm -r "${pkgdir}"/usr/lib/python*/site-packages/unicorn/lib
60   install -Dm 644 sample* shellcode.py -t "${pkgdir}/usr/share/doc/${pkgname}/samples"
63 package_ruby-unicorn-engine() {
64   depends=('ruby' 'unicorn')
65   replaces=('ruby-unicorn')
66   cd ${pkgbase}-${pkgver}/bindings/ruby/unicorn_gem
68   local _gemdir="$(gem env gemdir)"
69   gem install \
70     --local \
71     --verbose \
72     --ignore-dependencies \
73     --no-user-install \
74     --install-dir "${pkgdir}${_gemdir}" \
75     --bindir "${pkgdir}/usr/bin" \
76     ${pkgbase}-*.gem -- \
77     --with-opt-include="${srcdir}/${pkgbase}-${pkgver}/include" \
78     --with-opt-lib="${srcdir}/${pkgbase}-${pkgver}/build"
80   install -Dm 644 ../sample* -t "${pkgdir}/usr/share/doc/${pkgname}/samples"
82   # remove unrepreducible files
83   rm --force --recursive --verbose \
84     "${pkgdir}/${_gemdir}/cache/" \
85     "${pkgdir}/${_gemdir}/gems/${_gemname}-${pkgver}/vendor/" \
86     "${pkgdir}/${_gemdir}/doc/${_gemname}-${pkgver}/ri/ext/"
88   find "${pkgdir}/${_gemdir}/gems/" \
89     -type f \
90     \( \
91       -iname "*.o" -o \
92       -iname "*.c" -o \
93       -iname "*.so" -o \
94       -iname "*.time" -o \
95       -iname "gem.build_complete" -o \
96       -iname "Makefile" \
97     \) \
98     -delete
100   find "${pkgdir}/${_gemdir}/extensions/" \
101     -type f \
102     \( \
103       -iname "mkmf.log" -o \
104       -iname "gem_make.out" \
105     \) \
106     -delete
109 # vim: ts=2 sw=2 et: