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

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

# Include dpatch stuff.
# include /usr/share/dpatch/dpatch.make

CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

build: patch build-stamp
build-stamp: 
	dh_testdir
	#/opt/qt4-maemo5/bin/
	qmake-qt4 PREFIX=/opt/usr QMAKE_CFLAGS_DEBUG="$(CFLAGS)" QMAKE_CXXFLAGS_DEBUG="$(CFLAGS)" DEBUG=1 AUTOTYPE=0
	$(MAKE)
	touch build-stamp

clean: clean-patched unpatch
clean-patched:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	qmake keepassx.pro
	-$(MAKE) distclean
	rm -rf src/Makefile Makefile
	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs
	make INSTALL_ROOT=$(CURDIR)/debian/keepassx install

binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs changelog
	dh_installdocs
	dh_installexamples
	dh_installman debian/keepass.1
	dh_desktop
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

patch: patch-stamp

patch-stamp:
	dpatch apply-all

unpatch:
	dpatch deapply-all
	rm -rf debian/patched

binary: binary-indep binary-arch
.PHONY: build build-stamp clean clean-patched install binary-indep binary-arch binary patch patch-stamp unpatch binary
