#!/usr/bin/make -f


# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIBDIR:=debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)
PKGLIBDIR:=debian/libudunits2-0/usr/lib/$(DEB_HOST_MULTIARCH)
DEVLIBDIR:=debian/libudunits2-dev/usr/lib/$(DEB_HOST_MULTIARCH)

# magic debhelper rule
%:
	dh $@  --with autoreconf

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	LDFLAGS=" -Wl,--as-needed $(LDFLAGS)" dh_auto_configure -- --datarootdir=/usr/share/xml

override_dh_auto_install:
	dh_auto_install
	dh_installchangelogs CHANGE_LOG
	$(MAKE) pdf html info
	cp udunits2.info debian/libudunits2-0/usr/share/info
	cp prog/*info debian/udunits-bin/usr/share/info
	mkdir -p $(DEVLIBDIR)/pkgconfig
	cp $(LIBDIR)/*.a $(DEVLIBDIR)
	cp $(LIBDIR)/pkgconfig/* $(DEVLIBDIR)/pkgconfig
	# hacks because dh_links doesn't do multiarch yet
	dh_link -p libudunits2-dev  /usr/lib/$(DEB_HOST_MULTIARCH)/libudunits2.so.0.1.0   /usr/lib/$(DEB_HOST_MULTIARCH)/libudunits2.so
	dh_link -p libudunits2-0    /usr/lib/$(DEB_HOST_MULTIARCH)/libudunits2.so.0.1.0   /usr/lib/$(DEB_HOST_MULTIARCH)/libudunits2.so.0
