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
17 Summary: QEMU CPU Emulator
18 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/kqemu-%{_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 URL: http://fabrice.bellard.free.fr/qemu/
45 BuildRequires: SDL-devel >= 1.2.1
46 BuildRequires: alsa-lib-devel
47 %if %{with kqemu} && %{with dist_kernel}
48 BuildRequires: kernel-module-build >= 2.6.7
50 BuildRequires: rpmbuild(macros) >= 1.217
51 BuildRequires: sed >= 4.0
52 Requires: SDL >= 1.2.1
53 ExclusiveArch: %{ix86} %{x8664} ppc
54 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
55 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
57 # some SPARC boot image in ELF format
58 %define _noautostrip .*%{_datadir}/qemu/proll.elf
65 QEMU is a FAST! processor emulator. By using dynamic translation it
66 achieves a reasonnable speed while being easy to port on new host
67 CPUs. QEMU has two operating modes:
69 - User mode emulation. In this mode, QEMU can launch Linux processes
70 compiled for one CPU on another CPU. Linux system calls are converted
71 because of endianness and 32/64 bit mismatches. Wine (Windows
72 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
74 - Full system emulation. In this mode, QEMU emulates a full system,
75 including a processor and various peripherials.
76 It can also be used to provide virtual hosting of several
77 virtual PC on a single server.
80 QEMU to szybki(!) emulator procesora. Poprzez u¿ycie dynamicznego
81 t³umaczenia osi±ga rozs±dn± szybko¶æ i jest ³atwy do przeportowania,
82 aby dzia³a³ na kolejnych procesorach. QEMU ma dwa tryby pracy:
84 - Emulacja trybu u¿ytkownika. W tym trybie QEMU mo¿e uruchamiaæ
85 procesy linuksowe skompilowane dla jednego procesora na innym
86 procesorze. Linuksowe wywo³ania systemowe s± t³umaczone ze wzglêdu
87 na niezgodno¶æ kolejno¶ci bajtów w s³owie i 32/64-bitowego rozmiaru
88 s³owa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to g³ówne
91 - Pe³na emulacja systemu. W tym trybie QEMU emuluje ca³y system,
92 w³±czaj±c w to procesor i ró¿ne urz±dzenia peryferyjne.
93 Mo¿e byæ tak¿e u¿ywane do wirtualnego hostowania kilku wirtualnych
94 pecetów na pojedynczym serwerze.
96 %package -n kernel-misc-kqemu
97 Summary: kqemu - kernel module
98 Summary(pl): kqemu - modu³ j±dra
99 Version: %{_kqemu_version}
100 Release: %{_rel}@%{_kernel_ver_str}
102 %{?with_dist_kernel:%requires_releq_kernel_up}
103 License: Free to use, non-distributable
104 Requires(post,postun): /sbin/depmod
106 %description -n kernel-misc-kqemu
107 kqemu - kernel module.
109 %description -n kernel-misc-kqemu -l pl
112 %package -n kernel-smp-misc-kqemu
113 Summary: kqemu - SMP kernel module
114 Summary(pl): kqemu - modu³ j±dra SMP
115 Version: %{_kqemu_version}
116 Release: %{_rel}@%{_kernel_ver_str}
118 %{?with_dist_kernel:%requires_releq_kernel_up}
119 License: Free to use, non-distributable
120 Requires(post,postun): /sbin/depmod
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}
145 %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure
146 %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile
148 # cannot use optflags on x86 - they cause "no register to spill" errors
149 %if %{with cflags_passing}
150 %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target
152 %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target
155 %{?with_kqemu:echo -n > kqemu/install.sh}
160 for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}; do
161 if [ ! -r "%{_kernelsrcdir}/config-$cfg" ]; then
165 install -d include/{linux,config}
166 ln -sf %{_kernelsrcdir}/config-$cfg .config
167 ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h include/linux/autoconf.h
168 ln -sf %{_kernelsrcdir}/include/asm-%{_target_base_arch} include/asm
169 ln -sf %{_kernelsrcdir}/Module.symvers-$cfg Module.symvers
170 %if %{without dist_kernel}
171 ln -sf %{_kernelsrcdir}/scripts
173 touch include/config/MARKER
174 %{__make} -C %{_kernelsrcdir} clean \
175 RCS_FIND_IGNORE="-name 'kqemu-mod-*.*' -o" \
177 %{__make} -C %{_kernelsrcdir} modules \
179 mv kqemu.ko kqemu-mod-$cfg.ko
184 %if %{with userspace}
185 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
186 # they can be passed if the cflags_passing bcond is used
188 --prefix=%{_prefix} \
191 %{!?with_kqemu:--disable-kqemu} \
193 --interp-prefix=%{_libdir}/%{name}
198 rm -rf $RPM_BUILD_ROOT
200 %if %{with userspace}
202 DESTDIR=$RPM_BUILD_ROOT
204 install -d $RPM_BUILD_ROOT/sbin
205 cat <<'EOF' > $RPM_BUILD_ROOT/sbin/qemu-ifup
207 if [ -f /etc/sysconfig/qemu ]; then
208 . /etc/sysconfig/qemu
210 # of course this will work only for one interface. a lot possible to involve
211 sudo /sbin/ifconfig $1 ${INTERFACE_ADDR:-172.20.0.1}
216 install -d $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}{,smp}/misc
217 install kqemu/kqemu-mod-up.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}/misc/kqemu.ko
218 %if %{with smp} && %{with dist_kernel}
219 install kqemu/kqemu-mod-smp.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}smp/misc/kqemu.ko
223 # This dir is unneeded
224 rm -rf $RPM_BUILD_ROOT/usr/share/doc/qemu
227 rm -rf $RPM_BUILD_ROOT
231 %banner %{name} -e <<EOF
232 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
237 %post -n kernel-misc-kqemu
238 %depmod %{_kernel_ver}
239 %banner %{name}-module -e <<EOF
240 To autoload kqemu module, add to /etc/modprobe.conf:
241 alias char-major-250 kqemu
244 %postun -n kernel-misc-kqemu
245 %depmod %{_kernel_ver}
247 %post -n kernel-smp-misc-kqemu
248 %depmod %{_kernel_ver}smp
249 %banner %{name}-module -e <<EOF
250 To autoload kqemu module, add to /etc/modprobe.conf:
251 alias char-major-250 kqemu
254 %postun -n kernel-smp-misc-kqemu
255 %depmod %{_kernel_ver}smp
257 %if %{with userspace}
259 %defattr(644,root,root,755)
260 %doc README qemu-doc.html qemu-tech.html
261 %attr(755,root,root) /sbin/qemu-ifup
262 %attr(755,root,root) %{_bindir}/*
264 %{_mandir}/man1/qemu.1*
265 %{_mandir}/man1/qemu-img.1*
266 # FIXME: maybe better moved this into dev.spec
268 %dev(c,250,0) %attr(666,root,root) /dev/kqemu
273 %files -n kernel-misc-kqemu
274 %defattr(644,root,root,755)
276 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*
278 %if %{with smp} && %{with dist_kernel}
279 %files -n kernel-smp-misc-kqemu
280 %defattr(644,root,root,755)
282 /lib/modules/%{_kernel_ver}smp/misc/kqemu.ko*