#!/usr/bin/make -f

#    Copyright (C) 2000 Anton Kirilov Zinoviev

#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.

#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#    My e-mail is anton@lml.bas.bg, zinoviev@fmi.uni-sofia.bg

SHELL = /bin/sh

package=trscripts

build:
	$(checkdir)
	$(MAKE)

clean:
	$(checkdir)
	-$(MAKE) -i clean
	-rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars

binary-indep:	checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp/DEBIAN
	cp debian/postinst debian/tmp/DEBIAN
	cp debian/prerm debian/tmp/DEBIAN
	install -d debian/tmp/usr/share/doc/$(package)
	cp debian/copyright debian/tmp/usr/share/doc/$(package)
	cp debian/changelog debian/tmp/usr/share/doc/$(package)/changelog
	gzip -9v debian/tmp/usr/share/doc/$(package)/changelog
	cp debian/README.Debian debian/tmp/usr/share/doc/$(package)/
	cp README debian/tmp/usr/share/doc/$(package)/
	install -d debian/tmp/usr/share/doc/$(package)/source
	cp Makefile debian/tmp/usr/share/doc/$(package)/source
	cp csets debian/tmp/usr/share/doc/$(package)/source
	cp fallbacks debian/tmp/usr/share/doc/$(package)/source
	cp gen_trcs debian/tmp/usr/share/doc/$(package)/source
	chmod -x debian/tmp/usr/share/doc/$(package)/source/gen_trcs
	cp gen_trbdf debian/tmp/usr/share/doc/$(package)/source
	chmod -x debian/tmp/usr/share/doc/$(package)/source/gen_trbdf
	cp xcsets debian/tmp/usr/share/doc/$(package)/source
	install -d debian/tmp/usr/share/doc/$(package)/source/charmaps
	cp charmaps/* debian/tmp/usr/share/doc/$(package)/source/charmaps/
	install -d debian/tmp/usr/bin
	$(MAKE) prefix=`pwd`/debian/tmp/usr mandir=`pwd`/debian/tmp/usr/share/man install
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R go=rX,u=rwX debian/tmp
	dpkg --build debian/tmp ..

binary-arch:	checkroot build
	$(checkdir)

define checkdir
	test -f gen_trcs -a -f gen_trbdf -a -f debian/rules
endef

binary:		binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

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

