#!/usr/bin/make -f

MANTEMPLATE="${CURDIR}/doc/output/man/pgbackrest.1.txt"

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

#export DH_VERBOSE = 1

%:
	dh $@

override_dh_auto_build:
	perl $(CURDIR)/doc/doc.pl --out=man --out=html --cache-only \
	  --var=project-url-root=index.html --exclude=backlog \
	  --var=release-date-static=y
	txt2man \
	  -v "pgBackRest Command Reference" \
	  -t pgbackrest \
	  -s 1 \
	  ${MANTEMPLATE} > ${CURDIR}/doc/output/man/pgbackrest.1
	cd $(CURDIR)/libc; perl Makefile.PL PREFIX=/usr NO_PACKLIST=1
	make -C $(CURDIR)/libc/
	dh_auto_build

override_dh_auto_test:
	test "$(DEB_TARGET_ARCH_ENDIAN)" = "little" && \
		cd $(CURDIR)/libc; make test
	dh_auto_test

override_dh_auto_clean:
	rm -rf $(CURDIR)/doc/output
	test ! -f libc/Makefile || make -C libc distclean
	dh_auto_clean

override_dh_auto_install:
	make -C libc install DESTDIR=$(CURDIR)/debian/pgbackrest
	dh_auto_install
