# Makefile - for the TRR distribution.
# Last modified on Sat Jun 22 01:21:01 1996

# Edit the Makefile, type `make', and follow the instructions.

##----------------------------------------------------------------------
##  You MUST edit the following lines
##----------------------------------------------------------------------

# Where TRR directory is found
trrdir=/usr/local/lib/emacs/site-lisp/trr

# Where info files go.
infodir = /usr/local/info

# Name of your emacs binary
Emacs=emacs
#EMACS=mule

##----------------------------------------------------------------------
## You MAY need to edit these
##----------------------------------------------------------------------

# Using emacs in batch mode.
BATCH=$(EMACS) -batch -q -no-site-file

# Specify the byte-compiler for compiling TRR files
ELC= $(BATCH) -f batch-byte-compile

# Specify makeinfo program
#MAKEINFO = $(BATCH) trr.texi -l texinfmt -f texinfo-format-buffer -f save-buffer
MAKEINFO = makeinfo -o trr.info trr.texi

##----------------------------------------------------------------------
##  BELOW THIS LINE ON YOUR OWN RISK!
##----------------------------------------------------------------------

SHELL = /bin/sh

TRRSRC = trr.el trr-mesg.el trr-files.el trr-menus.el \
	 trr-graphs.el trr-sess.el

TRRELC = trr.elc trr-mesg.elc trr-files.elc trr-menus.elc \
	 trr-graphs.elc trr-sess.elc

SUBPROGS = update format

CONTENTS = CONTENTS

TEXIFILES = trr.texi

TEXTS = The_Constitution_Of_JAPAN

EXTRAFILES = Makefile README

first:
	@echo ""
	@echo "	 First of all, edit the Makefile && trr.el to suit your needs."
	@echo "	 Then run:"
	@echo
	@echo "	  make all"
	@echo
	@echo "	 and follow the instructions."
	@echo

all: main

main: elc info update format

install: main
	if [ ! -d $(trrdir) ]; then rm -f $(trrdir); mkdir $(trrdir); fi
	if [ ! -d $(trrdir)/text ]; then \
		rm -f $(trrdir)/text; mkdir $(trrdir)/text; \
		chmod 755 $(trrdir)/text; fi
	if [ ! -d $(trrdir)/record ]; then rm -f $(trrdir)/record; \
		mkdir $(trrdir)/record; chmod 755 $(trrdir)/record; fi
	cp update format $(trrdir)
	chmod 6711 $(trrdir)/update $(trrdir)/format
	cp *.elc $(trrdir)
	cp CONTENTS $(trrdir)
	(cd text; cp $(TEXTS) $(trrdir)/text)
	cp trr.info $(infodir)
	@echo 
	@echo "** TRR installation is almost completed."
	@echo "**"
	@echo "** Now edit \`CONTENTS' in the directory where you put"
	@echo "** TRR files ($(trrdir)/), and insert"
	@echo "** (autoload 'trr \"$(trrdir)/trr\" nil t)"
	@echo "** in your \`.emacs' or \`site-start.el' file."
	@echo "** then edit $(infodir)/dir to add TRR entry."
	@echo "**"
	@echo "** You may want to add some texts to TRR text directory."
	@echo "** Put them into $(trrdir)/text and edit \`CONTENTS'"
	@echo

info: $(TEXIFILES)
	$(MAKEINFO)

%.elc: %.el
	$(ELC) $<

elc: $(TRRELC)

format: Makefile format.org
	echo "#!/bin/sh" > format
	echo 'trrdir=$(trrdir)' | cat - format.org >> format

update: Makefile update.org
	echo "#!/bin/sh" > update
	echo 'recorddir=$(trrdir)/record' | cat - update.org >> update

clean:
	rm -f *~ *.elc

distclean: clean
	rm -f *.info
