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