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.0.ebuild,v 1.2 2012/10/20 16:27:36 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"
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 sdl \
20 smartcard spice static systemtap tci tls usbredir +uuid vde +vhost-net \
21 virtfs +vnc xattr xen xfs"
23 COMMON_TARGETS="i386 x86_64 alpha arm cris m68k microblaze microblazeel mips mipsel or32 ppc ppc64 sh4 sh4eb sparc sparc64 s390x unicore32"
24 IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} mips64 mips64el ppcemb xtensa xtensaeb"
25 IUSE_USER_TARGETS="${COMMON_TARGETS} armeb ppc64abi32 sparc32plus"
27 # Setup the default SoftMMU targets, while using the loops
28 # below to setup the other targets. x86_64 should be the only
29 # defaults on for qemu-kvm
30 IUSE="${IUSE} +qemu_softmmu_targets_x86_64"
31 REQUIRED_USE="|| ( qemu_softmmu_targets_x86_64"
33 for target in ${IUSE_SOFTMMU_TARGETS}; do
34 if [ "x${target}" = "xx86_64" ]; then
37 IUSE="${IUSE} qemu_softmmu_targets_${target}"
38 REQUIRED_USE="${REQUIRED_USE} qemu_softmmu_targets_${target}"
40 REQUIRED_USE="${REQUIRED_USE} )"
42 for target in ${IUSE_USER_TARGETS}; do
43 IUSE="${IUSE} qemu_user_targets_${target}"
46 REQUIRED_USE="${REQUIRED_USE}
47 static? ( !alsa !pulseaudio )
48 amd64? ( qemu_softmmu_targets_x86_64 )
49 x86? ( qemu_softmmu_targets_x86_64 )
51 kvm? ( kernel_linux )"
53 # Yep, you need both libcap and libcap-ng since virtfs only uses libcap.
54 LIB_DEPEND=">=dev-libs/glib-2.0[static-libs(+)]
55 sys-apps/pciutils[static-libs(+)]
56 sys-libs/zlib[static-libs(+)]
57 aio? ( dev-libs/libaio[static-libs(+)] )
58 caps? ( sys-libs/libcap-ng[static-libs(+)] )
59 curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
60 fdt? ( >=sys-apps/dtc-1.2.0[static-libs(+)] )
61 jpeg? ( virtual/jpeg[static-libs(+)] )
62 ncurses? ( sys-libs/ncurses[static-libs(+)] )
63 png? ( media-libs/libpng[static-libs(+)] )
64 rbd? ( sys-cluster/ceph[static-libs(+)] )
65 sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
66 sdl? ( >=media-libs/libsdl-1.2.11[static-libs(+)] )
67 spice? ( >=app-emulation/spice-0.9.0[static-libs(+)] )
68 tls? ( net-libs/gnutls[static-libs(+)] )
69 uuid? ( >=sys-apps/util-linux-2.16.0[static-libs(+)] )
70 vde? ( net-misc/vde[static-libs(+)] )
71 xattr? ( sys-apps/attr[static-libs(+)] )
72 xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
73 RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs(+)]} )
76 !<app-emulation/qemu-1.0
78 >=sys-firmware/seabios-1.7.0
81 alsa? ( >=media-libs/alsa-lib-1.0.13 )
82 bluetooth? ( net-wireless/bluez )
83 brltty? ( app-accessibility/brltty )
84 opengl? ( virtual/opengl )
85 pulseaudio? ( media-sound/pulseaudio )
86 python? ( =dev-lang/python-2*[ncurses] )
87 sdl? ( media-libs/libsdl[X] )
88 smartcard? ( dev-libs/nss )
89 spice? ( >=app-emulation/spice-protocol-0.8.1 )
90 systemtap? ( dev-util/systemtap )
91 usbredir? ( sys-apps/usbredir )
92 virtfs? ( sys-libs/libcap )
93 xen? ( app-emulation/xen-tools )"
98 kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
99 static? ( ${LIB_DEPEND} )"
101 STRIP_MASK="/usr/share/qemu/palcode-clipper"
104 usr/share/qemu/openbios-ppc
105 usr/share/qemu/openbios-sparc64
106 usr/share/qemu/openbios-sparc32
107 usr/share/qemu/palcode-clipper"
109 QA_WX_LOAD="${QA_PRESTRIPPED}
116 usr/bin/qemu-microblaze
121 usr/bin/qemu-ppc64abi32
127 usr/bin/qemu-sparc32plus"
131 ewarn "USE=static is very much a moving target because of the packages"
132 ewarn "we depend on will have their static libs ripped out or wrapped"
133 ewarn "with USE=static-libs or USE=static due to continued dicsussion"
134 ewarn "on the mailing list about USE=static's place in Gentoo. As a"
135 ewarn "result what worked today may not work tomorrow."
140 python_set_active_version 2
147 # Alter target makefiles to accept CFLAGS set via flag-o
148 sed -i 's/^\(C\|OP_C\|HELPER_C\)FLAGS=/\1FLAGS+=/' \
149 Makefile Makefile.target || die
151 python_convert_shebangs -r 2 "${S}/scripts/kvm/kvm_stat"
153 epatch "${FILESDIR}"/${P}-fix-mipsen.patch
154 [[ -n ${BACKPORTS} ]] && \
155 EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
162 local conf_opts audio_opts user_targets
164 for target in ${IUSE_SOFTMMU_TARGETS} ; do
165 use "qemu_softmmu_targets_${target}" && \
166 softmmu_targets="${softmmu_targets} ${target}-softmmu"
169 for target in ${IUSE_USER_TARGETS} ; do
170 use "qemu_user_targets_${target}" && \
171 user_targets="${user_targets} ${target}-linux-user"
174 einfo "Building the following softmmu targets: ${softmmu_targets}"
176 if [[ -n ${user_targets} ]]; then
177 einfo "Building the following user targets: ${user_targets}"
178 conf_opts="${conf_opts} --enable-linux-user"
180 conf_opts="${conf_opts} --disable-linux-user"
183 # Add support for SystemTAP
184 use systemtap && conf_opts="${conf_opts} --enable-trace-backend=dtrace"
186 # Fix QA issues. QEMU needs executable heaps and we need to mark it as such
187 #conf_opts="${conf_opts} --extra-ldflags=-Wl,-z,execheap"
189 # Add support for static builds
190 use static && conf_opts="${conf_opts} --static --disable-pie"
192 # We always want to attempt to build with PIE support as it results
193 # in a more secure binary. But it doesn't work with static or if
194 # the current GCC doesn't have PIE support.
195 if ! use static && gcc-specs-pie; then
196 conf_opts="${conf_opts} --enable-pie"
201 use alsa && audio_opts="alsa,${audio_opts}"
202 use sdl && audio_opts="sdl,${audio_opts}"
203 use pulseaudio && audio_opts="pa,${audio_opts}"
204 use mixemu && conf_opts="${conf_opts} --enable-mixemu"
206 # $(use_enable xen xen-pci-passthrough) for 1.2
207 # $(use_enable debug debug-mon) goes away for 1.2
208 # --disable-seccomp as in-tree seccomp is API incompatible (in-tree
209 # version is ancient)
210 ./configure --prefix=/usr \
213 --disable-guest-agent \
219 $(use_enable aio linux-aio) \
220 $(use_enable bluetooth bluez) \
221 $(use_enable brltty brlapi) \
222 $(use_enable caps cap-ng) \
224 $(use_enable debug debug-info) \
225 $(use_enable debug debug-tcg) \
226 $(use_enable doc docs) \
228 $(use_enable jpeg vnc-jpeg) \
230 $(use_enable kernel_linux nptl) \
231 $(use_enable ncurses curses) \
232 $(use_enable opengl) \
233 $(use_enable png vnc-png) \
235 $(use_enable sasl vnc-sasl) \
237 $(use_enable smartcard smartcard) \
238 $(use_enable smartcard smartcard-nss) \
239 $(use_enable spice) \
240 $(use_enable tci tcg-interpreter) \
241 $(use_enable tls vnc-tls) \
242 $(use_enable usbredir usb-redir) \
245 $(use_enable vhost-net) \
246 $(use_enable virtfs) \
248 $(use_enable xattr attr) \
250 $(use_enable xen xen-pci-passthrough) \
251 $(use_enable xfs xfsctl) \
252 --audio-drv-list=${audio_opts} \
253 --target-list="${softmmu_targets} ${user_targets}" \
255 --host-cc="$(tc-getBUILD_CC)" \
257 || die "configure failed"
259 # FreeBSD's kernel does not support QEMU assigning/grabbing
260 # host USB devices yet
261 use kernel_FreeBSD && \
262 sed -E -e "s|^(HOST_USB=)bsd|\1stub|" -i "${S}"/config-host.mak
266 emake DESTDIR="${ED}" install
268 if use kvm && [[ -n ${softmmu_targets} ]]; then
269 insinto /lib/udev/rules.d/
270 doins "${FILESDIR}"/65-kvm.rules
273 dodoc Changelog MAINTAINERS TODO pci-ids.txt
274 newdoc pc-bios/README README.pc-bios
277 dohtml qemu-doc.html qemu-tech.html || die
280 use python & dobin scripts/kvm/kvm_stat
282 # Remove SeaBIOS since we're using the SeaBIOS packaged one
283 rm "${ED}/usr/share/qemu/bios.bin"
284 dosym ../seabios/bios.bin /usr/share/qemu/bios.bin
286 # Remove vgabios since we're using the vgabios packaged one
287 rm "${ED}/usr/share/qemu/vgabios.bin"
288 rm "${ED}/usr/share/qemu/vgabios-cirrus.bin"
289 rm "${ED}/usr/share/qemu/vgabios-qxl.bin"
290 rm "${ED}/usr/share/qemu/vgabios-stdvga.bin"
291 rm "${ED}/usr/share/qemu/vgabios-vmware.bin"
292 dosym ../vgabios/vgabios.bin /usr/share/qemu/vgabios.bin
293 dosym ../vgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin
294 dosym ../vgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin
295 dosym ../vgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin
296 dosym ../vgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin
298 # Remove sgabios since we're using the sgabios packaged one
299 rm "${ED}/usr/share/qemu/sgabios.bin"
300 dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin
302 # Remove iPXE since we're using the iPXE packaged one
303 rm "${ED}/usr/share/qemu/pxe-*.rom"
304 dosym ../ipxe/808610de.rom /usr/share/qemu/pxe-e1000.rom
305 dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom
306 dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom
307 dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom
308 dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom
309 dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom
313 if [[ -n ${softmmu_targets} ]]; then
314 elog "If you don't have kvm compiled into the kernel, make sure you have"
315 elog "the kernel module loaded before running kvm. The easiest way to"
316 elog "ensure that the kernel module is loaded is to load it on boot."
317 elog "For AMD CPUs the module is called 'kvm-amd'"
318 elog "For Intel CPUs the module is called 'kvm-intel'"
319 elog "Please review /etc/conf.d/modules for how to load these"
321 elog "Make sure your user is in the 'kvm' group"
322 elog "Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
324 elog "The ssl USE flag was renamed to tls, so adjust your USE flags."
325 elog "The nss USE flag was renamed to smartcard, so adjust your USE flags."