3 # - wait till the gcc bug http://gcc.gnu.org/PR16185 is fixed.
6 %bcond_with kqemu # with QEMU accelerator module
7 %bcond_with cflags_passing # with passing rpmcflags to Makefiles
8 %bcond_with nosdlgui # do not use SDL gui (use X11 instead)
9 %bcond_with gcc4 # use gcc4 patches (broke build on gcc33)
10 %bcond_without dist_kernel # without distribution kernel
11 %bcond_without kernel # don't build kernel modules
12 %bcond_without smp # don't build SMP module
13 %bcond_without userspace # don't build userspace utilities
19 %define _kqemu_version 1.3.0pre7
21 Summary: QEMU CPU Emulator
22 Summary(pl): QEMU - emulator procesora
25 Release: %{_rel}%{?with_kqemu:k}
27 Group: Applications/Emulators
28 #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
29 Source0: http://fabrice.bellard.free.fr/qemu/%{name}-%{version}.tar.gz
30 # Source0-md5: eb175b26583280706fe7e4d8910d320d
31 Source1: http://fabrice.bellard.free.fr/qemu/kqemu-%{_kqemu_version}.tar.gz
32 # NoSource1-md5: 3b77edbada790f924456aa4675edd0be
34 Patch0: %{name}-nostatic.patch
35 Patch1: %{name}-DESTDIR.patch
36 Patch2: %{name}-longjmp.patch
37 Patch3: %{name}-dot.patch
38 Patch4: %{name}-initrd_load_addr.patch
39 Patch5: %{name}-gcc4_x86.patch
40 Patch6: %{name}-gcc4_ppc.patch
41 Patch7: %{name}-parallel.patch
42 Patch8: %{name}-nosdlgui.patch
43 Patch9: %{name}-ifup.patch
44 Patch10: %{name}-gcc33.patch
45 Patch11: %{name}-slirp_throttle.patch
46 URL: http://fabrice.bellard.free.fr/qemu/
47 BuildRequires: SDL-devel >= 1.2.1
48 BuildRequires: alsa-lib-devel
49 %{!?with_gcc4:BuildRequires: gcc < 5:4.0}
50 %if %{with kqemu} && %{with dist_kernel}
51 BuildRequires: kernel-module-build >= 3:2.6.7
53 BuildRequires: rpmbuild(macros) >= 1.217
54 BuildRequires: sed >= 4.0
55 Requires: SDL >= 1.2.1
56 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
57 ExclusiveArch: %{ix86} %{x8664} %{!?with_kqemu:ppc}
58 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
60 # some SPARC boot image in ELF format
61 %define _noautostrip .*%{_datadir}/qemu/proll.elf
64 QEMU is a FAST! processor emulator. By using dynamic translation it
65 achieves a reasonnable speed while being easy to port on new host
66 CPUs. QEMU has two operating modes:
68 - User mode emulation. In this mode, QEMU can launch Linux processes
69 compiled for one CPU on another CPU. Linux system calls are converted
70 because of endianness and 32/64 bit mismatches. Wine (Windows
71 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
73 - Full system emulation. In this mode, QEMU emulates a full system,
74 including a processor and various peripherials. It can also be used to
75 provide virtual hosting of several virtual PC on a single server.
78 QEMU to szybki(!) emulator procesora. Poprzez u¿ycie dynamicznego
79 t³umaczenia osi±ga rozs±dn± szybko¶æ i jest ³atwy do przeportowania,
80 aby dzia³a³ na kolejnych procesorach. QEMU ma dwa tryby pracy:
82 - Emulacja trybu u¿ytkownika. W tym trybie QEMU mo¿e uruchamiaæ
83 procesy linuksowe skompilowane dla jednego procesora na innym
84 procesorze. Linuksowe wywo³ania systemowe s± t³umaczone ze wzglêdu na
85 niezgodno¶æ kolejno¶ci bajtów w s³owie i 32/64-bitowego rozmiaru
86 s³owa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to g³ówne
89 - Pe³na emulacja systemu. W tym trybie QEMU emuluje ca³y system,
90 w³±czaj±c w to procesor i ró¿ne urz±dzenia peryferyjne. Mo¿e byæ tak¿e
91 u¿ywane do wirtualnego hostowania kilku wirtualnych pecetów na
94 %package -n kernel-misc-kqemu
95 Summary: kqemu - kernel module
96 Summary(pl): kqemu - modu³ j±dra
97 Version: %{_kqemu_version}
98 Release: %{_rel}@%{_kernel_ver_str}
100 %{?with_dist_kernel:%requires_releq_kernel_up}
101 License: Free to use, non-distributable
102 Requires(post,postun): /sbin/depmod
103 Requires: module-init-tools >= 3.2.2-2
105 %description -n kernel-misc-kqemu
106 kqemu - kernel module.
108 %description -n kernel-misc-kqemu -l pl
111 %package -n kernel-smp-misc-kqemu
112 Summary: kqemu - SMP kernel module
113 Summary(pl): kqemu - modu³ j±dra SMP
114 Version: %{_kqemu_version}
115 Release: %{_rel}@%{_kernel_ver_str}
117 %{?with_dist_kernel:%requires_releq_kernel_up}
118 License: Free to use, non-distributable
119 Requires(post,postun): /sbin/depmod
120 Requires: module-init-tools >= 3.2.2-2
122 %description -n kernel-smp-misc-kqemu
123 kqemu - SMP kernel module.
125 %description -n kernel-smp-misc-kqemu -l pl
126 kqemu - modu³ j±dra SMP.
129 %setup -q %{?with_kqemu:-a1}
139 # probably not needed
141 %{?with_nosdlgui:%patch8 -p1}
146 %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure
147 %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile
149 # cannot use optflags on x86 - they cause "no register to spill" errors
150 %if %{with cflags_passing}
151 %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target
153 %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target
157 echo -n > kqemu-%{_kqemu_version}/install.sh
162 cd kqemu-%{_kqemu_version}
163 mv -f kqemu-linux.c{,.orig}
164 for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}; do
165 if [ ! -r "%{_kernelsrcdir}/config-$cfg" ]; then
168 install -d o/include/linux
169 ln -sf %{_kernelsrcdir}/config-$cfg o/.config
170 ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers
171 ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h
172 %if %{with dist_kernel}
173 %{__make} -C %{_kernelsrcdir} O=$PWD/o prepare scripts
175 install -d o/include/config
176 touch o/include/config/MARKER
177 ln -sf %{_kernelsrcdir}/scripts o/scripts
179 if grep -q "^CONFIG_PREEMPT_RT=y$" o/.config; then
180 sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
181 kqemu-linux.c.orig > kqemu-linux.c
183 cat kqemu-linux.c.orig > kqemu-linux.c
186 %{__make} -C %{_kernelsrcdir} modules \
187 CC="%{__cc}" CPP="%{__cpp}" \
190 mv kqemu.ko kqemu-mod-$cfg.ko
195 %if %{with userspace}
196 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
197 # they can be passed if the cflags_passing bcond is used
199 --prefix=%{_prefix} \
201 %{?with_gcc4:--disable-gcc-check} \
202 %{!?with_kqemu:--disable-kqemu} \
205 --interp-prefix=%{_libdir}/%{name}
210 rm -rf $RPM_BUILD_ROOT
212 %if %{with userspace}
214 DESTDIR=$RPM_BUILD_ROOT
216 install -d $RPM_BUILD_ROOT/sbin
217 cat <<'EOF' > $RPM_BUILD_ROOT/sbin/qemu-ifup
219 if [ -f /etc/sysconfig/qemu ]; then
220 . /etc/sysconfig/qemu
222 # of course this will work only for one interface. a lot possible to involve
223 sudo /sbin/ifconfig $1 ${INTERFACE_ADDR:-172.20.0.1}
228 install -d $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}{,smp}/misc
229 install kqemu-%{_kqemu_version}/kqemu-mod-up.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}/misc/kqemu.ko
230 %if %{with smp} && %{with dist_kernel}
231 install kqemu-%{_kqemu_version}/kqemu-mod-smp.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}smp/misc/kqemu.ko
233 install -d $RPM_BUILD_ROOT/etc/modprobe.d
234 echo 'alias char-major-250 kqemu' > $RPM_BUILD_ROOT/etc/modprobe.d/kqemu.conf
238 rm -rf $RPM_BUILD_ROOT
242 %banner %{name} -e <<EOF
243 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
248 %post -n kernel-misc-kqemu
249 %depmod %{_kernel_ver}
251 %postun -n kernel-misc-kqemu
252 %depmod %{_kernel_ver}
254 %post -n kernel-smp-misc-kqemu
255 %depmod %{_kernel_ver}smp
257 %postun -n kernel-smp-misc-kqemu
258 %depmod %{_kernel_ver}smp
260 %if %{with userspace}
262 %defattr(644,root,root,755)
263 %doc README qemu-doc.html qemu-tech.html
264 %attr(755,root,root) /sbin/qemu-ifup
265 %attr(755,root,root) %{_bindir}/*
267 %{_mandir}/man1/qemu.1*
268 %{_mandir}/man1/qemu-img.1*
269 # FIXME: maybe better moved this into dev.spec
271 %dev(c,250,0) %attr(666,root,root) /dev/kqemu
276 %files -n kernel-misc-kqemu
277 %defattr(644,root,root,755)
278 %doc kqemu-%{_kqemu_version}/LICENSE
279 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/kqemu.conf
280 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*
282 %if %{with smp} && %{with dist_kernel}
283 %files -n kernel-smp-misc-kqemu
284 %defattr(644,root,root,755)
285 %doc kqemu-%{_kqemu_version}/LICENSE
286 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/kqemu.conf
287 /lib/modules/%{_kernel_ver}smp/misc/kqemu.ko*