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