70f595ea5b5c396f1ed18fba78c7497f81b8c29a
[gentoo.git] / app-emulation / qemu / qemu-2.5.0.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 PYTHON_COMPAT=( python2_7 )
8 PYTHON_REQ_USE="ncurses,readline"
9
10 inherit eutils flag-o-matic linux-info toolchain-funcs multilib python-r1 \
11         user udev fcaps readme.gentoo pax-utils
12
13 BACKPORTS=
14
15 if [[ ${PV} = *9999* ]]; then
16         EGIT_REPO_URI="git://git.qemu.org/qemu.git"
17         inherit git-2
18         SRC_URI=""
19 else
20         SRC_URI="http://wiki.qemu-project.org/download/${P}.tar.bz2
21         ${BACKPORTS:+
22                 https://dev.gentoo.org/~cardoe/distfiles/${P}-${BACKPORTS}.tar.xz}"
23         KEYWORDS="~amd64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
24 fi
25
26 DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
27 HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
28
29 LICENSE="GPL-2 LGPL-2 BSD-2"
30 SLOT="0"
31 IUSE="accessibility +aio alsa bluetooth +caps +curl debug +fdt glusterfs \
32 gnutls gtk gtk2 infiniband iscsi +jpeg \
33 kernel_linux kernel_FreeBSD lzo ncurses nfs nls numa opengl +pin-upstream-blobs
34 +png pulseaudio python \
35 rbd sasl +seccomp sdl sdl2 selinux smartcard snappy spice ssh static static-softmmu
36 static-user systemtap tci test +threads usb usbredir +uuid vde +vhost-net \
37 virgl virtfs +vnc vte xattr xen xfs"
38
39 COMMON_TARGETS="aarch64 alpha arm cris i386 m68k microblaze microblazeel mips
40 mips64 mips64el mipsel or32 ppc ppc64 s390x sh4 sh4eb sparc sparc64 unicore32
41 x86_64"
42 IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 moxie ppcemb tricore xtensa xtensaeb"
43 IUSE_USER_TARGETS="${COMMON_TARGETS} armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus tilegx"
44
45 use_softmmu_targets=$(printf ' qemu_softmmu_targets_%s' ${IUSE_SOFTMMU_TARGETS})
46 use_user_targets=$(printf ' qemu_user_targets_%s' ${IUSE_USER_TARGETS})
47 IUSE+=" ${use_softmmu_targets} ${use_user_targets}"
48
49 # Allow no targets to be built so that people can get a tools-only build.
50 # Block USE flag configurations known to not work.
51 REQUIRED_USE="${PYTHON_REQUIRED_USE}
52         gtk2? ( gtk )
53         qemu_softmmu_targets_arm? ( fdt )
54         qemu_softmmu_targets_microblaze? ( fdt )
55         qemu_softmmu_targets_ppc? ( fdt )
56         qemu_softmmu_targets_ppc64? ( fdt )
57         sdl2? ( sdl )
58         static? ( static-softmmu static-user )
59         static-softmmu? ( !alsa !pulseaudio !bluetooth !opengl !gtk !gtk2 )
60         virtfs? ( xattr )
61         vte? ( gtk )"
62
63 # Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
64 #
65 # The attr lib isn't always linked in (although the USE flag is always
66 # respected).  This is because qemu supports using the C library's API
67 # when available rather than always using the extranl library.
68 #
69 # Older versions of gnutls are supported, but it's simpler to just require
70 # the latest versions.  This is also why we require nettle.
71 COMMON_LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
72         sys-libs/zlib[static-libs(+)]
73         xattr? ( sys-apps/attr[static-libs(+)] )"
74 SOFTMMU_LIB_DEPEND="${COMMON_LIB_DEPEND}
75         >=x11-libs/pixman-0.28.0[static-libs(+)]
76         accessibility? ( app-accessibility/brltty[static-libs(+)] )
77         aio? ( dev-libs/libaio[static-libs(+)] )
78         alsa? ( >=media-libs/alsa-lib-1.0.13 )
79         bluetooth? ( net-wireless/bluez )
80         caps? ( sys-libs/libcap-ng[static-libs(+)] )
81         curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
82         fdt? ( >=sys-apps/dtc-1.4.0[static-libs(+)] )
83         glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
84         gnutls? (
85                 dev-libs/nettle[static-libs(+)]
86                 >=net-libs/gnutls-3.0[static-libs(+)]
87         )
88         gtk? (
89                 gtk2? (
90                         x11-libs/gtk+:2
91                         vte? ( x11-libs/vte:0 )
92                 )
93                 !gtk2? (
94                         x11-libs/gtk+:3
95                         vte? ( x11-libs/vte:2.90 )
96                 )
97         )
98         infiniband? ( sys-infiniband/librdmacm:=[static-libs(+)] )
99         iscsi? ( net-libs/libiscsi )
100         jpeg? ( virtual/jpeg:=[static-libs(+)] )
101         lzo? ( dev-libs/lzo:2[static-libs(+)] )
102         ncurses? ( sys-libs/ncurses:0=[static-libs(+)] )
103         nfs? ( >=net-fs/libnfs-1.9.3[static-libs(+)] )
104         numa? ( sys-process/numactl[static-libs(+)] )
105         opengl? (
106                 virtual/opengl
107                 media-libs/libepoxy[static-libs(+)]
108                 media-libs/mesa[static-libs(+)]
109                 media-libs/mesa[egl,gles2]
110         )
111         png? ( media-libs/libpng:0=[static-libs(+)] )
112         pulseaudio? ( media-sound/pulseaudio )
113         rbd? ( sys-cluster/ceph[static-libs(+)] )
114         sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
115         sdl? (
116                 !sdl2? (
117                         media-libs/libsdl[X]
118                         >=media-libs/libsdl-1.2.11[static-libs(+)]
119                 )
120                 sdl2? (
121                         media-libs/libsdl2[X]
122                         media-libs/libsdl2[static-libs(+)]
123                 )
124         )
125         seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
126         smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
127         snappy? ( app-arch/snappy[static-libs(+)] )
128         spice? (
129                 >=app-emulation/spice-protocol-0.12.3
130                 >=app-emulation/spice-0.12.0[static-libs(+)]
131         )
132         ssh? ( >=net-libs/libssh2-1.2.8[static-libs(+)] )
133         usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
134         usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
135         uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
136         vde? ( net-misc/vde[static-libs(+)] )
137         virgl? ( media-libs/virglrenderer[static-libs(+)] )
138         virtfs? ( sys-libs/libcap )
139         xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
140 USER_LIB_DEPEND="${COMMON_LIB_DEPEND}"
141 X86_FIRMWARE_DEPEND="
142         >=sys-firmware/ipxe-1.0.0_p20130624
143         pin-upstream-blobs? (
144                 ~sys-firmware/seabios-1.8.2
145                 ~sys-firmware/sgabios-0.1_pre8
146                 ~sys-firmware/vgabios-0.7a
147         )
148         !pin-upstream-blobs? (
149                 sys-firmware/seabios
150                 sys-firmware/sgabios
151                 sys-firmware/vgabios
152         )"
153 CDEPEND="
154         !static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND//\[static-libs(+)]} ) " ${use_softmmu_targets}) )
155         !static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND//\[static-libs(+)]} ) " ${use_user_targets}) )
156         qemu_softmmu_targets_i386? ( ${X86_FIRMWARE_DEPEND} )
157         qemu_softmmu_targets_x86_64? ( ${X86_FIRMWARE_DEPEND} )
158         python? ( ${PYTHON_DEPS} )
159         systemtap? ( dev-util/systemtap )
160         xen? ( app-emulation/xen-tools:= )"
161 DEPEND="${CDEPEND}
162         dev-lang/perl
163         =dev-lang/python-2*
164         sys-apps/texinfo
165         virtual/pkgconfig
166         kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
167         gtk? ( nls? ( sys-devel/gettext ) )
168         static-softmmu? ( $(printf "%s? ( ${SOFTMMU_LIB_DEPEND} ) " ${use_softmmu_targets}) )
169         static-user? ( $(printf "%s? ( ${USER_LIB_DEPEND} ) " ${use_user_targets}) )
170         test? (
171                 dev-libs/glib[utils]
172                 sys-devel/bc
173         )"
174 RDEPEND="${CDEPEND}
175         selinux? ( sec-policy/selinux-qemu )
176 "
177
178 STRIP_MASK="/usr/share/qemu/palcode-clipper"
179
180 QA_PREBUILT="
181         usr/share/qemu/openbios-ppc
182         usr/share/qemu/openbios-sparc64
183         usr/share/qemu/openbios-sparc32
184         usr/share/qemu/palcode-clipper
185         usr/share/qemu/s390-ccw.img
186         usr/share/qemu/u-boot.e500
187 "
188
189 QA_WX_LOAD="usr/bin/qemu-i386
190         usr/bin/qemu-x86_64
191         usr/bin/qemu-alpha
192         usr/bin/qemu-arm
193         usr/bin/qemu-cris
194         usr/bin/qemu-m68k
195         usr/bin/qemu-microblaze
196         usr/bin/qemu-microblazeel
197         usr/bin/qemu-mips
198         usr/bin/qemu-mipsel
199         usr/bin/qemu-or32
200         usr/bin/qemu-ppc
201         usr/bin/qemu-ppc64
202         usr/bin/qemu-ppc64abi32
203         usr/bin/qemu-sh4
204         usr/bin/qemu-sh4eb
205         usr/bin/qemu-sparc
206         usr/bin/qemu-sparc64
207         usr/bin/qemu-armeb
208         usr/bin/qemu-sparc32plus
209         usr/bin/qemu-s390x
210         usr/bin/qemu-unicore32"
211
212 DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure
213 you have the kernel module loaded before running kvm. The easiest way to
214 ensure that the kernel module is loaded is to load it on boot.\n
215 For AMD CPUs the module is called 'kvm-amd'\n
216 For Intel CPUs the module is called 'kvm-intel'\n
217 Please review /etc/conf.d/modules for how to load these\n\n
218 Make sure your user is in the 'kvm' group\n
219 Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
220
221 qemu_support_kvm() {
222         if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 \
223                 use qemu_softmmu_targets_ppc || use qemu_softmmu_targets_ppc64 \
224                 use qemu_softmmu_targets_s390x; then
225                 return 0
226         fi
227
228         return 1
229 }
230
231 pkg_pretend() {
232         if use kernel_linux && kernel_is lt 2 6 25; then
233                 eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
234         elif use kernel_linux; then
235                 if ! linux_config_exists; then
236                         eerror "Unable to check your kernel for KVM support"
237                 else
238                         CONFIG_CHECK="~KVM ~TUN ~BRIDGE"
239                         ERROR_KVM="You must enable KVM in your kernel to continue"
240                         ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in"
241                         ERROR_KVM_AMD+=" your kernel configuration."
242                         ERROR_KVM_INTEL="If you have an Intel CPU, you must enable"
243                         ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration."
244                         ERROR_TUN="You will need the Universal TUN/TAP driver compiled"
245                         ERROR_TUN+=" into your kernel or loaded as a module to use the"
246                         ERROR_TUN+=" virtual network device if using -net tap."
247                         ERROR_BRIDGE="You will also need support for 802.1d"
248                         ERROR_BRIDGE+=" Ethernet Bridging for some network configurations."
249                         use vhost-net && CONFIG_CHECK+=" ~VHOST_NET"
250                         ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net"
251                         ERROR_VHOST_NET+=" support"
252
253                         if use amd64 || use x86 || use amd64-linux || use x86-linux; then
254                                 CONFIG_CHECK+=" ~KVM_AMD ~KVM_INTEL"
255                         fi
256
257                         use python && CONFIG_CHECK+=" ~DEBUG_FS"
258                         ERROR_DEBUG_FS="debugFS support required for kvm_stat"
259
260                         # Now do the actual checks setup above
261                         check_extra_config
262                 fi
263         fi
264
265         if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
266                 eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt"
267                 eerror "instances are still pointing to it.  Please update your"
268                 eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag"
269                 eerror "and the right system binary (e.g. qemu-system-x86_64)."
270                 die "update your virt configs to not use qemu-kvm"
271         fi
272 }
273
274 pkg_setup() {
275         enewgroup kvm 78
276 }
277
278 # Sanity check to make sure target lists are kept up-to-date.
279 check_targets() {
280         local var=$1 mak=$2
281         local detected sorted
282
283         pushd "${S}"/default-configs >/dev/null || die
284
285         # Force C locale until glibc is updated. #564936
286         detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u))
287         sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u))
288         if [[ ${sorted} != "${detected}" ]] ; then
289                 eerror "The ebuild needs to be kept in sync."
290                 eerror "${var}: ${sorted}"
291                 eerror "$(printf '%-*s' ${#var} configure): ${detected}"
292                 die "sync ${var} to the list of targets"
293         fi
294
295         popd >/dev/null
296 }
297
298 src_prepare() {
299         check_targets IUSE_SOFTMMU_TARGETS softmmu
300         check_targets IUSE_USER_TARGETS linux-user
301
302         # Alter target makefiles to accept CFLAGS set via flag-o
303         sed -i -r \
304                 -e 's/^(C|OP_C|HELPER_C)FLAGS=/\1FLAGS+=/' \
305                 Makefile Makefile.target || die
306
307         # Cheap hack to disable gettext .mo generation.
308         use nls || rm -f po/*.po
309
310         epatch "${FILESDIR}"/qemu-2.5.0-cflags.patch
311         [[ -n ${BACKPORTS} ]] && \
312                 EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
313                         epatch
314
315         # Fix ld and objcopy being called directly
316         tc-export AR LD OBJCOPY
317
318         # Verbose builds
319         MAKEOPTS+=" V=1"
320
321         epatch_user
322 }
323
324 ##
325 # configures qemu based on the build directory and the build type
326 # we are using.
327 #
328 qemu_src_configure() {
329         debug-print-function ${FUNCNAME} "$@"
330
331         local buildtype=$1
332         local builddir="${S}/${buildtype}-build"
333         local static_flag="static-${buildtype}"
334
335         mkdir "${builddir}"
336
337         local conf_opts=(
338                 --prefix=/usr
339                 --sysconfdir=/etc
340                 --libdir=/usr/$(get_libdir)
341                 --docdir=/usr/share/doc/${PF}/html
342                 --disable-bsd-user
343                 --disable-guest-agent
344                 --disable-strip
345                 --disable-werror
346                 # We support gnutls/nettle for crypto operations.  It is possible
347                 # to use gcrypt when gnutls/nettle are disabled (but not when they
348                 # are enabled), but it's not really worth the hassle.  Disable it
349                 # all the time to avoid automatically detecting it. #568856
350                 --disable-gcrypt
351                 --python="${PYTHON}"
352                 --cc="$(tc-getCC)"
353                 --cxx="$(tc-getCXX)"
354                 --host-cc="$(tc-getBUILD_CC)"
355                 $(use_enable debug debug-info)
356                 $(use_enable debug debug-tcg)
357                 --enable-docs
358                 $(use_enable tci tcg-interpreter)
359                 $(use_enable xattr attr)
360         )
361
362         # Disable options not used by user targets as the default configure
363         # options will autoprobe and try to link in a bunch of unused junk.
364         conf_softmmu() {
365                 if [[ ${buildtype} == "user" ]] ; then
366                         echo "--disable-${2:-$1}"
367                 else
368                         use_enable "$@"
369                 fi
370         }
371         conf_opts+=(
372                 $(conf_softmmu accessibility brlapi)
373                 $(conf_softmmu aio linux-aio)
374                 $(conf_softmmu bluetooth bluez)
375                 $(conf_softmmu caps cap-ng)
376                 $(conf_softmmu curl)
377                 $(conf_softmmu fdt)
378                 $(conf_softmmu glusterfs)
379                 $(conf_softmmu gnutls)
380                 $(conf_softmmu gnutls nettle)
381                 $(conf_softmmu gtk)
382                 $(conf_softmmu infiniband rdma)
383                 $(conf_softmmu iscsi libiscsi)
384                 $(conf_softmmu jpeg vnc-jpeg)
385                 $(conf_softmmu kernel_linux kvm)
386                 $(conf_softmmu lzo)
387                 $(conf_softmmu ncurses curses)
388                 $(conf_softmmu nfs libnfs)
389                 $(conf_softmmu numa)
390                 $(conf_softmmu opengl)
391                 $(conf_softmmu png vnc-png)
392                 $(conf_softmmu rbd)
393                 $(conf_softmmu sasl vnc-sasl)
394                 $(conf_softmmu sdl)
395                 $(conf_softmmu seccomp)
396                 $(conf_softmmu smartcard)
397                 $(conf_softmmu snappy)
398                 $(conf_softmmu spice)
399                 $(conf_softmmu ssh libssh2)
400                 $(conf_softmmu usb libusb)
401                 $(conf_softmmu usbredir usb-redir)
402                 $(conf_softmmu uuid)
403                 $(conf_softmmu vde)
404                 $(conf_softmmu vhost-net)
405                 $(conf_softmmu virgl virglrenderer)
406                 $(conf_softmmu virtfs)
407                 $(conf_softmmu vnc)
408                 $(conf_softmmu vte)
409                 $(conf_softmmu xen)
410                 $(conf_softmmu xen xen-pci-passthrough)
411                 $(conf_softmmu xfs xfsctl)
412         )
413
414         case ${buildtype} in
415         user)
416                 conf_opts+=(
417                         --enable-linux-user
418                         --disable-system
419                         --disable-blobs
420                         --disable-tools
421                 )
422                 ;;
423         softmmu)
424                 # audio options
425                 local audio_opts="oss"
426                 use alsa && audio_opts="alsa,${audio_opts}"
427                 use sdl && audio_opts="sdl,${audio_opts}"
428                 use pulseaudio && audio_opts="pa,${audio_opts}"
429
430                 conf_opts+=(
431                         --disable-linux-user
432                         --enable-system
433                         --with-system-pixman
434                         --audio-drv-list="${audio_opts}"
435                 )
436                 use gtk && conf_opts+=( --with-gtkabi=$(usex gtk2 2.0 3.0) )
437                 use sdl && conf_opts+=( --with-sdlabi=$(usex sdl2 2.0 1.2) )
438                 ;;
439         tools)
440                 conf_opts+=(
441                         --disable-linux-user
442                         --disable-system
443                         --disable-blobs
444                 )
445                 static_flag="static"
446                 ;;
447         esac
448
449         local targets="${buildtype}_targets"
450         [[ -n ${targets} ]] && conf_opts+=( --target-list="${!targets}" )
451
452         # Add support for SystemTAP
453         use systemtap && conf_opts+=( --enable-trace-backend=dtrace )
454
455         # We always want to attempt to build with PIE support as it results
456         # in a more secure binary. But it doesn't work with static or if
457         # the current GCC doesn't have PIE support.
458         if use ${static_flag}; then
459                 conf_opts+=( --static --disable-pie )
460         else
461                 gcc-specs-pie && conf_opts+=( --enable-pie )
462         fi
463
464         echo "../configure ${conf_opts[*]}"
465         cd "${builddir}"
466         ../configure "${conf_opts[@]}" || die "configure failed"
467
468         # FreeBSD's kernel does not support QEMU assigning/grabbing
469         # host USB devices yet
470         use kernel_FreeBSD && \
471                 sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
472 }
473
474 src_configure() {
475         local target
476
477         python_setup
478
479         softmmu_targets= softmmu_bins=()
480         user_targets= user_bins=()
481
482         for target in ${IUSE_SOFTMMU_TARGETS} ; do
483                 if use "qemu_softmmu_targets_${target}"; then
484                         softmmu_targets+=",${target}-softmmu"
485                         softmmu_bins+=( "qemu-system-${target}" )
486                 fi
487         done
488
489         for target in ${IUSE_USER_TARGETS} ; do
490                 if use "qemu_user_targets_${target}"; then
491                         user_targets+=",${target}-linux-user"
492                         user_bins+=( "qemu-${target}" )
493                 fi
494         done
495
496         softmmu_targets=${softmmu_targets#,}
497         user_targets=${user_targets#,}
498
499         [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu"
500         [[ -n ${user_targets}    ]] && qemu_src_configure "user"
501         [[ -z ${softmmu_targets}${user_targets} ]] && qemu_src_configure "tools"
502 }
503
504 src_compile() {
505         if [[ -n ${user_targets} ]]; then
506                 cd "${S}/user-build"
507                 default
508         fi
509
510         if [[ -n ${softmmu_targets} ]]; then
511                 cd "${S}/softmmu-build"
512                 default
513         fi
514
515         if [[ -z ${softmmu_targets}${user_targets} ]]; then
516                 cd "${S}/tools-build"
517                 default
518         fi
519 }
520
521 src_test() {
522         if [[ -n ${softmmu_targets} ]]; then
523                 cd "${S}/softmmu-build"
524                 pax-mark m */qemu-system-* #515550
525                 emake -j1 check
526                 emake -j1 check-report.html
527         fi
528 }
529
530 qemu_python_install() {
531         python_domodule "${S}/scripts/qmp/qmp.py"
532
533         python_doscript "${S}/scripts/kvm/kvm_stat"
534         python_doscript "${S}/scripts/kvm/vmxcap"
535         python_doscript "${S}/scripts/qmp/qmp-shell"
536         python_doscript "${S}/scripts/qmp/qemu-ga-client"
537 }
538
539 src_install() {
540         if [[ -n ${user_targets} ]]; then
541                 cd "${S}/user-build"
542                 emake DESTDIR="${ED}" install
543
544                 # Install binfmt handler init script for user targets
545                 newinitd "${FILESDIR}/qemu-binfmt.initd-r1" qemu-binfmt
546         fi
547
548         if [[ -n ${softmmu_targets} ]]; then
549                 cd "${S}/softmmu-build"
550                 emake DESTDIR="${ED}" install
551
552                 # This might not exist if the test failed. #512010
553                 [[ -e check-report.html ]] && dohtml check-report.html
554
555                 if use kernel_linux; then
556                         udev_dorules "${FILESDIR}"/65-kvm.rules
557                 fi
558
559                 if use python; then
560                         python_foreach_impl qemu_python_install
561                 fi
562         fi
563
564         if [[ -z ${softmmu_targets}${user_targets} ]]; then
565                 cd "${S}/tools-build"
566                 emake DESTDIR="${ED}" install
567         fi
568
569         # Disable mprotect on the qemu binaries as they use JITs to be fast #459348
570         pushd "${ED}"/usr/bin >/dev/null
571         pax-mark m "${softmmu_bins[@]}" "${user_bins[@]}"
572         popd >/dev/null
573
574         # Install config file example for qemu-bridge-helper
575         insinto "/etc/qemu"
576         doins "${FILESDIR}/bridge.conf"
577
578         # Remove the docdir placed qmp-commands.txt
579         mv "${ED}/usr/share/doc/${PF}/html/qmp-commands.txt" "${S}/docs/" || die
580
581         cd "${S}"
582         dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt
583         newdoc pc-bios/README README.pc-bios
584         dodoc docs/qmp-*.txt
585
586         if [[ -n ${softmmu_targets} ]]; then
587                 # Remove SeaBIOS since we're using the SeaBIOS packaged one
588                 rm "${ED}/usr/share/qemu/bios.bin"
589                 if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
590                         dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
591                 fi
592
593                 # Remove vgabios since we're using the vgabios packaged one
594                 rm "${ED}/usr/share/qemu/vgabios.bin"
595                 rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
596                 rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
597                 rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
598                 rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
599                 if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
600                         dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
601                         dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
602                         dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
603                         dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
604                         dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
605                 fi
606
607                 # Remove sgabios since we're using the sgabios packaged one
608                 rm "${ED}/usr/share/qemu/sgabios.bin"
609                 if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
610                         dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
611                 fi
612
613                 # Remove iPXE since we're using the iPXE packaged one
614                 rm "${ED}"/usr/share/qemu/pxe-*.rom
615                 if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
616                         dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom
617                         dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
618                         dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
619                         dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
620                         dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
621                         dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
622                 fi
623         fi
624
625         qemu_support_kvm && readme.gentoo_create_doc
626 }
627
628 pkg_postinst() {
629         if qemu_support_kvm; then
630                 readme.gentoo_print_elog
631         fi
632
633         if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
634                 udev_reload
635         fi
636
637         fcaps cap_net_admin /usr/libexec/qemu-bridge-helper
638 }
639
640 pkg_info() {
641         echo "Using:"
642         echo "  $(best_version app-emulation/spice-protocol)"
643         echo "  $(best_version sys-firmware/ipxe)"
644         echo "  $(best_version sys-firmware/seabios)"
645         if has_version 'sys-firmware/seabios[binary]'; then
646                 echo "    USE=binary"
647         else
648                 echo "    USE=''"
649         fi
650         echo "  $(best_version sys-firmware/vgabios)"
651 }