3 # - wait till the gcc bug http://gcc.gnu.org/PR16185 is fixed.
4 # - update or drop gcc4 bcond patches
7 %bcond_without kqemu # disable KQEMU ACCELERATOR support in QEMU
8 %bcond_with cflags_passing # with passing rpmcflags to Makefiles
9 %bcond_with dosguest # add special patch when use with DOS as guest os
10 %bcond_with nosdlgui # do not use SDL gui (use X11 instead)
11 %bcond_without dist_kernel # without distribution kernel
12 %bcond_without kernel # build kqemu KERNEL MODULES
13 %bcond_without userspace # don't build userspace utilities
15 # no kernel kqemu module for ppc
22 %undefine with_dist_kernel
24 %if "%{_alt_kernel}" != "%{nil}"
25 %undefine with_userspace
27 %if %{without userspace}
28 # nothing to be placed to debuginfo package
29 %define _enable_debug_packages 0
36 %define kqemu_version 1.3.0pre11
37 %define qemu_version 0.9.1
39 Summary: QEMU CPU Emulator
40 Summary(pl.UTF-8): QEMU - emulator procesora
41 Name: %{pname}%{_alt_kernel}
42 Version: %{qemu_version}
43 Release: %{rel}%{?with_kqemu:k}
45 Group: Applications/Emulators
46 # Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
47 Source0: http://bellard.org/qemu/%{pname}-%{version}.tar.gz
48 # Source0-md5: 6591df8e9270eb358c881de4ebea1262
49 Source1: http://bellard.org/qemu/k%{pname}-%{kqemu_version}.tar.gz
50 # Source1-md5: 970521874ef8b1ba4598925ace5936c3
51 Patch0: %{pname}-nostatic.patch
52 Patch1: %{pname}-cc.patch
53 Patch3: %{pname}-dot.patch
54 Patch6: %{pname}-nosdlgui.patch
55 # Proof of concept, for reference, do not remove
56 Patch8: %{pname}-kde_virtual_workspaces_hack.patch
57 #Patch12: %{pname}-0.7.2-dyngen-check-stack-clobbers.patch
58 Patch13: %{pname}-dosguest.patch
59 Patch14: %{pname}-ppc_old_binutils.patch
60 Patch15: %{pname}-isa-bios-ram.patch
61 # below one fixes problems with passing ram size to bios/bootloader
62 # which affects coreboot/linuxbios
63 Patch16: %{pname}-piix-ram-size.patch
64 Patch17: %{pname}-CVE-2008-0928.patch
65 Patch18: %{pname}-CVE-2008-2004.patch
66 Patch19: %{pname}-gcc-workaround.patch
67 Patch20: %{pname}-dirent.patch
68 URL: http://bellard.org/qemu/
69 %if %{with kernel} && %{with dist_kernel}
70 BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.7
71 BuildRequires: rpmbuild(macros) >= 1.379
74 BuildRequires: SDL-devel >= 1.2.1
75 BuildRequires: alsa-lib-devel
76 BuildRequires: compat-gcc-34
77 BuildRequires: perl-tools-pod
78 BuildRequires: sed >= 4.0
82 Requires: SDL >= 1.2.1
83 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
84 ExclusiveArch: %{ix86} %{x8664} %{?with_userspace:ppc}
85 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
87 # some SPARC boot image in ELF format
88 %define _noautostrip .*%{_datadir}/qemu/openbios-sparc32
91 QEMU is a FAST! processor emulator. By using dynamic translation it
92 achieves a reasonnable speed while being easy to port on new host
93 CPUs. QEMU has two operating modes:
95 - User mode emulation. In this mode, QEMU can launch Linux processes
96 compiled for one CPU on another CPU. Linux system calls are converted
97 because of endianness and 32/64 bit mismatches. Wine (Windows
98 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
100 - Full system emulation. In this mode, QEMU emulates a full system,
101 including a processor and various peripherials. It can also be used to
102 provide virtual hosting of several virtual PC on a single server.
104 %description -l pl.UTF-8
105 QEMU to szybki(!) emulator procesora. Poprzez użycie dynamicznego
106 tłumaczenia osiąga rozsądną szybkość i jest łatwy do przeportowania,
107 aby działał na kolejnych procesorach. QEMU ma dwa tryby pracy:
109 - Emulacja trybu użytkownika. W tym trybie QEMU może uruchamiać
110 procesy linuksowe skompilowane dla jednego procesora na innym
111 procesorze. Linuksowe wywołania systemowe są tłumaczone ze względu na
112 niezgodność kolejności bajtów w słowie i 32/64-bitowego rozmiaru
113 słowa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to główne
116 - Pełna emulacja systemu. W tym trybie QEMU emuluje cały system,
117 włączając w to procesor i różne urządzenia peryferyjne. Może być także
118 używane do wirtualnego hostowania kilku wirtualnych pecetów na
119 pojedynczym serwerze.
121 %package -n kernel%{_alt_kernel}-misc-kqemu
122 Summary: kqemu - kernel module
123 Summary(pl.UTF-8): kqemu - moduł jądra
124 Version: %{kqemu_version}
125 Release: %{rel}@%{_kernel_ver_str}
127 %{?with_dist_kernel:%requires_releq_kernel}
129 Obsoletes: kernel%{_alt_kernel}-smp-misc-kqemu
130 Requires(post,postun): /sbin/depmod
131 Requires: module-init-tools >= 3.2.2-2
133 %description -n kernel%{_alt_kernel}-misc-kqemu
134 kqemu - kernel module.
136 %description -n kernel%{_alt_kernel}-misc-kqemu -l pl.UTF-8
140 %setup -q -n %{pname}-%{qemu_version} %{?with_kernel:-a1}
144 %{?with_nosdlgui:%patch6 -p1}
147 %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure
148 %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile
150 # cannot use optflags on x86 - they cause "no register to spill" errors
151 %if %{with cflags_passing}
152 %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target
154 %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target
158 echo -n > kqemu-%{kqemu_version}/install.sh
160 cat <<'EOF' > modprobe.conf
161 # enable dynamic major
162 options kqemu major=0
163 # for autoloading from static dev
164 #alias char-major-250 kqemu
167 cat <<'EOF' > udev.conf
168 KERNEL=="kqemu", NAME="%k", MODE="0666"
182 cd kqemu-%{kqemu_version}
183 %{__sed} -i 's#include ../config-host.mak##' ./common/Makefile
185 %{__sed} -i 's/^#ARCH=x86_64/ARCH=x86_64/' ./common/Makefile
186 %{__make} -C common -j1
187 mv -f kqemu-mod-x86_64.o{,.bin}
189 %{__sed} -i 's/^#ARCH=i386/ARCH=i386/' ./common/Makefile
190 %{__make} -C common -j1
191 mv -f kqemu-mod-i386.o{,.bin}
194 mv -f kqemu-linux.c{,.orig}
195 cat > Makefile <<'EOF'
197 kqemu-objs:= kqemu-linux.o kqemu-mod.o
199 $(obj)/kqemu-mod.o: $(src)/kqemu-mod-$(ARCH).o.bin
207 cd kqemu-%{kqemu_version}
208 %build_kernel_modules -m kqemu <<'EOF'
209 if grep -q "CONFIG_PREEMPT_RT" o/.config; then
210 sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
211 kqemu-linux.c.orig > kqemu-linux.c
213 cat kqemu-linux.c.orig > kqemu-linux.c
219 %if %{with userspace}
220 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
221 # they can be passed if the cflags_passing bcond is used
223 --prefix=%{_prefix} \
225 --host-cc="%{__ucc}" \
231 --interp-prefix=%{_libdir}/%{pname}
236 rm -rf $RPM_BUILD_ROOT
238 %if %{with userspace}
240 DESTDIR=$RPM_BUILD_ROOT
242 install -d $RPM_BUILD_ROOT%{_sysconfdir}
243 cat <<'EOF' > $RPM_BUILD_ROOT%{_sysconfdir}/qemu-ifup
250 %install_kernel_modules -m kqemu-%{kqemu_version}/kqemu -d misc
251 install -d $RPM_BUILD_ROOT/etc/{modprobe.d/%{_kernel_ver}{,smp},udev/rules.d}
252 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/kqemu.conf
253 install udev.conf $RPM_BUILD_ROOT/etc/udev/rules.d/kqemu.rules
257 rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-{doc,tech}.html
260 rm -rf $RPM_BUILD_ROOT
264 %banner %{pname} -e <<EOF
265 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
270 %post -n kernel%{_alt_kernel}-misc-kqemu
271 %depmod %{_kernel_ver}
273 %postun -n kernel%{_alt_kernel}-misc-kqemu
274 %depmod %{_kernel_ver}
276 %if %{with userspace}
278 %defattr(644,root,root,755)
279 %doc README qemu-doc.html qemu-tech.html
280 %attr(755,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/qemu-ifup
281 %attr(755,root,root) %{_bindir}/*
283 %{_mandir}/man1/qemu.1*
284 %{_mandir}/man1/qemu-img.1*
288 %files -n kernel%{_alt_kernel}-misc-kqemu
289 %defattr(644,root,root,755)
290 %doc kqemu-%{kqemu_version}/LICENSE
291 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
292 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}/kqemu.conf
293 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*