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
15 %define _kqemu_version 0.7.2
18 Summary: QEMU CPU Emulator
19 Summary(pl): QEMU - emulator procesora
22 Release: %{_rel}%{?with_kqemu:k}
24 Group: Applications/Emulators
25 #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
26 Source0: http://fabrice.bellard.free.fr/qemu/%{name}-%{version}.tar.gz
27 # Source0-md5: eb175b26583280706fe7e4d8910d320d
29 Source1: http://fabrice.bellard.free.fr/qemu/k%{name}-%{_kqemu_version}.tar.gz
30 # NoSource1-md5: 02cfdecda90458d6393781496ec6b48b
33 Patch0: %{name}-nostatic.patch
34 Patch1: %{name}-DESTDIR.patch
35 Patch2: %{name}-longjmp.patch
36 Patch3: %{name}-dot.patch
37 Patch4: %{name}-initrd_load_addr.patch
38 Patch5: %{name}-gcc4_x86.patch
39 Patch6: %{name}-gcc4_ppc.patch
40 Patch7: %{name}-parallel.patch
41 Patch8: %{name}-nosdlgui.patch
42 Patch9: %{name}-ifup.patch
43 Patch10: %{name}-gcc33.patch
44 Patch11: %{name}-slirp_throttle.patch
45 URL: http://fabrice.bellard.free.fr/qemu/
46 BuildRequires: SDL-devel >= 1.2.1
47 BuildRequires: alsa-lib-devel
48 %{!?with_gcc4:BuildRequires: gcc < 5:4.0}
49 %if %{with kqemu} && %{with dist_kernel}
50 BuildRequires: kernel-module-build >= 3:2.6.7
52 BuildRequires: rpmbuild(macros) >= 1.217
53 BuildRequires: sed >= 4.0
54 Requires: SDL >= 1.2.1
55 ExclusiveArch: %{ix86} %{x8664} %{!?with_kqemu:ppc}
56 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
57 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
59 # some SPARC boot image in ELF format
60 %define _noautostrip .*%{_datadir}/qemu/proll.elf
67 QEMU is a FAST! processor emulator. By using dynamic translation it
68 achieves a reasonnable speed while being easy to port on new host
69 CPUs. QEMU has two operating modes:
71 - User mode emulation. In this mode, QEMU can launch Linux processes
72 compiled for one CPU on another CPU. Linux system calls are converted
73 because of endianness and 32/64 bit mismatches. Wine (Windows
74 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
76 - Full system emulation. In this mode, QEMU emulates a full system,
77 including a processor and various peripherials. It can also be used to
78 provide virtual hosting of several virtual PC on a single server.
81 QEMU to szybki(!) emulator procesora. Poprzez u¿ycie dynamicznego
82 t³umaczenia osi±ga rozs±dn± szybko¶æ i jest ³atwy do przeportowania,
83 aby dzia³a³ na kolejnych procesorach. QEMU ma dwa tryby pracy:
85 - Emulacja trybu u¿ytkownika. W tym trybie QEMU mo¿e uruchamiaæ
86 procesy linuksowe skompilowane dla jednego procesora na innym
87 procesorze. Linuksowe wywo³ania systemowe s± t³umaczone ze wzglêdu na
88 niezgodno¶æ kolejno¶ci bajtów w s³owie i 32/64-bitowego rozmiaru
89 s³owa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to g³ówne
92 - Pe³na emulacja systemu. W tym trybie QEMU emuluje ca³y system,
93 w³±czaj±c w to procesor i ró¿ne urz±dzenia peryferyjne. Mo¿e byæ tak¿e
94 u¿ywane do wirtualnego hostowania kilku wirtualnych pecetów na
97 %package -n kernel-misc-kqemu
98 Summary: kqemu - kernel module
99 Summary(pl): kqemu - modu³ j±dra
100 Version: %{_kqemu_version}
101 Release: %{_rel}@%{_kernel_ver_str}
103 %{?with_dist_kernel:%requires_releq_kernel_up}
104 License: Free to use, non-distributable
105 Requires(post,postun): /sbin/depmod
107 %description -n kernel-misc-kqemu
108 kqemu - kernel module.
110 %description -n kernel-misc-kqemu -l pl
113 %package -n kernel-smp-misc-kqemu
114 Summary: kqemu - SMP kernel module
115 Summary(pl): kqemu - modu³ j±dra SMP
116 Version: %{_kqemu_version}
117 Release: %{_rel}@%{_kernel_ver_str}
119 %{?with_dist_kernel:%requires_releq_kernel_up}
120 License: Free to use, non-distributable
121 Requires(post,postun): /sbin/depmod
123 %description -n kernel-smp-misc-kqemu
124 kqemu - SMP kernel module.
126 %description -n kernel-smp-misc-kqemu -l pl
127 kqemu - modu³ j±dra SMP.
130 %setup -q %{?with_kqemu:-a1}
140 # probably not needed
142 %{?with_nosdlgui:%patch8 -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
157 %{?with_kqemu:echo -n > kqemu/install.sh}
162 mv -f kqemu-linux.c{,.orig}
163 for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}; do
164 if [ ! -r "%{_kernelsrcdir}/config-$cfg" ]; then
167 install -d o/include/linux
168 ln -sf %{_kernelsrcdir}/config-$cfg o/.config
169 ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers
170 ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h
171 %if %{with dist_kernel}
172 %{__make} -C %{_kernelsrcdir} O=$PWD/o prepare scripts
174 install -d o/include/config
175 touch o/include/config/MARKER
176 ln -sf %{_kernelsrcdir}/scripts o/scripts
178 if grep -q "^CONFIG_PREEMPT_RT=y$" o/.config; then
179 sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
180 kqemu-linux.c.orig > kqemu-linux.c
182 cat kqemu-linux.c.orig > kqemu-linux.c
185 %{__make} -C %{_kernelsrcdir} modules \
186 CC="%{__cc}" CPP="%{__cpp}" \
189 mv kqemu.ko kqemu-mod-$cfg.ko
194 %if %{with userspace}
195 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
196 # they can be passed if the cflags_passing bcond is used
198 --prefix=%{_prefix} \
200 %{?with_gcc4:--disable-gcc-check} \
201 %{!?with_kqemu:--disable-kqemu} \
204 --interp-prefix=%{_libdir}/%{name}
209 rm -rf $RPM_BUILD_ROOT
211 %if %{with userspace}
213 DESTDIR=$RPM_BUILD_ROOT
215 install -d $RPM_BUILD_ROOT/sbin
216 cat <<'EOF' > $RPM_BUILD_ROOT/sbin/qemu-ifup
218 if [ -f /etc/sysconfig/qemu ]; then
219 . /etc/sysconfig/qemu
221 # of course this will work only for one interface. a lot possible to involve
222 sudo /sbin/ifconfig $1 ${INTERFACE_ADDR:-172.20.0.1}
227 install -d $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}{,smp}/misc
228 install kqemu/kqemu-mod-up.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}/misc/kqemu.ko
229 %if %{with smp} && %{with dist_kernel}
230 install kqemu/kqemu-mod-smp.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}smp/misc/kqemu.ko
234 # This dir is unneeded
235 rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu
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}
250 %banner %{name}-module -e <<EOF
251 To autoload kqemu module, add to /etc/modprobe.conf:
252 alias char-major-250 kqemu
255 %postun -n kernel-misc-kqemu
256 %depmod %{_kernel_ver}
258 %post -n kernel-smp-misc-kqemu
259 %depmod %{_kernel_ver}smp
260 %banner %{name}-module -e <<EOF
261 To autoload kqemu module, add to /etc/modprobe.conf:
262 alias char-major-250 kqemu
265 %postun -n kernel-smp-misc-kqemu
266 %depmod %{_kernel_ver}smp
268 %if %{with userspace}
270 %defattr(644,root,root,755)
271 %doc README qemu-doc.html qemu-tech.html
272 %attr(755,root,root) /sbin/qemu-ifup
273 %attr(755,root,root) %{_bindir}/*
275 %{_mandir}/man1/qemu.1*
276 %{_mandir}/man1/qemu-img.1*
277 # FIXME: maybe better moved this into dev.spec
279 %dev(c,250,0) %attr(666,root,root) /dev/kqemu
284 %files -n kernel-misc-kqemu
285 %defattr(644,root,root,755)
287 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*
289 %if %{with smp} && %{with dist_kernel}
290 %files -n kernel-smp-misc-kqemu
291 %defattr(644,root,root,755)
293 /lib/modules/%{_kernel_ver}smp/misc/kqemu.ko*