#
# Makefile for sterno
#
# Copyright (c) 1997-1998 Mark Diekhans
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# $Id: Makefile,v 1.10 1998/02/13 18:31:03 markd Exp $
#
SHELL = /bin/sh
srcdir = ..

PREFIX = /usr/local
INSTDIR = ${PREFIX}/lib/sterno${VERSION}
TCLSH = tclsh8.0

PACKAGE = Sterno
VERSION = 0.2

LIBDIR = ${srcdir}/library
SRCS =  ${LIBDIR}/object.tcl ${LIBDIR}/class.tcl  ${LIBDIR}/instance.tcl


all: sterno.tcl pkgIndex.tcl

sterno.tcl: ${SRCS} Makefile
	rm -f $@
	cat ${SRCS} >$@
	echo "namespace eval ::Sterno {variable version ${VERSION}}" >>$@
	echo "package provide ${PACKAGE} ${VERSION}" >>$@
	chmod a-w,a+r $@

pkgIndex.tcl: Makefile
	rm -f $@
	echo 'if {[info tclversion] < 8.0} return' > $@
	echo 'package ifneeded ${PACKAGE} ${VERSION} "source $$dir/sterno.tcl"' >> $@

test: all
	cd ../tests && ${TCLSH} all

install: all
	@[ -d ${INSTDIR} ] || mkdir -p ${INSTDIR}
	@for f in sterno.tcl pkgIndex.tcl ; do \
	    echo Copying $$f to ${INSTDIR} ;\
	    rm -f ${INSTDIR}/$$f && cp $$f ${INSTDIR}/$$f ; \
	done

DISTNAME = sterno${VERSION}
DISTDIR  = tmp/${DISTNAME}
DISTFILE = tmp/${DISTNAME}.tar.gz
distribution:
	rm -rf ${DISTDIR} ${DISTFILE}
	mkdir -p ${DISTDIR}
	(cd ..; tar -cf - `cat MANIFEST`) | (cd  ${DISTDIR}; tar -xf -)
	(cd ${DISTDIR}/.. && tar -cf - ${DISTNAME} ) | (gzip -c9 > ${DISTFILE})

clean:
	rm -f sterno.tcl pkgIndex.tcl
	rm -rf tmp

