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