#!/usr/bin/make -f
export DEB_BUILD_MULTIARCH ?= $(shell dpkg-architecture -qDEB_BUILD_MULTIARCH)
export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --with autoreconf --parallel

override_dh_auto_configure:
	touch po/libgpg-error.pot
	dh_auto_configure --builddirectory=build -- \
	    --enable-static \
	    --disable-rpath \
	    --infodir=\$${prefix}/share/info \
	    --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_build-arch:
	dh_auto_build --parallel --builddirectory=build
ifeq ($(DEB_HOST_MULTIARCH),$(DEB_BUILD_MULTIARCH))
	tail -vn+0 build/src/lock-obj-pub.native.h
endif

override_dh_auto_install-arch:
	dh_auto_install --parallel --builddirectory=build

override_dh_install:
	sed -e"s,@DEB_HOST_MULTIARCH@,${DEB_HOST_MULTIARCH},g" \
	    debian/libgpg-error0.install.in > debian/libgpg-error0.install
	sed -e"s,@DEB_HOST_MULTIARCH@,${DEB_HOST_MULTIARCH},g" \
	    debian/libgpg-error-dev.install.in > debian/libgpg-error-dev.install
	dh_install --list-missing

override_dh_installchangelogs:
	dh_installchangelogs -A NEWS

override_dh_installdocs:
	dh_installdocs -A README

override_dh_makeshlibs:
	dh_makeshlibs -V --add-udeb=libgpg-error0-udeb

override_dh_link:
	dh_link -plibgpg-error-dev lib/$(DEB_HOST_MULTIARCH)/libgpg-error.so.0 usr/lib/$(DEB_HOST_MULTIARCH)/libgpg-error.so

