#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

DEB_CONFIGURE_EXTRA_FLAGS = \
	--with-docs \
	--with-pgconfigdir=/usr/lib/postgresql/8.4/bin \
	--with-pgsharedir=/usr/share/slony1 \
	--with-pgpkglibdir=/usr/lib/postgresql/8.4/lib \
	--sysconfdir=/etc/slony1 \
	--with-perlsharedir=/usr/share/slony1 \
	--with-docdir=NOTUSED \
	--with-perltools

DEB_DH_INSTALLINIT_ARGS = --name=slony1
DEB_DH_INSTALLLOGROTATE_ARGS = --name=slony1
DEB_INSTALL_DOCS_ALL = $(addprefix -X,[^1]\.1 [^7]\.7 \.dia \.dsl \.sgml \.sql \.xml \.xsl HTML\.index Makefile)
DEB_COMPRESS_EXCLUDE = \.pl \.sh

binary-post-install/slony1-bin::
	rm debian/$(cdbs_curpkg)/usr/bin/show_configuration

clean::
	rm -f doc/adminguide/slony.xml

altperl_scripts = slon_kill slon_start slon_watchdog slon_watchdog2 slonik_build_env \
	slonik_create_set slonik_drop_node slonik_drop_sequence slonik_drop_set slonik_drop_table slonik_execute_script \
	slonik_failover slonik_init_cluster slonik_merge_sets slonik_move_set slonik_print_preamble slonik_restart_node \
	slonik_store_node slonik_subscribe_set slonik_uninstall_nodes slonik_unsubscribe_set slonik_update_nodes \
	slony_show_configuration

build/slony1-bin::
	for f in $(altperl_scripts); do \
	  sed "s/@program@/$$f/g;s/@PROGRAM@/\U$$f/g" debian/altperl.1.in >debian/$$f.1 || exit $?; \
	done

clean::
	rm -f $(altperl_scripts:%=debian/%.1)
