#!/usr/bin/make -f

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

ifeq (,$(NUMJOBS))
	NUMJOBS = 1
endif

BUILDDIR = builddir

PKG_NAME = plasma-widget-cwp

CMAKEOPTS =	-DCMAKE_SKIP_RPATH=ON \
			-DCMAKE_BUILD_TYPE=Release \
			-DCMAKE_INSTALL_PREFIX=/usr \
			../

configure: configure-stamp
configure-stamp:
	dh_testdir
	mkdir -p $(BUILDDIR) && cd $(BUILDDIR) && cmake $(CMAKEOPTS)
	touch $@
build: configure build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp:
	dh_testdir
	cd $(BUILDDIR) && $(MAKE) -j$(NUMJOBS)
	touch $@
clean: do-clean
do-clean:
	dh_testdir
	dh_testroot
	[ ! -f Makefile ] || ( cd $(BUILDDIR) && $(MAKE) clean )
	test ! -d $(BUILDDIR) || rm -r $(BUILDDIR)
	dh_clean
install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(CURDIR)/debian/$(PKG_NAME)
binary-indep: build install
binary-arch: build install
	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
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure patch unpatch do-clean

