#!/usr/bin/make -f # # Based on the work by Marcus Brinkmann # Rewritten by Guillem Jover # Rewritten to use `dh' by Pino Toscano # export DEB_CFLAGS_MAINT_PREPEND := -Wall -pipe include /usr/share/dpkg/architecture.mk PKG_DEB_TARGET_GNU_CPU=$(subst _,-,$(DEB_TARGET_GNU_CPU)) PKG_DEB_HOST_GNU_CPU=$(subst _,-,$(DEB_HOST_GNU_CPU)) %: dh $@ -Bbuild NATIVE_ARCHS=i386 amd64 arm64 export TARGET_CFLAGS = $(shell DEB_HOST_ARCH=$(DEB_TARGET_ARCH) dpkg-buildflags --get CFLAGS) export TARGET_CPPFLAGS = $(shell DEB_HOST_ARCH=$(DEB_TARGET_ARCH) dpkg-buildflags --get CPPFLAGS) ifeq ($(DEB_HOST_ARCH),$(DEB_TARGET_ARCH)) # CPU compatibility is enough to cross-build trivially CONFIGURE_OPTIONS = \ --program-prefix=$(DEB_TARGET_GNU_CPU)-gnu- ARCHS=$(NATIVE_ARCHS) define d_a $(shell dpkg-architecture -f -a$1 -A$1 -q$2 2> /dev/null) endef else CONFIGURE_OPTIONS = \ --program-prefix=$(DEB_TARGET_GNU_CPU)-gnu- \ --build=$(DEB_BUILD_GNU_TYPE) \ --host=$(DEB_HOST_GNU_TYPE) \ --target=$(DEB_TARGET_GNU_TYPE) CROSSDEP=:$(DEB_TARGET_ARCH) ARCHS=$(DEB_TARGET_ARCH_CPU) # The cross compiler at this stage does not have these in its standard include export TARGET_CPPFLAGS += -I/usr/include -I/usr/include/$(DEB_TARGET_GNU_TYPE) -I/usr/include/$(DEB_TARGET_MULTIARCH) define d_a $($2) endef endif debian/control: debian/control.stamp debian/control.stamp: debian/control.in debian/control.native.in debian/control.target.in debian/rules sed -e 's/@crossdep@/$(CROSSDEP)/' < debian/control.in > debian/control echo "#Note: XXX this file is generated from .in files, see debian/rules" >> debian/control ifeq ($(DEB_HOST_GNU_CPU),$(DEB_TARGET_GNU_CPU)) cat debian/control.native.in >> debian/control endif $(foreach a,$(ARCHS), \ sed -e 's/@target@/$(subst _,-,$(call d_a,$a,DEB_TARGET_GNU_CPU)-gnu)/' \ -e 's/@debtarget@/$(call d_a,$a,DEB_TARGET_ARCH_CPU) GNU\/Hurd/' \ -e 's/@debhost@/any-$(call d_a,$a,DEB_HOST_ARCH_CPU)/' \ < debian/control.target.in >> debian/control ; ) touch $@ override_dh_auto_configure: dh_auto_configure -Bbuild -- \ --libexecdir=/usr/lib/mig/ \ $(CONFIGURE_OPTIONS) ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_TARGET_GNU_TYPE)) build-arch: debian/control.stamp build-indep: build: build-indep build-arch endif override_dh_auto_install: dh_auto_install --destdir=debian/tmp override_dh_install: dh_install dh_install -pmig-$(PKG_DEB_TARGET_GNU_CPU)-gnu /usr/lib/mig/$(DEB_TARGET_GNU_CPU)-gnu-migcom dh_install -pmig-$(PKG_DEB_TARGET_GNU_CPU)-gnu /usr/bin/$(DEB_TARGET_GNU_CPU)-gnu-mig override_dh_gencontrol: dh_gencontrol -- -V"mig:host=mig-$(PKG_DEB_HOST_GNU_CPU)-gnu (>= \$${source:Upstream-Version})" override_dh_auto_clean: dh_auto_clean rm -rf debian/control.stamp