#!/usr/bin/make -f

include /usr/share/postgresql-common/pgxs_debian_control.mk

build build-arch: build-stamp
build-stamp:
	dh_testdir
	+pg_buildext build build-%v
	$(MAKE) -C doc html
	mkdir -p results # create dir now so we can remove it when the regression tests were run as root
	touch build-stamp

build-indep:

clean: debian/control
	dh_testdir
	dh_testroot
	# pg_buildext clean doesn't work because build-*/doc isn't there
	#+pg_buildext clean build-%v
	rm -rf build-*/ regression.* results/* sql/plproxy.sql
	$(MAKE) -C doc clean
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	+pg_buildext install build-%v postgresql-%v-plproxy

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs -a --all NEWS AUTHORS doc/*.html
	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: binary-arch binary-indep

.PHONY: build build-arch build-indep clean binary binary-indep binary-arch debian/control
