#!/usr/bin/make -f

SRCDIR=$(CURDIR)
include /usr/share/postgresql-common/pgxs_debian_control.mk
.PHONY: debian/control

build build-arch: build-stamp
build-stamp:
	dh_testdir
	+pg_buildext configure $(CURDIR) version-%v "--libdir=/usr/lib/postgresql/%v/lib --datadir=/usr/share/postgresql-%v-plsh"
	+pg_buildext build $(CURDIR) version-%v
	touch $@

build-indep:

clean: debian/control
	dh_testdir
	dh_testroot
	rm -rf build-stamp version-?.?
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	+pg_buildext install $(CURDIR) version-%v postgresql-%v-plsh
	rm $(CURDIR)/debian/postgresql-*-plsh/usr/lib/postgresql/*/lib/pgplsh.la
	rm $(CURDIR)/debian/postgresql-*-plsh/usr/share/postgresql-*-plsh/test.sql
	chmod 644 $(CURDIR)/debian/postgresql-*-plsh/usr/share/postgresql-*-plsh/*

binary binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs -a
	dh_installdocs -a --all README NEWS
	dh_install -a
	dh_link -a
	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-indep:

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