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

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

#WAF=./waf
export IAMDEBPKGR=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

CFLAGS		?= $(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS	?= $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS		?= $(shell dpkg-buildflags --get LDFLAGS)
CFLAGS		+= $(HARDENING_CFLAGS)
CPPFLAGS	+= $(HARDENING_CFLAGS) -fPIC
LDFLAGS		+= $(HARDENING_LDFLAGS)

package = lifeograph
CC = gcc
CFLAGS += -g -Wall

ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O2
endif


clean: 
		dh_testdir
		dh_clean
#		$(WAF) --nocache distclean
		make -f makefile.debian clean
		rm -f lifeograph.desktop

install: build
		dh_clean
		dh_installdirs
#		$(WAF) --nocache install --destdir $(CURDIR)/debian/$(package)
		make -f makefile.debian install PREFIX=/usr \
			DESTDIR=$(CURDIR)/debian/$(package)

configure:
#		$(WAF) --nocache configure --prefix=/usr
		make -f makefile.debian preparations

build-arch: build-stamp
build-indep: build-stamp

build: build-arch build-indep

build-stamp: configure
#		$(WAF) --nocache build
		make -f makefile.debian all
		touch $@

binary-indep: install
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: install
		dh_testdir -a
		dh_testroot -a
		dh_installdocs -a
		dh_installchangelogs -a
#dh_installmenu
		dh_installman $(CURDIR)/lifeograph.1
		dh_strip -a
		dh_compress -a
		dh_fixperms -a
		dh_installdeb -a
		dh_shlibdeps -a
		dh_gencontrol -a
		dh_md5sums -a
		dh_builddeb -a

binary: binary-indep binary-arch

.PHONY: build build-arch build-indep binary binary-arch binary-indep \
        clean
