#!/usr/bin/make -f
APPNAME := portabase
builddir:
	mkdir -p builddir

builddir/Makefile: builddir
	cd src/metakit/builds && ../unix/configure --enable-threads --disable-shared
	cd builddir && qmake-qt4 PREFIX=/usr ../portabase.pro

build: build-stamp

build-stamp: builddir/Makefile
	dh_testdir
	cd src/metakit/builds && $(MAKE)
	mkdir -p builddir/src
	cp src/metakit/include/mk4.h builddir/src/
	cp src/metakit/include/mk4.inl builddir/src/
	cp src/metakit/include/mk4str.h builddir/src/
	cp src/metakit/include/mk4str.inl builddir/src/
	lrelease src/src.pro
	lrelease src/resources/translations/qt*.ts
	cd builddir && $(MAKE)
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	dh_clean
	rm -f src/resources/translations/*.qm
	rm -f src/build/mk4*
	rm -f src/metakit/builds/*.o
	rm -f src/metakit/builds/*.a
	rm -rf src/metakit/builds/tests
	rm -f src/metakit/builds/config.*
	rm -f src/metakit/builds/Makefile

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install

binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installexamples
	dh_installman
	dh_link
	dh_strip --dbg-package=portabase-dbg
	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 configure
