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