3 # - wait till the gcc bug http://gcc.gnu.org/PR16185 is fixed.
6 %bcond_without kqemu # disable KQEMU ACCELERATOR support in QEMU
7 %bcond_with cflags_passing # with passing rpmcflags to Makefiles
8 %bcond_with dosguest # add special patch when use with DOS as guest os
9 %bcond_with nosdlgui # do not use SDL gui (use X11 instead)
10 # Note that gcc4 build is very problematic and not supported by qemu team
11 %bcond_without gcc4 # use gcc4 patches (broke build on gcc33)
12 %bcond_without dist_kernel # without distribution kernel
13 %bcond_without kernel # build kqemu KERNEL MODULES
14 %bcond_without userspace # don't build userspace
22 %define _kqemu_version 1.3.0pre11
24 Summary: QEMU CPU Emulator
25 Summary(pl.UTF-8): QEMU - emulator procesora
28 Release: %{_rel}%{?with_kqemu:k}
30 Group: Applications/Emulators
31 #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
32 Source0: http://fabrice.bellard.free.fr/qemu/%{name}-%{version}.tar.gz
33 # Source0-md5: ab11a03ba30cf4a70641f0f170473d69
34 Source1: http://fabrice.bellard.free.fr/qemu/k%{name}-%{_kqemu_version}.tar.gz
35 # Source1-md5: 970521874ef8b1ba4598925ace5936c3
36 Patch0: %{name}-nostatic.patch
37 Patch1: %{name}-cc.patch
38 Patch3: %{name}-dot.patch
39 Patch4: %{name}-gcc4_x86.patch
40 Patch5: %{name}-gcc4_ppc.patch
41 Patch6: %{name}-nosdlgui.patch
42 # Proof of concept, for reference, do not remove
43 Patch8: %{name}-kde_virtual_workspaces_hack.patch
44 # http://gwenole.beauchesne.info/en/projects/qemu
45 Patch9: %{name}-0.8.0-gcc4-hacks.patch
46 Patch11: %{name}-0.7.2-gcc4-opts.patch
47 #Patch12: %{name}-0.7.2-dyngen-check-stack-clobbers.patch
48 Patch13: %{name}-dosguest.patch
49 URL: http://fabrice.bellard.free.fr/qemu/
50 %if %{with kernel} && %{with dist_kernel}
51 BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.7
52 BuildRequires: rpmbuild(macros) >= 1.379
55 BuildRequires: SDL-devel >= 1.2.1
56 BuildRequires: alsa-lib-devel
57 %{!?with_gcc4:BuildRequires: gcc < 5:4.0}
58 BuildRequires: perl-tools-pod
60 BuildRequires: sed >= 4.0
62 Requires: SDL >= 1.2.1
63 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
64 ExclusiveArch: %{ix86} %{x8664} ppc
65 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
67 # some SPARC boot image in ELF format
68 %define _noautostrip .*%{_datadir}/qemu/openbios-sparc32
71 QEMU is a FAST! processor emulator. By using dynamic translation it
72 achieves a reasonnable speed while being easy to port on new host
73 CPUs. QEMU has two operating modes:
75 - User mode emulation. In this mode, QEMU can launch Linux processes
76 compiled for one CPU on another CPU. Linux system calls are converted
77 because of endianness and 32/64 bit mismatches. Wine (Windows
78 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
80 - Full system emulation. In this mode, QEMU emulates a full system,
81 including a processor and various peripherials. It can also be used to
82 provide virtual hosting of several virtual PC on a single server.
84 %description -l pl.UTF-8
85 QEMU to szybki(!) emulator procesora. Poprzez użycie dynamicznego
86 tłumaczenia osiąga rozsądną szybkość i jest łatwy do przeportowania,
87 aby działał na kolejnych procesorach. QEMU ma dwa tryby pracy:
89 - Emulacja trybu użytkownika. W tym trybie QEMU może uruchamiać
90 procesy linuksowe skompilowane dla jednego procesora na innym
91 procesorze. Linuksowe wywołania systemowe są tłumaczone ze względu na
92 niezgodność kolejności bajtów w słowie i 32/64-bitowego rozmiaru
93 słowa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to główne
96 - Pełna emulacja systemu. W tym trybie QEMU emuluje cały system,
97 włączając w to procesor i różne urządzenia peryferyjne. Może być także
98 używane do wirtualnego hostowania kilku wirtualnych pecetów na
101 %package -n kernel%{_alt_kernel}-misc-kqemu
102 Summary: kqemu - kernel module
103 Summary(pl.UTF-8): kqemu - moduł jądra
104 Version: %{_kqemu_version}
105 Release: %{_rel}@%{_kernel_ver_str}
107 %{?with_dist_kernel:%requires_releq_kernel}
109 Obsoletes: kernel%{_alt_kernel}-smp-misc-kqemu
110 Requires(post,postun): /sbin/depmod
111 Requires: module-init-tools >= 3.2.2-2
113 %description -n kernel%{_alt_kernel}-misc-kqemu
114 kqemu - kernel module.
116 %description -n kernel%{_alt_kernel}-misc-kqemu -l pl.UTF-8
120 %if %{without kernel} && %{without dist_kernel}
121 %{error:%{name}: If building kernel module You need to enable at least one of up or smp}
125 %setup -q %{?with_kernel:-a1}
136 %{?with_nosdlgui:%patch6 -p1}
139 %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure
140 %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile
142 # cannot use optflags on x86 - they cause "no register to spill" errors
143 %if %{with cflags_passing}
144 %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target
146 %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target
150 echo -n > kqemu-%{_kqemu_version}/install.sh
152 cat <<'EOF' > modprobe.conf
153 # enable dynamic major
154 options kqemu major=0
155 # for autoloading from static dev
156 #alias char-major-250 kqemu
159 cat <<'EOF' > udev.conf
160 KERNEL=="kqemu", NAME="%k", MODE="0666"
170 cd kqemu-%{_kqemu_version}
172 %{__sed} -i 's#include ../config-host.mak##' ./common/Makefile
174 %{__sed} -i 's/^#ARCH=x86_64/ARCH=x86_64/' ./common/Makefile
175 %{__make} -j1 -C common
176 mv -f kqemu-mod-x86_64.o{,.bin}
178 %{__sed} -i 's/^#ARCH=i386/ARCH=i386/' ./common/Makefile
179 %{__make} -j1 -C common
180 mv -f kqemu-mod-i386.o{,.bin}
183 mv -f kqemu-linux.c{,.orig}
184 cat > Makefile <<'EOF'
186 kqemu-objs:= kqemu-linux.o kqemu-mod.o
188 $(obj)/kqemu-mod.o: $(src)/kqemu-mod-$(ARCH).o.bin
192 %build_kernel_modules -m kqemu <<'EOF'
193 if grep -q "CONFIG_PREEMPT_RT" o/.config; then
194 sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
195 kqemu-linux.c.orig > kqemu-linux.c
197 cat kqemu-linux.c.orig > kqemu-linux.c
203 %if %{with userspace}
204 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
205 # they can be passed if the cflags_passing bcond is used
207 --prefix=%{_prefix} \
209 --host-cc="%{__cc}" \
212 --kernel-path=%{_kernelsrcdir} \
216 %{?with_gcc4:--disable-gcc-check} \
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%{_sysconfdir}
230 cat <<'EOF' > $RPM_BUILD_ROOT%{_sysconfdir}/qemu-ifup
237 %install_kernel_modules -m kqemu-%{_kqemu_version}/kqemu -d misc
238 install -d $RPM_BUILD_ROOT/etc/{modprobe.d/%{_kernel_ver}{,smp},udev/rules.d}
239 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/kqemu.conf
240 install udev.conf $RPM_BUILD_ROOT/etc/udev/rules.d/kqemu.rules
244 rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-{doc,tech}.html
247 rm -rf $RPM_BUILD_ROOT
251 %banner %{name} -e <<EOF
252 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
257 %post -n kernel%{_alt_kernel}-misc-kqemu
258 %depmod %{_kernel_ver}
260 %postun -n kernel%{_alt_kernel}-misc-kqemu
261 %depmod %{_kernel_ver}
263 %if %{with userspace}
265 %defattr(644,root,root,755)
266 %doc README qemu-doc.html qemu-tech.html
267 %attr(755,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/qemu-ifup
268 %attr(755,root,root) %{_bindir}/*
270 %{_mandir}/man1/qemu.1*
271 %{_mandir}/man1/qemu-img.1*
275 %files -n kernel%{_alt_kernel}-misc-kqemu
276 %defattr(644,root,root,755)
277 %doc kqemu-%{_kqemu_version}/LICENSE
278 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
279 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}/kqemu.conf
280 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*