#!/usr/bin/make -f
#                                                       -*- makefile -*-
# debian/rules file for the Debian/GNU Linux centericq package
# Copyright 2002-2003 by Julien LEMOINE <speedblue@debian.org>

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


CXXFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CXXFLAGS += -O0
else
	CXXFLAGS += -O2
endif
config.status: configure
	dh_testdir
	dh_autotools-dev_updateconfig
	CXXFLAGS="$(CXXFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) 	\
	  --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr 			\
          --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info

build: build-stamp

build-stamp:  config.status
	dh_testdir
	$(MAKE)
	mkdir doc && doxygen doxygen.cfg
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -rf build-stamp doc config.log config.sub config.guess
	-$(MAKE) distclean
	dh_autotools-dev_restoreconfig
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) install DESTDIR=$(CURDIR)/debian/happycoders-libdbg
	mv doc/html \
          $(CURDIR)/debian/happycoders-libdbg/usr/share/doc/happycoders-libdbg/doc-html
#deplace dev files in libdbg-dev packages
	mkdir -p $(CURDIR)/debian/happycoders-libdbg-dev/usr/lib/happycoders
	mkdir -p $(CURDIR)/debian/happycoders-libdbg-dev/usr/include/happycoders
	mv $(CURDIR)/debian/happycoders-libdbg/usr/include/happycoders/dbg \
	$(CURDIR)/debian/happycoders-libdbg-dev/usr/include/happycoders
	mv $(CURDIR)/debian/happycoders-libdbg/usr/lib/happycoders/*.a	\
	$(CURDIR)/debian/happycoders-libdbg-dev/usr/lib/happycoders
	mv $(CURDIR)/debian/happycoders-libdbg/usr/lib/happycoders/*.la	\
	$(CURDIR)/debian/happycoders-libdbg-dev/usr/lib/happycoders

binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
	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 
