1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/app-emulation/qemu/qemu-1.2.1.ebuild,v 1.3 2012/12/05 21:37:29 cardoe Exp $
8 inherit eutils flag-o-matic linux-info toolchain-funcs multilib python user
10 SRC_URI="http://wiki.qemu.org/download/${P}.tar.bz2"
11 KEYWORDS="~amd64 ~ppc ~ppc64 ~x86 ~x86-fbsd"
13 DESCRIPTION="Free machine emulator and virtualizer"
14 HOMEPAGE="http://www.qemu.org/"
16 LICENSE="GPL-2 LGPL-2 BSD-2"
18 IUSE="+aio alsa bluetooth brltty +caps +curl debug doc fdt +jpeg kernel_linux \
19 kernel_FreeBSD kvm mixemu ncurses opengl +png pulseaudio python rbd sasl \
20 +seccomp sdl smartcard spice static systemtap tci +threads tls usbredir \
21 +uuid vde +vhost-net virtfs +vnc xattr xen xfs"
23 COMMON_TARGETS="i386 x86_64 alpha arm cris m68k microblaze microblazeel mips mipsel ppc ppc64 sh4 sh4eb sparc sparc64 s390x"
24 IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} lm32 mips64 mips64el ppcemb xtensa xtensaeb"
25 IUSE_USER_TARGETS="${COMMON_TARGETS} armeb ppc64abi32 sparc32plus unicore32"
27 # Setup the default SoftMMU targets, while using the loops
28 # below to setup the other targets.
31 for target in ${IUSE_SOFTMMU_TARGETS}; do
32 IUSE="${IUSE} qemu_softmmu_targets_${target}"
33 REQUIRED_USE="${REQUIRED_USE} qemu_softmmu_targets_${target}"
35 REQUIRED_USE="${REQUIRED_USE} )"
37 for target in ${IUSE_USER_TARGETS}; do
38 IUSE="${IUSE} qemu_user_targets_${target}"
41 # Block USE flag configurations known to not work
42 REQUIRED_USE="${REQUIRED_USE}
43 static? ( !alsa !pulseaudio !bluetooth )
46 # Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
47 LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
48 sys-apps/pciutils[static-libs(+)]
49 sys-libs/zlib[static-libs(+)]
50 aio? ( dev-libs/libaio[static-libs(+)] )
51 caps? ( sys-libs/libcap-ng[static-libs(+)] )
52 curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
53 fdt? ( >=sys-apps/dtc-1.2.0[static-libs(+)] )
54 jpeg? ( virtual/jpeg[static-libs(+)] )
55 ncurses? ( sys-libs/ncurses[static-libs(+)] )
56 png? ( media-libs/libpng[static-libs(+)] )
57 rbd? ( sys-cluster/ceph[static-libs(+)] )
58 sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
59 sdl? ( >=media-libs/libsdl-1.2.11[static-libs(+)] )
60 seccomp? ( >=sys-libs/libseccomp-1.0.0[static-libs(+)] )
61 spice? ( >=app-emulation/spice-0.9.0[static-libs(+)] )
62 tls? ( net-libs/gnutls[static-libs(+)] )
63 uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
64 vde? ( net-misc/vde[static-libs(+)] )
65 xattr? ( sys-apps/attr[static-libs(+)] )
66 xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
67 RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs(+)]} )
70 >=sys-firmware/seabios-1.7.0
73 alsa? ( >=media-libs/alsa-lib-1.0.13 )
74 bluetooth? ( net-wireless/bluez )
75 brltty? ( app-accessibility/brltty )
76 opengl? ( virtual/opengl )
77 pulseaudio? ( media-sound/pulseaudio )
78 python? ( =dev-lang/python-2*[ncurses] )
79 sdl? ( media-libs/libsdl[X] )
80 smartcard? ( dev-libs/nss )
81 spice? ( >=app-emulation/spice-protocol-0.12.0 )
82 systemtap? ( dev-util/systemtap )
84 >=sys-apps/usbredir-0.3.4
85 x86? ( <sys-apps/usbredir-0.5 )
87 virtfs? ( sys-libs/libcap )
88 xen? ( app-emulation/xen-tools )"
92 doc? ( app-text/texi2html )
93 kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
94 static? ( ${LIB_DEPEND} )"
96 STRIP_MASK="/usr/share/qemu/palcode-clipper"
99 usr/share/qemu/openbios-ppc
100 usr/share/qemu/openbios-sparc64
101 usr/share/qemu/openbios-sparc32
102 usr/share/qemu/palcode-clipper"
104 QA_WX_LOAD="${QA_PRESTRIPPED}
111 usr/bin/qemu-microblaze
116 usr/bin/qemu-ppc64abi32
122 usr/bin/qemu-sparc32plus"
126 ewarn "USE=static is very much a moving target because of the packages"
127 ewarn "we depend on will have their static libs ripped out or wrapped"
128 ewarn "with USE=static-libs or USE=static due to continued dicsussion"
129 ewarn "on the mailing list about USE=static's place in Gentoo. As a"
130 ewarn "result what worked today may not work tomorrow."
135 python_set_active_version 2
142 # Alter target makefiles to accept CFLAGS set via flag-o
143 sed -i 's/^\(C\|OP_C\|HELPER_C\)FLAGS=/\1FLAGS+=/' \
144 Makefile Makefile.target || die
146 python_convert_shebangs -r 2 "${S}/scripts/kvm/kvm_stat"
148 epatch "${FILESDIR}"/qemu-1.2.0-cflags.patch
149 [[ -n ${BACKPORTS} ]] && \
150 EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
157 local conf_opts audio_opts user_targets
159 for target in ${IUSE_SOFTMMU_TARGETS} ; do
160 use "qemu_softmmu_targets_${target}" && \
161 softmmu_targets="${softmmu_targets} ${target}-softmmu"
164 for target in ${IUSE_USER_TARGETS} ; do
165 use "qemu_user_targets_${target}" && \
166 user_targets="${user_targets} ${target}-linux-user"
169 einfo "Building the following softmmu targets: ${softmmu_targets}"
171 if [[ -n ${user_targets} ]]; then
172 einfo "Building the following user targets: ${user_targets}"
173 conf_opts="${conf_opts} --enable-linux-user"
175 conf_opts="${conf_opts} --disable-linux-user"
178 # Add support for SystemTAP
179 use systemtap && conf_opts="${conf_opts} --enable-trace-backend=dtrace"
181 # Fix QA issues. QEMU needs executable heaps and we need to mark it as such
182 #conf_opts="${conf_opts} --extra-ldflags=-Wl,-z,execheap"
184 # Add support for static builds
185 use static && conf_opts="${conf_opts} --static --disable-pie"
187 # We always want to attempt to build with PIE support as it results
188 # in a more secure binary. But it doesn't work with static or if
189 # the current GCC doesn't have PIE support.
190 if ! use static && gcc-specs-pie; then
191 conf_opts="${conf_opts} --enable-pie"
196 use alsa && audio_opts="alsa,${audio_opts}"
197 use sdl && audio_opts="sdl,${audio_opts}"
198 use pulseaudio && audio_opts="pa,${audio_opts}"
199 use mixemu && conf_opts="${conf_opts} --enable-mixemu"
201 ./configure --prefix=/usr \
204 --disable-guest-agent \
209 $(use_enable aio linux-aio) \
210 $(use_enable bluetooth bluez) \
211 $(use_enable brltty brlapi) \
212 $(use_enable caps cap-ng) \
214 $(use_enable debug debug-info) \
215 $(use_enable debug debug-tcg) \
216 $(use_enable doc docs) \
218 $(use_enable jpeg vnc-jpeg) \
220 $(use_enable kernel_linux nptl) \
221 $(use_enable ncurses curses) \
222 $(use_enable opengl) \
223 $(use_enable png vnc-png) \
225 $(use_enable sasl vnc-sasl) \
227 $(use_enable seccomp) \
228 $(use_enable smartcard smartcard) \
229 $(use_enable smartcard smartcard-nss) \
230 $(use_enable spice) \
231 $(use_enable tci tcg-interpreter) \
232 $(use_enable tls vnc-tls) \
233 $(use_enable usbredir usb-redir) \
236 $(use_enable vhost-net) \
237 $(use_enable virtfs) \
239 $(use_enable xattr attr) \
241 $(use_enable xen xen-pci-passthrough) \
242 $(use_enable xfs xfsctl) \
243 --audio-drv-list=${audio_opts} \
244 --target-list="${softmmu_targets} ${user_targets}" \
246 --host-cc="$(tc-getBUILD_CC)" \
248 || die "configure failed"
250 # FreeBSD's kernel does not support QEMU assigning/grabbing
251 # host USB devices yet
252 use kernel_FreeBSD && \
253 sed -E -e "s|^(HOST_USB=)bsd|\1stub|" -i "${S}"/config-host.mak
257 emake DESTDIR="${ED}" install
259 if use kvm && [[ -n ${softmmu_targets} ]]; then
260 insinto /lib/udev/rules.d/
261 doins "${FILESDIR}"/65-kvm.rules
264 dodoc Changelog MAINTAINERS TODO pci-ids.txt
265 newdoc pc-bios/README README.pc-bios
268 dohtml qemu-doc.html qemu-tech.html || die
271 use python & dobin scripts/kvm/kvm_stat
273 # Avoid collision with app-emulation/libcacard
274 use smartcard && mv "${ED}/usr/bin/vscclient" "${ED}/usr/bin/qemu-vscclient"
276 # Remove SeaBIOS since we're using the SeaBIOS packaged one
277 rm "${ED}/usr/share/qemu/bios.bin"
278 dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
280 # Remove vgabios since we're using the vgabios packaged one
281 rm "${ED}/usr/share/qemu/vgabios.bin"
282 rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
283 rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
284 rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
285 rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
286 dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
287 dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
288 dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
289 dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
290 dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
292 # Remove sgabios since we're using the sgabios packaged one
293 rm "${ED}/usr/share/qemu/sgabios.bin"
294 dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
296 # Remove iPXE since we're using the iPXE packaged one
297 rm "${ED}"/usr/share/qemu/pxe-*.rom
298 dosym ../ipxe/808610de.rom /usr/share/qemu/pxe-e1000.rom
299 dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
300 dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
301 dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
302 dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
303 dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
307 if [[ -n ${softmmu_targets} ]]; then
308 elog "If you don't have kvm compiled into the kernel, make sure you have"
309 elog "the kernel module loaded before running kvm. The easiest way to"
310 elog "ensure that the kernel module is loaded is to load it on boot."
311 elog "For AMD CPUs the module is called 'kvm-amd'"
312 elog "For Intel CPUs the module is called 'kvm-intel'"
313 elog "Please review /etc/conf.d/modules for how to load these"
315 elog "Make sure your user is in the 'kvm' group"
316 elog "Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
318 elog "The ssl USE flag was renamed to tls, so adjust your USE flags."
319 elog "The nss USE flag was renamed to smartcard, so adjust your USE flags."