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 %if %{with dist_kernel}
21 %define _kqemu_version 1.3.0pre7
23 Summary: QEMU CPU Emulator
24 Summary(pl): QEMU - emulator procesora
27 Release: %{_rel}%{?with_kqemu:k}
29 Group: Applications/Emulators
30 #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
31 Source0: http://fabrice.bellard.free.fr/qemu/%{name}-%{version}.tar.gz
32 # Source0-md5: 67d924324a5ab79d017bd97a1e767285
33 Source1: http://fabrice.bellard.free.fr/qemu/k%{name}-%{_kqemu_version}.tar.gz
34 # NoSource1-md5: 3b77edbada790f924456aa4675edd0be
36 Patch0: %{name}-nostatic.patch
37 Patch1: %{name}-cc.patch
38 Patch2: %{name}-longjmp.patch
39 Patch3: %{name}-dot.patch
41 Patch5: %{name}-gcc4_x86.patch
42 Patch6: %{name}-gcc4_ppc.patch
43 Patch7: %{name}-parallel.patch
44 Patch8: %{name}-nosdlgui.patch
45 Patch9: %{name}-ifup.patch
46 Patch10: %{name}-gcc33.patch
48 URL: http://fabrice.bellard.free.fr/qemu/
49 BuildRequires: SDL-devel >= 1.2.1
50 BuildRequires: alsa-lib-devel
51 %{!?with_gcc4:BuildRequires: gcc < 5:4.0}
52 %if %{with kqemu} && %{with dist_kernel}
53 BuildRequires: kernel-module-build >= 3:2.6.7
55 BuildRequires: rpmbuild(macros) >= 1.217
56 BuildRequires: sed >= 4.0
57 Requires: SDL >= 1.2.1
58 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
59 ExclusiveArch: %{ix86} %{x8664} %{!?with_kqemu:ppc}
60 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
62 # some SPARC boot image in ELF format
63 %define _noautostrip .*%{_datadir}/qemu/proll.elf
66 QEMU is a FAST! processor emulator. By using dynamic translation it
67 achieves a reasonnable speed while being easy to port on new host
68 CPUs. QEMU has two operating modes:
70 - User mode emulation. In this mode, QEMU can launch Linux processes
71 compiled for one CPU on another CPU. Linux system calls are converted
72 because of endianness and 32/64 bit mismatches. Wine (Windows
73 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
75 - Full system emulation. In this mode, QEMU emulates a full system,
76 including a processor and various peripherials. It can also be used to
77 provide virtual hosting of several 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 na
87 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. Mo¿e byæ tak¿e
93 u¿ywane do wirtualnego hostowania kilku wirtualnych pecetów na
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
105 Requires: module-init-tools >= 3.2.2-2
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
122 Requires: module-init-tools >= 3.2.2-2
124 %description -n kernel-smp-misc-kqemu
125 kqemu - SMP kernel module.
127 %description -n kernel-smp-misc-kqemu -l pl
128 kqemu - modu³ j±dra SMP.
131 %setup -q %{?with_kernel:-a1}
141 # probably not needed
143 %{?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
158 echo -n > kqemu-%{_kqemu_version}/install.sh
160 cat <<'EOF' > modprobe.conf
161 # enable dynamic major
162 options kqemu major=0
163 # for autoloading from static dev
164 #alias char-major-250 kqemu
167 cat <<'EOF' > udev.conf
168 KERNEL=="kqemu", NAME="%k", MODE="0666"
174 cd kqemu-%{_kqemu_version}
175 mv -f kqemu-linux.c{,.orig}
176 for cfg in %{?with_dist_kernel:%{?with_smp:smp} up}%{!?with_dist_kernel:nondist}; do
177 if [ ! -r "%{_kernelsrcdir}/config-$cfg" ]; then
180 install -d o/include/linux
181 ln -sf %{_kernelsrcdir}/config-$cfg o/.config
182 ln -sf %{_kernelsrcdir}/Module.symvers-$cfg o/Module.symvers
183 ln -sf %{_kernelsrcdir}/include/linux/autoconf-$cfg.h o/include/linux/autoconf.h
184 %if %{with dist_kernel}
185 %{__make} -C %{_kernelsrcdir} O=$PWD/o prepare scripts
187 install -d o/include/config
188 touch o/include/config/MARKER
189 ln -sf %{_kernelsrcdir}/scripts o/scripts
191 if grep -q "^CONFIG_PREEMPT_RT=y$" o/.config; then
192 sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
193 kqemu-linux.c.orig > kqemu-linux.c
195 cat kqemu-linux.c.orig > kqemu-linux.c
198 %{__make} -C %{_kernelsrcdir} modules \
199 CC="%{__cc}" CPP="%{__cpp}" \
202 mv kqemu.ko kqemu-mod-$cfg.ko
207 %if %{with userspace}
208 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
209 # they can be passed if the cflags_passing bcond is used
211 --prefix=%{_prefix} \
213 --host-cc="%{__cc}" \
215 %{?with_gcc4:--disable-gcc-check} \
216 %{!?with_kqemu:--disable-kqemu} \
218 --interp-prefix=%{_libdir}/%{name}
223 rm -rf $RPM_BUILD_ROOT
225 %if %{with userspace}
227 DESTDIR=$RPM_BUILD_ROOT
229 install -d $RPM_BUILD_ROOT/sbin
230 cat <<'EOF' > $RPM_BUILD_ROOT/sbin/qemu-ifup
232 if [ -f /etc/sysconfig/qemu ]; then
233 . /etc/sysconfig/qemu
235 # of course this will work only for one interface. a lot possible to involve
236 sudo /sbin/ifconfig $1 ${INTERFACE_ADDR:-172.20.0.1}
241 install -d $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}{,smp}/misc
242 install -d $RPM_BUILD_ROOT/etc/{modprobe.d/%{_kernel_ver}{,smp},udev/rules.d}
243 install kqemu-%{_kqemu_version}/kqemu-mod-up.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}/misc/kqemu.ko
244 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/kqemu.conf
245 %if %{with smp} && %{with dist_kernel}
246 install kqemu-%{_kqemu_version}/kqemu-mod-smp.ko $RPM_BUILD_ROOT/lib/modules/%{_kernel_ver}smp/misc/kqemu.ko
247 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}smp/kqemu.conf
249 install udev.conf $RPM_BUILD_ROOT/etc/udev/rules.d/kqemu.rules
253 rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-{doc,tech}.html
256 rm -rf $RPM_BUILD_ROOT
260 %banner %{name} -e <<EOF
261 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
266 %post -n kernel-misc-kqemu
267 %depmod %{_kernel_ver}
269 %postun -n kernel-misc-kqemu
270 %depmod %{_kernel_ver}
272 %post -n kernel-smp-misc-kqemu
273 %depmod %{_kernel_ver}smp
275 %postun -n kernel-smp-misc-kqemu
276 %depmod %{_kernel_ver}smp
278 %if %{with userspace}
280 %defattr(644,root,root,755)
281 %doc README qemu-doc.html qemu-tech.html
282 %attr(755,root,root) /sbin/qemu-ifup
283 %attr(755,root,root) %{_bindir}/*
285 %{_mandir}/man1/qemu.1*
286 %{_mandir}/man1/qemu-img.1*
290 %files -n kernel-misc-kqemu
291 %defattr(644,root,root,755)
292 %doc kqemu-%{_kqemu_version}/LICENSE
293 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
294 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}/kqemu.conf
295 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*
297 %if %{with smp} && %{with dist_kernel}
298 %files -n kernel-smp-misc-kqemu
299 %defattr(644,root,root,755)
300 %doc kqemu-%{_kqemu_version}/LICENSE
301 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
302 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}smp/kqemu.conf
303 /lib/modules/%{_kernel_ver}smp/misc/kqemu.ko*