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