#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

# Define package name variable for a one-stop change.
PACKAGE_NAME = mondo-doc

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

# Build both architecture dependent and independent
build: build-indep

# Build architecture independent
build-indep:
	$(MAKE) -f Makefile.man VERSION=VVV
	$(MAKE) -f Makefile.howto VERSION=VVV
	touch build-indep-stamp

# Clean up
clean:
	dh_testdir
	dh_testroot
	rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
	# Clean temporary document directory
	rm -rf debian/doc-temp
	# Clean up.
	-$(MAKE) distclean
	rm -f config.log
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
	cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
	cp -f /usr/share/misc/config.guess config.guess
endif

	dh_clean 

# Install architecture dependent and independent
install: install-indep

# Install architecture independent
install-indep: build-indep
	dh_testdir
	dh_testroot
	dh_clean -k -i
	$(MAKE) -f Makefile.man install INSTALLDIR=$(CURDIR)/debian/$(PACKAGE_NAME)/usr/share/doc/$(PACKAGE_NAME)
	$(MAKE) -f Makefile.howto install INSTALLDIR=$(CURDIR)/debian/$(PACKAGE_NAME)/usr/share/doc/$(PACKAGE_NAME)

# Must not depend on anything. This is to be called by
# binary-arch/binary-indep
# in another 'make' thread.
binary-common:
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture independant packages using the common target.
binary-indep: build-indep install-indep
	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common

# Build architecture depdendent and independent packages
binary: binary-indep
.PHONY: clean binary
