File: rules

package info (click to toggle)
qemu 1:2.8+dfsg-6+deb9u8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 80,544 kB
  • sloc: ansic: 1,023,069; sh: 16,809; python: 15,697; cpp: 12,293; asm: 11,295; perl: 4,421; makefile: 2,076; objc: 1,224; xml: 708
file content (317 lines) | stat: -rwxr-xr-x 10,607 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#!/usr/bin/make -f
SHELL = /bin/sh -e

# get DEB_VERSION
include /usr/share/dpkg/pkg-info.mk
# get DEB_HOST_ARCH DEB_HOST_ARCH_OS DEB_HOST_GNU_TYPE DEB_HOST_MULTIARCH DEB_BUILD_GNU_TYPE
include /usr/share/dpkg/architecture.mk
# get CFLAGS LDFLAGS etc
include /usr/share/dpkg/buildflags.mk

ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)
VENDOR := UBUNTU
DEB_BUILD_PARALLEL = yes
else
VENDOR := DEBIAN
endif

# support parallel build using DEB_BUILD_OPTIONS=parallel=N
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  MAKEFLAGS += -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

# verbose build
V ?= 1

# list of packages we're supposed to build
BUILD_PACKAGES = $(call dpkg_late_eval,BUILD_PACKAGES,dh_listpackages)

enable_system = $(if $(filter qemu-system,${BUILD_PACKAGES}),enable,disable)
enable_linux_user = $(if $(filter qemu-user,${BUILD_PACKAGES}),enable,disable)

DATAPATH = /usr/share/qemu:/usr/share/seabios:/usr/lib/ipxe/qemu

# we add another set of configure options from debian/control
common_configure_opts = \
	--with-pkgversion="Debian $(DEB_VERSION)" \
	--extra-cflags="$(CFLAGS) $(CPPFLAGS) -DCONFIG_QEMU_DATAPATH='\"${DATAPATH}\"' -DVENDOR_$(VENDOR)" \
	--extra-ldflags="$(LDFLAGS) -Wl,--as-needed" \
	--prefix=/usr \
	--sysconfdir=/etc \
	--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
	--libexecdir=/usr/lib/qemu \
	--localstatedir=/var \
	--disable-blobs \
	--disable-strip \
	--with-system-pixman \
	--interp-prefix=/etc/qemu-binfmt/%M \
	--localstatedir=/var \

# Cross compiling support
ifneq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
common_configure_opts  += --cross-prefix=$(DEB_HOST_GNU_TYPE)-
endif

ifeq (${enable_system},enable)

# list of system (softmmu) targets, from ./configure
system_targets = \
 i386 x86_64 alpha aarch64 arm cris lm32 m68k microblaze microblazeel \
 mips mipsel mips64 mips64el moxie or32 ppc ppcemb ppc64 sh4 sh4eb \
 sparc sparc64 s390x tricore xtensa xtensaeb unicore32

# qemu-system subpackages, from d/control
sys_systems = arm mips ppc sparc x86
systems = ${sys_systems} misc
sysarch_arm   = $(filter aarch64 arm,${system_targets})
sysarch_mips  = $(filter mips mipsel mips64 mips64el,${system_targets})
sysarch_ppc   = $(filter ppc ppc64 ppcemb,${system_targets})
sysarch_sparc = $(filter sparc sparc64,${system_targets})
sysarch_x86   = $(filter i386 x86_64,${system_targets})
sysarch_misc  = $(filter-out $(foreach s,${sys_systems},${sysarch_$s}),${system_targets})

else

systems =

endif # enable_system

ifeq (${enable_linux_user},enable)

# list of linux-user targets, from ./configure
user_targets = \
 i386 x86_64 alpha aarch64 arm armeb cris m68k microblaze microblazeel \
 mips mipsel mips64 mips64el mipsn32 mipsn32el or32 \
 ppc ppc64 ppc64abi32 ppc64le sh4 sh4eb sparc sparc64 sparc32plus \
 s390x tilegx

endif	# enable_linux_user

configure-stamp: configure
	dh_testdir

	# system build
	rm -rf qemu-build; mkdir qemu-build
	cd qemu-build && \
	    ../configure ${common_configure_opts} --disable-user \
		--${enable_system}-system \
		--${enable_linux_user}-linux-user \
		--enable-modules \
		$(shell sh debian/extract-config-opts \
		    $(DEB_HOST_ARCH_OS)-$(DEB_HOST_ARCH) debian/control) \
		$(QEMU_CONFIGURE_OPTIONS) || \
	 { echo ===== CONFIGURE FAILED ===; tail -n 50 config.log; exit 1; }

ifeq ($(enable_linux_user),enable)
# do not use debian/configure-opts here, all optional stuff will be enabled
# automatically, dependencies are already verified in the main build
	rm -rf user-static-build; mkdir user-static-build
	cd user-static-build && \
	    ../configure ${common_configure_opts} \
		--static --disable-system \
		--target-list="$(addsuffix -linux-user,${user_targets})"
endif
	touch $@

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp: configure-stamp
	dh_testdir

	# system and utils build
	$(MAKE) -C qemu-build V=${V}
ifeq (${enable_system},enable)
	dtc -o qemu-build/pc-bios/bamboo.dtb pc-bios/bamboo.dts
endif

ifeq ($(enable_linux_user),enable)
	# user-static build
	# we use this invocation to build just the binaries
	$(MAKE) -C user-static-build V=${V} $(foreach t,${user_targets},subdir-${t}-linux-user)
endif
	touch $@

clean:	debian/control
	dh_testdir
	rm -rf qemu-build user-static-build
	rm -f configure-stamp build-stamp
	find scripts/ -name '*.pyc' -delete || :
	dh_clean

# define ${ai} variable to be one of -i (indep), -a (arch) or nothing (both)
ai :=
binary-indep: ai := -i
binary-indep: install
binary-arch: ai := -a
binary-arch: install
binary: install

define inst-system
	mkdir -p debian/qemu-system-$1/usr/share/man/man1 debian/qemu-system-$1/usr/bin
	for t in ${sysarch_$1}; do \
	    mv debian/tmp/usr/bin/qemu-system-$$t debian/qemu-system-$1/usr/bin/; \
	    echo ".so man1/qemu-system.1" > debian/qemu-system-$1/usr/share/man/man1/qemu-system-$$t.1; \
	done
	echo sysarch:$1=\
$(if $(wordlist 10,20,${sysarch_$1}),\
$(wordlist 1,8,${sysarch_$1})\$${Newline}   $(wordlist 9,20,${sysarch_$1}),\
${sysarch_$1}) \
> debian/qemu-system-$1.substvars
	echo sysprovides:$1=${addprefix qemu-system-,${filter-out $1,${sysarch_$1}}} | \
	  sed -e 's/ /, /g' -e 'y/_/-/' >> debian/qemu-system-$1.substvars
	dh_link -pqemu-system-$1 usr/share/doc/qemu-system-common usr/share/doc/qemu-system-$1/common

endef

install: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs -a

	# system and utils install
	$(MAKE) -C qemu-build DESTDIR=$(CURDIR)/debian/tmp install

ifeq (${enable_system},enable)

	# qemu-system subpackages
	mv debian/tmp/usr/share/man/man1/qemu.1 debian/tmp/usr/share/man/man1/qemu-system.1
	$(foreach s,${systems},$(call inst-system,$s))

ifneq ($(filter $(DEB_HOST_ARCH),amd64 i386),)
# We used to load kvm module on x86 using an initscript,
# but modern kernels do that automatically.  Remove the initscript.
# Remove this fragment for stretch+1.
	for x in preinst postinst postrm; do \
	  echo 'dpkg-maintscript-helper rm_conffile /etc/init.d/qemu-system-x86 1:2.2+dfsg-3~ -- "$$@"' \
	    >> debian/qemu-system-x86.$$x.debhelper ; \
	done
# there's no need to restore the links b/c kernel autoloads our modules
	echo 'if [ configure = "$$1" ] && dpkg --compare-versions "$$2" le-nl 1:2.2+dfsg-3~; then update-rc.d qemu-system-x86 remove >/dev/null; fi' \
	  >> debian/qemu-system-x86.postinst.debhelper
endif

# remove now-unused target-x86_64.conf (and /etc/qemu dir too, see #797608)
	for x in preinst postinst postrm; do \
	  echo 'dpkg-maintscript-helper rm_conffile /etc/qemu/target-x86_64.conf 1:2.4+dfsg-1~ -- "$$@"' \
            >> debian/qemu-system-x86.$$x.debhelper ; \
	  echo '[ -d /etc/qemu ] && rmdir /etc/qemu 2>/dev/null || :' \
	    >> debian/qemu-system-x86.$$x.debhelper; \
	done

ifeq ($(DEB_HOST_ARCH_OS),linux)

# /usr/bin/kvm compat script.  This needs some more work for other arches
# How about a manpage for it?
ifneq ($(filter $(DEB_HOST_ARCH),amd64 i386),)
	dh_install -pqemu-kvm debian/kvm /usr/bin/
	dh_install -pqemu-kvm debian/kvm.1 /usr/share/man/man1/
ifeq ($(VENDOR),UBUNTU)
# on ubuntu there was kvm-spice package/binary which was used in libvirt xml
	dh_link -pqemu-kvm usr/bin/kvm usr/bin/kvm-spice \
		usr/bin/qemu-system-x86_64 usr/bin/qemu-system-x86_64-spice
endif
endif
ifeq ($(VENDOR),UBUNTU)
# apport hook is ubuntu-specific
	dh_install -pqemu-system-common debian/source_qemu.py \
		usr/share/apport/package-hooks/
endif

# virtfs-proxy-helper and qemu-bridge-helper are linux-specific
	for f in usr/bin/virtfs-proxy-helper \
	         usr/share/man/man1/virtfs-proxy-helper.1 \
		 usr/lib/qemu/qemu-bridge-helper \
	; do \
	  mkdir -p debian/qemu-system-common/$${f%/*} ; \
	  mv debian/tmp/$$f debian/qemu-system-common/$$f ; \
	done

endif # linux

endif # enable_system

ifeq ($(enable_linux_user),enable)
	# qemu-user
	mkdir -p debian/qemu-user/usr/bin debian/qemu-user/usr/share/man/man1
	for t in ${user_targets}; do \
	    mv debian/tmp/usr/bin/qemu-$$t \
		debian/qemu-user/usr/bin ; \
	    ln -s qemu-user.1 \
		debian/qemu-user/usr/share/man/man1/qemu-$$t.1 ; \
	done

	# qemu-user-static
	mkdir -p debian/qemu-user-static/usr/bin debian/qemu-user-static/usr/share/man/man1
	for t in ${user_targets}; do \
	    cp -p user-static-build/$$t-linux-user/qemu-$$t \
		debian/qemu-user-static/usr/bin/qemu-$$t-static ; \
	    ln -s qemu-user-static.1 \
		    debian/qemu-user-static/usr/share/man/man1/qemu-$$t-static.1 ; \
	done

	# binfmt support
	for x in postinst prerm; do \
	    sed -e s/@SUFFIX@/-static/ -e s/@PACKAGE@/qemu-user-static/ \
		debian/binfmt-update-in >> debian/qemu-user-static.$$x.debhelper ; \
	    sed -e s/@SUFFIX@// -e s/@PACKAGE@/qemu-user-binfmt/ \
		debian/binfmt-update-in >> debian/qemu-user-binfmt.$$x.debhelper ; \
	done

endif	# enable_linux_user

# install whole thing so --list-missing works right
	dh_install --list-missing
# install the rest for arch/indep as needed
	dh_installdocs ${ai} -Nqemu-user-binfmt
	dh_installchangelogs ${ai} -Nqemu-user-binfmt
	dh_installdocs ${ai} -pqemu-user-binfmt --link-doc=qemu-user
	dh_installman ${ai}
	dh_installudev ${ai}
ifneq (${ai},-i)	# do not run this for binary-indep
ifeq (${enable_system},enable)
# qemu-ifup is arch-specific
	install -D debian/qemu-ifup.$(DEB_HOST_ARCH_OS) \
		debian/qemu-system-common/etc/qemu-ifup
endif
	dh_installinit -pqemu-guest-agent
endif
	dh_link ${ai}
	dh_strip ${ai}
	dh_compress ${ai}
	dh_fixperms ${ai}
	dh_makeshlibs ${ai}
	dh_shlibdeps ${ai}
	dh_installdeb ${ai}
ifeq ($(enable_linux_user),enable)
# after shlibdeps finished, grab ${shlibs:Depends} from -user package
# and transform it into Built-Using field for -user-static.
# See also dpkg-query bug #588505
	if [ -f debian/qemu-user.substvars ]; then \
	  pkgs=$$(sed -n -e's/([^)]*)//g' -e's/,//g' -e's/^shlibs:Depends=//p' debian/qemu-user.substvars); \
	  srcs=; for p in $$pkgs; do \
	    srcs="$$srcs $$(dpkg-query -f '$${source:Package} (= $${source:Version}),' -W $$p)"; \
	  done ; \
	  echo "built-using=$$srcs" >> debian/qemu-user-static.substvars ; \
	fi
endif
	dh_gencontrol ${ai}
	dh_md5sums ${ai}
	dh_builddeb ${ai}

ifneq (,$(wildcard debian/control-in))
# only include rules for debian/control if debian/control-in is present
debian/control: debian/control-in debian/rules
	echo '# autogenerated file, please edit debian/control-in' > $@.tmp
	sed -e 's/^:$(shell echo ${VENDOR} | tr '[A-Z]' '[a-z]')://' \
		-e '/^:[a-z]*:/D' $< >> $@.tmp
	mv -f $@.tmp $@
	chmod -w $@
endif

get-orig-source:
	./debian/get-orig-source.sh ${DEB_VERSION}

.PHONY: build clean binary-indep binary-arch binary install get-orig-source