3 # - wait till the gcc bug http://gcc.gnu.org/PR16185 is fixed.
6 %bcond_without kqemu # disable KQEMU ACCELERATOR support in QEMU
7 %bcond_with cflags_passing # with passing rpmcflags to Makefiles
8 %bcond_with dosguest # add special patch when use with DOS as guest os
9 %bcond_with nosdlgui # do not use SDL gui (use X11 instead)
10 # Note that gcc4 build is very problematic and not supported by qemu team
11 %bcond_with gcc4 # use gcc4 patches (broke build on gcc33)
12 %bcond_without dist_kernel # without distribution kernel
13 %bcond_without kernel # build kqemu KERNEL MODULES
14 %bcond_without up # don't build up module
15 %bcond_without smp # don't build SMP module
16 %bcond_without userspace # don't build userspace utilities
17 %bcond_with grsec_kernel # build for kernel-grsecurity
20 %undefine with_dist_kernel
22 %if %{with dist_kernel} && %{with grsec_kernel}
23 %define alt_kernel grsecurity
26 # no kernel kqemu module for ppc
32 %if "%{_alt_kernel}" != "%{nil}"
33 %undefine with_userspace
36 %define kqemu_version 1.3.0pre11
37 %define qemu_version 0.9.1
41 Summary: QEMU CPU Emulator
42 Summary(pl): QEMU - emulator procesora
43 Name: %{pname}%{_alt_kernel}
44 Version: %{qemu_version}
45 Release: %{rel}%{?with_kqemu:k}
47 Group: Applications/Emulators
48 #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
49 Source0: http://fabrice.bellard.free.fr/qemu/%{pname}-%{version}.tar.gz
50 # Source0-md5: 6591df8e9270eb358c881de4ebea1262
51 Source1: http://fabrice.bellard.free.fr/qemu/k%{pname}-%{kqemu_version}.tar.gz
52 # Source1-md5: 970521874ef8b1ba4598925ace5936c3
53 Patch0: %{pname}-nostatic.patch
54 Patch1: %{pname}-cc.patch
55 Patch3: %{pname}-dot.patch
56 Patch4: %{pname}-gcc4_x86.patch
57 Patch5: %{pname}-gcc4_ppc.patch
58 Patch6: %{pname}-nosdlgui.patch
59 Patch7: %{pname}-ifup.patch
60 # Proof of concept, for reference, do not remove
61 Patch8: %{pname}-kde_virtual_workspaces_hack.patch
62 # http://gwenole.beauchesne.info/en/projects/qemu
63 Patch9: %{pname}-0.8.0-gcc4-hacks.patch
64 Patch11: %{pname}-0.7.2-gcc4-opts.patch
65 #Patch12: %{pname}-0.7.2-dyngen-check-stack-clobbers.patch
66 Patch13: %{pname}-dosguest.patch
67 Patch14: %{pname}-ppc_old_binutils.patch
68 Patch15: %{pname}-isa-bios-ram.patch
69 # below one fixes problems with passing ram size to bios/bootloader
70 # which affects coreboot/linuxbios
71 Patch16: %{pname}-piix-ram-size.patch
72 URL: http://fabrice.bellard.free.fr/qemu/
74 %{?with_dist_kernel:BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.7}
75 BuildRequires: rpmbuild(macros) >= 1.330
78 BuildRequires: SDL-devel >= 1.2.1
79 BuildRequires: alsa-lib-devel
80 %{!?with_gcc4:BuildRequires: gcc < 5:4.0}
81 BuildRequires: perl-tools-pod
83 BuildRequires: sed >= 4.0
85 Requires: SDL >= 1.2.1
86 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
87 ExclusiveArch: %{ix86} %{x8664} %{?with_userspace:ppc}
88 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
90 # some SPARC boot image in ELF format
91 %define _noautostrip .*%{_datadir}/qemu/openbios-sparc32
94 QEMU is a FAST! processor emulator. By using dynamic translation it
95 achieves a reasonnable speed while being easy to port on new host
96 CPUs. QEMU has two operating modes:
98 - User mode emulation. In this mode, QEMU can launch Linux processes
99 compiled for one CPU on another CPU. Linux system calls are converted
100 because of endianness and 32/64 bit mismatches. Wine (Windows
101 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
103 - Full system emulation. In this mode, QEMU emulates a full system,
104 including a processor and various peripherials. It can also be used to
105 provide virtual hosting of several virtual PC on a single server.
108 QEMU to szybki(!) emulator procesora. Poprzez u¿ycie dynamicznego
109 t³umaczenia osi±ga rozs±dn± szybko¶æ i jest ³atwy do przeportowania,
110 aby dzia³a³ na kolejnych procesorach. QEMU ma dwa tryby pracy:
112 - Emulacja trybu u¿ytkownika. W tym trybie QEMU mo¿e uruchamiaæ
113 procesy linuksowe skompilowane dla jednego procesora na innym
114 procesorze. Linuksowe wywo³ania systemowe s± t³umaczone ze wzglêdu na
115 niezgodno¶æ kolejno¶ci bajtów w s³owie i 32/64-bitowego rozmiaru
116 s³owa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to g³ówne
119 - Pe³na emulacja systemu. W tym trybie QEMU emuluje ca³y system,
120 w³±czaj±c w to procesor i ró¿ne urz±dzenia peryferyjne. Mo¿e byæ tak¿e
121 u¿ywane do wirtualnego hostowania kilku wirtualnych pecetów na
122 pojedynczym serwerze.
124 %package -n kernel%{_alt_kernel}-misc-kqemu
125 Summary: kqemu - kernel module
126 Summary(pl): kqemu - modu³ j±dra
127 Version: %{kqemu_version}
128 Release: %{rel}@%{_kernel_ver_str}
130 %{?with_dist_kernel:%requires_releq_kernel_up}
132 Requires(post,postun): /sbin/depmod
133 Requires: module-init-tools >= 3.2.2-2
135 %description -n kernel%{_alt_kernel}-misc-kqemu
136 kqemu - kernel module.
138 %description -n kernel%{_alt_kernel}-misc-kqemu -l pl
141 %package -n kernel%{_alt_kernel}-smp-misc-kqemu
142 Summary: kqemu - SMP kernel module
143 Summary(pl): kqemu - modu³ j±dra SMP
144 Version: %{kqemu_version}
145 Release: %{rel}@%{_kernel_ver_str}
147 %{?with_dist_kernel:%requires_releq_kernel_smp}
149 Requires(post,postun): /sbin/depmod
150 Requires: module-init-tools >= 3.2.2-2
152 %description -n kernel%{_alt_kernel}-smp-misc-kqemu
153 kqemu - SMP kernel module.
155 %description -n kernel%{_alt_kernel}-smp-misc-kqemu -l pl
156 kqemu - modu³ j±dra SMP.
160 %if %{with dist_kernel} && %{without up} && %{without smp}
161 %{error:%{pname}: If building kernel module You need to enable at least one of up or smp}
166 %setup -q -n %{pname}-%{qemu_version} %{?with_kernel:-a1}
177 %{?with_nosdlgui:%patch6 -p1}
181 %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure
182 %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile
184 # cannot use optflags on x86 - they cause "no register to spill" errors
185 %if %{with cflags_passing}
186 %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target
188 %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target
192 echo -n > kqemu-%{kqemu_version}/install.sh
194 cat <<'EOF' > modprobe.conf
195 # enable dynamic major
196 options kqemu major=0
197 # for autoloading from static dev
198 #alias char-major-250 kqemu
201 cat <<'EOF' > udev.conf
202 KERNEL=="kqemu", NAME="%k", MODE="0666"
215 cd kqemu-%{kqemu_version}
217 %{__sed} -i 's#include ../config-host.mak##' ./common/Makefile
219 %{__sed} -i 's/^#ARCH=x86_64/ARCH=x86_64/' ./common/Makefile
220 %{__make} -C common -j1
221 mv -f kqemu-mod-x86_64.o{,.bin}
223 %{__sed} -i 's/^#ARCH=i386/ARCH=i386/' ./common/Makefile
224 %{__make} -C common -j1
225 mv -f kqemu-mod-i386.o{,.bin}
228 mv -f kqemu-linux.c{,.orig}
229 cat > Makefile <<'EOF'
231 kqemu-objs:= kqemu-linux.o kqemu-mod.o
233 $(obj)/kqemu-mod.o: $(src)/kqemu-mod-$(ARCH).o.bin
237 %build_kernel_modules -m kqemu <<'EOF'
238 if grep -q "CONFIG_PREEMPT_RT" o/.config; then
239 sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
240 kqemu-linux.c.orig > kqemu-linux.c
242 cat kqemu-linux.c.orig > kqemu-linux.c
248 %if %{with userspace}
249 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
250 # they can be passed if the cflags_passing bcond is used
252 --prefix=%{_prefix} \
254 --host-cc="%{__cc}" \
259 %{?with_gcc4:--disable-gcc-check} \
261 --interp-prefix=%{_libdir}/%{pname}
266 rm -rf $RPM_BUILD_ROOT
268 %if %{with userspace}
270 DESTDIR=$RPM_BUILD_ROOT
272 install -d $RPM_BUILD_ROOT/sbin
273 cat <<'EOF' > $RPM_BUILD_ROOT/sbin/qemu-ifup
275 if [ -f /etc/sysconfig/qemu ]; then
276 . /etc/sysconfig/qemu
278 # of course this will work only for one interface. a lot possible to involve
279 sudo /sbin/ifconfig $1 ${INTERFACE_ADDR:-172.20.0.1}
284 %install_kernel_modules -m kqemu-%{kqemu_version}/kqemu -d misc
285 install -d $RPM_BUILD_ROOT/etc/{modprobe.d/%{_kernel_ver}{,smp},udev/rules.d}
286 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/kqemu.conf
287 %if %{with smp} && %{with dist_kernel}
288 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}smp/kqemu.conf
290 install udev.conf $RPM_BUILD_ROOT/etc/udev/rules.d/kqemu.rules
294 rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-{doc,tech}.html
297 rm -rf $RPM_BUILD_ROOT
301 %banner %{pname} -e <<EOF
302 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
307 %post -n kernel%{_alt_kernel}-misc-kqemu
308 %depmod %{_kernel_ver}
310 %postun -n kernel%{_alt_kernel}-misc-kqemu
311 %depmod %{_kernel_ver}
313 %post -n kernel%{_alt_kernel}-smp-misc-kqemu
314 %depmod %{_kernel_ver}smp
316 %postun -n kernel%{_alt_kernel}-smp-misc-kqemu
317 %depmod %{_kernel_ver}smp
319 %if %{with userspace}
321 %defattr(644,root,root,755)
322 %doc README qemu-doc.html qemu-tech.html
323 %attr(755,root,root) /sbin/qemu-ifup
324 %attr(755,root,root) %{_bindir}/*
326 %{_mandir}/man1/qemu.1*
327 %{_mandir}/man1/qemu-img.1*
331 %if %{with up} || %{without dist_kernel}
332 %files -n kernel%{_alt_kernel}-misc-kqemu
333 %defattr(644,root,root,755)
334 %doc kqemu-%{kqemu_version}/LICENSE
335 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
336 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}/kqemu.conf
337 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*
340 %if %{with smp} && %{with dist_kernel}
341 %files -n kernel%{_alt_kernel}-smp-misc-kqemu
342 %defattr(644,root,root,755)
343 %doc kqemu-%{kqemu_version}/LICENSE
344 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
345 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}smp/kqemu.conf
346 /lib/modules/%{_kernel_ver}smp/misc/kqemu.ko*