#!/usr/bin/make -f

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

# This is the debhelper compatibility version to use.
export DH_COMPAT=3

# 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)


ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

config.status: configure
configure: configure-stamp
configure-stamp:
	dh_testdir
	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
	            --prefix=/usr --mandir=\$${prefix}/share/man
	touch configure-stamp

build: configure-stamp build-stamp
build-stamp:
	$(MAKE)
	touch build-stamp

clean:
	-$(MAKE) distclean
	dh_clean
	rm -rf configure-stamp
	rm -rf build-stamp

install:
	dh_clean -k
	dh_testroot
	dh_installdirs
	$(MAKE) install DESTDIR=`pwd`/debian/micq

binary-indep: build install

binary-arch: build install
	dh_testroot
	dh_installdocs doc/html
	
	dh_installchangelogs ChangeLog
	
	dh_installman doc/micq.1
	dh_installman doc/micq.7
	dh_installman doc/micqrc.5
	
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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