## -*- makefile -*-
##
## Makefile for isa-mode 
##
##
## Author:  David Aspinall <da@dcs.ed.ac.uk>
##
## $Id: Makefile,v 1.13 1994/03/11 19:20:57 da Exp $
##
## 
###########################################################################
##
## Use:
##
##    make compile        - cleanout all .elc's and recompile
##    make <file.elc>     - byte compile file if .el file is newer
##                          (do all if <file.elc> is omitted)
##    make install        - install .el and .elc's into INSTALLDIR
##    make dist           - make a distribution (cleaned dir + tarfile)
## 
###########################################################################
##
## Things to edit: INSTALLDIR, EMACS
##
## See-also: isa-site.el, isa-compdefs.el
## 
###########################################################################

# Directory to install .elc files in.
INSTALLDIR = /export/local/share/isabelle/emacs

# Emacs to use as byte compiler  (needs batch-byte-compile function).
EMACS = emacs19

# Directory to make distribution in
FTPDIR = /home/da/pub




############################################################################

# Byte compilation command
BYTECOMP = $(EMACS) -batch -q -l ./isa-compdefs.el -f batch-byte-compile 

# Name of ftp directory and tar file
NAME = isa-mode

# Working directory
WRKDIR :sh = pwd

SHELL = /bin/sh

EL:sh = if test -d RCS ;\
	then ls RCS/*.el,v | sed s+RCS/++ | sed s/,v// ;\
	else ls *.el ;\
	fi

ELC = $(EL:.el=.elc)

DISTFILES:sh= if test -d RCS ;\
	       then ls RCS/*,v | sed s+RCS/++ | sed s+,v++ ;\
	       else ls ;\
	      fi

.SUFFIXES:	.el .elc

.el.elc:
	$(BYTECOMP) $< 

all:    $(ELC)


## 
## compile : byte compile files in working directory:
##           Clearout old .elc's and re-compile in a
##           single Emacs process.
##
compile:
	@echo "*************************************************"
	@echo " Byte compiling..."
	@echo "*************************************************"
	rm -f $(ELC)
	$(BYTECOMP) $(EL)
	rm -f isa-compdefs.elc isa-menus.elc
	@echo "*************************************************"
	@echo " Finished."
	@echo "*************************************************"

##
## install :  copy lisp files into INSTALLDIR
##	      (watch that INSTALLDIR is set correctly)
install:
	@echo "*************************************************"
	@echo " Cleaning target directory and copying files..."
	@echo "*************************************************"
	if test $(INSTALLDIR) != $(WRKDIR) ;\
        then mkdirhier $(INSTALLDIR)       ;\
	     rm -f $(INSTALLDIR)/*         ;\
	     for lispfile in $(EL)         ;\
	     do if test -r $${lispfile}c       ;\
	        then cp $${lispfile}c $(INSTALLDIR) ;\
		else cp $${lispfile}  $(INSTALLDIR) ;\
                fi					 ;\
	     done					 ;\
	fi
	@echo "*************************************************"
	@echo " Finished."
	@echo "*************************************************"
	

##
## dist: create a distribution: make directory and 
##       packaged contents in FTPDIR.
##
dist:
	@echo "*************************************************"
	@echo " Incrementing version number..."
	@echo " (No effect if Master RCS absent)"
	@echo "*************************************************"
	if test -r RCS/isa-dist-stamp.el,v ;\
	then co -q -l isa-dist-stamp.el  ;\
	     date '+(setq isa-dist-stamp "$$Revision: 1.13 $$ dated: %h %d 19%y.")' > isa-dist-stamp.el ;\
	     ci -u -f -mincrement isa-dist-stamp.el ;\
	     rm -f isa-dist-stamp.elc ;\
	fi
	@echo "*************************************************"
	@echo " Cleaning ftp directory..."
	@echo "*************************************************"
	rm -f $(FTPDIR)/$(NAME)/*
	rm -f $(FTPDIR)/$(NAME).tar*
	@echo "*************************************************"
	@echo " Copying master files from working directory..."
	@echo "*************************************************"
	mkdir -p $(FTPDIR)/$(NAME)
	for distfile in $(DISTFILES) ;\
	  do cp $${distfile} $(FTPDIR)/$(NAME)/$${distfile} ;\
	done
	@echo "*************************************************"
	@echo " Copying .elc files from working directory..."
	@echo "*************************************************"
	cp *.elc $(FTPDIR)/$(NAME)
	rm -f $(FTPDIR)/$(NAME)/isa-site.elc
	@echo "*************************************************"
	@echo " Making compressed tar file..."
	@echo "*************************************************"
	tar -cvhf $(FTPDIR)/$(NAME).tar -C $(FTPDIR) $(NAME)
	gzip $(FTPDIR)/$(NAME).tar
	@echo "*************************************************"
	@echo " Finished."
	@echo "*************************************************"

