]> git.pld-linux.org Git - packages/qemu.git/blob - qemu.spec
- fixes from AC-branch
[packages/qemu.git] / qemu.spec
1 #
2 # TODO:
3 # - wait till the gcc bug http://gcc.gnu.org/PR16185 is fixed.
4 # - update or drop gcc4 bcond patches
5 #
6 # Conditional build:
7 %bcond_without  kqemu                   # disable KQEMU ACCELERATOR support in QEMU
8 %bcond_with     cflags_passing          # with passing rpmcflags to Makefiles
9 %bcond_with     dosguest                # add special patch when use with DOS as guest os
10 %bcond_with     nosdlgui                # do not use SDL gui (use X11 instead)
11 # Note that gcc4 build is very problematic and not supported by qemu team
12 %bcond_with     gcc4                    # use gcc4 patches (broke build on gcc33)
13 %bcond_without  dist_kernel             # without distribution kernel
14 %bcond_without  kernel                  # build kqemu KERNEL MODULES
15 %bcond_without  userspace               # don't build userspace utilities
16
17 %if %{without kernel}
18 %undefine       with_dist_kernel
19 %endif
20
21 # no kernel kqemu module for ppc
22 %ifarch ppc
23 %undefine      with_kqemu
24 %undefine      with_kernel
25 %endif
26
27 %if "%{_alt_kernel}" != "%{nil}"
28 %undefine       with_userspace
29 %endif
30
31 %define         kqemu_version   1.3.0pre11
32 %define         qemu_version    0.9.1
33 %define         pname   qemu
34
35 %define         rel     8
36 Summary:        QEMU CPU Emulator
37 Summary(pl.UTF-8):      QEMU - emulator procesora
38 Name:           %{pname}%{_alt_kernel}
39 Version:        %{qemu_version}
40 Release:        %{rel}%{?with_kqemu:k}
41 License:        GPL
42 Group:          Applications/Emulators
43 #Source0Download: http://fabrice.bellard.free.fr/qemu/download.html
44 Source0:        http://fabrice.bellard.free.fr/qemu/%{pname}-%{version}.tar.gz
45 # Source0-md5:  6591df8e9270eb358c881de4ebea1262
46 Source1:        http://fabrice.bellard.free.fr/qemu/k%{pname}-%{kqemu_version}.tar.gz
47 # Source1-md5:  970521874ef8b1ba4598925ace5936c3
48 Patch0:         %{pname}-nostatic.patch
49 Patch1:         %{pname}-cc.patch
50 Patch3:         %{pname}-dot.patch
51 Patch4:         %{pname}-gcc4_x86.patch
52 Patch5:         %{pname}-gcc4_ppc.patch
53 Patch6:         %{pname}-nosdlgui.patch
54 # Proof of concept, for reference, do not remove
55 Patch8:         %{pname}-kde_virtual_workspaces_hack.patch
56 # http://gwenole.beauchesne.info/en/projects/qemu
57 Patch9:         %{pname}-0.8.0-gcc4-hacks.patch
58 Patch11:        %{pname}-0.7.2-gcc4-opts.patch
59 #Patch12:       %{pname}-0.7.2-dyngen-check-stack-clobbers.patch
60 Patch13:        %{pname}-dosguest.patch
61 Patch14:        %{pname}-ppc_old_binutils.patch
62 Patch15:        %{pname}-isa-bios-ram.patch
63 # below one fixes problems with passing ram size to bios/bootloader
64 # which affects coreboot/linuxbios
65 Patch16:        %{pname}-piix-ram-size.patch
66 URL:            http://fabrice.bellard.free.fr/qemu/
67 %if %{with kernel} && %{with dist_kernel}
68 BuildRequires:  kernel%{_alt_kernel}-module-build >= 3:2.6.7
69 BuildRequires:  rpmbuild(macros) >= 1.379
70 %endif
71 %if %{with userspace}
72 BuildRequires:  SDL-devel >= 1.2.1
73 BuildRequires:  alsa-lib-devel
74 %{!?with_gcc4:BuildRequires:    gcc < 5:4.0}
75 BuildRequires:  perl-tools-pod
76 BuildRequires:  sed >= 4.0
77 BuildRequires:  tetex
78 BuildRequires:  which
79 %endif
80 Requires:       SDL >= 1.2.1
81 # sparc is currently unsupported (missing cpu_get_real_ticks() impl in vl.c)
82 ExclusiveArch:  %{ix86} %{x8664} %{?with_userspace:ppc}
83 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
84
85 # some SPARC boot image in ELF format
86 %define         _noautostrip    .*%{_datadir}/qemu/openbios-sparc32
87
88 %description
89 QEMU is a FAST! processor emulator. By using dynamic translation it
90 achieves a reasonnable speed while being easy to port on new host
91 CPUs. QEMU has two operating modes:
92
93 - User mode emulation. In this mode, QEMU can launch Linux processes
94   compiled for one CPU on another CPU. Linux system calls are converted
95   because of endianness and 32/64 bit mismatches. Wine (Windows
96   emulation) and DOSEMU (DOS emulation) are the main targets for QEMU.
97
98 - Full system emulation. In this mode, QEMU emulates a full system,
99   including a processor and various peripherials. It can also be used to
100   provide virtual hosting of several virtual PC on a single server.
101
102 %description -l pl.UTF-8
103 QEMU to szybki(!) emulator procesora. Poprzez użycie dynamicznego
104 tłumaczenia osiąga rozsądną szybkość i jest łatwy do przeportowania,
105 aby działał na kolejnych procesorach. QEMU ma dwa tryby pracy:
106
107 - Emulacja trybu użytkownika. W tym trybie QEMU może uruchamiać
108   procesy linuksowe skompilowane dla jednego procesora na innym
109   procesorze. Linuksowe wywołania systemowe są tłumaczone ze względu na
110   niezgodność kolejności bajtów w słowie i 32/64-bitowego rozmiaru
111   słowa. Wine (emulacja Windows) i DOSEMU (emulacja DOS-a) to główne
112   cele QEMU.
113
114 - Pełna emulacja systemu. W tym trybie QEMU emuluje cały system,
115   włączając w to procesor i różne urządzenia peryferyjne. Może być także
116   używane do wirtualnego hostowania kilku wirtualnych pecetów na
117   pojedynczym serwerze.
118
119 %package -n kernel%{_alt_kernel}-misc-kqemu
120 Summary:        kqemu - kernel module
121 Summary(pl.UTF-8):      kqemu - moduł jądra
122 Version:        %{kqemu_version}
123 Release:        %{rel}@%{_kernel_ver_str}
124 Group:          Base/Kernel
125 %{?with_dist_kernel:%requires_releq_kernel}
126 License:        GPL v2
127 Obsoletes:      kernel%{_alt_kernel}-smp-misc-kqemu
128 Requires(post,postun):  /sbin/depmod
129 Requires:       module-init-tools >= 3.2.2-2
130
131 %description -n kernel%{_alt_kernel}-misc-kqemu
132 kqemu - kernel module.
133
134 %description -n kernel%{_alt_kernel}-misc-kqemu -l pl.UTF-8
135 kqemu - moduł jądra.
136
137 %prep
138 %setup -q -n %{pname}-%{qemu_version} %{?with_kernel:-a1}
139 %patch0 -p1
140 %patch1 -p1
141 %patch3 -p1
142 %if %{with gcc4}
143 %patch9 -p1
144 %patch11 -p1
145 #%patch12 -p1
146 #%patch4 -p0
147 %patch5 -p1
148 %endif
149 %{?with_nosdlgui:%patch6 -p1}
150 #%patch8 -p1
151
152 %{__sed} -i -e 's/sdl_static=yes/sdl_static=no/' configure
153 %{__sed} -i 's/.*MAKE) -C kqemu$//' Makefile
154
155 # cannot use optflags on x86 - they cause "no register to spill" errors
156 %if %{with cflags_passing}
157 %{__sed} -i -e 's/-Wall -O2 -g/-Wall %{rpmcflags}/' Makefile Makefile.target
158 %else
159 %{__sed} -i 's/-Wall -O2 -g/-Wall -O2/' Makefile Makefile.target
160 %endif
161
162 %if %{with kernel}
163 echo -n > kqemu-%{kqemu_version}/install.sh
164
165 cat <<'EOF' > modprobe.conf
166 # enable dynamic major
167 options kqemu major=0
168 # for autoloading from static dev
169 #alias char-major-250 kqemu
170 EOF
171
172 cat <<'EOF' > udev.conf
173 KERNEL=="kqemu", NAME="%k", MODE="0666"
174 EOF
175
176 %if %{with dosguest}
177 %patch13 -p1
178 %endif
179 %patch14 -p1
180 %patch15 -p1
181 %patch16 -p1
182
183 cd kqemu-%{kqemu_version}
184 %{__sed} -i 's#include ../config-host.mak##' ./common/Makefile
185 %ifarch %{x8664}
186 %{__sed} -i 's/^#ARCH=x86_64/ARCH=x86_64/' ./common/Makefile
187 %{__make} -C common -j1
188 mv -f kqemu-mod-x86_64.o{,.bin}
189 %else
190 %{__sed} -i 's/^#ARCH=i386/ARCH=i386/' ./common/Makefile
191 %{__make} -C common -j1
192 mv -f kqemu-mod-i386.o{,.bin}
193 %endif
194
195 mv -f kqemu-linux.c{,.orig}
196 cat > Makefile <<'EOF'
197 obj-m := kqemu.o
198 kqemu-objs:= kqemu-linux.o kqemu-mod.o
199
200 $(obj)/kqemu-mod.o: $(src)/kqemu-mod-$(ARCH).o.bin
201         cp $< $@
202 EOF
203 cd -
204 %endif
205
206 %build
207 %if %{with kernel}
208 cd kqemu-%{kqemu_version}
209 %build_kernel_modules -m kqemu <<'EOF'
210 if grep -q "CONFIG_PREEMPT_RT" o/.config; then
211         sed 's/SPIN_LOCK_UNLOCKED/SPIN_LOCK_UNLOCKED(kqemu_lock)/' \
212                 kqemu-linux.c.orig > kqemu-linux.c
213 else
214         cat kqemu-linux.c.orig > kqemu-linux.c
215 fi
216 EOF
217 cd -
218 %endif
219
220 %if %{with userspace}
221 # --extra-cflags don't work (overridden by CFLAGS in Makefile*)
222 # they can be passed if the cflags_passing bcond is used
223 ./configure \
224         --prefix=%{_prefix} \
225         --cc="%{__cc}" \
226         --host-cc="%{__cc}" \
227         --make="%{__make}" \
228 %if %{with kqemu}
229         --kernel-path=%{_kernelsrcdir} \
230 %else
231         --disable-kqemu \
232 %endif
233         %{?with_gcc4:--disable-gcc-check} \
234         --enable-alsa \
235         --interp-prefix=%{_libdir}/%{pname}
236 %{__make}
237 %endif
238
239 %install
240 rm -rf $RPM_BUILD_ROOT
241
242 %if %{with userspace}
243 %{__make} install \
244         DESTDIR=$RPM_BUILD_ROOT
245
246 install -d $RPM_BUILD_ROOT%{_sysconfdir}
247 cat <<'EOF' > $RPM_BUILD_ROOT%{_sysconfdir}/qemu-ifup
248 #!/bin/sh
249
250 EOF
251 %endif
252
253 %if %{with kernel}
254 %install_kernel_modules -m kqemu-%{kqemu_version}/kqemu -d misc
255 install -d $RPM_BUILD_ROOT/etc/{modprobe.d/%{_kernel_ver}{,smp},udev/rules.d}
256 install modprobe.conf $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/kqemu.conf
257 install udev.conf $RPM_BUILD_ROOT/etc/udev/rules.d/kqemu.rules
258 %endif
259
260 # already packaged
261 rm -rf $RPM_BUILD_ROOT%{_docdir}/qemu/qemu-{doc,tech}.html
262
263 %clean
264 rm -rf $RPM_BUILD_ROOT
265
266 %if %{with kernel}
267 %post
268 %banner %{pname} -e <<EOF
269 To enable qemu accelerator (kqemu), the kqemu kernel module must be loaded:
270 modprobe kqemu
271 EOF
272 %endif
273
274 %post   -n kernel%{_alt_kernel}-misc-kqemu
275 %depmod %{_kernel_ver}
276
277 %postun -n kernel%{_alt_kernel}-misc-kqemu
278 %depmod %{_kernel_ver}
279
280 %if %{with userspace}
281 %files
282 %defattr(644,root,root,755)
283 %doc README qemu-doc.html qemu-tech.html
284 %attr(755,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/qemu-ifup
285 %attr(755,root,root) %{_bindir}/*
286 %{_datadir}/qemu
287 %{_mandir}/man1/qemu.1*
288 %{_mandir}/man1/qemu-img.1*
289 %endif
290
291 %if %{with kernel}
292 %files -n kernel%{_alt_kernel}-misc-kqemu
293 %defattr(644,root,root,755)
294 %doc kqemu-%{kqemu_version}/LICENSE
295 %config(noreplace) %verify(not md5 mtime size) /etc/udev/rules.d/kqemu.rules
296 %config(noreplace) %verify(not md5 mtime size) /etc/modprobe.d/%{_kernel_ver}/kqemu.conf
297 /lib/modules/%{_kernel_ver}/misc/kqemu.ko*
298 %endif
This page took 0.101518 seconds and 4 git commands to generate.