#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# This file is public domain software, originally written by Joey Hess. 

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

build: build-stamp
build-stamp:
	dh_testdir
	./configure --prefix=/usr
	$(MAKE)
	$(MAKE) check
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	[ ! -f Makefile ] || $(MAKE) clean
	[ ! -f Makefile ] || $(MAKE) distclean
	rm -f config.log config.status
	dh_clean


INSTALLDIR := $(CURDIR)/debian/tmp/usr
DOCDIR := $(CURDIR)/debian/tmp/usr/share/doc/libsparsehash-dev

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) prefix=$(INSTALLDIR) docdir=$(DOCDIR) install
	install -m 755 -d $(DOCDIR)/html
	mv $(DOCDIR)/*.html $(DOCDIR)/*.css $(DOCDIR)/html/

	# fix non-Debian kosher aspects of build
	rm -f $(DOCDIR)/ChangeLog $(DOCDIR)/COPYING $(DOCDIR)/INSTALL
	[ -s $(DOCDIR)/NEWS ] || rm -f $(DOCDIR)/NEWS
	rm -f $(DOCDIR)/README.windows

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installexamples
	dh_install --sourcedir='debian/tmp' --autodest
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
