# Makefile  -  Makefile for TeXsis version 2.18
# @(#) $Id: Makefile,v 18.2 1999/08/17 15:29:45 myers Exp $
#######################################################################
# This is the Makefile for TeXsis.  See the README file for more
# details about TeXsis.  For installation instructions for non-Unix
# machines run the file Install.tex through plain TeX.
#
# To make a preloaded format for texsis simply give the command 
#
# 	make texsis
#
# To make a copy of the manual say
#
# 	make Manual
#
# If you are installing TeXsis on your system then you can 
# have things automatically installed in the right places by 
# EDITING THE PARAMETERS BELOW and then saying:
#
# 	make install
#
# (Note: To install things in the system directories you must be the 
#  superuser, but anybody can install TeXsis under their home directory.)
#
#######################################################################
# Copyright (C) 1990,1991,1994,1995,1997,2000 by Eric Myers and Frank E. Paige
# This file is a part of TeXsis.  Distribution and/or modifications
# are allowed under the terms of the LaTeX Project Public License (LPPL).
# See the file COPYING or ftp://feynman.physics.lsa.umich.edu/texsis/LPPL
#######################################################################
.SUFFIXES: .tex .doc .txs .dvi 

# "prefix" is the directory path prefix for where you want to put the
# executable files  when they are installed.  It is just the general
# first part of the path. 
prefix=/usr/local

# TEXMFDIR is the top level directory for TeX files on your system.
# This used to be something like /usr/local/lib/tex, but now the
# recommended TeX Directory Structure (TDS) standard is just a directory
# called "texmf" rooted somewhere like /usr/local or /usr/share
# Modify to suit your own system.
#TEXMFDIR=$(HOME)/tex#		for personal installation
#TEXMFDIR=$(prefix)/lib/tex#	The old place for it (pre TDS)
#TEXMFDIR=/usr/lib/teTeX/texmf#    or might be /usr/lib/texmf/texm 
TEXMFDIR=/usr/share/texmf#	common


# TEXSISDIR is where the TeXsis sources live. Saying 'make install' 
# will put them there.  The source files and manual are supposed
# to be available for people to use or copy, so these should be out in
# the open.  Suggested place is .../texmf/tex/texsis
#TEXSISDIR=$(HOME)/tex/texsis#       	for personal installation
#TEXSISDIR=$(TEXMFDIR)/texsis#		the old place for it
TEXSISDIR=$(TEXMFDIR)/tex/texsis#		the new TDS location

# TEXSISFORMAT is the directory where 'make install' will put 
# texsis.fmt.  This is was once /usr/local/lib/tex/formats, but with
# the TDS becomes .../texmf/web2c (or perhaps /texmf/ini)
#TEXSISFORMAT=$(TEXSISDIR)# 		for personal installation
#TEXSISFORMAT=$(TEXMFDIR)/formats#	old place to put it
TEXSISFORMAT=$(TEXMFDIR)/web2c#	

# TEXSISINPUTS is the directory where 'make install' will put the
# style files and patch files so that TeXsis will find them.
# This was once /usr/local/lib/tex/inputs or wherever else your TeX
# looks for input files (i.e. TEXSISINPUTS).  Some older versions of TeX
# call the directory 'macros' rather than 'inputs'.  
#TEXSISINPUTS=$(TEXSISDIR)# 		for personal installation
TEXSISINPUTS=$(TEXSISDIR)#		for system installation

# TEXSISDOCS is the directory where 'make install' puts the TeXsis
# manual, both the source code and a .dvi file.  This could be the
# same directory as TEXSISDIR, but the new TeX directory heirarchy
# has a separate directory for documentation.
#TEXSISDOCS=$(TEXSISDIR)#		for same place as the source code
TEXSISDOCS=$(TEXMFDIR)/doc/texsis#	new standard location

# VIRTEX is the full path name of the virtex command on your system.
# TeX 3.xxx uses the name it is called by as the format to load, so 
# 'make install' makes a link to virtex called 'texsis'.
VIRTEX=$(prefix)/bin/virtex

# BINDIR is the directory where your executables are kept, and in
# particular where to put the texsis command (which is a link to
# $(VIRTEX) above.  
#BINDIR=$(HOME)/bin#		personal installation
BINDIR=$(prefix)/bin#		system installation

# MANDIR is where to put the texsis manual page.  This is  usually 
# /usr/local/man/man1. 
# (Note: This is just a short Unix man page, not the full TeXsis manual.)
#MANDIR=/dev/null#			to skip intalling man pages
#MANDIR=$(HOME)/man/man1# 		personal man pages, if you have them
MANDIR=$(prefix)/man/man1#		system local man pages

# MKDIR is the command to create a directory.  Usually this is 
# /bin/mkdir -p, but some machines don't support the -p flag.
MKDIR=/bin/mkdir -p

# INSTALL is the command used by 'make install' to put the format and
# manual pages in place.  This could be `install` but `cp` is enough.
#INSTALL=install -c 
INSTALL=/bin/cp

# (End of installation parameters.  Don't monkey with the stuff below.)
#######################################################################
# What follows describes how to make the texsis format file and the
# manual and how to install this stuff on the system using the definitions
# made above.

# VERSION is the current version number.
VERSION=2.18

# some Make's need to be told explicitly to use the Bourne shell.  Argh!
SHELL=/bin/sh

# The default target is to make both the format and the manual

all: texsis manual 

texsis: texsis.fmt

Manual: Manual.dvi cover
manual: Manual.dvi

cover:  TXScover.dvi
	mv TXScover.dvi cover.dvi


# TeXsis source files:

TEXSIS= texsis.tex TXSfonts.tex TXSinit.tex TXSmacs.tex TXSprns.tex \
        TXSeqns.tex TXSrefs.tex TXSsects.tex TXStags.tex TXStitle.tex \
        TXSenvmt.tex TXSfigs.tex TXSfmts.tex TXSdcol.tex TXSletr.tex \
        TXSmemo.tex TXSconts.tex TXSsymb.tex TXSruled.tex TXShead.tex 

# Make the site file TXSsite.tex, but only if it does not already exist:

TXSsite.tex: TXSsite.000
	if [ -s TXSsite.tex ]; then \
          echo "%==================================================" ;\
          echo "% TXSsite.tex exists.  I will not overwrite it!    " ;\
          echo "% To put TXSsite.000 in place you must copy it yourself. " ;\
          echo "%==================================================" ;\
        else \
          echo "% Copying proto site file TXSsite.000 to TXSsite.tex." ;\
          /bin/cp -i TXSsite.000 TXSsite.tex ;\
        fi

# how to make the texsis.fmt format file from the sources:

texsis.fmt:  $(TEXSIS)
	initex \&plain texsis '\dump'


# There may be more style files than these at your installation,
# but these are the ones that come with the current TeXsis distribution,
# and we want to be sure we get all of them out of RCS and have them
# around for the install or making the distribution.

STYLES=	AIP.txs CVformat.txs Elsevier.txs IEEE.txs Formletr.txs \
        PhysRev.txs Tablebod.txs WorldSci.txs nuclproc.txs \
        printfont.txs thesis.txs twin.txs spine.txs color.txs \
	Exam.txs Spanish.txs Swedish.txs 

# TeXsis manual:

MANUAL= Manual.tex TXSdoc.doc TXSdocM.doc TXSdoc0.doc \
        TXSintro.doc TXSfonts.doc TXSeqns.doc TXSprns.doc \
        TXSsymb.doc TXSrefs.doc TXSenvmt.doc TXSfigs.doc TXSruled.doc \
        TXSsects.doc TXSfmts.doc TXSletr.doc TXSdcol.doc TXStags.doc \
        TXSmisc.doc TXSinstl.doc TXSapxF.doc TXSrevs.doc TXSend.doc  \
	penguin.eps penguin2.eps 

Manual.dvi: $(MANUAL) texsis.fmt
	if [ -s Manual.aux ]; then \
          echo "% Manual.aux exists.  Making a single pass..." ;\
        else \
          echo "% First pass to create Manual.aux file..." ;\
          tex \&./texsis Manual;\
          echo "% Second pass..." ;\
        fi
	time tex \&./texsis Manual

Manual.ps: Manual.dvi
	dvips Manual

# Cover for a 3-ring binder or similar:

TXScover.dvi:  TXScover.doc
	tex \&./texsis TXScover.doc


# Other related files. These are also checked out of RCS and included
# in the distribution.

OTHER= Example.tex Fonts.tex index.tex TXSsite.000 Install.tex \
	texsis.1 texsis.el texsis.lsm texsis.bst TXScover.doc letr \
	README COPYING INSTALL

# 'make install' not only copies the files to where they should be but
# also creates a link named texsis to the executable virtex.  This is
# because TeX 3.x looks at the name it is invoked by and tries to
# load a format file by that same name. 

install:  texsis.fmt  Manual.dvi $(TEXSIS) $(MANUAL) $(STYLES) texsis.1 
	if [ ! -d $(TEXSISFORMAT) ]; then $(MKDIR) $(TEXSISFORMAT); fi
	$(INSTALL) texsis.fmt $(TEXSISFORMAT)
	if [ ! -d $(TEXSISINPUTS) ]; then $(MKDIR) $(TEXSISINPUTS); fi
	if [ -f $(TEXSISINPUTS)/TXSpatch.tex ]; then \
           /bin/mv $(TEXSISINPUTS)/TXSpatch.tex TXSpatch.old ; fi
	-/bin/rm -f $(BINDIR)/texsis
	/bin/ln -s $(VIRTEX)  $(BINDIR)/texsis
	for name in $(STYLES)  ; do \
           $(INSTALL) $$name $(TEXSISINPUTS) ; done
	if [ -f TXSpatch.tex ]; then \
           $(INSTALL) TXSpatch.tex $(TEXSISINPUTS) ; fi
	if [ ! -d $(TEXSISDIR) ]; then $(MKDIR) $(TEXSISDIR); fi
	for name in $(TEXSIS)  ; do \
           $(INSTALL) $$name $(TEXSISDIR) ; done
	$(INSTALL) index.tex $(TEXSISDIR)
	if [ -f TXSsite.tex ]; then $(INSTALL) TXSsite.tex $(TEXSISDIR) ; fi
	if [ ! -d $(TEXSISDOCS) ]; then $(MKDIR) $(TEXSISDOCS); fi 
	for name in $(MANUAL) ; do \
	  $(INSTALL) $$name $(TEXSISDOCS) ; done
	if [ -d $(MANDIR) ]; then $(INSTALL) texsis.1 $(MANDIR); fi
	$(INSTALL) Example.tex $(TEXSISDOCS)
	$(INSTALL) Manual.dvi $(TEXSISDOCS)
	echo "TeXsis $(VERSION) installed."

# 'make Install' instead uses plain TeX to print the installation
# instructions from the appendix of the Manual.  It uses a few TeXsis files.

Install:  Install.dvi

Install.dvi:  Install.tex TXSmacs.tex TXSenvmt.tex TXSdocM.doc
	tex Install
	echo "Created Install.dvi -- print this for the instructions."

Install.ps: Install.dvi
	dvips Install.dvi


# 'make example' will simply run the example file Example.tex

Example: example
example: Example.tex
	tex \&./texsis Example


# (end of installation instructions)
# =====================================================================*
# DISTRIBUTION:
#
# The following are instructions for making the distribution files
# for propagating TeXsis to other sites.  You really don't need to
# worry about this stuff, it's just for us.
#
# The target 'tar' creates the compressed tar archive of the TeXsis
# distribution. 

TARNAME=texsis-$(VERSION)
TARFLAGS=cof #		 the -o is to suppress chown/chgrp info

$(TARNAME): 
	-$(MKDIR) $(TARNAME)
	rm -f $(TARNAME)/*

TARFILES= $(TEXSIS) $(STYLES) $(MANUAL) $(OTHER)


tar:  $(TARNAME) $(TARFILES) 
	echo "Assembling the files for a tar archive..."
	chmod u+w $(TARNAME)/*
	cp Makefile $(TARNAME)
	cp README MANIFEST COPYING INSTALL NEWS $(TARNAME)
	-cp Manual.aux Manual.ind Install.ps  $(TARNAME)
	cp $(TARFILES) $(TARNAME)
	echo "building tar archive..."
	tar $(TARFLAGS) $(TARNAME).tar  $(TARNAME)
	echo "compessing the tar file with gzip..."
	gzip $(TARNAME).tar

##	MAKEFLAGS=""  cd $(TARNAME) && make tar-files

zip:  $(TARNAME) $(TARFILES) 
	echo "Assembling the files for a zip archive..."
	chmod u+w $(TARNAME)/*
	cp Makefile $(TARNAME)
	cp README MANIFEST COPYING INSTALL NEWS $(TARNAME)
	-cp Manual.aux Manual.ind Install.ps  $(TARNAME)
	cp $(TARFILES) $(TARNAME)
	echo "building zip archive..."
	zip -r  $(TARNAME).zip  $(TARNAME)



clean-tar:
	/bin/rm -rf $(TARNAME) 

# The processed index file Manual.ind is made using the makeindex
# program, which the user may not have.  Hence we make it for the
# distribution.

index: Manual.ind

Manual.ind:  Manual.idx
	makeindex Manual.idx


# mtexsis: mTeXsis is a mini TeXsis for e-prints.  Only the core
# TeXsis macros are included, and all comments and empty lines are
# stripped off by the sed script called 'strip4mtexsis'.

MTEXSIS = TXSfonts.tex TXSmacs.tex TXSinit.tex TXShead.tex TXSeqns.tex \
	TXSprns.tex TXSrefs.tex TXSsects.tex TXStags.tex TXStitle.tex \
	TXSenvmt.tex TXSfmts.tex TXSfigs.tex TXSruled.tex TXSsymb.tex

mtexsis: mtexsis.tex

mtexsis.tex : mtexsis.pre $(MTEXSIS) mtexsis.post
	cat mtexsis.pre > mtexsis.tex
	for name in $(MTEXSIS)  ; do \
           sed -f ./strip4mtexsis $$name >> mtexsis.tex ; \
        done
	cat mtexsis.post >> mtexsis.tex

# OLD:
# The targets 'UNIX' and 'VMS' create a collection of shar bundles 
# for distributing TeXsis to other sites.  The list of files to pack 
# is in the file MANIFEST, the instructions on how to pack are in 
# bundle and vms_bundle.  These require that you have the makekit
# program!   This is no longer supported after TeXsis 2.16!

UNIX: .Unix.bundled

.Unix.bundled: MANIFEST $(TEXSIS) $(MANUAL) $(STYLES) $(OTHER) \
		Install.tex texsis.1 
	./bundle
	touch ./.Unix.bundled

VMS: vms_bundle MANIFEST .Unix.bundled
	./vms_bundle
	touch ./.VMS.bundled


# ---------- diff patch file from previous version, using `patch`

OLD=2.17
NEW=2.18
PATCHFILE=diff-$(OLD)-$(NEW)

patchfile: 
	-diff -rc2  TeXsis-$(OLD) texsis-$(NEW) > $(PATCHFILE) 
	grep "^Only" $(PATCHFILE)

#======================================================================*
# RCS library:
# How to checkout from RCS.  rmtco performs a remote checkout from the 
# master RCS archive on physgi01.phy.bnl.gov.  On that machine use 'co'.
GET=rmtco

Source: $(TEXSIS)
Styles: $(STYLES)
Other:  $(OTHER)

$(STYLES):
	$(GET) $@
$(TEXSIS):
	$(GET) $@
$(MANUAL):
	$(GET) $@
$(OTHER):
	$(GET) $@

# (end of distribution)
######################################################################
# Preview: target for previewing manual on a Workstation  This is mostly
#  useful while I'm working on it.  dviview is my own script, but you 
# can get it from the TeXsis ftp server (it's not in the distribution).

preview: Manual.dvi
	dviview Manual.dvi

######################################################################
# clean up a bit (or a lot)

clean:  
	/bin/rm -f texsis.fmt
	/bin/rm -f *.log
	/bin/rm -f Manual.ref
	/bin/rm -f Manual.cnt
	/bin/rm -f Manual.tbl
	/bin/rm -f Manual.fgl
	/bin/rm -f core

veryclean: clean  clean-tar
	/bin/rm -f *.dvi
	/bin/rm -f *.fmt
	/bin/rm -f TEXSIS??

# Danger, Will Robinson!  (included only to force a fresh GET from RCS)

kill: veryclean
	/bin/rm -f $(TEXSIS) $(MANUAL) $(STYLES) $(OTHER)

# Force RCS to update version numbers (run this on physsgi01)

newversion:  $(TEXSIS) $(MANUAL) 
	ci -f18.0 -m"Updated version to 2.18" $(TEXSIS) $(MANUAL) 

#>>> EOF Makefile <<<





