3 # - wait till the gcc bug http://gcc.gnu.org/PR16185 is fixed.
4 # - kqemu could be distributable if somebody bothers to contact qemu
5 # author http://fabrice.bellard.free.fr/qemu/qemu-accel.html
8 %bcond_without kqemu # disable QEMU accelerator support
9 %bcond_with cflags_passing # with passing rpmcflags to Makefiles
10 %bcond_with nosdlgui # do not use SDL gui (use X11 instead)
11 %bcond_with gcc4 # use gcc4 patches (broke build on gcc33)
12 %bcond_without dist_kernel # without distribution kernel
13 %bcond_with kernel # build kqemu kernel modules
14 %bcond_without smp # don't build SMP module
15 %bcond_without userspace # don't build userspace utilities
17 %define _kqemu_version 1.3.0pre7
19 Summary: QEMU CPU Emulator
20 Summary(pl): QEMU - emulator procesora
23 Release: %{_rel}%{?with_kqemu:k}
25 Group: Applications/Emulators
26 #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
27 Source0: http://fabrice.bellard.free.fr/qemu/%{name}-%{version}.tar.gz
28 # Source0-md5: 67d924324a5ab79d017bd97a1e767285
29 Source1: http://fabrice.bellard.free.fr/qemu/k%{name}-%{_kqemu_version}.tar.gz
30 # NoSource1-md5: 3b77edbada790f924456aa4675edd0be
32 Patch0: %{name}-nostatic.patch
33 Patch1: %{name}-cc.patch
34 Patch2: %{name}-longjmp.patch
35 Patch3: %{name}-dot.patch
36 Patch4: %{name}-gcc4_x86.patch
37 Patch5: %{name}-gcc4_ppc.patch
38 Patch6: %{name}-nosdlgui.patch
39 Patch7: %{name}-ifup.patch
40 Patch8: %{name}-gcc33.patch
41 Patch9: %{name}-parallel.patch
42 URL: http://fabrice.bellard.free.fr/qemu/
43 BuildRequires: SDL-devel >= 1.2.1
44 BuildRequires: alsa-lib-devel
45 %{!?with_gcc4:BuildRequires: gcc < 5:4.0}
46 %if %{with kqemu} && %{with dist_kernel}
47 BuildRequires: kernel-module-build >= 3:2.6.7
49 BuildRequires: rpmbuild(macros) >= 1.217
50 BuildRequires: sed >= 4.0
51 Requires: SDL >= 1.2.1
52 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
53 ExclusiveArch: %{ix86} %{x8664} %{!?with_kqemu:ppc}
54 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
56 # some SPARC boot image in ELF format
57 %define _noautostrip .*%{_datadir}/qemu/proll.elf
60 QEMU is a FAST! processor emulator. By using dynamic translation it
61 achieves a reasonnable speed while being easy to port on new host
62 CPUs. QEMU has two operating modes:
64 - User mode emulation. In this mode, QEMU can launch Linux processes
65 compiled for one CPU on another CPU. Linux system calls are converted
66 because of endianness and 32/64 bit mismatches. Wine (Windows
67 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
69 - Full system emulation. In this mode, QEMU emulates a full system,
70 including a processor and various peripherials. It can also be used to
71 provide virtual hosting of several virtual PC on a single server.
74 QEMU to szybki(!) emulator procesora. Poprzez u¿ycie dynamicznego
75 t³umaczenia osi±ga rozs±dn± szybko¶æ i jest ³atwy do przeportowania,
76 aby dzia³a³ na kolejnych procesorach. QEMU ma dwa tryby pracy:
78 - Emulacja trybu u¿ytkownika. W tym trybie QEMU mo¿e uruchamiaæ
79 procesy linuksowe skompilowane dla jednego procesora na innym
80 procesorze. Linuksowe wywo³ania systemowe s± t³umaczone ze wzglêdu na
81 niezgodno¶æ kolejno¶ci bajtów w s³owie i 32/64-bitowego rozmiaru
82 s³owa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to g³ówne
85 - Pe³na emulacja systemu. W tym trybie QEMU emuluje ca³y system,
86 w³±czaj±c w to procesor i ró¿ne urz±dzenia peryferyjne. Mo¿e byæ tak¿e
87 u¿ywane do wirtualnego hostowania kilku wirtualnych pecetów na
90 %package -n kernel-misc-kqemu
91 Summary: kqemu - kernel module
92 Summary(pl): kqemu - modu³ j±dra
93 Version: %{_kqemu_version}
94 Release: %{_rel}@%{_kernel_ver_str}
96 %{?with_dist_kernel:%requires_releq_kernel_up}
97 License: Free to use, non-distributable
98 Requires(post,postun): /sbin/depmod
99 Requires: module-init-tools >= 3.2.2-2
101 %description -n kernel-misc-kqemu
102 kqemu - kernel module.
104 %description -n kernel-misc-kqemu -l pl
107 %package -n kernel-smp-misc-kqemu
108 Summary: kqemu - SMP kernel module
109 Summary(pl): kqemu - modu³ j±dra SMP
110 Version: %{_kqemu_version}
111 Release: %{_rel}@%{_kernel_ver_str}
113 %{?with_dist_kernel:%requires_releq_kernel_up}
114 License: Free to use, non-distributable
115 Requires(post,postun): /sbin/depmod
116 Requires: module-init-tools >= 3.2.2-2
118 %description -n kernel-smp-misc-kqemu
119 kqemu - SMP kernel module.
121 %description -n kernel-smp-misc-kqemu -l pl
122 kqemu - modu³ j±dra SMP.
125 %setup -q %{?with_kernel:-a1}
134 %{?with_nosdlgui:%patch6 -p1}
137 # probably not needed
140 %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure
141 %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile
143 # cannot use optflags on x86 - they cause "no register to spill" errors
144 %if %{with cflags_passing}
145 %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target
147 %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target
151 echo -n > kqemu-%{_kqemu_version}/install.sh
153 cat <<'EOF' > modprobe.conf
154 # enable dynamic major
155 options kqemu major=0
156 # for autoloading from static dev
157 #alias char-major-250 kqemu
160 cat <<'EOF' > udev.conf
161 KERNEL=="kqemu", NAME="%k", MODE="0666"
167 cd kqemu-%{_kqemu_version}
168 mv -f kqemu-linux.c{,.orig}
169 for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}; do
170 if [ ! -r "%{_kernelsrcdir}/config-$cfg" ]; then
173 install -d o/include/linux
174 ln -sf %{_kernelsrcdir}/config-$cfg o/.config
175 ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers
176 ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h
177 %if %{with dist_kernel}
178 %{__make} -C %{_kernelsrcdir} O=$PWD/o prepare scripts
180 install -d o/include/config
181 touch o/include/config/MARKER
182 ln -sf %{_kernelsrcdir}/scripts o/scripts
184 if grep -q "^CONFIG_PREEMPT_RT=y$" o/.config; then
185 sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
186 kqemu-linux.c.orig > kqemu-linux.c
188 cat kqemu-linux.c.orig > kqemu-linux.c
191 %{__make} -C %{_kernelsrcdir} modules \
192 CC="%{__cc}" CPP="%{__cpp}" \
195 mv kqemu.ko kqemu-mod-$cfg.ko
200 %if %{with userspace}
201 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
202 # they can be passed if the cflags_passing bcond is used
204 --prefix=%{_prefix} \
206 --host-cc="%{__cc}" \
209 --kernel-path=%{_kernelsrcdir} \
213 %{?with_gcc4:--disable-gcc-check} \
215 --interp-prefix=%{_libdir}/%{name}
220 rm -rf $RPM_BUILD_ROOT
222 %if %{with userspace}
224 DESTDIR=$RPM_BUILD_ROOT
226 install -d $RPM_BUILD_ROOT/sbin
227 cat <<'EOF' > $RPM_BUILD_ROOT/sbin/qemu-ifup
229 if [ -f /etc/sysconfig/qemu ]; then
230 . /etc/sysconfig/qemu
232 # of course this will work only for one interface. a lot possible to involve
233 sudo /sbin/ifconfig $1 ${INTERFACE_ADDR:-172.20.0.1}
238 install -d $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}{,smp}/misc
239 install -d $RPM_BUILD_ROOT/etc/{modprobe.d/%{_kernel_ver}{,smp},udev/rules.d}
240 install kqemu-%{_kqemu_version}/kqemu-mod-up.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}/misc/kqemu.ko
241 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/kqemu.conf
242 %if %{with smp} && %{with dist_kernel}
243 install kqemu-%{_kqemu_version}/kqemu-mod-smp.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}smp/misc/kqemu.ko
244 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}smp/kqemu.conf
246 install udev.conf $RPM_BUILD_ROOT/etc/udev/rules.d/kqemu.rules
250 rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-{doc,tech}.html
253 rm -rf $RPM_BUILD_ROOT
257 %banner %{name} -e <<EOF
258 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
263 %post -n kernel-misc-kqemu
264 %depmod %{_kernel_ver}
266 %postun -n kernel-misc-kqemu
267 %depmod %{_kernel_ver}
269 %post -n kernel-smp-misc-kqemu
270 %depmod %{_kernel_ver}smp
272 %postun -n kernel-smp-misc-kqemu
273 %depmod %{_kernel_ver}smp
275 %if %{with userspace}
277 %defattr(644,root,root,755)
278 %doc README qemu-doc.html qemu-tech.html
279 %attr(755,root,root) /sbin/qemu-ifup
280 %attr(755,root,root) %{_bindir}/*
282 %{_mandir}/man1/qemu.1*
283 %{_mandir}/man1/qemu-img.1*
287 %files -n kernel-misc-kqemu
288 %defattr(644,root,root,755)
289 %doc kqemu-%{_kqemu_version}/LICENSE
290 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
291 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}/kqemu.conf
292 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*
294 %if %{with smp} && %{with dist_kernel}
295 %files -n kernel-smp-misc-kqemu
296 %defattr(644,root,root,755)
297 %doc kqemu-%{_kqemu_version}/LICENSE
298 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
299 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}smp/kqemu.conf
300 /lib/modules/%{_kernel_ver}smp/misc/kqemu.ko*