#!/usr/bin/make -f

PACKAGE = epic4-script-lice
DEST = $(CURDIR)/debian/$(PACKAGE)

build-arch:
build-indep:
build:
# Nothing to do

clean:
	dh_testdir
	dh_testroot
	rm -f install-stamp
	dh_clean
	

install: install-stamp
install-stamp: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# Install the default theme and variables.
	gzip -c -d .irc/lice/lice.defaults.gz > \
		$(DEST)/etc/epic4/lice/lice.defaults
	patch $(DEST)/etc/epic4/lice/lice.defaults \
	      debian/patches/defaults.diff
	install -m 0644 $(CURDIR)/.irc/themes/default \
			$(DEST)/etc/epic4/lice/themes/default

	# Install proper script
	cp -dR $(CURDIR)/.irc/* $(DEST)/usr/share/epic4/lice
	rm -f $(DEST)/usr/share/epic4/lice/*.reasons
	mv $(DEST)/usr/share/epic4/lice/lice.irc.gz \
	   $(DEST)/usr/share/epic4/lice/lice-real.irc.gz

	# Patch theme script
	gzip -d $(DEST)/usr/share/epic4/lice/lice/lice.theme.gz
	patch $(DEST)/usr/share/epic4/lice/lice/lice.theme \
		debian/patches/theme.diff
	gzip -9n $(DEST)/usr/share/epic4/lice/lice/lice.theme
	   
	# Install the wrapper script.
	install -m 0644 $(CURDIR)/debian/wrapper.irc \
			$(DEST)/usr/share/epic4/lice/lice.irc 

	rm $(DEST)/usr/share/epic4/lice/extra/sscan
	rm $(DEST)/usr/share/epic4/lice/help/COPYING.gz
	rm $(DEST)/usr/share/epic4/lice/help/LICENSE.gz

	touch install-stamp


binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installexamples .irc/*.reasons
	dh_installchangelogs 
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb


binary-arch: build install
# Nothing to do

binary: binary-indep binary-arch

.PHONY: build clean binary-indep binary-arch binary
