#! /usr/bin/gmake -f

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
CFLAGS += -g -gdwarf-2 -fno-omit-frame-pointer
ifeq ($(DEB_HOST_ARCH),solaris-i386)
CFLAGS += -msave-args
endif
export CFLAGS

%:
	dh $@ --builddirectory=debian/build --with=autoreconf --parallel

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export DEB_BUILD_MAINT_OPTIONS := hardening=+bindnow,-pie

export V := 1

override_dh_autoreconf:
	dh_autoreconf ./autogen.sh

override_dh_auto_test:
	# libcheck.a isn't built with -fPIC, so we have trouble on amd64 if
	# we link with -fPIC etc. here.
	VERBOSE=1 dh_auto_test -- LDFLAGS=

override_dh_auto_install:
	dh_auto_install
	rm -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libpipeline.la

override_dh_installdocs:
	dh_installdocs --link-doc=libpipeline1

VERSION_MINOR = $(shell dpkg-parsechangelog | sed -n 's/^Version: //p' | \
			cut -d. -f1,2).0

override_dh_makeshlibs:
	dh_makeshlibs -V'libpipeline1 (>= $(VERSION_MINOR))' -- -c4
