aboutsummaryrefslogtreecommitdiff
path: root/debian/rules
blob: 3037a48189bbc5fd3b14f87b0b75dce2b2582bec (plain)
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
#!/usr/bin/make -f

deb_source := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
deb_version := $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')
upstream_version := $(shell echo '$(deb_version)' | sed 's/.*://; s/-[^-]*$$//')
git_rev := $(shell echo '$(upstream_version)' | sed 's/.*+//')

DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_ARCH_OS = $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_HOST_ARCH_CPU = $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
DEB_HOST_GNU_CPU = $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_BUILD_ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)

QEMU_CPU = $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
ifeq ($(QEMU_CPU),powerpc)
  QEMU_CPU = ppc
endif
ifneq (,$(filter $(DEB_HOST_ARCH),armel armhf))
  QEMU_CPU = armv7l
endif

ifneq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  conf_arch += --cross-prefix=$(DEB_HOST_GNU_TYPE)- --cpu=$(QEMU_CPU)
endif

ifeq ($(DEB_HOST_ARCH_OS),linux)
# Note: We differ from Debian here by favoring the pulseaudio driver, since that's default in Ubuntu.
#       Users override this when calling qemu by exporting the environment variable QEMU_AUDIO_DRV.
       conf_audio_drv += --audio-drv-list=pa,alsa,sdl,oss
endif
ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
       conf_audio_drv += --audio-drv-list=oss,sdl,pa
endif
# KVM on PowerPC needs at least 2.6.33 kernel headers
ifeq ($(DEB_HOST_ARCH_CPU),powerpc)
       conf_arch += --disable-kvm
endif

ifeq ($(DEB_HOST_ARCH_CPU),arm)
       conf_arch += --enable-kvm
endif


# binfmt support
ALL_BINFMT_TARGETS=alpha arm armeb cris i386 m68k microblaze mips mipsel ppc ppc64 ppc64abi32 sh4 sh4eb sparc sparc32plus sparc64 x86_64
ifeq ($(DEB_HOST_ARCH),amd64)
BINFMT_TARGETS=$(filter-out i386 x86_64, $(ALL_BINFMT_TARGETS))
endif
ifneq (,$(findstring $(DEB_HOST_ARCH), arm armel armhf))
BINFMT_TARGETS=$(filter-out arm, $(ALL_BINFMT_TARGETS))
endif
ifeq ($(DEB_HOST_ARCH),i386)
BINFMT_TARGETS=$(filter-out i386, $(ALL_BINFMT_TARGETS))
endif
ifeq ($(DEB_HOST_ARCH),powerpc)
BINFMT_TARGETS=$(filter-out ppc, $(ALL_BINFMT_TARGETS))
endif
ifeq ($(DEB_HOST_ARCH),ppc64)
BINFMT_TARGETS=$(filter-out ppc ppc64 ppc64abi32 , $(ALL_BINFMT_TARGETS))
endif
ifeq ($(DEB_HOST_ARCH),sparc)
BINFMT_TARGETS=$(filter-out sparc sparc32plus sparc64, $(ALL_BINFMT_TARGETS))
endif
ifeq ($(DEB_HOST_ARCH),sparc64)
BINFMT_TARGETS=$(filter-out sparc sparc32plus sparc64, $(ALL_BINFMT_TARGETS))
endif
ifeq ($(BINFMT_TARGETS),)
BINFMT_TARGETS=$(ALL_BINFMT_TARGETS)
endif

# namespace to use for data files
NAMESPACE := linaro

# basedir in which to install BIOSes and keymaps below prefix
DATASUBDIR := share/qemu-$(NAMESPACE)
DATADIR := /usr/$(DATASUBDIR)
# XXX doesn't work because it's #defined in the source should send an upstream
# patch to allow ./configuring that
#CFLAGS += -DSHARE_SUFFIX="$(DATASUBDIR)"

# Workaround for var tracking blowing up the memory requirements more than
# tenfold on armel; we'll keep -g enabled but disable this particular feature
ifneq (,$(findstring $(DEB_HOST_ARCH), armel armhf))
CFLAGS += -fno-var-tracking
endif

# XXX for some reason, --remote doesn't work with gitorious so this needs to be
# run from a local checkout
# --remote=git://gitorious.org/qemu-maemo/qemu-maemo.git
get-orig-source:
	git archive \
	    --format=tar \
	    --prefix=$(deb_source)-$(upstream_version)/ \
	    $(git_rev) \
	    | gzip >$(deb_source)_$(upstream_version).orig.tar.gz

override_dh_auto_configure:
	# system build
	mkdir -p $(CURDIR)/system-build
	cd $(CURDIR)/system-build && \
		../configure \
		    --with-pkgversion="Debian $(deb_version)" \
		    --extra-cflags="$(CFLAGS)" \
		    --extra-ldflags="$(LDFLAGS)" \
		    --prefix=/usr \
		    --datadir=$(DATADIR) \
		    --interp-prefix=/etc/qemu-binfmt/%M \
		    --disable-blobs \
		    --disable-strip \
		    --disable-linux-user \
		    --disable-bsd-user \
		    --disable-spice \
		    --enable-fdt \
		    $(conf_arch) $(conf_audio_drv)

ifeq ($(DEB_HOST_ARCH_OS),linux)
	# user build
	mkdir -p $(CURDIR)/user-build
	cd $(CURDIR)/user-build && \
		../configure \
		    --with-pkgversion="Debian $(deb_version)" \
		    --extra-cflags="$(CFLAGS)" \
		    --extra-ldflags="$(LDFLAGS)" \
		    --prefix=/usr \
		    --datadir=$(DATADIR) \
		    --interp-prefix=/etc/qemu-binfmt/%M \
		    --disable-blobs \
		    --disable-strip \
		    --disable-system \
		    --enable-uname-release=2.6.32 \
		    $(conf_arch)

	# static user build
	mkdir -p $(CURDIR)/user-static-build
	cd $(CURDIR)/user-static-build && \
		../configure \
		    --with-pkgversion="Debian $(deb_version)" \
		    --extra-cflags="$(CFLAGS)" \
		    --extra-ldflags="$(LDFLAGS)" \
		    --prefix=/usr \
		    --datadir=$(DATADIR) \
		    --interp-prefix=/etc/qemu-binfmt/%M \
		    --disable-blobs \
		    --disable-strip \
		    --disable-system \
		    --static \
		    --enable-uname-release=2.6.32 \
		    $(conf_arch)

ifeq ($(DEB_HOST_ARCH),amd64)
	# spice build
	mkdir -p $(CURDIR)/spice-build
	cd $(CURDIR)/spice-build && \
		../configure \
		    --with-pkgversion="Debian $(deb_version)" \
		    --extra-cflags="$(CFLAGS)" \
		    --extra-ldflags="$(LDFLAGS)" \
		    --prefix=/usr \
		    --interp-prefix=/etc/qemu-binfmt/%M \
		    --disable-blobs \
		    --disable-strip \
		    --disable-system \
		    --target-list="x86_64-softmmu i386-softmmu x86_64-linux-user i386-linux-user" \
		    --enable-spice \
		    $(conf_arch)
endif
endif

override_dh_auto_build:
	# system build
	dh_auto_build -B system-build --parallel
ifeq ($(DEB_HOST_ARCH_OS),linux)
	# user build
	dh_auto_build -B user-build --parallel

	# static user build
	dh_auto_build -B user-static-build --parallel

ifeq ($(DEB_HOST_ARCH),amd64)
	# spice build
	dh_auto_build -B spice-build --parallel
endif
endif

override_dh_auto_install:
ifeq ($(DEB_HOST_ARCH_OS),linux)
	dh_auto_install -B user-static-build --destdir=$(CURDIR)/debian/tmp
	for script in prerm postinst; do \
		sed -e 's/^BINFMT_TARGETS=.*/BINFMT_TARGETS=\"$(BINFMT_TARGETS)\"/g' \
                $(CURDIR)/debian/qemu-user-static.$$script.in \
		> $(CURDIR)/debian/qemu-user-static.$$script; \
	done
	for target in $(CURDIR)/debian/tmp/usr/bin/qemu-*; do \
		install -m 755 $$target $(CURDIR)/debian/tmp/usr/bin/$$(basename $$target)-static; \
	done
	dh_auto_install -B user-build --destdir=$(CURDIR)/debian/tmp
	for target in $(BINFMT_TARGETS) ; do \
		install -m 644 $(CURDIR)/debian/binfmts/qemu-$$target \
			$(CURDIR)/debian/qemu-user-static/usr/share/binfmts ; \
	done
	f=debian/qemu-user-static.sysctl; [ -f debian/qemu-user-static.sysctl.$(DEB_BUILD_ARCH) ] && f=debian/qemu-user-static.sysctl.$(DEB_BUILD_ARCH); cp $$f debian/qemu-user-static/etc/sysctl.d/30-qemu-user-static.conf
ifeq ($(DEB_HOST_ARCH),amd64)
	dh_auto_install -B spice-build --destdir=$(CURDIR)/debian/spice-tmp
	for target in qemu-i386 qemu-x86_64 qemu-system-x86_64; do \
		mv $(CURDIR)/debian/spice-tmp/usr/bin/$$target \
			$(CURDIR)/debian/spice-tmp/usr/bin/$$target-spice; \
	done
	mv $(CURDIR)/debian/spice-tmp/usr/bin/qemu-system-i386 \
	   $(CURDIR)/debian/spice-tmp/usr/bin/qemu-spice
endif
endif
	dh_auto_install -B system-build --destdir=$(CURDIR)/debian/tmp
	mv $(CURDIR)/debian/tmp/usr/share/man/man1/qemu.1 \
	   $(CURDIR)/debian/tmp/usr/share/man/man1/qemu-system.1

override_dh_install:
ifeq ($(DEB_HOST_ARCH),amd64)
	dh_install -pqemu-kvm-spice --sourcedir=$(CURDIR)/debian/spice-tmp
endif
	dh_install -Nqemu-kvm-spice

override_dh_auto_clean:
	rm -rf user-static-build user-build system-build spice-build

override_dh_auto_test:
	# tests are broken ATM

%:
	dh $@

.PHONY: get-orig-source