]> git.draconx.ca Git - gentoo-draconx.git/blob - app-emulation/qemu/qemu-1.2.1.ebuild
9a0142a6f7313fb1b84a1a06965fcb3103203acb
[gentoo-draconx.git] / app-emulation / qemu / qemu-1.2.1.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.1.ebuild,v 1.3 2012/12/05 21:37:29 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 \
20 +seccomp sdl smartcard spice static systemtap tci +threads tls usbredir \
21 +uuid vde +vhost-net virtfs +vnc xattr xen xfs"
22
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"
26
27 # Setup the default SoftMMU targets, while using the loops
28 # below to setup the other targets.
29 REQUIRED_USE="|| ("
30
31 for target in ${IUSE_SOFTMMU_TARGETS}; do
32         IUSE="${IUSE} qemu_softmmu_targets_${target}"
33         REQUIRED_USE="${REQUIRED_USE} qemu_softmmu_targets_${target}"
34 done
35 REQUIRED_USE="${REQUIRED_USE} )"
36
37 for target in ${IUSE_USER_TARGETS}; do
38         IUSE="${IUSE} qemu_user_targets_${target}"
39 done
40
41 # Block USE flag configurations known to not work
42 REQUIRED_USE="${REQUIRED_USE}
43         static? ( !alsa !pulseaudio !bluetooth )
44         virtfs? ( xattr )"
45
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(+)]} )
68         !app-emulation/kqemu
69         sys-firmware/ipxe
70         >=sys-firmware/seabios-1.7.0
71         sys-firmware/sgabios
72         sys-firmware/vgabios
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 )
83         usbredir? (
84                 >=sys-apps/usbredir-0.3.4
85                 x86? ( <sys-apps/usbredir-0.5 )
86                 )
87         virtfs? ( sys-libs/libcap )
88         xen? ( app-emulation/xen-tools )"
89
90 DEPEND="${RDEPEND}
91         virtual/pkgconfig
92         doc? ( app-text/texi2html )
93         kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
94         static? ( ${LIB_DEPEND} )"
95
96 STRIP_MASK="/usr/share/qemu/palcode-clipper"
97
98 QA_PREBUILT="
99         usr/share/qemu/openbios-ppc
100         usr/share/qemu/openbios-sparc64
101         usr/share/qemu/openbios-sparc32
102         usr/share/qemu/palcode-clipper"
103
104 QA_WX_LOAD="${QA_PRESTRIPPED}
105         usr/bin/qemu-i386
106         usr/bin/qemu-x86_64
107         usr/bin/qemu-alpha
108         usr/bin/qemu-arm
109         usr/bin/qemu-cris
110         usr/bin/qemu-m68k
111         usr/bin/qemu-microblaze
112         usr/bin/qemu-mips
113         usr/bin/qemu-mipsel
114         usr/bin/qemu-ppc
115         usr/bin/qemu-ppc64
116         usr/bin/qemu-ppc64abi32
117         usr/bin/qemu-sh4
118         usr/bin/qemu-sh4eb
119         usr/bin/qemu-sparc
120         usr/bin/qemu-sparc64
121         usr/bin/qemu-armeb
122         usr/bin/qemu-sparc32plus"
123
124 pkg_pretend() {
125         if use static; then
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."
131         fi
132 }
133
134 pkg_setup() {
135         python_set_active_version 2
136         python_pkg_setup
137
138         enewgroup kvm 78
139 }
140
141 src_prepare() {
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
145
146         python_convert_shebangs -r 2 "${S}/scripts/kvm/kvm_stat"
147
148         epatch "${FILESDIR}"/qemu-1.2.0-cflags.patch
149         [[ -n ${BACKPORTS} ]] && \
150                 EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" \
151                         epatch
152
153         epatch_user
154 }
155
156 src_configure() {
157         local conf_opts audio_opts user_targets
158
159         for target in ${IUSE_SOFTMMU_TARGETS} ; do
160                 use "qemu_softmmu_targets_${target}" && \
161                 softmmu_targets="${softmmu_targets} ${target}-softmmu"
162         done
163
164         for target in ${IUSE_USER_TARGETS} ; do
165                 use "qemu_user_targets_${target}" && \
166                 user_targets="${user_targets} ${target}-linux-user"
167         done
168
169         einfo "Building the following softmmu targets: ${softmmu_targets}"
170
171         if [[ -n ${user_targets} ]]; then
172                 einfo "Building the following user targets: ${user_targets}"
173                 conf_opts="${conf_opts} --enable-linux-user"
174         else
175                 conf_opts="${conf_opts} --disable-linux-user"
176         fi
177
178         # Add support for SystemTAP
179         use systemtap && conf_opts="${conf_opts} --enable-trace-backend=dtrace"
180
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"
183
184         # Add support for static builds
185         use static && conf_opts="${conf_opts} --static --disable-pie"
186
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"
192         fi
193
194         # audio options
195         audio_opts="oss"
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"
200
201         ./configure --prefix=/usr \
202                 --sysconfdir=/etc \
203                 --disable-bsd-user \
204                 --disable-guest-agent \
205                 --disable-libiscsi \
206                 --disable-strip \
207                 --disable-werror \
208                 --python=python2 \
209                 $(use_enable aio linux-aio) \
210                 $(use_enable bluetooth bluez) \
211                 $(use_enable brltty brlapi) \
212                 $(use_enable caps cap-ng) \
213                 $(use_enable curl) \
214                 $(use_enable debug debug-info) \
215                 $(use_enable debug debug-tcg) \
216                 $(use_enable doc docs) \
217                 $(use_enable fdt) \
218                 $(use_enable jpeg vnc-jpeg) \
219                 $(use_enable kvm) \
220                 $(use_enable kernel_linux nptl) \
221                 $(use_enable ncurses curses) \
222                 $(use_enable opengl) \
223                 $(use_enable png vnc-png) \
224                 $(use_enable rbd) \
225                 $(use_enable sasl vnc-sasl) \
226                 $(use_enable sdl) \
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) \
234                 $(use_enable uuid) \
235                 $(use_enable vde) \
236                 $(use_enable vhost-net) \
237                 $(use_enable virtfs) \
238                 $(use_enable vnc) \
239                 $(use_enable xattr attr) \
240                 $(use_enable xen) \
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}" \
245                 --cc="$(tc-getCC)" \
246                 --host-cc="$(tc-getBUILD_CC)" \
247                 ${conf_opts} \
248                 || die "configure failed"
249
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
254 }
255
256 src_install() {
257         emake DESTDIR="${ED}" install
258
259         if use kvm && [[ -n ${softmmu_targets} ]]; then
260                 insinto /lib/udev/rules.d/
261                 doins "${FILESDIR}"/65-kvm.rules
262         fi
263
264         dodoc Changelog MAINTAINERS TODO pci-ids.txt
265         newdoc pc-bios/README README.pc-bios
266
267         if use doc; then
268                 dohtml qemu-doc.html qemu-tech.html || die
269         fi
270
271         use python & dobin scripts/kvm/kvm_stat
272
273         # Avoid collision with app-emulation/libcacard
274         use smartcard && mv "${ED}/usr/bin/vscclient" "${ED}/usr/bin/qemu-vscclient"
275
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
279
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
291
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
295
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
304 }
305
306 pkg_postinst() {
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"
314                 elog
315                 elog "Make sure your user is in the 'kvm' group"
316                 elog "Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
317                 elog
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."
320         fi
321 }