#!/usr/bin/make -f
# -*- makefile -*-

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

SHARED_PKG := libdatrie1
SHLIB_VER := 0.2.0

%:
	dh $@ --with autoreconf

override_dh_auto_build-indep:
ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS)),)
	dh_auto_build -- -C doc
endif

override_dh_auto_build-arch:
	dh_auto_build -- -C datrie
	dh_auto_build -- -C tools
	dh_auto_build -- -C man

# No test for doc
override_dh_auto_test-indep:

ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
override_dh_auto_test-arch:
	dh_auto_test -- -C tests
endif

override_dh_auto_install-indep:
ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS)),)
	$(MAKE) -C doc install DESTDIR=$(CURDIR)/debian/tmp
endif

override_dh_install-indep:
ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS)),)
	dh_install -i -Xjquery.js
endif

override_dh_link-indep:
ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS)),)
	dh_link -i
endif

ifneq ($(filter nodoc,$(DEB_BUILD_OPTIONS)),)
override_dh_installdocs-indep:
	dh_installdocs -plibdatrie-doc -Xdoc-base
endif

override_dh_auto_install-arch:
	$(MAKE) -C datrie install DESTDIR=$(CURDIR)/debian/tmp
	$(MAKE) -C tools  install DESTDIR=$(CURDIR)/debian/tmp
	$(MAKE) -C man    install DESTDIR=$(CURDIR)/debian/tmp
	$(MAKE) install-am DESTDIR=$(CURDIR)/debian/tmp

override_dh_installchangelogs-arch:
	dh_installchangelogs -Nlibdatrie-dev -a

override_dh_installdocs-arch:
	dh_installdocs -plibdatrie-dev --link-doc=libdatrie1
	dh_installdocs --remaining-packages -a

override_dh_makeshlibs:
	dh_makeshlibs -a -p$(SHARED_PKG) -V'$(SHARED_PKG) (>= $(SHLIB_VER))' \
		--add-udeb="libdatrie1-udeb"
