#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.

package=libplot-perl
ddir=$(shell /bin/pwd)/debian/tmp
INSTALL=/usr/bin/install
PREFIX=$(shell /bin/pwd)/debian/tmp/usr

arch= $(shell dpkg --print-architecture)
perlvers = 5.004

build:
	$(checkdir)
	touch build
	perl Makefile.PL INSTALLDIRS=perl   \
	     PREFIX=$(PREFIX)  \
	     INSTALLPRIVLIB=$(PREFIX)/lib/perl5  \
	     INSTALLARCHLIB=$(PREFIX)/lib/perl5/i386-linux/$(perlvers)  \
	     INSTALLMAN1DIR=$(ddir)/usr/man/man1  \
	     INSTALLMAN3DIR=$(ddir)/usr/man/man3

	make 	     INSTALLPRIVLIB=$(PREFIX)/lib/perl5  \
	     INSTALLARCHLIB=$(PREFIX)/lib/perl5/i386-linux/$(perlvers)  

clean:
	$(checkdir)
	-rm -f build
	-make clean
	-rm Makefile
	-rm -rf blib
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/files* core debian/substvars

binary-indep: checkroot build
	$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	$(INSTALL) -d  debian/tmp/DEBIAN
	$(INSTALL) -d  debian/tmp/usr/doc/$(package)
	make      INSTALLPRIVLIB=$(PREFIX)/lib/perl5  \
	     INSTALLARCHLIB=$(PREFIX)/lib/perl5/i386-linux/$(perlvers)  \
	     pure_install

	chmod 644 debian/tmp/usr/lib/perl5/$(arch)-linux/$(perlvers)/auto/*/*/*.so
	strip --strip-unneeded  \
	      debian/tmp/usr/lib/perl5/$(arch)-linux/$(perlvers)/auto/*/*/*.so

	chmod 644 debian/tmp/usr/lib/perl5/$(arch)-linux/$(perlvers)/auto/*/*/*.bs
	cd debian/tmp; chmod 644  \
           usr/lib/perl5/*/*.pm  \
#	rm -f debian/tmp/usr/lib/perl5/$(arch)-linux/$(perlvers)/perllocal.pod

	cp -r examples debian/tmp/usr/doc/$(package)
	gzip -9v debian/tmp/usr/doc/$(package)/examples/*
	cp Changes debian/tmp/usr/doc/$(package)/changelog
	cp debian/README.debian debian/tmp/usr/doc/$(package)
	cp debian/changelog debian/tmp/usr/doc/$(package)/changelog.Debian
	-gzip -v9 debian/tmp/usr/doc/$(package)/*
	gzip -v9 debian/tmp/usr/man/man3/*

	cp debian/copyright debian/tmp/usr/doc/$(package)

	dpkg-shlibdeps blib/arch/auto/Graphics/Libplot/Libplot.so
	
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

binary: binary-indep binary-arch

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

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




