# $Id: Makefile,v 2.12 1994/10/25 11:46:25 kris Exp kris $
#
# Un*x Makefile for XY-pic macros, fonts, documentation, and distribution.
# Copyright (c) 1991-1994  Kristoffer H. Rose  <kris@diku.dk>
#
# This file is part of the XY-pic macro package.
# Copyright (c) 1991-1994  Kristoffer H. Rose  <kris@diku.dk>
# See the README and INSTALL files for further information.
#
# The XY-pic package 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.
#
# The XY-pic package 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 package; if not, write to the Free Software Foundation, Inc.,
# 675 Mass Ave, Cambridge, MA 02139, USA.

VERSION = 2.12
SHORTVERSION = 212

# CONTENTS:
#
#   Configuration section:
#	Directories.
#	Fonts.
#	Programs.
#
#   Generic targets.
#   Macros.
#   Fonts.
#   Manual: User's guide and reference manual.
#   Reference manual.
#   TeXnical documentation.
#   Distribution tree.
#   Ftp'able distribution.
#   Mail'able distribution (not finished).
#   Tags.
#   RCS stuff.
#
#   Log.


#### CONFIGURATION SECTION ##################################################

# Please configure as instructed below for each of the DIRECTORIES, FONTS,
# and PROGRAMS sections.  This involves editing (a copy of) this file (mostly
# removing/inserting # characters to uncomment/comment definition lines).

# DIRECTORIES.
#
# The following variables define the directories where the various parts of
# XY-pic should be installed.
#
# FIRST the files needed by the TeX program to use the package:
#
# You should *either* (A) set TEXLIBDIR to a standard library directory that
# has subdirectories inputs (for macros), fonts (for TFM fonts), and doc (for
# documentation),
#
# *or* you should (B) set each of the variables TEXINPUTDIR, TEXFONTDIR, and
# TEXDOCDIR directly to the appropriate directories.
#
# The variable USR is provided as a convenience such that invoking a command
# like `make USR=/usr install' will do the right thing.
#
USR = /usr/local
TEXLIBDIR = $(USR)/lib/tex
#
#For Karl Berry's web2c `lib' distribution use this:
#TEXLIBDIR = $(USR)/lib/texmf
#
TEXINPUTDIR = $(TEXLIBDIR)/inputs
TEXFONTDIR = $(TEXLIBDIR)/fonts
TEXDOCDIR = $(TEXLIBDIR)/doc
#
#For Karl Berry's web2c `lib' distribution use these:
#TEXINPUTDIR = $(TEXLIBDIR)/tex/xypic
#TEXFONTDIR = $(TEXLIBDIR)/fonts/xypic/tfm
#
# SECOND you should set MFINPUTDIR to a place where the METAFONT source files
# of the XY-pic fonts should be installed, or just to . if you don't want the
# font sources installed.
#
MFINPUTDIR = $(USR)/lib/mf/inputs
#MFINPUTDIR = .
#
#For Karl Berry's web2c `lib' distribution use this:
#MFINPUTDIR = $(TEXLIBDIR)/fonts/xypic/src
#
# THIRD you should set FONTDIR to the directory where bitmap fonts are stored.
# (If you do not plan to install bitmap fonts because they are automatically
# generated and remember to set the MAGS variable below to `.' then you may
# ignore this step.)
#
# Since the location of individual fonts sometimes depend on properties of
# the font, you can insert
#
#	$${dpi}		for the font resolution in `Dots Per Inch' (NOT the
#   			device resolution---that should be inserted directly)
#
#	$${mode}	for the METAFONT `mode' used to generate the font
#
# ---what these get set to depends on the next section.
#
# For example, if you set FONTDIR=/usr/lib/tex/pk$${dpi} and decide in the
# next section to generate PK fonts at 300 dpi using a generic mode
# (localfont) then you get files named /usr/lib/tex/pk300/xy*.300pk.
#
# If your installation still uses the (inefficient) principle of having all
# PK files in the same directory as the TFM files then you should just set
# FONTDIR=$(TEXFONTDIR).
#
#FONTDIR = $(TEXFONTDIR)
FONTDIR = $(TEXLIBDIR)/$(PK)fonts/$${mode}$${dpi}
#
#For Karl Berry's web2c `lib' distribution use this:
#MFINPUTDIR = $(TEXLIBDIR)/fonts/tmp/$${mode}


# FONTS.
#
# The METAFONT program needs to know the `mode' of your printer in order to
# be able to generate correct fonts for it.  On most installations the mode
# `localfont' is made synonymous with the mode required for the default
# printer; in that case you can just pick the `MODE = localfont' line.  If
# this is not the case -- or you need fonts for several output devices---then
# you will have to consult the local METAFONT guide/guru to inquire what
# modes are used at your site.  A good place to look for the modes used is in
# the MakeTeXPK script found on some sites.
#
# Select the MODE to the mode (i.e., printer) you wish to use:
#
#MODE = localfont
MODE=cx
#
# You should also decide which TeX \magsteps you wish the font to be
# generated at.
#
# Set this just to . (dot) if you installed the font sources above and have the
# MakeTeXPK script installed such that fonts are generated automatically when
# needed---then only TFM files needed by TeX will be installed.
#
#MAGS = .
#MAGS = 0
MAGS = 0 0.5 1

# PROGRAMS.
#
# You don't have to edit the following lines unless you have a non-standard
# un*x system or un*x TeX installation...
#
SHELL = /bin/sh
#
LATEX = TEXFONTS=.:$(TEXFONTDIR):$$TEXFONTS latex
BIBTEX = BIBINPUTS=. bibtex
INITEX = TEXFONTS=.:$(TEXFONTDIR):$$TEXFONTS initex
#
# Set MF to a command that will run plain METAFONT on your system.
#
MF = MFINPUTS=.:$(MFINPUTDIR):$$MFINPUTS mf
#
# Set GFTOPK to the command "false" and PK to "gf" if you use GF rather than PK
# bitmap font files.  There is no support for PXL-files [are they still used?].
#
GFTOPK = gftopk -v
PK=pk
#
#GFTOPK = false
#PK=gf
#
RM = rm -f
#
# Set INSTALL to cp if your system does not have the install command.
#
INSTALL = install -c -m 444
INSTALLW = install -c -m 644
#INSTALL = cp
#INSTALLW = cp
#
MKDIR = mkdir -p
#
# DOC2TEX <file>: output efficient .tex file from inefficient .doc <file> with
# inlined documentation [my favourite hack :-].  Removes all DOCMODE lines,
# leaving only things before the first and in DOCMODE(...DOCMODE) brackets;
# also removes all blank lines and comment lines.
#
# If it breaks your sed you can just uncomment the `DOC2TEX = cat ...' line
# although that will make the installed macro files three times larger and the
# reading of them somewhat slower...so in that case you are probably better of
# getting the `run' distribution where this has already been done for you!
#
DOC2TEX = sed \
	-e '/^.DOCMODE(/b Yes' \
	-e '/^.DOCMODE/b No' \
	-e 'x' \
	-e '/%%DONTCOPY%%/b Ignore' \
	-e 'x' \
	-e 's/[ 	][ 	]*/ /g' \
	-e 's/{%.*$$/{%/' -e 's/}%.*$$/}%/' -e 's/ %.*$$//'  \
	-e '/^ *%$$/d' -e '/^ *$$/d' -e '/^ *%[^%]/d' \
	-e 's/^%% \$$Id/%% $@ from $$Id/' \
	-e 'b End' \
	-e ': No' -e 's/.*/%%DONTCOPY%%/' -e 'x' -e 'd' \
	-e ': Yes' -e 's/.*//' -e 'x' -e 'd' \
	-e ': Ignore' -e 'x' -e 'd' \
	-e ': End'
#
#DOC2TEX = cat
#
# MF2TFM script: make .tfm file and all requested bitmap files from .mf
# file by executing METAFONT with $${mode} and $${dpi} as described above.
#
# NOTE: for use as implicit make rule; do not modify unless you are sure you
# need to!
#
MF2TFM = set -x; mode=$(MODE);\
	if [ "$(MAGS)" = "." ]; then \
	  $(MF) "\\mode=$$mode; input $<";\
	  $(RM) $*.*gf;\
	else \
	  for mag in $(MAGS); do \
	    $(MF) "\\mode=$$mode; mag=magstep($$mag); input $<"; done;\
	  for f in $*.*gf; do if test -f "$$f"; then \
	    if $(GFTOPK) ./$$f; then $(RM) $$f; fi; else :; fi; done;\
	fi

#### END OF CONFIGURATION SECTION ###########################################


# GENERIC TARGETS.
#
.DEFAULT:	all
.PHONY:		all install clean realclean World Release
#
all:		macros fonts
#
install:	all install.macros install.fonts
#
clean:
	$(RM) *.aux *.toc *.lof *.blg *.log *.idx *.ilg *.fmt \
	  *.ps *.nops *.tmp *.ans *.xyc \
	  ./#* *~ core *.BAK *JNL 
#
realclean:	clean
	$(RM) MANIFEST CATALOG
	$(RM) xydoc.back; touch xydoc.back
	$(RM) *.bbl *.glo *.ind \
	  *.tfm *.*gf *.*pk *.tex *.dvi *.dvips *.last *.gif
#
# DON'T use these unless you are an XY-pic developer ... :-)
fresh:		TAGS realclean rcsclean
	$(RM) make.*
sterile:	realclean
	$(RM) make.* xydoc.back TAGS
	test -w Makefile || $(RM) Makefile
#
Up:		macros MANIFEST TAGS

World:
	make realclean rcsclean 
	time make USR=$$SYS PUB=$$HOME/pub Up install ftp \
	 2>&1 |tee make.World

Release:
	make realclean rcsclean 
	time make USR=$$SYS PUB=$$HOME/ftp/diku/users/kris/TeX Up install ftp \
	 2>&1 |tee make.Release


# MACROS.
#
TRAILERSOURCES =	Announce TRAILER COPYING CATALOG.doc MANIFEST \
			README README.ctan Makefile $(INSTALLSTAR)

INSTALLSTAR =		INSTALL INSTALL.OzTeX INSTALL.Textures

KERNELSOURCES = 	xy.doc xyidioms.doc xy.sty xypic.doc xypic.sty
OPTIONSOURCES = 	xydummy.doc \
	xycurve.doc xyframe.doc xycmtip.doc \
	xyline.doc xyrotate.doc xycolor.doc \
	xyall.doc xymatrix.doc xyarrow.doc xygraph.doc xy2cell.doc xyv2.doc \
	xypoly.doc \
	xyps.doc xyps-c.doc xyps-l.doc xyps-r.doc xyps-col.doc \
	xypsdict.doc \
	xyps-dvi.doc xyps-oz.doc xyps-txt.doc \
	xyps-dto.doc xyps-one.doc xyps-wdo.doc xyps-pub.doc
FORMATSOURCES = 	xytex.ini xylatex.ini xyamslatex.ini
MACROSOURCES =		$(TRAILERSOURCES) $(KERNELSOURCES) $(OPTIONSOURCES) \
			$(FORMATSOURCES)
#
TRAILERRUN =		Announce TRAILER COPYING CATALOG $(INSTALLSTAR)
KERNELRUN =		xy.tex xyidioms.tex xy.sty xypic.tex xypic.sty
OPTIONRUN = 		xydummy.tex \
	xycurve.tex xyframe.tex  xycmtip.tex \
	xyline.tex xyrotate.tex xycolor.tex  \
	xyall.tex xymatrix.tex xyarrow.tex xygraph.tex xy2cell.tex xyv2.tex \
	xypoly.tex \
	xyps.tex xyps-col.tex xyps-c.tex xyps-l.tex xyps-r.tex \
	xyps-dvi.tex xyps-col.tex xyps-oz.tex xyps-txt.tex \
	xyps-dto.tex xyps-one.tex xyps-wdo.tex xyps-pub.tex
MACRORUN =		$(KERNELRUN) $(OPTIONRUN)
#
# Macros have .tex suffix and are generated from the .doc files.
#
.SUFFIXES:	.tex .doc
.doc.tex:;	$(DOC2TEX) $< > $@
#
.PHONY:		texinputs macros install.macros
#
texinputs macros: $(MACRORUN)
install.macros:	$(MACRORUN)
	-test -d $(TEXINPUTDIR) || $(MKDIR) $(TEXINPUTDIR)
	@echo 'Expect (ignored) errors below...'
	-test -f $(TEXINPUTDIR)/xypic.tex.orig &&\
	  mv -f $(TEXINPUTDIR)/xypic.tex.orig $(TEXINPUTDIR)/xypic-2.tex
	-test -f $(TEXINPUTDIR)/xypic.tex \
	     -a ! -f $(TEXINPUTDIR)/xypic-2.tex &&\
	  mv -f $(TEXINPUTDIR)/xypic.tex $(TEXINPUTDIR)/xypic-2.tex
	-test -f $(TEXINPUTDIR)/xypic.sty.orig &&\
	  mv -f $(TEXINPUTDIR)/xypic.sty.orig $(TEXINPUTDIR)/xypic-2.sty
	-test -f $(TEXINPUTDIR)/xypic.sty \
	     -a ! -f $(TEXINPUTDIR)/xypic-2.sty &&\
	  mv -f $(TEXINPUTDIR)/xypic.sty $(TEXINPUTDIR)/xypic-2.sty
	for f in $(MACRORUN); do $(INSTALL) $$f $(TEXINPUTDIR)/$$f; done
#
# Kernel dependencies:
#
xy.tex:	xy.doc
xyidioms.tex:	xyidioms.doc
#
# Standard option dependencies:
#
xydummy.tex:	xydummy.doc
xyall.tex:	xyall.doc
#
xymatrix.tex:	xymatrix.doc
xyarrow.tex:	xyarrow.doc
xy2cell.tex:	xy2cell.doc
xygraph.tex:	xygraph.doc
xyv2.tex:	xyv2.doc
xypoly.tex:	xypoly.doc
#
xycurve.tex:	xycurve.doc
xyframe.tex:	xyframe.doc
xycmtip.tex:	xycmtip.doc
xyline.tex:	xyline.doc
xyrotate.tex:	xyrotate.doc
xycolor.tex:	xycolor.doc
#
xyps.tex:	xyps.doc
xyps-l.tex:	xyps-l.doc
xyps-r.tex:	xyps-r.doc
xyps-c.tex:	xyps-c.doc
xyps-col.tex:	xyps-col.doc
xyps-dto.tex:	xyps-dto.doc
xyps-dvi.tex:	xyps-dvi.doc
xyps-one.tex:	xyps-one.doc
xyps-oz.tex:	xyps-oz.doc
xyps-pub.tex:	xyps-pub.doc
xyps-txt.tex:	xyps-txt.doc
xyps-wdo.tex:	xyps-wdo.doc


# FONTS.
#
.PHONY:		mfinputs texfonts $(PK)fonts fonts install.fonts
#
FONTSOURCES = \
	xydash10.mf xyd.mf \
	xyatip10.mf xybtip10.mf xybsql10.mf xycmat10.mf xycmbt10.mf xyd2.mf \
	xycirc10.mf
#
TEXFONTRUN = \
	xydash10.tfm \
	xyatip10.tfm xybtip10.tfm xycmat10.tfm xycmbt10.tfm xybsql10.tfm \
	xycirc10.tfm
#
# These are NOT valid dependencies:
PKFONTRUN = xy*.*$(PK)
#
FONTRUN = $(FONTSOURCES) $(TEXFONTRUN) $(PKFONTRUN)
#
# Note: we only depend on the tfm-files, so you must remove them to
# regenerate the fonts at all desired magnifications.
#
.SUFFIXES:	.mf .tfm
.mf.tfm:;	$(MF2TFM)
#
mfinputs:	$(FONTSOURCES)
#
texfonts $(PK)fonts fonts: $(FONTSOURCES) $(TEXFONTRUN)
install.fonts:	fonts
	if test -n "$(MFINPUTDIR)"; then \
	  test -d $(MFINPUTDIR) || $(MKDIR) $(MFINPUTDIR); \
	  for f in $(FONTSOURCES);do $(INSTALL) $$f $(MFINPUTDIR)/$$f;done; fi
	-test -d $(TEXFONTDIR) || $(MKDIR) $(TEXFONTDIR)
	for f in $(TEXFONTRUN); do $(INSTALL) $$f $(TEXFONTDIR)/$$f; done
	for f in $(PKFONTRUN); do if test -f "$$f"; then \
	  dpi=`expr "$$f" : '.*\.\([0-9]*\)[a-z]*$$'`; mode=$(MODE); \
	  test -d "$(FONTDIR)" || $(MKDIR) $(FONTDIR); \
	  $(INSTALL) $$f $(FONTDIR)/$$f; else :; fi; done
#
xy*.*$(PK):	# Since it is in FONTRUN
	@echo "PK-files:" echo xy*.*pk
#
# Standard fonts...semidirectional, directional, and other:
#
xydash10.tfm:	xydash10.mf xyd2.mf
xyatip10.tfm:	xyatip10.mf xyd.mf
xybtip10.tfm:	xybtip10.mf xyd.mf
xycmat10.tfm:	xycmat10.mf xyd.mf
xycmbt10.tfm:	xycmbt10.mf xyd.mf
xybsql10.tfm:	xybsql10.mf xyd.mf
xycirc10.tfm:	xycirc10.mf

# FORMATS:
#
# Build formats...
#
.SUFFIXES:	.ini .fmt
.ini.fmt:;	$(INITEX) $<
#
xytex.fmt:	xytex.ini
xylatex.fmt:	xylatex.ini
xyamslatex.fmt:	xyamslatex.ini


# MANUAL: USER'S GUIDE AND REFERENCE MANUAL.
#
# Note: the first generations use the DVIPS backend to run faster.
#
.PHONY:		guide manual install.manual
#
MANUALSOURCES =		\
	xyguide.man xydoc.sty latin1.sty xydoc.bib \
	xyrefer.man $(KERNELSOURCES) $(OPTIONSOURCES)
#
MANUALRUN = 	xyguide.dvi xyrefer.dvi
#
.SUFFIXES:	.man .dvips .dvi
.man.dvips:
	echo "\\UsePSspecials{dvips}" > xydoc.back
	$(LATEX) $<
	$(BIBTEX) $*
	$(LATEX) $<
	echo "\\UsePSheader{xy$(SHORTVERSION)dict.ps}\\UsePSspecials{dvips}" \
	 > xydoc.back
	$(LATEX) $<
	mv $*.dvi $*.dvips
#
.dvips.dvi:
	echo "\\NoPSspecials" > xydoc.back
	$(LATEX) $*.man
#
guide:		xyguide.dvi 
#
manual:		$(MANUALRUN)
install.manual:	manual
	-test -d $(TEXDOCDIR) || $(MKDIR) $(TEXDOCDIR)
	for f in $(MANUALRUN); do $(INSTALL) $$f $(TEXDOCDIR)/$$f; done
	for f in COPYING TRAILER; do \
	  $(INSTALL) $$f $(TEXDOCDIR)/xy.$$f; done
#
xyguide.dvips:	xyguide.man xydoc.sty latin1.sty xydoc.bib \
	xy$(SHORTVERSION)dict.ps macros fonts
xyrefer.dvips:	xyrefer.man xydoc.sty latin1.sty xydoc.bib \
	xy$(SHORTVERSION)dict.ps macros fonts $(KERNELSOURCES) $(OPTIONSOURCES)
#
xyguide.dvi:	xyguide.dvips
xyrefer.dvi:	xyrefer.dvips
#
xy$(SHORTVERSION)dict.ps xypsdict.tex: xypsdict.doc
	-$(RM) xy$(SHORTVERSION)dict.ps
	sed -e 's/%%SHORTVERSION%%/$(SHORTVERSION)/' \
		< xypsdict.doc > xypsdict.tex
	$(LATEX) xypsdict


# TeXNICAL DOCUMENTATION.
#
# Generated as plain DVI file by hand because of index...
#
TeXNICALSOURCES = \
	xysource.man xydoc.sty xydoc.bib latin1.sty \
	$(MACROSOURCES) $(FONTSOURCES) COPYING.ed
#
xysource.dvips: macros fonts $(TeXNICALSOURCES) \
		COPYING.tex macros.tmp xy$(SHORTVERSION)dict.ps
	-$(RM) xysource.ind; touch xysource.ind
	echo "\\UsePSspecials{dvips}" > xydoc.back
	$(LATEX) xysource.man
	$(BIBTEX) xysource
	$(LATEX) xysource.man
	sort -t'{' -df +1 -2 macros.tmp xysource.idx |uniq >xysource.ind
	echo "\\UsePSheader{xy$(SHORTVERSION)dict.ps}\\UsePSspecials{dvips}" \
	 > xydoc.back
	$(LATEX) xysource.man
	mv xysource.dvi xysource.dvips
#
xysource.dvi:	xysource.dvips
#
COPYING.tex: COPYING COPYING.ed
	(cat COPYING.ed; echo w COPYING.tex; echo q) | ed - COPYING
#
# Macro index...requires GNU AWK (gawk) or (in a pinch) NAWK.
#
GAWK = gawk
#
macros.tmp:	$(KERNELSOURCES) $(OPTIONSOURCES) $(FONTSOURCES)
	-$(RM) macros.tmp
	for f in $(KERNELSOURCES) $(OPTIONSOURCES) $(FONTSOURCES);\
	do $(GAWK) '\
	  func err(s) { printf("%s,%d: %s\n",FILENAME,FNR,s) >>"/dev/stderr"};\
	  func prt(s,i) { \
	   printf("\\macroentry{%s}{%s}{%d}\n",s,FILENAME,FNR) };\
	  func prtdef(i) { t = substr($$0,i);\
	   if (match(t,/[\\|][a-zA-Z@]*|\\.|[^\\|]|{([^{}]|\\{|\\})*}/) != 1) \
	    err("Weird TeX token");\
	   else prt(substr($$0,i,RLENGTH),i) };\
	  func prtcsdef(i) { t = substr($$0,i);\
	   if (match(t,/{([^{}]|\\{|\\})*}|{([^{}]|\\{|\\})*{([^{}]|\\{|\\})*}([^{}]|\\{|\\})*}/) != 1) \
	    err("Weird TeX cs name token");\
	   else prt(substr($$0,i+1,RLENGTH-2),i) };\
	  /^\\let[^A-Za-z@]/		||\
	  /^\\def[^A-Za-z@]/		{ prtdef(5); next };\
	  /^\\gdef[^A-Za-z@]/		||\
	  /^\\edef[^A-Za-z@]/		||\
	  /^\\xdef[^A-Za-z@]/		{ prtdef(6); next };\
	  /^\\newif[^A-Za-z@]/		{ prtdef(7); next };\
	  /^\\xydef@[^A-Za-z@]/		||\
	  /^\\xylet@[^A-Za-z@]/		{ prtdef(8); next };\
	  /^\\xyfont@[^A-Za-z@]/	{ prtdef(9); next };\
	  /^\\global\\let[^A-Za-z@]/	{ prtdef(12); next };\
	  /^\\xywarnifdefined[^A-Za-z@]/ { prtdef(17); next };\
	  /^\\ifx\\undefined[^A-Za-z@]/ { prtdef(15); next };\
	  /^\\xynew@{[^{}]*}/		{ prtdef(index($$0,"}")+1); next };\
	  /^\\xydefcsname@{/		{ prtcsdef(14); next };\
	  /^\\xyletcsnamecsname@{/	{ prtcsdef(20); next }' $$f;\
	done > macros.tmp


# DISTRIBUTION TREE.
#
PUB = $(USR)/pub
DISTDIR = $(PUB)/xy-$(VERSION)
DISTFONTDIR = $(DISTDIR)/$(PK)fonts/$${mode}$${dpi}
#
# Files:
#
SOURCES = $(MACROSOURCES) $(FONTSOURCES) $(MANUALSOURCES)
#
# Commands:
#
# TAR <files>		output tar archive with <files>
# GZIP			compression filter
# GZ			filename extension appropriate for compressed files
#
# TODO: change compression to proper GNU gzip once everyone supports it...
#
TAR = tar cvf -
GZIP = gzip -v9
GZ = .gz
#
# Targets:
#
.PHONY: dist dist-$(VERSION) distsrc distrun distps
#
dist dist-$(VERSION):	### distsrc distrun distdoc
	cd $(DISTDIR);\
	  find . -type f -print | sed 's,^./,,' | sort > MANIFEST
	$(INSTALL) README.ctan $(DISTDIR)/README
#
distsrc:	$(DISTDIR)/src
#
distrun:	$(DISTDIR)/Announce \
		$(DISTDIR)/CATALOG \
		$(DISTDIR)/TRAILER \
		$(DISTDIR)/COPYING \
		$(DISTDIR)/INSTALL \
		$(DISTDIR)/texinputs \
		$(DISTDIR)/texfonts \
		$(DISTDIR)/mfinputs \
		$(DISTDIR)/$(PK)fonts \
		$(DISTDIR)/doc/xyguide.dvi \
		$(DISTDIR)/doc/xyrefer.dvi \
		$(DISTDIR)/ps
#
distdoc:	$(DISTDIR)/doc/xyguide.ps \
		$(DISTDIR)/doc/xyrefer.ps \
#
# Explanation targets:
#
$(DISTDIR)/Announce: Announce $(DISTDIR)
	$(INSTALL) Announce $(DISTDIR)/Announce

$(DISTDIR)/CATALOG: CATALOG $(DISTDIR)
	$(INSTALL) CATALOG $(DISTDIR)/CATALOG
#
# The CATALOG is automatically generated:
#
CATALOG:	CATALOG.doc
	$(LATEX) CATALOG.doc
	mv -f CATALOG.out CATALOG

$(DISTDIR)/TRAILER: TRAILER $(DISTDIR)
	$(INSTALL) TRAILER $(DISTDIR)/TRAILER

$(DISTDIR)/COPYING: COPYING $(DISTDIR)
	$(INSTALL) COPYING $(DISTDIR)/COPYING

$(DISTDIR)/INSTALL: $(INSTALLSTAR) $(DISTDIR)
	for f in INSTALL*; do if test -f "$$f"; then \
	  $(INSTALL) $$f $(DISTDIR)/$$f; else :; fi; done
#
# Directory targets:
#
$(DISTDIR):
	-test -d $(DISTDIR) || $(MKDIR) $(DISTDIR)

$(DISTDIR)/src: $(SOURCES) MANIFEST $(DISTDIR)
	-test -d $(DISTDIR)/src || $(MKDIR) $(DISTDIR)/src
	$(INSTALLW) MANIFEST $(DISTDIR)/src/MANIFEST
	for f in $(SOURCES); do echo $$f; done | sort -fu |\
	 while read u; do $(INSTALL) $$u $(DISTDIR)/src/$$u; done
#
# The MANIFEST in src is just a list of the distributed source files.
#
MANIFEST:	$(SOURCES)
	ls -alg `for f in $(SOURCES); do echo $$f; done | sort -fu` >MANIFEST

$(DISTDIR)/texinputs: texinputs $(DISTDIR)
	-test -d $(DISTDIR)/texinputs \
	 || $(MKDIR) $(DISTDIR)/texinputs
	for f in $(MACRORUN); \
	 do $(INSTALL) $$f $(DISTDIR)/texinputs/$$f; done

$(DISTDIR)/texfonts: texfonts $(DISTDIR)
	-test -d $(DISTDIR)/texfonts \
	 || $(MKDIR) $(DISTDIR)/texfonts
	for f in $(TEXFONTRUN); \
	 do $(INSTALL) $$f $(DISTDIR)/texfonts/$$f; done

$(DISTDIR)/mfinputs: mfinputs $(DISTDIR)
	-test -d $(DISTDIR)/mfinputs \
	 || $(MKDIR) $(DISTDIR)/mfinputs
	for f in $(FONTSOURCES); \
	 do $(INSTALL) $$f $(DISTDIR)/mfinputs/$$f; done

$(DISTDIR)/$(PK)fonts: $(PK)fonts $(DISTDIR)
	-test -d $(DISTDIR)/$(PK)fonts || $(MKDIR) $(DISTDIR)/$(PK)fonts
	for f in $(PKFONTRUN); do if test -f "$$f"; then \
	  dpi=`expr "$$f" : '.*\.\([0-9]*\)[a-z]*$$'`; mode=$(MODE); \
	  test -d "$(DISTFONTDIR)" || $(MKDIR) $(DISTFONTDIR); \
	  $(INSTALL) $$f $(DISTFONTDIR)/$$f; else :; fi; done

$(DISTDIR)/ps: xy$(SHORTVERSION)dict.ps $(DISTDIR)
	-test -d $(DISTDIR)/ps || $(MKDIR) $(DISTDIR)/ps
	$(INSTALL) xy$(SHORTVERSION)dict.ps $(DISTDIR)/ps

# Document targets:
#
$(DISTDIR)/doc/xyguide.dvi:	xyguide.dvi $(DISTDIR)/doc
	$(INSTALL) xyguide.dvi $(DISTDIR)/doc

$(DISTDIR)/doc/xyguide.ps:	xyguide.ps $(DISTDIR)/doc
	$(INSTALL) xyguide.ps $(DISTDIR)/doc

$(DISTDIR)/doc/xyrefer.dvi:	xyrefer.dvi $(DISTDIR)/doc
	$(INSTALL) xyrefer.dvi $(DISTDIR)/doc

$(DISTDIR)/doc/xyrefer.ps:	xyrefer.ps $(DISTDIR)/doc
	$(INSTALL) xyrefer.ps $(DISTDIR)/doc

$(DISTDIR)/doc:
	-test -d $(DISTDIR)/doc || $(MKDIR) $(DISTDIR)/doc


# FTP'ABLE DISTRIBUTION.
#
FTPDIR = $(PUB)
FTPDOCDIR = $(PUB)/xy-$(VERSION)/doc
#
.PHONY:		ftp ftp-$(VERSION) ftpsrc ftprun ftpdoc
#
ftp ftp-$(VERSION):	ftpsrc ftprun ftpdoc ftpunpacked
	$(INSTALL) Announce $(FTPDIR)/xy$(SHORTVERSION).Announce
	$(INSTALL) TRAILER $(FTPDIR)/xy$(SHORTVERSION).TRAILER
#
ftpsrc $(FTPDIR)/xy$(SHORTVERSION)src.tar$(GZ): distsrc
	cd $(DISTDIR)/.. ;\
	 tar cvf - xy-$(VERSION)/src \
	 | $(GZIP) > $(FTPDIR)/xy$(SHORTVERSION)src.tar$(GZ)
#
ftprun $(FTPDIR)/xy$(SHORTVERSION)run.tar$(GZ): distrun $(DISTDIR)/doc
	cd $(DISTDIR)/.. ;\
	 tar cvf - \
	  xy-$(VERSION)/TRAILER xy-$(VERSION)/INSTALL* xy-$(VERSION)/COPYING \
	  xy-$(VERSION)/doc/xyguide.dvi xy-$(VERSION)/doc/xyrefer.dvi \
	  xy-$(VERSION)/texinputs xy-$(VERSION)/texfonts \
	  xy-$(VERSION)/mfinputs xy-$(VERSION)/$(PK)fonts \
	  xy-$(VERSION)/ps \
	 | $(GZIP) > $(FTPDIR)/xy$(SHORTVERSION)run.tar$(GZ)
#
ftpdoc: distdoc
	$(GZIP) < $(DISTDIR)/doc/xyguide.ps > $(FTPDIR)/xyguide.ps$(GZ)
	$(GZIP) < $(DISTDIR)/doc/xyrefer.ps > $(FTPDIR)/xyrefer.ps$(GZ)
#
ftpunpacked: dist
	test $(DISTDIR) = $(FTPDIR)/xy-$(VERSION) || \
	 (cd $(DISTDIR)/.. ; tar cf - xy-$(VERSION) |(cd $(FTPDIR); tar xvf -))
	cd $(FTPDIR); rm -f xy; ln -s xy-$(VERSION) xy
#
# PostScript targets:
#
# DVIPS should be Tom Rokicki's dvips PostScript DVI driver.
DVIPS = dvips -f
#
.SUFFIXES:	.ps
.dvips.ps:;	$(DVIPS) < $< > $@
#
xyguide.ps:	xyguide.dvips
xyrefer.ps:	xyrefer.dvips


# WWW PUBLICITY
#
WWWDIR = $$HOME/www/users/kris
TOPPSDIR = $$HOME/www/research-groups/topps/activities
#
WWWSOURCES = Xy-pic.html Xy-pic.xbm Xy-pic.blurb
#
www:		Xy-pic.html Xy-pic.gif Xy-pic.blurb
	$(INSTALL) Xy-pic.html Xy-pic.gif $(WWWDIR)
	$(INSTALL) Xy-pic.blurb $(TOPPSDIR)/xypic.blurb
#
# GIF creation.  TODO: should be transparent...?
#
Xy-pic.gif:	Xy-pic.xbm
	xbmtopbm < Xy-pic.xbm | pgmtoppm white | ppmtogif > Xy-pic.gif

# MAIL'ABLE DISTRIBUTION (not finished).
#
# If there is a demand then this will (again) generate shar file series for
# each of the distributions...but since CTAN this is not much used...
#
SHARDIR = $(PUB)
SHAR = shar -v -M -D -o$${shar} -l50
#
.PHONY:		shar shar-$(VERSION) sharsrc sharrun shardoc
#
shar shar-$(VERSION):	sharsrc
#
sharsrc: distsrc
	cd $(DISTDIR)/src; shar=$(SHARDIR)/xy$(SHORTVERSION)src.; $(SHAR) *
#
#...
#
# However, announcements are still needed!
#
.PHONY:		announce
#
MAILSOURCES = Announce Users mail.Users
#
announce:	$(MAILSOURCES)
	@./mail.Users


# TAGS for Emacs.
#
TAGS:	$(SOURCES)
	-$(RM) TAGS
	for f in `for ff in $(SOURCES); do echo $$ff; done |sort -u`;\
	do\
	 $(GAWK) '\
	  func err(s) { printf("%s,%d: %s\n",FILENAME,FNR,s) >>"/dev/stderr"};\
	  func prt(s,n) { printf("%s\177%d,%d\n",s,FNR,c+n) };\
	  func prtdef(i) { t = substr($$0,i);\
	   if (match(t,/[\\|][a-zA-Z@]*|\\.|[^\\|]|{([^{}]|\\{|\\})*}/) != 1) \
	    err("Weird TeX token");\
	   else prt(substr($$0,1,i+RLENGTH),i) };\
	  func prtcsdef(i) { t = substr($$0,i);\
	   if (match(t,/{([^{}]|\\{|\\})*}|{([^{}]|\\{|\\})*{([^{}]|\\{|\\})*}([^{}]|\\{|\\})*}/) != 1) \
	    err("Weird TeX cs name token");\
	   else prt(substr($$0,1,i+RLENGTH),i) };\
	  func fin() { c += length($$0) + 1; next };\
	  BEGIN { c = 0 };\
	  /^\\let[^A-Za-z@]/		||\
	  /^\\def[^A-Za-z@]/		{ prtdef(5); fin() };\
	  /^\\gdef[^A-Za-z@]/		||\
	  /^\\edef[^A-Za-z@]/		||\
	  /^\\xdef[^A-Za-z@]/		{ prtdef(6); fin() };\
	  /^\\newif[^A-Za-z@]/		{ prtdef(7); fin() };\
	  /^\\xydef@[^A-Za-z@]/		||\
	  /^\\xylet@[^A-Za-z@]/		{ prtdef(8); fin() };\
	  /^\\xyfont@[^A-Za-z@]/	{ prtdef(9); fin() };\
	  /^\\global\\let[^A-Za-z@]/	{ prtdef(12); fin() };\
	  /^\\xywarnifdefined[^A-Za-z@]/ { prtdef(17); fin() };\
	  /^\\ifx\\undefined[^A-Za-z@]/ { prtdef(15); fin() };\
	  /^\\xynew@{[^{}]*}/		{ prtdef(index($$0,"}")+1); fin() };\
	  /^\\xydefcsname@{/		{ prtcsdef(14); fin() };\
	  /^\\xyletcsnamecsname@{/	{ prtcsdef(20); fin() };\
	  /\?\?\=\[/	{ s = $$0; i = 0;\
	   while (first = index(s, "\?\?=[")) {\
	    s = substr(s,first+4); i += first+4;\
	    if (j = index(s, "]")) prt(substr($$0,1,i+j-1),i);\
	    else printf("Unmatched []s") }; fin() };\
	  /^@[A-Za-z]*{/ { prt($$0,index($$0,"{")+1); fin() };\
	  { fin() }' $$f >TAGS.tmp ;\
	 wc -c TAGS.tmp|$(GAWK) '{printf "\f\n%s,%s\n","'"$$f"'",$$1}'>>TAGS;\
	 cat TAGS.tmp >>TAGS ;\
	done
	$(RM) TAGS.tmp


# RCS STUFF
#
.PHONY: co co-$(VERSION) ci ci-$(VERSION) cici rlog rcsclean
#
ALLSOURCES = $(SOURCES) $(MANUALSOURCES) $(TeXNICALSOURCES) \
	$(WWWSOURCES) $(MAILSOURCES)
#
co co-$(VERSION):
	$(MAKE) `$(MAKE) rcslist`
#
ci ci-$(VERSION): cici Makefile
cici:;	ci -r$(VERSION) `$(MAKE) rcslockedlist`
#
rcslist:
	-@rlog -R `for f in $(ALLSOURCES); do echo $$f; done | sort -u` \
	  2>/dev/null | sed 's;RCS/\(.*\),v;\1;'
rcslockedlist:
	-@rlog -R -L `for f in $(ALLSOURCES); do echo $$f; done | sort -u` \
	  2>/dev/null | sed 's;RCS/\(.*\),v;\1;'
#
rcscleanlist:
	-@make rcslist \
	 | while read f; do if test -w $$f -o $$f = Makefile; then :; \
	     else echo $$f; fi; done
#
rcsclean:
	 -$(RM) `make rcscleanlist`
#
# RCS dependencies:
#
rcsdep:
	make rcslist | while read f; do \
	  echo "$$f: RCS/$$f,v; test -d RCS && co $$f || :"; done
Announce:; test -d RCS -a -f RCS/Announce,v && co Announce || :
CATALOG.doc:; test -d RCS -a -f RCS/CATALOG.doc,v && co CATALOG.doc || :
COPYING:; test -d RCS -a -f RCS/COPYING,v && co COPYING || :
COPYING.ed:; test -d RCS -a -f RCS/COPYING.ed,v && co COPYING.ed || :
INSTALL:; test -d RCS -a -f RCS/INSTALL,v && co INSTALL || :
INSTALL.OzTeX:; test -d RCS -a -f RCS/INSTALL.OzTeX,v && co INSTALL.OzTeX || :
INSTALL.Textures:; test -d RCS -a -f RCS/INSTALL.Textures,v && co INSTALL.Textures || :
Makefile:; test -d RCS -a -f RCS/Makefile,v && co Makefile || :
README:; test -d RCS -a -f RCS/README,v && co README || :
README.ctan:; test -d RCS -a -f RCS/README.ctan,v && co README.ctan || :
TRAILER:; test -d RCS -a -f RCS/TRAILER,v && co TRAILER || :
Users:; test -d RCS -a -f RCS/Users,v && co Users || :
latin1.sty:; test -d RCS -a -f RCS/latin1.sty,v && co latin1.sty || :
mail.Users:; test -d RCS -a -f RCS/mail.Users,v && co mail.Users || :
xy.doc:; test -d RCS -a -f RCS/xy.doc,v && co xy.doc || :
xy.sty:; test -d RCS -a -f RCS/xy.sty,v && co xy.sty || :
xy2cell.doc:; test -d RCS -a -f RCS/xy2cell.doc,v && co xy2cell.doc || :
xyall.doc:; test -d RCS -a -f RCS/xyall.doc,v && co xyall.doc || :
xyarrow.doc:; test -d RCS -a -f RCS/xyarrow.doc,v && co xyarrow.doc || :
xyatip10.mf:; test -d RCS -a -f RCS/xyatip10.mf,v && co xyatip10.mf || :
xybsql10.mf:; test -d RCS -a -f RCS/xybsql10.mf,v && co xybsql10.mf || :
xybtip10.mf:; test -d RCS -a -f RCS/xybtip10.mf,v && co xybtip10.mf || :
xycirc10.mf:; test -d RCS -a -f RCS/xycirc10.mf,v && co xycirc10.mf || :
xycmat10.mf:; test -d RCS -a -f RCS/xycmat10.mf,v && co xycmat10.mf || :
xycmbt10.mf:; test -d RCS -a -f RCS/xycmbt10.mf,v && co xycmbt10.mf || :
xycmtip.doc:; test -d RCS -a -f RCS/xycmtip.doc,v && co xycmtip.doc || :
xycolor.doc:; test -d RCS -a -f RCS/xycolor.doc,v && co xycolor.doc || :
xycurve.doc:; test -d RCS -a -f RCS/xycurve.doc,v && co xycurve.doc || :
xyd.mf:; test -d RCS -a -f RCS/xyd.mf,v && co xyd.mf || :
xyd2.mf:; test -d RCS -a -f RCS/xyd2.mf,v && co xyd2.mf || :
xydash10.mf:; test -d RCS -a -f RCS/xydash10.mf,v && co xydash10.mf || :
xydoc.bib:; test -d RCS -a -f RCS/xydoc.bib,v && co xydoc.bib || :
xydoc.sty:; test -d RCS -a -f RCS/xydoc.sty,v && co xydoc.sty || :
xydummy.doc:; test -d RCS -a -f RCS/xydummy.doc,v && co xydummy.doc || :
xyframe.doc:; test -d RCS -a -f RCS/xyframe.doc,v && co xyframe.doc || :
xygraph.doc:; test -d RCS -a -f RCS/xygraph.doc,v && co xygraph.doc || :
xyguide.man:; test -d RCS -a -f RCS/xyguide.man,v && co xyguide.man || :
xyidioms.doc:; test -d RCS -a -f RCS/xyidioms.doc,v && co xyidioms.doc || :
xyknot.doc:; test -d RCS -a -f RCS/xyknot.doc,v && co xyknot.doc || :
xylatex.ini:; test -d RCS -a -f RCS/xylatex.ini,v && co xylatex.ini || :
xyamslatex.ini:; test -d RCS -a -f RCS/xyamslatex.ini,v && co xyamslatex.ini || :
xyline.doc:; test -d RCS -a -f RCS/xyline.doc,v && co xyline.doc || :
xymatrix.doc:; test -d RCS -a -f RCS/xymatrix.doc,v && co xymatrix.doc || :
xypic.doc:; test -d RCS -a -f RCS/xypic.doc,v && co xypic.doc || :
xypic.sty:; test -d RCS -a -f RCS/xypic.sty,v && co xypic.sty || :
xypoly.doc:; test -d RCS -a -f RCS/xypoly.doc,v && co xypoly.doc || :
xyps-c.doc:; test -d RCS -a -f RCS/xyps-c.doc,v && co xyps-c.doc || :
xyps-col.doc:; test -d RCS -a -f RCS/xyps-col.doc,v && co xyps-col.doc || :
xyps-dto.doc:; test -d RCS -a -f RCS/xyps-dto.doc,v && co xyps-dto.doc || :
xyps-dvi.doc:; test -d RCS -a -f RCS/xyps-dvi.doc,v && co xyps-dvi.doc || :
xyps-l.doc:; test -d RCS -a -f RCS/xyps-l.doc,v && co xyps-l.doc || :
xyps-one.doc:; test -d RCS -a -f RCS/xyps-one.doc,v && co xyps-one.doc || :
xyps-oz.doc:; test -d RCS -a -f RCS/xyps-oz.doc,v && co xyps-oz.doc || :
xyps-pub.doc:; test -d RCS -a -f RCS/xyps-pub.doc,v && co xyps-pub.doc || :
xyps-r.doc:; test -d RCS -a -f RCS/xyps-r.doc,v && co xyps-r.doc || :
xyps-txt.doc:; test -d RCS -a -f RCS/xyps-txt.doc,v && co xyps-txt.doc || :
xyps-wdo.doc:; test -d RCS -a -f RCS/xyps-wdo.doc,v && co xyps-wdo.doc || :
xyps.doc:; test -d RCS -a -f RCS/xyps.doc,v && co xyps.doc || :
xypsdict.doc:; test -d RCS -a -f RCS/xypsdict.doc,v && co xypsdict.doc || :
xyrefer.man:; test -d RCS -a -f RCS/xyrefer.man,v && co xyrefer.man || :
xyrotate.doc:; test -d RCS -a -f RCS/xyrotate.doc,v && co xyrotate.doc || :
xysource.man:; test -d RCS -a -f RCS/xysource.man,v && co xysource.man || :
xytex.ini:; test -d RCS -a -f RCS/xytex.ini,v && co xytex.ini || :
xyv2.doc:; test -d RCS -a -f RCS/xyv2.doc,v && co xyv2.doc || :

Xy-pic.html:; test -d RCS -a -f RCS/Xy-pic.html,v && co Xy-pic.html || :
Xy-pic.blurb:; test -d RCS -a -f RCS/Xy-pic.blurb,v && co Xy-pic.blurb || :
Xy-pic.xbm:; test -d RCS -a -f RCS/Xy-pic.xbm,v && co Xy-pic.xbm || :


# LOG
#
# $Log: Makefile,v $
# Revision 2.12  1994/10/25  11:46:25  kris
# Interim release just before v3 [works with AMS-LaTeX 1.2]...
#
# Revision 2.11  1994/07/05  10:37:32  kris
# Third 3beta release [bug fixes].
# Experimental graph feature included (for ECCT-94 presentation).
#
# Revision 2.10  1994/06/15  13:35:19  kris
# Second 3beta release [bug fixes].
#
# Revision 2.9  1994/06/09  14:53:07  kris
# Release 3beta.
#
# Revision 2.8  1994/04/08  04:30:00  kris
# Second (bug fix) 3alpha release.
#
# Revision 2.7  1994/03/08  02:06:01  kris
# Release 3alpha.
#
# Revision 2.6.9.1  1994/03/07  04:22:46  kris
# Last internal 3alpha and pre-2.7 release.
#
# MAJOR REORGANISATION for version 2.7...
#
# Revision 2.6  1992/06/24  01:23:34  kris
# Ready to release v.2.6.
#
# Revision 2.5  1992/02/24  03:30:54  kris
# Default magsteps now just 0, 0.5, 1, and 2.
#
# Revision 2.3  1992/01/13  02:12:28  kris
# Fixed installation instructions and other details.
#
# Revision 2.1  1992/01/02  14:54:07  kris
# Release version.
#
# Revision 1.6  1991/12/17  04:51:16  kris
# Version distributed with `final draft' on Usenet.

# Tell Emacs that this is a Makefile and how it is formatted:
# Local Variables:
# mode:fundamental
# fill-prefix:"# "
# fill-column:77
# End:
