# Makefile for WB-tree File Based Associative String Data Base.
# Copyright (C) 1991, 1992, 1993 Holland Mark Martin
#
#Permission to use, copy, modify, and distribute this software and its
#documentation for educational, research, and non-profit purposes and
#without fee is hereby granted, provided that the above copyright
#notice appear in all copies and that both that copyright notice and
#this permission notice appear in supporting documentation, and that
#the name of Holland Mark Martin not be used in advertising or
#publicity pertaining to distribution of the software without specific,
#written prior consent in each case.  Permission to incorporate this
#software into commercial products can be obtained from Jonathan
#Finger, Holland Mark Martin, 174 Middlesex Turnpike, Burlington, MA,
#01803-4467, USA.  Holland Mark Martin makes no representations about
#the suitability or correctness of this software for any purpose.  It
#is provided "as is" without express or implied warranty.  Holland Mark
#Martin is under no obligation to provide any services, by way of
#maintenance, update, or otherwise.

mfiles = Makefile make.scm all.scm VMSBUILD.COM
sfiles = handle.scm blink.scm defs.scm sys.h sys.c sys.scm prev.scm \
	del.scm ent.scm comp.scm scan.scm
tfiles = example.scm test.scm test2.scm db.scm db.c stats.scm blkio.scm \
	view.c check.c
dfiles = README dbscm.doc ChangeLog Design.doc TBD ANNOUNCE # old.scm
afiles = $(tfiles) $(sfiles) $(mfiles) $(dfiles)
# ofiles and hfiles are built by compilation from *.scm
ofiles = handle.o blink.o prev.o ent.o sys.o del.o stats.o blkio.o scan.o
shfiles = defs.h ent.h blink.h handle.h prev.h del.h stats.h blkio.h scan.h
scfiles = ent.c blink.c handle.c prev.c del.c stats.c blkio.c scan.c
hfiles = $(shfiles) sys.h
SHELL = /bin/sh
scheme = scm
#CC = cc -Aa
#CFLAGS = -p	#for profiling
CC = gcc -O2

all:	dbscm check view

dbscm:	db.a
	cd ../scm;make dbscm
	-rm -f dbscm
	mv ../scm/dbscm ./dbscm
	rm db.a
db.a:	$(ofiles) db.o Makefile
	ar crv db.a db.o $(ofiles)
lint:	blink.c sys.c handle.c sys.h defs.h
	lint db.c handle.c blink.c prev.c ent.c sys.c
check:	check.o $(ofiles)
	$(CC) $(CFLAGS) -o check check.o $(ofiles)
view:	view.c
	$(CC) $(CFLAGS) -o view view.c

check.o: check.c $(hfiles)
scan.o: scan.c $(hfiles)
blkio.o: blkio.c $(hfiles)
stats.o: stats.c $(hfiles)
del.o:	del.c $(hfiles)
ent.o:	ent.c $(hfiles)
sys.o:	sys.c $(hfiles)
blink.o:	blink.c $(hfiles)
handle.o:	handle.c $(hfiles)
db.o:	db.c $(hfiles)
	$(CC) $(CFLAGS) -I../scm -c db.c

scan.c scan.h:	scan.scm
	echo '(compile "scan.scm")(quit 0)' | $(scheme) comp.scm

blkio.c blkio.h:	blkio.scm
	echo '(compile "blkio.scm")(quit 0)' | $(scheme) comp.scm

stats.c stats.h:	stats.scm
	echo '(compile "stats.scm")(quit 0)' | $(scheme) comp.scm

blink.c blink.h:	blink.scm
	echo '(compile "blink.scm")(quit 0)' | $(scheme) comp.scm

ent.c ent.h:	ent.scm
	echo '(compile "ent.scm")(quit 0)' | $(scheme) comp.scm

del.c del.h:	del.scm
	echo '(compile "del.scm")(quit 0)' | $(scheme) comp.scm

prev.c prev.h:	prev.scm
	echo '(compile "prev.scm")(quit 0)' | $(scheme) comp.scm

handle.c handle.h:	handle.scm
	echo '(compile "handle.scm")(quit 0)' | $(scheme) comp.scm

defs.h:	defs.scm
	echo '(compileh "defs.scm")(quit 0)' | $(scheme) comp.scm

tar:	wb.tar
wb.tar:	temp/wb
	cd temp; tar chf ../wb.tar wb
shar:	wb.shar
wb.shar:	temp/wb
	cd temp; shar wb >../wb.shar
dclshar:	wb.com
com:	wb.com
wb.com:	temp/wb
	cd temp; dclshar wb >../wb.com
zip:	wb.zip
wb.zip:	temp/wb
	cd temp; zip -ru ../wb.zip wb
pubzip:	temp/wb
	cd temp; zip -ru ../../pub/wb.zip wb

temp/wb:	$(afiles)
	-rm -rf temp
	mkdir temp
	mkdir temp/wb
	ln  $(afiles) temp/wb

dist:	tar.gz
tar.Z:	wb.tar.Z
wb.tar.Z:	wb.tar
	-rm -f wb.tar.Z
	compress wb.tar
tar.gz:	wb.tar.gz
wb.tar.gz:	wb.tar
	-rm -f wb.tar.gz
	gzip wb.tar
shar.Z:	wb.shar.Z
wb.shar.Z:	wb.shar
	-rm -f wb.shar.Z
	compress wb.shar

pubdiffs:	temp/wb
	mv temp/wb temp/nwb
	cd temp;unzip ../../pub/wb.zip
	-rm -f wb.diffs
	-diff -c temp/wb temp/nwb > wb.diffs
	-rm -rf temp
	ls -l wb.diffs

distdiffs:	temp/wb
	mv temp/wb temp/nwb
	cd temp;zcat ../../dist/wb*.tar.z | tar xvf -
	-rm -f wb.pat
	-diff -c temp/wb temp/nwb > wb.pat
	-rm -rf temp
	ls -l wb.pat

TAGS:
tags:	$(sfiles) $(tfiles) $(rfiles)
	etags $(tfiles) $(sfiles) $(rfiles)
clean:
	-rm -f *~ \#* *.orig a.out core TAGS lints tmp* db.a
	-rm -rf temp
distclean:
	-rm -f *~ \#* *.o *.orig a.out core TAGS lints tmp* db.a
	-rm -f $(shfiles) $(scfiles)
	-rm -f *.bv *.db *.rec
	-rm -rf temp
