#!/usr/bin/make -f
# MAde with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Cristoph Lameter.

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

pkg		:= cl-odcl
prefix		:= debian/tmp

INSTALL		:= install
INSTALLFLAGS	:= -g root -o root -m 0644
INSTALLDIRFLAGS	:= -d -g root -o root -m 0755

SOURCESDEST	:= $(prefix)/usr/share/common-lisp/repositories/odcl
SYSDIR		:= $(prefix)/usr/share/common-lisp/systems

INSTALLSOURCES	:= $(shell find . -type f -name '*.lisp' | grep -v ^./debian)

build:
	@echo "nothing to be done for $@"

clean:
	$(checkdir)
	-$(MAKE) clean
	dh_clean
#	 be clever and try to grab a CVS changelog
	[ -f ChangeLog ] || [ ! -f ../$(pkg)/ChangeLog ] || cp ../$(pkg)/ChangeLog .
	[ -f ChangeLog ] || [ ! -f ../$(subst cl-,,$(pkg))/ChangeLog ] || cp ../$(pkg)/ChangeLog .

binary-indep:
	$(checkdir)
	dh_testroot
	dh_clean -k

	$(INSTALL) $(INSTALLDIRFLAGS) $(SOURCESDEST) $(SYSDIR)
	$(INSTALL) $(INSTALLFLAGS) odcl.system $(SYSDIR)
# 	this presumes the sources aren't in subdirs
	$(INSTALL) $(INSTALLFLAGS) $(INSTALLSOURCES) $(SOURCESDEST)

	dh_installdocs
	dh_installexamples
#	dh_installmenu
#	dh_installcron
#	dh_installmanpages
#	dh_undocumented

	[ ! -f ChangeLog ] || dh_installchangelogs ChangeLog
	[ -f ChangeLog ] || dh_installchangelogs

	dh_link
#	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
#	dh_shlibdeps
	dh_gencontrol
#	dh_makeshlibs
	dh_md5sums
	dh_builddeb

binary-arch:
	@echo "nothing to be done for $@"
	

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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

define checkdir
	test -f debian/rules
	test -f VERSION
endef
