# /u/ftp/pub/makefile, Fri Jun  4 12:26:31 1999
# Edit by Nelson H. F. Beebe <beebe@math.utah.edu>
# Extend DELETE-SELECTED to include html files; for some time, the
# 00*dir.* files have been unnecessarily regenerated daily because of
# that bug, sigh...
#
# /u/ftp/pub/makefile, Wed Feb 24 05:53:19 1999
# Edit by Nelson H. F. Beebe <beebe@math.utah.edu>
# Filter out "/incoming$" from report of ftp protection problems:
# some users now have private /incoming directores with protection
# drwx-wx-wx.
#
# /u/ftp/pub/makefile, Thu Feb 18 18:10:31 1999
# Edit by Nelson H. F. Beebe <beebe@math.utah.edu>
# Add FIND variable and IDXPRUNE filter to speed up find, by
# eliminating traversal of the large tex/bib/idx directory tree
#
# /u/ftp/pub/makefile, Sat Jul 18 08:13:57 1998
# Edit by Nelson H. F. Beebe <beebe@math.utah.edu>
# Remove misc/* subdirectories
#
# /u/ftp/pub/makefile, Tue Jun 23 19:18:21 1998
# Edit by Nelson H. F. Beebe <beebe@math.utah.edu>
# Add new emacs subdirectory to DIRS list.
#
# /u/ftp/pub/makefile, Mon Apr 27 08:18:58 1998
# Edit by Super-User <root@math.utah.edu>
# Update mupad directory lists
#
# /u/ftp/pub/makefile, Fri Feb 20 09:05:16 1998
# Edit by Super-User <root@sundown.math.utah.edu>
# Update mupad directory lists
#
# /u/ftp/pub/makefile, Wed Feb 11 10:40:51 1998
# Edit by Nelson H. F. Beebe <beebe@csc-sun.math.utah.edu>
# Remove tuglib from "all" target; there is a separate cron job
# on csc-sun.math.utah.edu that updates tuglib files.
#
# /u/ftp/pub/makefile, Fri Oct 17 18:00:48 1997
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Add fyi and std directories to DIRS.
#
# /u/ftp/pub/makefile, Mon Sep 15 15:25:38 1997
# Edit by Nelson H. F. Beebe <beebe@chamberlin.math.utah.edu>
# Change to use gzip instead of compress.  As of today, all
# compressed files in this tree have been converted to
# gzip form instead, except for the pub/mupad tree, which is
# mirrored from elsewhere, and has .Z files.
# Change all uses of ln to $(LN).
#
# /u/ftp/pub/makefile, Tue May 13 08:27:14 1997
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Add /u tree to INDEX target commands
#
# /u/ftp/pub/makefile, Fri Mar 28 13:01:22 1997
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Update DIRS with new emtex directory
#
# /u/ftp/pub/makefile, Thu Jan 16 11:11:27 1997
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Update DIRS with new mupad directories
#
# /u/ftp/pub/makefile, Mon Nov 25 06:28:42 1996
# Edit by Nelson H. F. Beebe <beebe@chamberlin.math.utah.edu>
# Update DIRS with new mupad directories
#
# /u/ftp/pub/makefile, Fri Oct  4 16:16:07 1996
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Update with additional code in lastnn target to create
# *.html files for all 00last*.lst and 00tdir*.lst directory
# listings.
#
# /u/ftp/pub/makefile, Thu Oct  3 18:24:20 1996
# Edit by Nelson H. F. Beebe <beebe@chamberlin.math.utah.edu>
# Update with new lastnn target, and targets to make directory
# listings of files newer than 7, 14, 30, 60, 90, 120, 150, 180,
# 270 and 365 days.
# Add ../index to the list of files for which .html files are
# created.
# Add .. to the DIRS list, since there are 00*.* files needed
# there too.
# Correct test in htmlfiles target for comparing write date
# of indextohtml.awk with index.html; it previously incorrectly
# compared against the date of index.
#
# /u/ftp/pub/makefile, Tue Apr 18 18:24:28 1995
# Edit by Nelson H. F. Beebe <beebe@chamberlin.math.utah.edu>
# Update with new htmlfiles and dirlst_u targets for maintaining
# HTML index files in each directory of both pub and u.
#
# /u/ftp/pub/makefile, Mon Apr  3 14:40:39 1995
# Edit by Nelson H. F. Beebe <beebe@chamberlin.math.utah.edu>
# Update with one more mupad directory in DIRS.
#
# /u/ftp/pub/makefile, Thu Mar  9 08:29:39 1995
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Make minor correction in CHECK-PROTECTIONS target.
#
# /u/ftp/pub/makefile, Sat Mar  4 13:10:22 1995
# Edit by Nelson H. F. Beebe <beebe@chamberlin.math.utah.edu>
# Add absolute paths for Mail and mail.  Add MANAGER variable.
#
# /u/ftp/pub/makefile, Mon Feb 27 13:02:08 1995
# Edit by Nelson H. F. Beebe <beebe@chamberlin.math.utah.edu>
# Add CHECK-INCOMING target
#
# /u/ftp/pub/makefile, Fri Nov 11 19:14:44 1994
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Update LS definition for Sun Solaris 2.x, and update DIRS
#
# /u/ftp/pub/makefile, Thu Sep  1 12:16:37 1994
# Edit by Pieter Bowman <bowman@chamberlin.math.utah.edu>
# Change for running on chamberlin.math.utah.edu
#
# /u/ftp/pub/makefile, Thu May 26 07:53:39 1994
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Remove /outgoing from list of files for which lack of read access
# produces a warning message---for security reasons, it no longer has
# read access.
#
# /u/ftp/pub/makefile, Sat Apr  2 12:20:45 1994
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Add benchmarks/x11perf and bibnet directories
#
# /u/ftp/pub/makefile, Wed Aug 18 15:06:07 1993
# Edit by Nelson H. F. Beebe <beebe@csc-sun.math.utah.edu>
# Use find instead of grep on ls-lR in CHECK-PROTECTIONS target to get
# full path names.
#
# /u/ftp/pub/makefile, Mon May 10 11:28:02 1993
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Add solaris subdirectory
#
# /u/ftp/pub/makefile, Tue Apr 20 11:52:52 1993
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Add new makeindex directories.  Change `hostname` to $(HOSTNAME), to
# encourage use of ftp.math.utah.edu instead of csc-sun.math.utah.edu,
# since we may move this service to a new machine in the near future.
# Change `pwd` to $(PWD) to massage file names into absolute ftp paths.
#
# /usr/spool/ftpftp/pub/makefile, Mon Nov 23 09:16:31 1992
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Add tex/apstex30 directory.
#
# /usr/spool/ftpftp/pub/makefile, Fri Jul 17 12:28:46 1992
# Edit by Nelson H. F. Beebe <beebe@csc-sun.math.utah.edu>
# Simplify CHECK-PROTECTIONS grepping
#
# /usr/spool/ftpftp/pub/makefile, Tue Jul  7 12:44:37 1992
# Edit by Operator <root@csc-sun.math.utah.edu>
# Add CHECK-PROTECTIONS step to catch file protection
# problems
#
# /usr/spool/ftpftp/pub/makefile, Tue Jun 30 09:40:23 1992
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Change ls to $(LS); Sun has both Berkeley and SysV versions
# and we want only to the Berkeley version, /bin/ls, here
#
# /usr/spool/ftpftp/pub/makefile, Sat Jun 27 07:35:37 1992
# Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
# Add ls-lrt and ls-lrt.z targets
#
# /usr/spool/ftpftp/pub/makefile, Fri Jun 19 10:24:12 1992
# Edit by Nelson H. F. Beebe <beebe@math.utah.edu>
# Add ls-lr and ls-lr.z targets
#
# /usr/spool/ftpftp/pub/makefile, Tue Nov 26 07:26:51 1991
# Edit by Operator <root@csc-sun.math.utah.edu>
# add ftp/awk
#
# /usr/spool/ftpftp/pub/makefile, Mon Nov  4 14:03:14 1991
# Edit by Operator <root@csc-sun.math.utah.edu>
# Add ibmpc/kermit
#
# /usr/spool/ftpftp/pub/makefile, Sat Nov  2 11:18:52 1991
# Edit by Operator <root@csc-sun.math.utah.edu>
#
# /usr/spool/ftpftp/pub/makefile, Fri Nov  1 08:33:50 1991
# Edit by Operator <root@csc-sun.math.utah.edu>
#
# /usr/spool/ftpftp/pub/makefile, Sat Oct 19 17:41:37 1991
# Edit by Nelson H. F. Beebe <beebe@magna.math.utah.edu>
#
# /usr/spool/ftpftp/pub/makefile, Tue Oct 15 14:13:15 1991
# Edit by Operator <root@csc-sun.math.utah.edu>
#
# /usr/spool/ftpftp/pub/makefile, Tue Oct  8 11:51:15 1991
# Edit by Nelson H. F. Beebe <beebe@magna.math.utah.edu>
#
# /usr/spool/ftpftp/pub/makefile, Wed Oct  2 18:15:20 1991
# Edit by Operator <root@csc-sun.math.utah.edu>
#
# /usr/spool/ftpftp/pub/Makefile, Mon May 20 17:57:17 1991
# Edit by Nelson H. F. Beebe <beebe@math.utah.edu>
#
#=======================================================================
# Makefile for creating directory listings in ~ftp/pub file tree
#
# The 00*dir.lst and 00last*days.lst files contain shortened
# output from "ls -l" or equivalents, so as to keep the file line
# widths short.  This is because the tuglib e-mail server has to
# encode any file with lines longer than 80 characters, and we
# want to be able to send these files in plain text.
#
# The 00*dir.cmd and 00last* files exclude directories; these cannot
# be ftp'ed, and anyway, they change whenever the 00* files are
# updated.
#
# The ls-lr (ls-lR) and ls-lrt (ls-lRt) files contain a recursive
# anonymous ftp directory tree listing made by "ls -lR" (alphabetical)
# and "ls -lRt" (reverse time order) respectively.  Their compressed
# versions are retrieved by archie servers so that this archive is
# included in the archie data base.  archie servers exist on at least
# these hosts: archie.mcgill.ca, archie.funet.fi, archie.au,
# archie.sura.net, and archie.ans.net
#
# [04-Mar-1995]
#=======================================================================

# Use either nawk or gawk
AWK		= gawk
AWK		= nawk

# Filter to turn "find ... -ls" output into "ls -l" output
AWKFIND         = awk '{printf("%10s%3s %-8s%9s %-3s%3s%6s %s\n",\
		$$3,$$4,$$5,$$7,$$8,$$9,$$10,$$11)}'

# Shortened form of "ls -l" with total, size-in-blocks, and owner fields
# discarded
AWKSHORT        = 	awk '/^[^t]/ {printf("%10s%9s %-3s%3s%6s %s\n",\
		$$1,$$4,$$5,$$6,$$7,$$8)}'

CMP		= cmp

CRC		= /u/ftp/bin/crc

# This filter removes Date, 00*dir.*, and index lines from 00*dir.lst
# files for comparison purposes.
DELETE-SELECTED	= egrep -v '00t?dir[.](cmd|lst|html)| index|^. Date:'

# Warning: do NOT include directories here which are symlinks.  Just
# in case you do, the loop below in the dirlst target will ignore
# them.

DIRS            = .. . awk awkpretty benchmarks benchmarks/x11perf bibnet \
		  bibnet/authors bibnet/authors/a bibnet/authors/b \
		  bibnet/authors/c bibnet/authors/d bibnet/authors/e \
		  bibnet/authors/f bibnet/authors/g bibnet/authors/h \
		  bibnet/authors/i bibnet/authors/j bibnet/authors/k \
		  bibnet/authors/l bibnet/authors/m bibnet/authors/n \
		  bibnet/authors/o bibnet/authors/p bibnet/authors/q \
		  bibnet/authors/r bibnet/authors/s bibnet/authors/t \
		  bibnet/authors/u bibnet/authors/v bibnet/authors/w \
		  bibnet/authors/x bibnet/authors/y bibnet/authors/z \
		  bibnet/institutions bibnet/journals bibnet/subjects \
		  bibnet/tools bibnet/tools/emacs bibnet/tools/examples \
		  bibnet/tools/software bibnet/tools/strings dec-alpha doc \
		  elefunt emacs ibmpc ibmpc/indexdir ibmpc/arc-lst \
		  ibmpc/kermit ibmpc/simteldir macintosh math math/contest \
		  math/doc math/src math/src/coxeter mathbio mf mf/cm \
		  mf/macros mf/pandora mf/pandora/pandora mf/ransom mg \
		  mg/mg-1.3x misc \
		  mupad \
		  mupad/mathpad \
		  mupad/doc \
		  mupad/contrib \
		  mupad/paper/ode-demos \
		  mupad/paper \
		  mupad/support \
		  mupad/distrib/windows \
		  mupad/distrib/macintosh \
		  mupad/distrib/unix \
		  mupad/distrib \
		  rfc rfc/fyi rfc/std rfc/rfc-editor \
		  sgml solaris tex tex/apstex30 tex/authidx \
		  tex/bib tex/bibtex tex/bibtex/astron \
		  tex/bibtex/big tex/bibtex/mac tex/dosfonts tex/dvi \
		  tex/dvi/cxref tex/dvi/doc tex/dviold tex/dviold/doc \
		  tex/errata tex/errata/impatient tex/errata/sewell tex/fonts \
		  tex/mail tex/pub tex/pub/afm tex/pub/aps tex/pub/changebar \
		  tex/pub/chem tex/pub/checksum-1.03 \
		  tex/pub/checksum-1.03/ibmpcdos tex/pub/checksum-1.03/vaxvms \
		  tex/pub/checksum-1.04 tex/pub/checksum-1.04/applemac \
		  tex/pub/checksum-1.04/ibmpcdos tex/pub/checksum-1.04/vaxvms \
		  tex/pub/checksum-1.06 tex/pub/checksum-1.06/alphavms \
		  tex/pub/checksum-1.06/ibmpcdos tex/pub/checksum-1.06/vaxvms \
		  tex/pub/chess tex/pub/cscope tex/pub/cweb \
		  tex/pub/cweb/cweb-0-5 tex/pub/cweb/cweb-2-7 \
		  tex/pub/cweb/cweb-2-8 tex/pub/decus tex/pub/detex \
		  tex/pub/dotex tex/pub/dvidoc tex/pub/dviln03 \
		  tex/pub/dvi2tty tex/pub/dvitty tex/pub/emtex tex/pub/epic \
		  tex/pub/fonttool tex/pub/genealogy tex/pub/german \
		  tex/pub/gnuindex tex/pub/idx-index tex/pub/index-cite \
		  tex/pub/info tex/pub/iran tex/pub/jtex tex/pub/jtex/jisfont \
		  tex/pub/jtex/minijtex tex/pub/latex-index tex/pub/latexinfo \
		  tex/pub/lgraph tex/pub/local-guide tex/pub/make \
		  tex/pub/makeindex tex/pub/makeindex/2-02 \
		  tex/pub/makeindex/2-09 tex/pub/makeindex/2-10 \
		  tex/pub/makeindex/2-11 tex/pub/makeindex/2-12 \
		  tex/pub/mathematica tex/pub/mitqms tex/pub/music \
		  tex/pub/newidx tex/pub/paper tex/pub/patashnik \
		  tex/pub/patch tex/pub/pcmake tex/pub/psfig tex/pub/r2bib \
		  tex/pub/s2latex tex/pub/sewell tex/pub/slitex-fonts \
		  tex/pub/texhax tex/pub/tgrind tex/pub/tib tex/pub/tib2 \
		  tex/pub/tib3 tex/pub/troff-to-tex tex/pub/tugboat \
		  tex/pub/undump tex/pub/wd2latex tex/pub/web \
		  tex/pub/wp2latex tex/pub/xhmeia tex/siam ultrix uuthesis \
		  uuthesis/samplethesis209 uuthesis/samplethesis2e \
		  vax vax/arc vax/compress vax/vmstar xdvi

# Filter to remove 00last*.* and 00*dir*.* files from "find ... -ls" listings
EGREP           = egrep -v '/00(last.*days|t?dir)\.(cmd|lst)'

GNULS		= /usr/local/bin/ls

GREP		= grep

GZIP		= /usr/local/bin/gzip

HEAD		= head

HOSTNAME	= `uname -n | /bin/sed -e 's/chamberlin/ftp/'`

HTMLCHECK	= /usr/local/bin/html-check

IDXPRUNE	= \( -name idx -type d \) -prune -o

INDEXTOHTML	= $(AWK) -f $(INDEXTOHTMLFILE)
INDEXTOHTMLFILE	= $(TOP)/misc/indextohtml.awk
INDEXTOHTMLFLAGS = -v HEADER=1 -v INDENT=1

# Filter to remove 00last*, 00*dir*, and directories from "ls -l" listings
LASTFILTER      = $(EGREP) | $(AWKFIND) | $(AWKSHORT) | grep -v '^d' | \
		sort -f +5

LN		= /bin/ln

# NB: On Sun Solaris 2.x, need -g switch on ls so that the awk
# programs for creating 00*dir.* files work.
LS		= /bin/ls
LS		= /bin/ls -g

LSR		= /u/ftp/bin/lsr

LSTOHTML	= $(AWK) -f $(LSTOHTMLFILE)
LSTOHTMLFILE	= $(TOP)/misc/lstohtml.awk
LSTOHTMLFLAGS	= -v INDENT=1

LSTOINDEXHTMLTABLEFILE = $(TOP)/misc/ls-to-index-html-table.awk
LSTOINDEXHTMLTABLE = $(GNULS) -l --full-time | $(AWK) -f $(LSTOINDEXHTMLTABLEFILE) $(LSTOINDEXHTMLTABLEFLAGS)
LSTOINDEXHTMLTABLEFLAGS = -v AFTER=index.after -v BEFORE=index.before -v DIRCOLS=3 -v INDENT=2

FIND		= /bin/find

FTPROOT         = $(TOP)/..

# Customize this line to your installation
MANAGER		= beebe

MV		= mv

NEWER		= $(TOP)/newer

PACKAGEINDEX	= .PACKAGEINDEX

PWDFILTER	= `pwd | /bin/sed -e 's@/export/home/[0-9][0-9][0-9][0-9]/ftp/@/@' \
		   -e 's@/home/[0-9][0-9][0-9][0-9]/ftp/@/@' \
		   -e 's@/u/ftp/@/@' `

RM		= /bin/rm -f

# This one must be true path name, not $(PWDFILTER).
TOP             = /u/ftp/pub

WWW		= http://www.math.utah.edu
WWWFTP		= $(WWW)

#=======================================================================

# [20-Jan-2000] Move INDEX file from after netlib-crc to before htmlfiles
all:      time-begin dirlst dirlst_u INDEX htmlfiles htmlfiles-2 \
	  CHECK-PROTECTIONS netlib-crc ls-lr.gz ls-lrt.gz last7 \
	  last14 last30 last60 last90 last120 last150 last180 last270 \
	  last365 CHECK-CORE-DUMPS CHECK-INCOMING time-end

# Errors should not terminate makes with this file
.IGNORE:

CHECK-CORE-DUMPS:	INDEX
	-grep '/core$$' INDEX >/tmp/CHECK-CORE-DUMPS
	if [ -s /tmp/CHECK-CORE-DUMPS ] ; \
	then \
		/usr/ucb/Mail -s "ftp core dumps" $(MANAGER) </tmp/CHECK-CORE-DUMPS ; \
	fi
	-$(RM) /tmp/CHECK-CORE-DUMPS

CHECK-INCOMING:
	-ls -l /u/ftp/incoming | grep -v 'total 0' >/tmp/CHECK-INCOMING
	if [ -s /tmp/CHECK-INCOMING ] ; \
	then \
		/usr/ucb/Mail -s "ftp incoming" $(MANAGER) </tmp/CHECK-INCOMING ; \
	fi
	-$(RM) /tmp/CHECK-INCOMING

# This has intentionally no dependents, even though it depends on
# ls-lr.  Check file protections to make sure that all are readable
# except for those in the etc directory that must be hidden.

# FTPHOME needs to be an absolute path, rather than a symbolic link,
# since find otherwise quits immediately.
FTPHOME=/home/2001/ftp

CHECK-PROTECTIONS:
	$(FIND) $(FTPHOME) $(IDXPRUNE) ! -perm -444 -ls | \
		grep -v $(FTPHOME)'.*[.]notar$$' | \
		grep -v $(FTPHOME)'/incoming$$' | \
		grep -v $(FTPHOME)'/outgoing$$' | \
		grep -v $(FTPHOME)'/usr/bin/' | \
		grep -v $(FTPHOME)'/etc' | \
		grep -v '/incoming$$' >/tmp/CHECK-PROTECTIONS
	if [ -s /tmp/CHECK-PROTECTIONS ] ; \
	then \
		/usr/ucb/Mail -s "ftp protections" $(MANAGER) </tmp/CHECK-PROTECTIONS ; \
	fi
	-$(RM) /tmp/CHECK-PROTECTIONS

chmod:
	chmod -R o+r *


# Remove editor backup files in entire tree
clean:
	$(FIND) . $(IDXPRUNE) \( -name '*~' -o -name '.*~' \) -print | xargs /bin/rm

clobber:	clean

# [17-Jun-1994] Following suggestion on TeXhax for CTAN archive sites, create
# directory listings in /tmp, and only update them if they have changed, so
# that directory time stamps are not unnecessarily modified.  Because the
# 00*dir.lst files contain a date stamp line, we have to exclude that line in
# the comparisons, as well as the listing lines for the 00*dir.* and index files
# themselves.
# [14-May-1999] Add test to skip directories which are symlinks to
# other directories; otherwise, the 00*dir.html files created will
# have erroneous hypertext links in them.
dirlst:
	for dir in $(DIRS) ; \
	do \
		if [ ! -d $$dir ] ; \
		then \
			echo $$dir | /usr/ucb/Mail -s "ftp: bad directory" $(MANAGER) ; \
			continue ; \
		fi ; \
		if [ -h $$dir ] ; \
		then \
			continue ; \
		fi ; \
		echo $$dir ; \
		cd $$dir ; \
		if [ ! -f 00dir.lst ] ; then touch 00dir.lst ; fi ; \
		if [ ! -f 00dir.cmd ] ; then touch 00dir.cmd ; fi ; \
		if [ ! -f 00tdir.lst ] ; then touch 00tdir.lst ; fi ; \
		if [ ! -f 00tdir.cmd ] ; then touch 00tdir.cmd ; fi ; \
		echo "# Alphabetical file listing" >/tmp/00dir.lst ; \
		echo "# Host:      $(HOSTNAME)" >>/tmp/00dir.lst ; \
		echo "# Directory: $(PWDFILTER)" >>/tmp/00dir.lst ; \
		echo "# Date:      `date`" >>/tmp/00dir.lst ; \
		echo "# PROTECTION  BYTES  LAST-WRITE  FILENAME" >>/tmp/00dir.lst ; \
		$(LS) -lL | $(AWKSHORT) >>/tmp/00dir.lst ; \
		awk '/^[-l]/ {print "get " $$6}' </tmp/00dir.lst >/tmp/00dir.cmd ; \
		echo "# Reverse time ordered file listing" >/tmp/00tdir.lst ; \
		echo "# Host:      $(HOSTNAME)" >>/tmp/00tdir.lst ; \
		echo "# Directory: $(PWDFILTER)" >>/tmp/00tdir.lst ; \
		echo "# Date:      `date`" >>/tmp/00tdir.lst ; \
		echo "# PROTECTION  BYTES  LAST-WRITE  FILENAME" >>/tmp/00tdir.lst ; \
		$(LS) -lLt | $(AWKSHORT) >>/tmp/00tdir.lst ; \
		awk '/^[-l]/ {print "get " $$6}' </tmp/00tdir.lst >/tmp/00tdir.cmd ; \
		chmod o+r /tmp/00* ; \
		$(DELETE-SELECTED) 00dir.lst >/tmp/00dir.lst.1 ; \
		$(DELETE-SELECTED) /tmp/00dir.lst >/tmp/00dir.lst.2 ; \
		$(DELETE-SELECTED) 00tdir.lst >/tmp/00tdir.lst.1 ; \
		$(DELETE-SELECTED) /tmp/00tdir.lst >/tmp/00tdir.lst.2 ; \
		if $(CMP) -s /tmp/00dir.lst.1 /tmp/00dir.lst.2  ; \
		then true ; else /bin/cp /tmp/00dir.lst 00dir.lst ; fi ; \
		if $(CMP) -s /tmp/00dir.cmd 00dir.cmd  ; \
		then true ; else /bin/cp /tmp/00dir.cmd 00dir.cmd ; fi ; \
		if $(CMP) -s /tmp/00tdir.lst.1 /tmp/00tdir.lst.2 ; \
		then true ; else /bin/cp /tmp/00tdir.lst 00tdir.lst ; fi ; \
		if $(CMP) -s /tmp/00tdir.cmd 00tdir.cmd  ; \
		then true ; else /bin/cp /tmp/00tdir.cmd 00tdir.cmd ; fi ; \
		if $(NEWER) 00dir.lst 00dir.html || $(NEWER) $(LSTOHTMLFILE) 00dir.html ; \
		then $(LSTOHTML) $(LSTOHTMLFLAGS) -v PREFIX=$(WWWFTP) -v FILE=$$dir/00dir.lst 00dir.lst >00dir.html; \
		fi ; \
		if $(NEWER) 00tdir.lst 00tdir.html || $(NEWER) $(LSTOHTMLFILE) 00tdir.html ; \
		then $(LSTOHTML) $(LSTOHTMLFLAGS) -v PREFIX=$(WWWFTP) -v FILE=$$dir/00tdir.lst 00tdir.lst >00tdir.html ; \
		fi ; \
		cd $(TOP) ; \
		/bin/rm -f /tmp/00*dir.* ; \
	done

# For every directory in the math user tree, u, create 00*dir.* files,
# and if an index file does not exist, create a symbolic link to it
# from 00dir.lst.
dirlst_u:
	$(FIND) ../u -type d -print | sort >/tmp/u-dirs.lst
	$(MAKE) DIRS='`cat /tmp/u-dirs.lst`' dirlst
	for dir in `cat /tmp/u-dirs.lst` ; \
	do \
	    if [ ! -f $$dir/index ] ; then $(LN) -s 00dir.lst $$dir/index ; fi ; \
	done
	$(RM) /tmp/u-dirs.lst

# Dummy target for force make to do something
FRC:

# For every index file in the pub and u trees, and in .., make a
# corresponding index.html file if one doesn't exist, or is out of
# date.
#
# To save time, because the tree is very large, and a find in it now
# takes about 5 min wallclock time, we search the top-level INDEX file
# instead.  There are 1400+ index files in the tree, and this target
# takes 7m15s wallclock time on a Sun SPARC 20/512 server.
#
# Unfortunately, make has no syntax for a rule for converting a
# file without an extension to one with an extension, so we use a
# small helper utility, newer (source code, newer.c, in this
# directory), for doing the necessary time stamp checking.

#OLD:	$(FIND) pub $(IDXPRUNE) -name index -print | \
#OLD:		grep -v '/RCS/' | \
#OLD:		sort >/tmp/index-files.lst ; \
#OLD:	$(FIND) u -name index -print | \
#OLD:		grep -v '/RCS/' | \
#OLD:		sort >>/tmp/index-files.lst ; \

htmlfiles:
	(cd ..; \
	$(AWK) -F/ '$$NF == "index" {print substr($$0,2)}' INDEX | \
		$(GREP) -v pub/mirrors > /tmp/index-files.lst ; \
	for f in index `cat /tmp/index-files.lst` ; \
	do \
	    if $(NEWER) $$f $$f.html || $(NEWER)  $(INDEXTOHTMLFILE) $$f.html ; \
	    then \
		echo Making $$f.html ... ; \
		$(INDEXTOHTML) $(INDEXTOHTMLFLAGS) -v PREFIX=$(WWWFTP) -v FILE=/$$f $$f >$$f.html ; \
		$(HTMLCHECK) $$f.html 2>&1 | egrep -v '[.][.][.]$$|[.][.][.] valid' ; \
	    fi ; \
	done ; \
	$(RM) /tmp/index-files.lst \
	)

# For every .PACKAGEINDEX file in the tree, make a corresponding
# index.html file if one doesn't exist, or is out of date.  This is an
# improved way of constructing index.html files, compared to that used
# in the preceding htmlfiles target, and gradually, we will change to
# this new system.
#
# To save time, because the tree is very large, and a find in it now
# takes about 5 min wallclock time, we search the top-level INDEX file
# instead.  This target then takes about 5 sec when an index.html file
# has to be created, and about 2 sec otherwise, on a Sun Enterprise
# 5500 server.
#
# Unfortunately, make has no syntax for a rule for converting a file
# without an extension to one with an extension, so we use a small
# helper utility, newer (source code, newer.c, in this directory), for
# doing the necessary time stamp checking.

htmlfiles-2:
	(cd ..; \
	$(AWK) -F/ '$$NF == "'$(PACKAGEINDEX)'" {print substr($$0,2)}' INDEX \
		> /tmp/index-files.lst ; \
	for f in `cat /tmp/index-files.lst` ; \
	do \
	    d=`dirname $$f` ; \
	    g=`basename $$f` ; \
	    (cd $$d ; \
	    newestfile=`$(LS) -1 -t | $(GREP) -v 'index[.]html' | $(HEAD) -1` ; \
	    if $(NEWER) $$g index.html || \
		$(NEWER) $(LSTOINDEXHTMLTABLEFILE) index.html || \
		$(NEWER) $$newestfile index.html ; \
	    then \
		echo Making $$d/index.html ... ; \
		$(LSTOINDEXHTMLTABLE) >index.html ; \
		$(HTMLCHECK) index.html 2>&1 | egrep -v '[.][.][.]$$|[.][.][.] valid' ; \
	    fi ; \
	    ) ; \
	done ; \
	$(RM) /tmp/index-files.lst \
	)

# The INDEX file excludes the bibliography index files (through the
# IDXPRUNE selection), because there are several hundred thousand of
# them, and they are not required except for online bibliography index
# searching.  It is updated only if it differs from the previous one.
INDEX:	FRC
	$(FIND) . $(IDXPRUNE) ! -type d -print | sed -e 's@^[.]/@/pub/@' | sort >INDEX.tmp
	$(FIND) ../u -print | sed -e 's@^[.][.]@@' | sort >>INDEX.tmp
	if $(CMP) -s INDEX INDEX.tmp ; \
	then \
	    $(RM) INDEX.tmp ; \
	else \
	    $(RM) INDEX ../INDEX ; \
	    $(MV) INDEX.tmp INDEX ; \
	    $(LN) INDEX ../INDEX ; \
	fi

last7:
	$(MAKE) DAYS=7 lastnn

last14:
	$(MAKE) DAYS=14 lastnn

last30:
	$(MAKE) DAYS=30 lastnn

last60:
	$(MAKE) DAYS=60 lastnn

last90:
	$(MAKE) DAYS=90 lastnn

last120:
	$(MAKE) DAYS=120 lastnn

last150:
	$(MAKE) DAYS=150 lastnn

last180:
	$(MAKE) DAYS=180 lastnn

last270:
	$(MAKE) DAYS=270 lastnn

last365:
	$(MAKE) DAYS=365 lastnn

lastnn:
	echo "# Files changed in last $(DAYS) days" >00last$(DAYS)days.lst;\
	echo "# Host:      $(HOSTNAME)" >>00last$(DAYS)days.lst;\
	echo "# Directory: $(PWDFILTER)" >>00last$(DAYS)days.lst;\
	echo "# Date:      `date`" >>00last$(DAYS)days.lst;\
	echo "# PROTECTION  BYTES  LAST-WRITE  FILENAME"  >>00last$(DAYS)days.lst;\
	$(FIND) . $(IDXPRUNE) -mtime `expr -$(DAYS) - 1` -ls | $(LASTFILTER) >>00last$(DAYS)days.lst;\
	awk '/^[-l]/ {print "get " $$6}' <00last$(DAYS)days.lst >00last$(DAYS)days.cmd
	echo '# FILES IN REVERSE TIME ORDER (excluding index files)' \
		>00tdir$(DAYS)days.lst
	grep '^# ' 00last$(DAYS)days.lst >>00tdir$(DAYS)days.lst
	egrep -v '^# |/index$$' 00last$(DAYS)days.lst |\
		sort +2Mr -3 +3nr -4 +4nr -5 +5 >>00tdir$(DAYS)days.lst
	awk '/^[-l]/ {print "get " $$6}' <00tdir$(DAYS)days.lst >00tdir$(DAYS)days.cmd
	if $(NEWER) 00last$(DAYS)days.lst 00last$(DAYS)days.html || $(NEWER) $(LSTOHTMLFILE) 00last$(DAYS)days.html ; \
	then \
	    echo Making 00last$(DAYS)days.html ... ; \
	    $(LSTOHTML) $(LSTOHTMLFLAGS) -v PREFIX=$(WWWFTP) -v FILE=/00last$(DAYS)days.html 00last$(DAYS)days.lst >00last$(DAYS)days.html ; \
	    $(HTMLCHECK) 00last$(DAYS)days.html 2>&1 | egrep -v '[.][.][.]$$|[.][.][.] valid' ; \
	fi
	if $(NEWER) 00tdir$(DAYS)days.lst 00tdir$(DAYS)days.html || $(NEWER) pub/misc/lstohtml.awk 00tdir$(DAYS)days.html ; \
	then \
	    echo Making 00tdir$(DAYS)days.html ... ; \
	    $(LSTOHTML) $(LSTOHTMLFLAGS) -v PREFIX=$(WWWFTP) -v FILE=/00tdir$(DAYS)days.html 00tdir$(DAYS)days.lst >00tdir$(DAYS)days.html ; \
	    $(HTMLCHECK) 00tdir$(DAYS)days.html 2>&1 | egrep -v '[.][.][.]$$|[.][.][.] valid' ; \
	fi
	chmod o+r 00*

ls-lr:	FRC
	-$(RM) ls-lr ls-lR $(FTPROOT)/ls-lR
	cd $(FTPROOT) ; $(LS) -lR >$(FTPROOT)/ls-lr
	-$(RM) ls-lr ; $(LN) $(FTPROOT)/ls-lr ls-lr
	-$(RM) ls-lR ; $(LN) $(FTPROOT)/ls-lr ls-lR
	-$(RM) $(FTPROOT)/ls-lR ; $(LN) $(FTPROOT)/ls-lr $(FTPROOT)/ls-lR
	cd $(FTPROOT) ; $(RM) ls-lR.html ; $(AWK) -f pub/misc/lstohtml.awk ls-lr >ls-lr.html ; $(LN) ls-lr.html ls-lR.html
	-$(RM) ls-lr.html ; $(LN) $(FTPROOT)/ls-lr.html ls-lr.html
	-$(RM) ls-lrt.html ; $(LN) $(FTPROOT)/ls-lrt.html ls-lrt.html

# [26-Jun-1992] Save the compressed listing under an archie-style name
# too for archie to grab.
ls-lr.gz:	ls-lr
	$(RM) ls-lr.gz $(FTPROOT)/ls-lr.gz
	$(GZIP) <$(FTPROOT)/ls-lr >$(FTPROOT)/ls-lr.gz
	$(LN) $(FTPROOT)/ls-lr.gz ls-lr.gz

ls-lrt:	FRC
	$(RM) ls-lrt ls-lRt $(FTPROOT)/ls-lrt $(FTPROOT)/ls-lRt
	cd $(FTPROOT) ; $(LS) -lRt >$(FTPROOT)/ls-lrt
	$(LN) $(FTPROOT)/ls-lrt ls-lrt
	$(LN) $(FTPROOT)/ls-lrt ls-lRt
	$(LN) $(FTPROOT)/ls-lrt $(FTPROOT)/ls-lRt
	cd $(FTPROOT) ; $(RM) ls-lRt.html ; $(AWK) -f pub/misc/lstohtml.awk  ls-lrt >ls-lrt.html ; $(LN) ls-lrt.html ls-lRt.html

ls-lrt.gz:	ls-lrt
	$(RM) ls-lrt.gz $(FTPROOT)/ls-lrt.gz
	$(GZIP) <$(FTPROOT)/ls-lrt >$(FTPROOT)/ls-lrt.gz
	$(LN) $(FTPROOT)/ls-lrt.gz ls-lrt.gz

netlib-crc:
	$(LSR) bibnet | egrep -v '^#|~$$' | $(CRC) >bibnet/crc

time-begin:
	@echo "========== Begin: `date` =========="

time-end:
	@echo "========== End:   `date` =========="

tuglib:
	(chdir /tuglib/admin; $(MAKE) all)
	if [ ! -s /tuglib/admin/LIBS ] ;\
	then echo "/tuglib/admin/LIBS is trashed" | /bin/mail $(MANAGER) ;\
	fi