#!/usr/bin/make -f
# Copyright 2013 hello-debhelper project (used according to license) with modifications by RethinkDB

package?=$(shell cat debian/control | grep '^Source:' | awk '{ printf "%s" , $$2 }')

PVERSION?=$(shell cat debian/rethinkdb.version)

DEBUG?=0

clean:
	dh_clean
	if [ -e build ] ; then rm -rf build ; fi ;

install: build
	dh_clean
	dh_installdirs
	$(MAKE) DEBUG=$(DEBUG) DESTDIR=$(CURDIR)/debian/$(package) PVERSION=$(PVERSION) STRIP_ON_INSTALL=0 install

build:
	./configure
	$(MAKE) DEBUG=$(DEBUG) PVERSION=$(PVERSION) VERBOSE=1 SYMBOLS=1
	touch build

binary-indep: install

binary-arch: install
	dh_installdocs -a
	dh_installchangelogs -a
	dh_strip --dbg-package=$(package)-dbg
	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: binary binary-arch binary-indep clean install build

