#!/usr/bin/make -f
export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

# Work around FTBFS on ppc64el in Ubuntu, which uses -O3 by default instead
# of -O2 like Debian. TODO: Investigate and fix root cause.
ifeq ($(DEB_HOST_ARCH),ppc64el)
ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
export DEB_CFLAGS_MAINT_STRIP = -O3
export DEB_CFLAGS_MAINT_APPEND = -O2
endif
endif

%:
	dh $@

# Multiarch is supported, but to support upgrades, the library needs to stay in
# the non-multiarch path for one release with a symlink from the multiarch
# path. See #850453.
override_dh_auto_configure:
	dh_auto_configure -- --libdir='$${prefix}/lib' --libexecdir='$${prefix}/lib'

override_dh_install:
	dh_install --fail-missing

# (shell-command "cd ../ ; debian/rules debian/qemubuilder.README.Debian")
debian/qemubuilder.README.Debian:
	w3m -dump 'http://wiki.debian.org/qemubuilder?action=raw' > $@.tmp
	mv $@.tmp $@

