# SIMSYNCH, simulate synchronous systems.	-*-makefile-*-
# Copyright (C) 1997 Aubrey Jaffer

# 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., 675 Mass Ave, Cambridge, MA 02139, USA.

# $Header: /usr/local/cvsroot/synch/Makefile,v 1.21 1998/06/04 21:08:53 jaffer Exp $

SHELL = /bin/sh
intro:
	@echo
	@echo "Welcome to SIMSYNCH.  Read \"synch.info\" (or \"synch.texi\")"
	@echo "to learn how to use SIMSYNCH."
	@echo
	@echo
	-make synch.info

include srcdir.mk

srcdir.mk: .. Makefile
	echo -e "srcdir = `pwd`/\n" > srcdir.mk

dvidir=../dvi/
dvi:	$(dvidir)synch.dvi
$(dvidir)synch.dvi:	$(srcdir)synch.texi $(dvidir)synch.fn
#	cd $(dvidir);texi2dvi $(srcdir)synch.texi
	-(cd $(dvidir);texindex synch.??)
	cd $(dvidir);tex $(srcdir)synch.texi
$(dvidir)synch.fn:
	cd $(dvidir);tex $(srcdir)synch.texi
xdvi:	$(dvidir)synch.dvi
	xdvi -s 6 $(dvidir)synch.dvi
ps:	synch.ps
synch.ps:	$(dvidir)synch.dvi
	dvips $(dvidir)synch.dvi -o synch.ps

TEXI2HTMLPATH = /usr/local/bin/texi2html
HTMLDIR =$(HOME)/../colorage/public_html/synch/
html:	$(HTMLDIR) $(HTMLDIR)synch_toc.html
$(HTMLDIR):	$(HTMLDIR)synch_toc.html synch.ps
	mv synch.ps $(HTMLDIR)
	sync
#	cd $(HTMLDIR);zip synchhtml synch_*.html synch.ps
$(HTMLDIR)synch_toc.html:	$(TEXI2HTMLPATH) $(srcdir)synch.texi
	cd $(HTMLDIR);texi2html -split -verbose $(srcdir)synch.texi
cvshtml:	$(HTMLDIR)cvs/synch.html
$(HTMLDIR)cvs/synch.html:	$(HTMLDIR)cvs synch.ps core
	cvs2html -a -k -f -v -c cvsseq.html -o $(HTMLDIR)cvs/
#	add -a -k for dump of differences.
$(HTMLDIR)cvs:
	mkdir $(HTMLDIR)cvs
	chmod g+w $(HTMLDIR)cvs
core:
	mkdir core

prefix = /usr/local
exec_prefix = $(prefix)
#bindir = $(exec_prefix)/bin
#libdir = $(exec_prefix)/lib
infodir = $(exec_prefix)/info
info:	$(infodir)/synch.info
$(infodir)/synch.info:	synch.texi
	makeinfo synch.texi -o $(infodir)/synch.info
	install-info $(infodir)/synch.info $(infodir)/dir
	-rm $(infodir)/synch.info*.gz

infoz:	$(infodir)/synch.info.gz
$(infodir)/synch.info.gz:	$(infodir)/synch.info
	gzip -f $(infodir)/synch.info*

scheme = scm
SYNCH = ../synch/

foo.pds:	foo.scm $(SYNCH)simsynch.scm $(SYNCH)scm2mach.scm $(SYNCH)run.scm Makefile
	$(scheme) -l$(SYNCH)run.scm -e"(translate 'foo)"
foo-plc:		foo.scm $(SYNCH)simsynch.scm $(SYNCH)run.scm foo.plc
	$(scheme) -l$(SYNCH)run.scm -e"(compare-plcs 'foo)"

#### Stuff for maintaining SimSynch below ####

VERSION = 1a3
ver = $(VERSION)
RM_R = rm -rf

docfiles = ChangeLog synch.texi
srcfiles = simsynch.scm logic.scm scm2vrlg.scm scm2mach.scm run.scm \
	models.scm logical.v
pubfiles = Makefile COPYING $(docfiles) $(srcfiles)
tagfiles = Makefile synch.texi $(srcfiles)

makedev = make -f $(HOME)/makefile.dev
CHPAT=$(HOME)/bin/chpat
dest = $(HOME)/dist/
pubdir = $(HOME)/pub/
temp/synch:	$(pubfiles)
	-rm -rf temp
	mkdir temp
	mkdir temp/synch
	ln  $(pubfiles) temp/synch

release:	dist
	rsync -v $(dest)README $(dest)synch$(VERSION).tar.gz martigny.ai.mit.edu:dist/
	upload $(dest)README $(dest)synch$(VERSION).tar.gz prep.ai.mit.edu:gnu/jacal/
upzip:	$(HOME)/pub/synch.zip
	rsync -v $(HOME)/pub/synch.zip martigny.ai.mit.edu:pub/

dist:	$(dest)synch$(VERSION).tar.gz
$(dest)synch$(VERSION).tar.gz:	temp/synch
	$(makedev) DEST=$(dest) PROD=synch ver=$(VERSION) tar.gz
shar:	synch.shar
synch.shar:	temp/synch
	$(makedev) PROD=synch shar
dclshar:	synch.com
com:	synch.com
synch.com:	temp/synch
	$(makedev) PROD=synch com
zip:	synch.zip
synch.zip:	temp/synch
	cd temp; zip -r ../synch.zip synch
distzip:	synch$(VERSION).zip
synch$(VERSION).zip:	temp/synch
	$(makedev) DEST=$(dest) PROD=synch ver=$(VERSION) zip
	mv $(dest)synch$(VERSION).zip /c/scm/dist/
pubzip:	temp/synch
	$(makedev) DEST=$(HOME)/pub/ PROD=synch zip

diffs:	pubdiffs
pubdiffs:	temp/synch
	$(makedev) DEST=$(HOME)/pub/ PROD=synch pubdiffs
distdiffs:	temp/synch
	$(makedev) DEST=$(dest) PROD=synch ver=$(ver) distdiffs

new:
	echo `date` \ Aubrey Jaffer \ \<`whoami`@`hostname`\>> change
	echo>> change
	echo '	* Makefile (VERSION): Bumped from $(VERSION) to $(ver).'>>change
	echo>> change
	cat ChangeLog >> change
	mv -f change ChangeLog
	$(CHPAT) synch$(VERSION) synch$(ver) \
		../public_html/README.html ../dist/README
	$(CHPAT) $(VERSION) $(ver) synch.texi Makefile \
		../public_html/SIMSYNCH.html
	cvs commit -m '(VERSION): Bumped from $(VERSION) to $(ver).'
	cvs tag -F synch$(ver)

doszip:	/c/scm/synch.zip
/c/scm/synch.zip:	synch.zip
	cp synch.zip /c/scm/synch.zip
#zip:	synch.zip
#synch.zip:	temp/synch
#	cd temp; zip -r ../synch.zip synch
#pubzip:	temp/synch
#	cd temp; zip -r $(pubdir)synch.zip synch
diska:	synch.zip
	mcd a:
	-mdel synch.zip
	mcopy -nm synch.zip a:/
diskb:	synch.zip
	mcd b:
	-mdel synch.zip
	mcopy -nm synch.zip b:/

#pubdiffs:	temp/synch
#	mv temp/synch temp/nsynch
#	cd temp;unzip $(pubdir)synch.zip
#	-rm -f synch.diffs
#	-diff -c temp/synch temp/nsynch > synch.diffs
#	-rm -rf temp
#	ls -l synch.diffs

TAGS:	tags
tags:	$(tagfiles)
	etags $(tagfiles)

clean:	distclean
distclean:
	-rm -f *~ \#* *.orig *.rej a.out core TAGS lints tmp*
#	-rm -f *.pds
	-rm -rf temp
	-rm *.o *.so
	make TAGS
