#!/usr/bin/make -f

%:
	dh $@

# see README for scripts to fix
scripts_to_fix = \
	Du.sh \
	encryptedpw.sh \
	ex57.sh \
	ex69.sh \
	ex70.sh \
	ex71.sh \
	ex71a.sh \
	ex71b.sh \
	ex71c.sh \
	ex72.sh \
	logevents.sh \
	m4.sh \
	pw.sh \
	read-r.sh \
	rnd.sh \
	rot13.sh \
	rot13a.sh \
	here-function.sh \
	avoid-subshell.sh \
	usb.sh \
	prepend.sh \
	array-assign.bash \
	cdll \
	directory-info.sh \
	is-spammer.sh \
	bashrc \
	commentblock.sh \
	self-document.sh \
	dev-tcp.sh \
	archiveweblogs.sh \
	multiple-processes.sh \
	is_spammer.bash \
	iscan.sh \
	Hash.lib \
	hash-example.sh \
	quote-fetch.sh \
	ftpget.sh \
	whx.sh \
	pad.sh \
	nightly-backup.sh \
	tohtml.sh \
	insertion-sort.bash \
	tree2.sh \
	petals.sh \
	realname.sh \
	qky.sh \
	maned.sh \
	progress-bar.sh \
	nim.sh \
	paragraph-space.sh \
	sw.sh \
	UseGetOpt.sh \
	UseGetOpt-2.sh

override_dh_installchangelogs:
	dh_installchangelogs Change.log

override_dh_installdocs:
	dh_installdocs HTML abs-book.sgml
	mv debian/abs-guide/usr/share/doc/abs-guide/HTML \
		debian/abs-guide/usr/share/doc/abs-guide/html

override_dh_installexamples:
	dh_installexamples *.sh *.bash bashrc cdll Hash.lib
	cd debian/abs-guide/usr/share/doc/abs-guide/examples && \
	for f in $(scripts_to_fix); do \
	  sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/&/g' \
	    $$f > $$f.new; \
	  if cmp -s $$f $$f.new; then \
	    rm -f $$f.new; \
	  else \
	    echo fixed $$f; \
	    mv -f $$f.new $$f; \
	  fi; \
	done

	cd debian/abs-guide/usr/share/doc/abs-guide/examples && \
	for file in case4.sh fetch_address.sh fetch_address-2.sh ; do \
	    sed -i 's|#!/bin/bash4|#!/bin/bash|' $$file ; \
	done

override_dh_compress:
	dh_compress -X.sh -X.anchors -Xbashrc