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