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