diff options
Diffstat (limited to 'debian/rules')
-rwxr-xr-x | debian/rules | 233 |
1 files changed, 233 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..3037a48 --- /dev/null +++ b/debian/rules @@ -0,0 +1,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 |