#!/usr/bin/make -f

#export DH_VERBOSE=1

include /usr/share/dpkg/architecture.mk

#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

options = export DEBUG=-DNDEBUG DISTRIBUTION=debian \
	  CONFIG_SHELL=/bin/sh ;

ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
	confflags += --build=$(DEB_HOST_GNU_TYPE)
else
	confflags += --host $(DEB_HOST_GNU_TYPE) --build $(DEB_BUILD_GNU_TYPE)
endif

confflags += \
	--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
	--libexecdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
	$(nil)

build-arch: build
build-indep: build
build: built
built: config
	$(MAKE) default
	rm -f po/attr.pot
	$(MAKE) -C po attr.pot
	touch built

config: .census
.census:
	dh_testdir
	$(options) $(MAKE) configure LOCAL_CONFIGURE_OPTIONS="$(confflags)"
	touch .census

check: built
	dh_testdir
	
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) -C test tests || true
endif


clean:
	dh_testdir
	-rm -f built .census
	$(MAKE) distclean
	dh_clean

binary-indep:

binary-arch: check
	dh_testdir
	dh_testroot
	
	dh_prep
	dh_installdirs
	
	DIST_ROOT=$(CURDIR)/debian/tmp \
	  $(MAKE) install install-dev install-lib
	
	dh_install
	dh_installdocs
	dh_installchangelogs doc/CHANGES
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_makeshlibs -N libattr1
	dh_makeshlibs -p libattr1 -V 'libattr1 (>= 1:2.4.46-8)' --add-udeb libattr1-udeb
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean
