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
15 %bcond_with grsec_kernel # build for kernel-grsecurity
18 %undefine with_dist_kernel
20 %if %{with dist_kernel} && %{with grsec_kernel}
21 %define alt_kernel grsecurity
24 # no kernel kqemu module for ppc
30 %if "%{_alt_kernel}" != "%{nil}"
31 %undefine with_userspace
34 %define kqemu_version 1.3.0pre11
35 %define qemu_version 0.9.1
39 Summary: QEMU CPU Emulator
40 Summary(pl.UTF-8): QEMU - emulator procesora
41 Name: %{pname}%{_alt_kernel}
42 Version: %{qemu_version}
43 Release: %{rel}%{?with_kqemu:k}
45 Group: Applications/Emulators
46 #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
47 Source0: http://fabrice.bellard.free.fr/qemu/%{pname}-%{version}.tar.gz
48 # Source0-md5: 6591df8e9270eb358c881de4ebea1262
49 Source1: http://fabrice.bellard.free.fr/qemu/k%{pname}-%{kqemu_version}.tar.gz
50 # Source1-md5: 970521874ef8b1ba4598925ace5936c3
51 Patch0: %{pname}-nostatic.patch
52 Patch1: %{pname}-cc.patch
53 Patch3: %{pname}-dot.patch
54 Patch4: %{pname}-gcc4_x86.patch
55 Patch5: %{pname}-gcc4_ppc.patch
56 Patch6: %{pname}-nosdlgui.patch
57 # Proof of concept, for reference, do not remove
58 Patch8: %{pname}-kde_virtual_workspaces_hack.patch
59 # http://gwenole.beauchesne.info/en/projects/qemu
60 Patch9: %{pname}-0.8.0-gcc4-hacks.patch
61 Patch11: %{pname}-0.7.2-gcc4-opts.patch
62 #Patch12: %{pname}-0.7.2-dyngen-check-stack-clobbers.patch
63 Patch13: %{pname}-dosguest.patch
64 URL: http://fabrice.bellard.free.fr/qemu/
65 %if %{with kernel} && %{with dist_kernel}
66 BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.7
67 BuildRequires: rpmbuild(macros) >= 1.379
70 BuildRequires: SDL-devel >= 1.2.1
71 BuildRequires: alsa-lib-devel
72 %{!?with_gcc4:BuildRequires: gcc < 5:4.0}
73 BuildRequires: perl-tools-pod
74 BuildRequires: sed >= 4.0
78 Requires: SDL >= 1.2.1
79 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
80 ExclusiveArch: %{ix86} %{x8664} %{?with_userspace:ppc}
81 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
83 # some SPARC boot image in ELF format
84 %define _noautostrip .*%{_datadir}/qemu/openbios-sparc32
87 QEMU is a FAST! processor emulator. By using dynamic translation it
88 achieves a reasonnable speed while being easy to port on new host
89 CPUs. QEMU has two operating modes:
91 - User mode emulation. In this mode, QEMU can launch Linux processes
92 compiled for one CPU on another CPU. Linux system calls are converted
93 because of endianness and 32/64 bit mismatches. Wine (Windows
94 emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
96 - Full system emulation. In this mode, QEMU emulates a full system,
97 including a processor and various peripherials. It can also be used to
98 provide virtual hosting of several virtual PC on a single server.
100 %description -l pl.UTF-8
101 QEMU to szybki(!) emulator procesora. Poprzez użycie dynamicznego
102 tłumaczenia osiąga rozsądną szybkość i jest łatwy do przeportowania,
103 aby działał na kolejnych procesorach. QEMU ma dwa tryby pracy:
105 - Emulacja trybu użytkownika. W tym trybie QEMU może uruchamiać
106 procesy linuksowe skompilowane dla jednego procesora na innym
107 procesorze. Linuksowe wywołania systemowe są tłumaczone ze względu na
108 niezgodność kolejności bajtów w słowie i 32/64-bitowego rozmiaru
109 słowa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to główne
112 - Pełna emulacja systemu. W tym trybie QEMU emuluje cały system,
113 włączając w to procesor i różne urządzenia peryferyjne. Może być także
114 używane do wirtualnego hostowania kilku wirtualnych pecetów na
115 pojedynczym serwerze.
117 %package -n kernel%{_alt_kernel}-misc-kqemu
118 Summary: kqemu - kernel module
119 Summary(pl.UTF-8): kqemu - moduł jądra
120 Version: %{kqemu_version}
121 Release: %{rel}@%{_kernel_ver_str}
123 %{?with_dist_kernel:%requires_releq_kernel}
125 Obsoletes: kernel%{_alt_kernel}-smp-misc-kqemu
126 Requires(post,postun): /sbin/depmod
127 Requires: module-init-tools >= 3.2.2-2
129 %description -n kernel%{_alt_kernel}-misc-kqemu
130 kqemu - kernel module.
132 %description -n kernel%{_alt_kernel}-misc-kqemu -l pl.UTF-8
136 %setup -q -n %{pname}-%{qemu_version} %{?with_kernel:-a1}
147 %{?with_nosdlgui:%patch6 -p1}
150 %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure
151 %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile
153 # cannot use optflags on x86 - they cause "no register to spill" errors
154 %if %{with cflags_passing}
155 %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target
157 %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target
161 echo -n > kqemu-%{kqemu_version}/install.sh
163 cat <<'EOF' > modprobe.conf
164 # enable dynamic major
165 options kqemu major=0
166 # for autoloading from static dev
167 #alias char-major-250 kqemu
170 cat <<'EOF' > udev.conf
171 KERNEL=="kqemu", NAME="%k", MODE="0666"
174 cd kqemu-%{kqemu_version}
175 %{__sed} -i 's#include ../config-host.mak##' ./common/Makefile
177 %{__sed} -i 's/^#ARCH=x86_64/ARCH=x86_64/' ./common/Makefile
178 %{__make} -j1 -C common
179 mv -f kqemu-mod-x86_64.o{,.bin}
181 %{__sed} -i 's/^#ARCH=i386/ARCH=i386/' ./common/Makefile
182 %{__make} -j1 -C common
183 mv -f kqemu-mod-i386.o{,.bin}
186 mv -f kqemu-linux.c{,.orig}
187 cat > Makefile <<'EOF'
189 kqemu-objs:= kqemu-linux.o kqemu-mod.o
191 $(obj)/kqemu-mod.o: $(src)/kqemu-mod-$(ARCH).o.bin
203 cd kqemu-%{kqemu_version}
204 %build_kernel_modules -m kqemu <<'EOF'
205 if grep -q "CONFIG_PREEMPT_RT" o/.config; then
206 sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
207 kqemu-linux.c.orig > kqemu-linux.c
209 cat kqemu-linux.c.orig > kqemu-linux.c
215 %if %{with userspace}
216 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
217 # they can be passed if the cflags_passing bcond is used
219 --prefix=%{_prefix} \
221 --host-cc="%{__cc}" \
224 --kernel-path=%{_kernelsrcdir} \
228 %{?with_gcc4:--disable-gcc-check} \
230 --interp-prefix=%{_libdir}/%{pname}
235 rm -rf $RPM_BUILD_ROOT
237 %if %{with userspace}
239 DESTDIR=$RPM_BUILD_ROOT
241 install -d $RPM_BUILD_ROOT%{_sysconfdir}
242 cat <<'EOF' > $RPM_BUILD_ROOT%{_sysconfdir}/qemu-ifup
249 %install_kernel_modules -m kqemu-%{kqemu_version}/kqemu -d misc
250 install -d $RPM_BUILD_ROOT/etc/{modprobe.d/%{_kernel_ver}{,smp},udev/rules.d}
251 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/kqemu.conf
252 install udev.conf $RPM_BUILD_ROOT/etc/udev/rules.d/kqemu.rules
256 rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-{doc,tech}.html
259 rm -rf $RPM_BUILD_ROOT
263 %banner %{pname} -e <<EOF
264 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
269 %post -n kernel%{_alt_kernel}-misc-kqemu
270 %depmod %{_kernel_ver}
272 %postun -n kernel%{_alt_kernel}-misc-kqemu
273 %depmod %{_kernel_ver}
275 %if %{with userspace}
277 %defattr(644,root,root,755)
278 %doc README qemu-doc.html qemu-tech.html
279 %attr(755,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/qemu-ifup
280 %attr(755,root,root) %{_bindir}/*
282 %{_mandir}/man1/qemu.1*
283 %{_mandir}/man1/qemu-img.1*
287 %files -n kernel%{_alt_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*