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