#! /usr/bin/make -f
#
# © 2009 Cyril Brulebois <kibi@debian.org>


##### INCLUDE
#

include /usr/share/quilt/quilt.make


##### VARIABLES
#

DEB_BUILD_ARCH      ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
NO_MAKE_CHECK_ARCHS := arm
CFLAGS              := $(CFLAGS) -Wall


##### OVERRIDES
#

# Need to set an environment variable to make sure proper linking
# against libphtread happens:
override_dh_auto_configure:
	PTHREAD_LIBS=-lpthread dh_auto_configure

# Need to disable the test suite on some architectures (additionally,
# use 'make check' rather than 'make test'):
override_dh_auto_test:
ifeq (,$(filter $(DEB_BUILD_ARCH),$(NO_MAKE_CHECK_ARCHS)))
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) check
endif
endif

# Need to install those in both packages:
override_dh_installdocs:
	dh_installdocs AUTHORS NEWS README

# Need to pass -V to dh_makeshlibs:
override_dh_makeshlibs:
	dh_makeshlibs -V


##### TARGETS
#

# Need to update config.{guess,sub}:
build: $(QUILT_STAMPFN) build-stamp
build-stamp:
	cp /usr/share/misc/config.guess .
	cp /usr/share/misc/config.sub   .
	dh build
	touch $@

# Need to remove them:
clean: unpatch
	dh $@
	rm -f config.guess config.sub

# Everything else:
%:
	dh $@
