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