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