#! /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
endif
FLAGS := CFLAGS='$(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CFLAGS) -Wall' \
	 LDFLAGS='$(shell dpkg-buildflags --get LDFLAGS)'

override_dh_auto_build:
ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
	$(MAKE) $(CROSS) $(FLAGS)
else
	$(MAKE) debug $(CROSS) $(FLAGS)
endif

override_dh_installchangelogs:
	dh_installchangelogs debian/changelog-upstream.html
