#!/usr/bin/make -f

# Alice/SEAM libxml binding for Debian/GNU
# Guido Tack <tack@ps.uni-sb.de>

# needed if dpkg-buildpackage is not used

export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

# cross-compilation

ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  configure_options += --build $(DEB_BUILD_GNU_TYPE)
else
  configure_options += --host $(DEB_HOST_GNU_TYPE) --build $(DEB_BUILD_GNU_TYPE)
endif

# generic Debian directories

DEB_BASE_DIR = $(CURDIR)
DEB_DEBIAN_DIR = $(DEB_BASE_DIR)/debian
DEB_SOURCE_DIR = $(DEB_BASE_DIR)
DEB_BUILD_DIR = $(DEB_DEBIAN_DIR)/BUILD
DEB_INSTALL_DIR = $(DEB_DEBIAN_DIR)/INSTALL

# generic targets

configure: configure-stamp
configure-stamp: 

build: build-stamp
build-stamp: configure-stamp 
	dh_testdir
	cd $(DEB_SOURCE_DIR) && $(MAKE) compiledll
	echo > $@

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs
	-mkdir $(DEB_INSTALL_DIR)
	$(MAKE) installdll \
	  INSTALLDIR=$(DEB_INSTALL_DIR)/usr/share/alice/lib/xml
	echo > $@

clean:
	dh_testdir
	dh_testroot
	rm -f configure-stamp build-stamp install-stamp
	rm -rf $(DEB_BUILD_DIR) $(DEB_INSTALL_DIR)
	-$(MAKE) clean
	dh_clean

# package-specific targets

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_install --sourcedir=$(DEB_INSTALL_DIR)
	dh_installdocs
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_makeshlibs -V
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-arch

.PHONY: configure build install clean binary-arch binary
