#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Build with --as-needed to reduce library dependencies (e.g. libncurses)
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

AUTORECONF_SOURCES = INSTALL Makefile.in aclocal.m4 configure doc/Makefile.in \
                     filters/Makefile.in src/Makefile.in tools/config.guess \
                     tools/config.sub tools/depcomp tools/install-sh \
                     tools/missing

%:
	dh $@ --with autoreconf

override_dh_auto_build:
	# Update timestamp on distributed completion.c to avoid regenerating
	touch src/completion.c
	dh_auto_build

override_dh_install:
	chmod -x $(CURDIR)/debian/rlwrap/usr/share/rlwrap/filters/README
	chmod -x $(CURDIR)/debian/rlwrap/usr/share/rlwrap/filters/RlwrapFilter.3pm
	chmod -x $(CURDIR)/debian/rlwrap/usr/share/rlwrap/filters/RlwrapFilter.pm

override_dh_autoreconf:
	for f in $(AUTORECONF_SOURCES); do \
		[ -f $$f.debian-backup ] || mv $$f $$f.debian-backup; \
	done
	dh_autoreconf

override_dh_autoreconf_clean:
	dh_autoreconf_clean
	for f in $(AUTORECONF_SOURCES); do \
		[ ! -f $$f.debian-backup ] || mv $$f.debian-backup $$f; \
	done
