#! /usr/bin/make -f
%:
	dh $@

DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE  := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CROSS :=
else
CROSS := \
	CC=$(DEB_HOST_GNU_TYPE)-gcc \
	PKG_CONFIG=$(DEB_HOST_GNU_TYPE)-pkg-config
endif

cflags := $(shell dpkg-buildflags --get CPPFLAGS)
cflags += $(shell dpkg-buildflags --get CFLAGS)
cflags += -Wall -Werror -D_FILE_OFFSET_BITS=64
ldflags := $(shell dpkg-buildflags --get LDFLAGS)

override_dh_auto_build:
	dh_auto_build -- $(CROSS) CFLAGS='$(cflags)' LFLAGS='$(ldflags)'
