]> git.draconx.ca Git - gentoo-draconx.git/blob - app-emulation/qemu/qemu-1.2.0.ebuild
Merge branch 'amythaon'
[gentoo-draconx.git] / app-emulation / qemu / qemu-1.2.0.ebuild
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 $
4
5 EAPI="4"
6
7 PYTHON_DEPEND="2"
8 inherit eutils flag-o-matic linux-info toolchain-funcs multilib python user
9
10 SRC_URI="http://wiki.qemu.org/download/${P}.tar.bz2"
11 KEYWORDS=""
12
13 DESCRIPTION="Free machine emulator and virtualizer"
14 HOMEPAGE="http://www.qemu.org/"
15
16 LICENSE="GPL-2 LGPL-2 BSD-2"
17 SLOT="0"
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"
22
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"
26
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"
32
33 for target in ${IUSE_SOFTMMU_TARGETS}; do
34         if [ "x${target}" = "xx86_64" ]; then
35                 continue
36         fi
37         IUSE="${IUSE} qemu_softmmu_targets_${target}"
38         REQUIRED_USE="${REQUIRED_USE} qemu_softmmu_targets_${target}"
39 done
40 REQUIRED_USE="${REQUIRED_USE} )"
41
42 for target in ${IUSE_USER_TARGETS}; do
43         IUSE="${IUSE} qemu_user_targets_${target}"
44 done
45
46 REQUIRED_USE="${REQUIRED_USE}
47         static? ( !alsa !pulseaudio )
48         amd64? ( qemu_softmmu_targets_x86_64 )
49         x86? ( qemu_softmmu_targets_x86_64 )
50         virtfs? ( xattr )
51         kvm? ( kernel_linux )"
52
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(+)]} )
74         !app-emulation/kqemu
75         !app-emulation/qemu
76         !<app-emulation/qemu-1.0
77         sys-firmware/ipxe
78         >=sys-firmware/seabios-1.7.0
79         sys-firmware/sgabios
80         sys-firmware/vgabios
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 )"
94
95 DEPEND="${RDEPEND}
96         app-text/texi2html
97         virtual/pkgconfig
98         kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
99         static? ( ${LIB_DEPEND} )"
100
101 STRIP_MASK="/usr/share/qemu/palcode-clipper"
102
103 QA_PREBUILT="
104         usr/share/qemu/openbios-ppc
105         usr/share/qemu/openbios-sparc64
106         usr/share/qemu/openbios-sparc32
107         usr/share/qemu/palcode-clipper"
108
109 QA_WX_LOAD="${QA_PRESTRIPPED}
110         usr/bin/qemu-i386
111         usr/bin/qemu-x86_64
112         usr/bin/qemu-alpha
113         usr/bin/qemu-arm
114         usr/bin/qemu-cris
115         usr/bin/qemu-m68k
116         usr/bin/qemu-microblaze
117         usr/bin/qemu-mips
118         usr/bin/qemu-mipsel
119         usr/bin/qemu-ppc
120         usr/bin/qemu-ppc64
121         usr/bin/qemu-ppc64abi32
122         usr/bin/qemu-sh4
123         usr/bin/qemu-sh4eb
124         usr/bin/qemu-sparc
125         usr/bin/qemu-sparc64
126         usr/bin/qemu-armeb
127         usr/bin/qemu-sparc32plus"
128
129 pkg_pretend() {
130         if use static; then
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."
136         fi
137 }
138
139 pkg_setup() {
140         python_set_active_version 2
141         python_pkg_setup
142
143         enewgroup kvm 78
144 }
145
146 src_prepare() {
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
150
151         python_convert_shebangs -r 2 "${S}/scripts/kvm/kvm_stat"
152
153         epatch "${FILESDIR}"/${P}-fix-mipsen.patch
154         [[ -n ${BACKPORTS} ]] && \
155                 EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
156                         epatch
157
158         epatch_user
159 }
160
161 src_configure() {
162         local conf_opts audio_opts user_targets
163
164         for target in ${IUSE_SOFTMMU_TARGETS} ; do
165                 use "qemu_softmmu_targets_${target}" && \
166                 softmmu_targets="${softmmu_targets} ${target}-softmmu"
167         done
168
169         for target in ${IUSE_USER_TARGETS} ; do
170                 use "qemu_user_targets_${target}" && \
171                 user_targets="${user_targets} ${target}-linux-user"
172         done
173
174         einfo "Building the following softmmu targets: ${softmmu_targets}"
175
176         if [[ -n ${user_targets} ]]; then
177                 einfo "Building the following user targets: ${user_targets}"
178                 conf_opts="${conf_opts} --enable-linux-user"
179         else
180                 conf_opts="${conf_opts} --disable-linux-user"
181         fi
182
183         # Add support for SystemTAP
184         use systemtap && conf_opts="${conf_opts} --enable-trace-backend=dtrace"
185
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"
188
189         # Add support for static builds
190         use static && conf_opts="${conf_opts} --static --disable-pie"
191
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"
197         fi
198
199         # audio options
200         audio_opts="oss"
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"
205
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 \
211                 --sysconfdir=/etc \
212                 --disable-bsd-user \
213                 --disable-guest-agent \
214                 --disable-libiscsi \
215                 --disable-strip \
216                 --disable-werror \
217                 --python=python2 \
218                 --disable-seccomp \
219                 $(use_enable aio linux-aio) \
220                 $(use_enable bluetooth bluez) \
221                 $(use_enable brltty brlapi) \
222                 $(use_enable caps cap-ng) \
223                 $(use_enable curl) \
224                 $(use_enable debug debug-info) \
225                 $(use_enable debug debug-tcg) \
226                 $(use_enable doc docs) \
227                 $(use_enable fdt) \
228                 $(use_enable jpeg vnc-jpeg) \
229                 $(use_enable kvm) \
230                 $(use_enable kernel_linux nptl) \
231                 $(use_enable ncurses curses) \
232                 $(use_enable opengl) \
233                 $(use_enable png vnc-png) \
234                 $(use_enable rbd) \
235                 $(use_enable sasl vnc-sasl) \
236                 $(use_enable sdl) \
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) \
243                 $(use_enable uuid) \
244                 $(use_enable vde) \
245                 $(use_enable vhost-net) \
246                 $(use_enable virtfs) \
247                 $(use_enable vnc) \
248                 $(use_enable xattr attr) \
249                 $(use_enable xen) \
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}" \
254                 --cc="$(tc-getCC)" \
255                 --host-cc="$(tc-getBUILD_CC)" \
256                 ${conf_opts} \
257                 || die "configure failed"
258
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
263 }
264
265 src_install() {
266         emake DESTDIR="${ED}" install
267
268         if use kvm && [[ -n ${softmmu_targets} ]]; then
269                 insinto /lib/udev/rules.d/
270                 doins "${FILESDIR}"/65-kvm.rules
271         fi
272
273         dodoc Changelog MAINTAINERS TODO pci-ids.txt
274         newdoc pc-bios/README README.pc-bios
275
276         if use doc; then
277                 dohtml qemu-doc.html qemu-tech.html || die
278         fi
279
280         use python & dobin scripts/kvm/kvm_stat
281
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
285
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
297
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
301
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
310 }
311
312 pkg_postinst() {
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"
320                 elog
321                 elog "Make sure your user is in the 'kvm' group"
322                 elog "Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
323                 elog
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."
326         fi
327 }