#!/usr/bin/make -f
# -*- makefile -*-

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

TARFILE?=cwrt_1.0~svn$(shell date +%Y%m%d).orig.tar

DEB_BUILD_OPTIONS_PARALLEL ?= $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))

ifeq "$(DEB_BUILD_OPTIONS_PARALLEL)" ""
    PARALLEL_MAKEFLAGS = "-j4"
endif

get-orig-source:
	svn export https://trace1.isource-nokia.nokia.com/isource/svnroot/BrDo/cwrt/trunk cwrt
	rm -rf cwrt/debian
	rm -rf cwrt/wrt/serviceprovider
	tar cf ../$(TARFILE) cwrt
	rm -rf cwrt
	gzip -9fn ../$(TARFILE)

../$(TARFILE): get-orig-source

configure: configure-stamp

configure-stamp:
	dh_testdir
	qmake -r INSTALL_PREFIX=/usr CONFIG-=debug CONFIG+=release CONFIG+=maemo CONFIG+=maemo5
	touch configure-stamp

build: build-stamp

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

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	$(MAKE) distclean || true

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_installdirs

	INSTALL_ROOT=$(CURDIR)/debian/tmp $(MAKE) install


# Build architecture-independent files here.
binary-indep: install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs #CHANGELOGS#
	dh_installdocs
	dh_installexamples
	dh_install --sourcedir=debian/tmp
#	dh_installmenu
#	dh_installdebconf
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_python
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
	dh_makeshlibs
	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
