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