summaryrefslogtreecommitdiff
path: root/libre/qemu-static/PKGBUILD
blob: 5388b3582edfea4230dcbba6d96b027daf763479 (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
# Maintainer: Márcio Silva <coadde@parabola.nu>
# based of qemu

pkgbase=qemu
pkgname=('qemu-static'
         'qemu-arch-extra-static'
         'binfmt-qemu-static')
pkgver=2.5.1
pkgrel=1.10
arch=('i686' 'x86_64' 'armv7h')
license=('GPL2' 'LGPL2.1')
url='http://wiki.qemu.org/'
makedepends=('pixman-static' 'glib2-static' 'pcre-static' 'python2')
source=(http://wiki.qemu.org/download/${pkgbase}-${pkgver}.tar.bz2
        qemu-{extra,aarch64,arm,i386,mips,mips64,x86_64}-static.conf)
md5sums=('42e73182dea8b9213fa7050e168a4615'
         '46e56355a3161863a7418b2285c1a7d7'
         '6a9c73902b0482b6344dc33087fa0504'
         '0413b0b1298245a893e1662d8c8c37a5'
         '76d7cf73da93456e795f820008c0119f'
         '7a1b6c7cc47d8408c3572f983de5411b'
         '9051b02a6cb2f58e30924734508595ef'
         '3fdb58990d64db8f7c4ffb509fc29666')

_extra_arches=(aarch64 alpha arm armeb cris m68k microblaze microblazeel
or32 ppc ppc64 ppc64abi32 ppc64le s390x tilegx
sh4 sh4eb sparc sparc32plus sparc64 unicore32)
if [[ $CARCH = x86_64 || $CARCH = i686 ]]; then
  _native_arches=(x86_64 i386)
  _extra_arches+=(aarch64 arm armeb mips mips64 mips64el mipsel mipsn32 mipsn32el)
elif [[ $CARCH = armv7h ]]; then
  _native_arches=(arm)
  _extra_arches+=(x86_64 i386 mips mips64 mips64el mipsel mipsn32 mipsn32el)
elif [[ $CARCH = mips64el ]]; then
  _native_arches=(mips mips64 mips64el mipsel mipsn32 mipsn32el)
  _extra_arches+=(x86_64 i386 aarch64 arm armeb)
fi

prepare() {
  for _p in *.patch; do
    [[ -e "$_p" ]] || continue
    msg2 "Patching $_p"
    patch -p1 -d ${pkgbase}-${pkgver} < "$_p"
  done
}

build ()
{
  cd ${pkgbase}-${pkgver}
  # qemu vs. make 4 == bad
  export ARFLAGS="rv"
  # http://permalink.gmane.org/gmane.comp.emulators.qemu/238740
  export CFLAGS+=' -fPIC'
  ./configure --prefix=/usr --sysconfdir=/etc --audio-drv-list='' \
              --python=/usr/bin/python2 --smbd=/usr/bin/smbd \
              --disable-docs --libexecdir=/usr/lib/qemu \
              --disable-gtk --disable-linux-aio --disable-seccomp \
              --disable-spice --localstatedir=/var \
              --enable-tpm \
              --disable-modules --disable-{rbd,glusterfs,libiscsi,curl} \
              --disable-system --static --disable-vnc \
              --disable-attr --disable-blobs --disable-vhost-net \
              --disable-bzip2 --disable-libssh2 --disable-gcrypt \
              --disable-nettle --disable-curses --disable-kvm \
              --disable-guest-agent
  make V=99
}

package_qemu-static() {
  pkgdesc='A generic and free processor emulator which achieves a good emulation speed by using dynamic translation (static binaries only)'
  optdepends=('qemu-arch-extra-static: extra architectures support')
  options=(!strip)

  make -C ${pkgbase}-${pkgver} DESTDIR="${pkgdir}" install

  cd "${pkgdir}"

  # remove extra arch
  for _arch in "${_extra_arches[@]}"; do
    rm -vf usr/bin/qemu-${_arch}
  done

  # rename all qemu-* binaries
  cd usr/bin
    for _arch in "${_native_arches[@]}"; do
      mv -v qemu-${_arch} qemu-${_arch}-static
    done
  cd ../..

  # remove conflicting files
  rm -vr usr/{lib,share}
  rm -v usr/bin/{ivshmem-{client,server},qemu-{img,io,nbd}}
}

package_qemu-arch-extra-static() {
  pkgdesc='QEMU with full support for non native architectures (static binaries only)'
  replaces=('qemu-static-arch-extra')
  conflicts=('qemu-static-arch-extra')
  options=(!strip)

  cd qemu-${pkgver}
  install -dm755 "${pkgdir}"/usr/bin
  for _arch in "${_extra_arches[@]}"; do
    install -m755 ${_arch}-*/qemu-${_arch} "${pkgdir}"/usr/bin
    mv -v "${pkgdir}"/usr/bin/qemu-${_arch}{,-static}
  done

  # manually stripping
  find "${pkgdir}"/usr/bin -type f -exec strip {} \;
}

package_binfmt-qemu-static() {
  pkgdesc='Register qemu-static interpreters for various binary formats'
  depends=('qemu-arch-extra-static')

  install -dm755 "${pkgdir}"/usr/lib/binfmt.d

  if [[ $CARCH = x86_64 ]]; then
    install -m644 "${srcdir}"/qemu-x86_64-static.conf "${pkgdir}"/usr/lib/binfmt.d/qemu-static.conf
  elif [[ $CARCH = i686 ]]; then
    install -m644 "${srcdir}"/qemu-i386-static.conf "${pkgdir}"/usr/lib/binfmt.d/qemu-static.conf
  elif [[ $CARCH = armv7h ]]; then
    install -m644 "${srcdir}"/qemu-arm-static.conf "${pkgdir}"/usr/lib/binfmt.d/qemu-static.conf
  elif [[ $CARCH = mips64el ]]; then
    install -m644 "${srcdir}"/qemu-mips64-static.conf "${pkgdir}"/usr/lib/binfmt.d/qemu-static.conf
  fi
  install -m644 "${srcdir}"/qemu-extra-static.conf "${pkgdir}"/usr/lib/binfmt.d/qemu-extra-static.conf
}