# Generated automatically from Makefile.in by configure.
###=====================================================================
### Makefile for bibsort, a BibTeX bibliography file sort utility.
###
### Current target list:
###	all			make documentation files
###	$(PROGNAME).hlp		VAX (Open)VMS HELP file of manual pages
###	$(PROGNAME).html	HTML form of manual pages
###	$(PROGNAME).pdf		Portable Document Format form of manual
###				pages
###	$(PROGNAME).ps		PostScript file of typeset manual pages
###	$(PROGNAME).ser		spelling errors
###	$(PROGNAME).shar	UNIX shar bundle for e-mail distribution
###	$(PROGNAME).tar		UNIX tar archive bundle
###	$(PROGNAME).txt		ASCII text file of manual pages
###	$(PROGNAME).zip		Info-ZIP archive bundle
###	$(PROGNAME).zoo		Zoo archive bundle
###	check			run validation suite (currently a dummy)
###	clean			remove temporary files
###	clobber			remove all automatically recreatable 
###				files
###	distclean		same as clobber
###	install			install bibsort on system
###	install-exe		install bibsort executable on system
###	install-ftp		install bibsort on anonymous ftp 
###				directory
###	install-html		install bibsort HTML file on system
###	install-man		install bibsort manual pages on system
###	maintainer-clean	remove absolutely everything that 
###				"make" can rebuild at the maintainer's 
###				site (do NOT use this target!)
###	mostlyclean		same as clean
###	realclean		same as clobber
###	reconfigure		regenerate configure script and run it
###	spell			check spelling (with two spellers)
###	test-version		test extraction of version number
###	uninstall		remove installed executable and man 
###				pages
###	uninstall		remove 
###	uninstall-exe		remove installed executable 
###	uninstall-ftp		remove files installed in anonymous ftp
###				directory
###	uninstall-html		remove installed HTML file
###	uninstall-man		remove installed man pages
### 
### [17-Jan-2000] -- update for version 0.15
### [24-Sep-1999] -- update for version 0.13, and use of GNU 
###		     autoconfigure
### [24-Nov-1997]
###=====================================================================

PROGNAME	= bibsort
VERSION		= 0.15
DATE		= 17-Jan-2000

###=====================================================================
### Installation locations

prefix          = /usr/local
exec_prefix     = $(prefix)

# Change these two directories to match local conventions if you
# wish to do "make install" and "make install-ftp":
bindir          = $(exec_prefix)/bin
catdir		= $(prefix)/man/cat1
mandir		= $(prefix)/man/man1
manext		= 1
ftpdir		= /u/ftp/pub/tex/bib
htmlmandir	= $(prefix)/share/html/man/man1

###=====================================================================
### Program and program flag definitions

AUTOCONF	= autoconf

AWK		= /usr/local/bin/mawk

## This is either Robert Solovay's checksum program, or else cat, in which
## case the checksum in the file header of the installed executable will be
## incorrect.
CHECKSUM	= checksum

CHMOD		= chmod

CMP		= cmp

COL		= col -b

## We prefer to retain file modification times on installed files, but
## not all cp implementations have the -p (preserve timestamp) switch.
## Fortunately, all rcp and scp implementations seem to support -p, so
## we use one of them instead.
CP		= scp -p

DIFF		= diff

DISTILL		= distill

GZIP		= gzip

ISPELL		= ispell

JAR		= jar

LN		= ln

LS		= ls

MAN2HTML	= man2html

MAN2HTMLFLAGS	= -grammar-level 3.2

MAN2PS		= ./man2ps

MKDIR		= mkdir

NROFF		= nroff

RM		= rm -f

SED		= sed

SHAR		= shar

SHELL		= ksh

SORT		= /usr/local/bin/sort

SPELL		= spell

TAR		= tar

UNZIP		= unzip

ZIP		= zip

ZOO		= zoo

###=====================================================================
### Files

CHECKFILES      = test/*.opt test/*.in test/okay/*.err test/okay/*.out

CHECKOPTFILES   = check001.opt check002.opt check003.opt check004.opt \
		  check005.opt check006.opt check007.opt check008.opt \
		  check009.opt check010.opt check011.opt check012.opt \
		  check013.opt check014.opt check015.opt check016.opt \
		  check017.opt check018.opt check019.opt check020.opt \
		  check021.opt check022.opt check023.opt check024.opt \
		  check025.opt check026.opt check027.opt check028.opt \
		  check029.opt check030.opt check031.opt check032.opt \
		  check033.opt check034.opt check035.opt

CHECKNAMES	= $(CHECKOPTFILES:.opt=)

DISTFILES       = CHANGELOG COPYING Makefile.in README README.AWK \
		  $(PROGNAME).hlp $(PROGNAME).sin $(PROGNAME).sok \
		  $(PROGNAME).txt configure.in configure man2ps \
		  mkdir.sh rofvms.awk save/configure save/Makefile \
		  $(CHECKFILES) $(DOCFILES)

DOCFILES	= $(HTMLFILES) $(MANFILES) $(PDFFILES) $(PSFILES) $(TXTFILES)

HTMLFILES	= $(MANFILES:.man=.html)

MANFILES	= $(PROGNAME).man

PDFFILES	= $(MANFILES:.man=.pdf)

PSFILES		= $(MANFILES:.man=.ps)

TXTFILES	= $(MANFILES:.man=.txt)

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

all:	$(PROGNAME).txt $(PROGNAME).hlp

## VAX VMS help file format from $(PROGNAME).txt
$(PROGNAME).hlp:	$(PROGNAME).txt rofvms.awk
	$(AWK) -f rofvms.awk <$(PROGNAME).txt >$(PROGNAME).hlp

$(PROGNAME).html:	$(PROGNAME).man
	$(MAN2HTML) $(MAN2HTMLFLAGS) $(PROGNAME).man

$(PROGNAME).jar:	$(DISTFILES)
	-$(RM) $(PROGNAME).jar
	$(JAR) cf $(PROGNAME).jar $(DISTFILES)
	-$(MKDIR) $(PROGNAME)-$(VERSION)
	cd $(PROGNAME)-$(VERSION); $(JAR) xf ../$(PROGNAME).jar
	$(JAR) cf $(PROGNAME)-$(VERSION).jar $(PROGNAME)-$(VERSION)
	-$(RM) -r $(PROGNAME)-$(VERSION)
	-$(RM) $(PROGNAME).jar
	$(LN) $(PROGNAME)-$(VERSION).jar $(PROGNAME).jar

$(PROGNAME).pdf:	$(PROGNAME).ps
	$(DISTILL) $(PROGNAME).ps

$(PROGNAME).ps:	$(PROGNAME).man
	$(MAN2PS) <$(PROGNAME).man >$(PROGNAME).ps

$(PROGNAME).shar:	$(DISTFILES)
	$(SHAR) -b -c -v $(DISTFILES) >$(PROGNAME).shar

$(PROGNAME).tar:	$(DISTFILES)
	-$(RM) $(PROGNAME).tar $(PROGNAME).tar-lst
	$(TAR) chf $(PROGNAME).tar $(DISTFILES)
	-$(MKDIR) $(PROGNAME)-$(VERSION)
	cd $(PROGNAME)-$(VERSION); $(TAR) xf ../$(PROGNAME).tar
	$(TAR) cf $(PROGNAME)-$(VERSION).tar $(PROGNAME)-$(VERSION)
	-$(RM) -r $(PROGNAME)-$(VERSION)
	-$(RM) $(PROGNAME).tar
	$(LN) $(PROGNAME)-$(VERSION).tar $(PROGNAME).tar

$(PROGNAME).txt:	$(PROGNAME).man
	$(NROFF) -man $? | $(COL) >$@

$(PROGNAME).zip:	$(DISTFILES)
	-$(RM) $(PROGNAME)*.zip
	-$(RM) $(PROGNAME)*.zip-lst
	$(ZIP) $(PROGNAME)-$(VERSION).zip $(DISTFILES)
	$(UNZIP) -v $(PROGNAME)-$(VERSION).zip >$(PROGNAME)-$(VERSION).zip-lst
	$(LN) $(PROGNAME)-$(VERSION).zip $(PROGNAME).zip

$(PROGNAME).zoo:	$(DISTFILES)
	-$(RM) $(PROGNAME)*.zoo
	-$(RM) $(PROGNAME)*.zoo-lst
	$(ZOO) a $(PROGNAME)-$(VERSION).zoo $(DISTFILES)
	$(ZOO) v $(PROGNAME)-$(VERSION).zoo >$(PROGNAME)-$(VERSION).zoo-lst
	$(LN) $(PROGNAME)-$(VERSION).zoo $(PROGNAME).zoo

check:	all
	@echo ""
	@echo ========================================================================
	@echo Test of $(PROGNAME): there should be no output, other than the test and 
	@echo command names.  The tests take about 20 sec on a fast workstation.
	@-cd test ; \
	for f in $(CHECKNAMES) ; \
	do \
		echo ============ $$f: $(PROGNAME) `cat $$f.opt` ; \
		../$(PROGNAME).sh `cat $$f.opt` < $$f.in 2> $$f.err > $$f.out ; \
		if $(CMP) -s okay/$$f.err $$f.err ; \
		then \
			$(RM) $$f.err ; \
		else \
			$(DIFF) okay/$$f.err $$f.err ; \
		fi ; \
		if $(CMP) -s okay/$$f.out $$f.out ; \
		then \
			$(RM) $$f.out ; \
		else \
			$(DIFF) okay/$$f.out $$f.out ; \
		fi ; \
	done
	@echo ========================================================================
	@echo ""

clean mostlyclean:
	-$(RM) *.o
	-$(RM) *.shar
	-$(RM) *.tar
	-$(RM) *.jar
	-$(RM) *.tar-lst
	-$(RM) *.zip
	-$(RM) *.zip-lst
	-$(RM) *.zoo
	-$(RM) *.zoo-lst
	-$(RM) *~
	-$(RM) \#*
	-$(RM) core
	-$(RM) tg_[0-9][0-9][0-9][0-9][0-9].*

clobber: distclean

### While this step requires autoconf, it should only ever be used at the
### developer's site, where it is universally available.
configure:	configure.in
	$(AUTOCONF)

dist:	docs $(PROGNAME).jar $(PROGNAME).tar $(PROGNAME).zip $(PROGNAME).zoo

distclean:	clean
	-$(RM) $(PROGNAME).ser
	-$(RM) $(PROGNAME).sh
	-$(RM) Makefile
	-$(RM) config.cache config.log config.status

dist:	docs $(PROGNAME).jar $(PROGNAME).tar $(PROGNAME).zip $(PROGNAME).zoo

docs:	$(DOCFILES)

install:	install-exe install-html install-man

install-exe: uninstall-exe
	$(SED)	-e 's@# *!/bin/sh@#! $(SHELL)@' \
		-e 's@^gawk@$(AWK)@' \
		-e 's@^SORT=.*$$@SORT=$(SORT)@' \
		$(PROGNAME).sh | \
		$(CHECKSUM) > $(bindir)/$(PROGNAME)
	$(CHMOD) 755 $(bindir)/$(PROGNAME)
	$(LN) $(bindir)/$(PROGNAME) $(bindir)/$(PROGNAME)-$(VERSION)
	$(LS) -l $(bindir)/$(PROGNAME) $(bindir)/$(PROGNAME)-$(VERSION)

install-html:	$(PROGNAME).html uninstall-html
	-if [ -d $(htmlmandir) ] ; \
	then \
		true ; \
	else \
		$(MKDIR) $(htmlmandir) 2>/dev/null ; \
	fi
	-if [ -d $(htmlmandir) ] ; \
	then \
		$(RM) $(htmlmandir)/$(PROGNAME).html ; \
		$(CP) $(PROGNAME).html $(htmlmandir)/$(PROGNAME).html ; \
		$(CHMOD) 664 $(htmlmandir)/$(PROGNAME).html ; \
		$(LS) -l $(htmlmandir)/$(PROGNAME).html ; \
	else \
		echo "Skipping HTML file installation: $(htmlmandir) does not exist" ; \
	fi

install-man:	uninstall-man
	$(CP) $(PROGNAME).man $(mandir)/$(PROGNAME).$(manext)
	$(CHMOD) 664 $(mandir)/$(PROGNAME).$(manext)
	$(LS) -l $(mandir)/$(PROGNAME).$(manext)

install-ftp:	$(PROGNAME).tar $(PROGNAME).zip $(PROGNAME).zoo install-ftp
	$(TAR) tvf $(PROGNAME)-$(VERSION).tar >$(ftpdir)/$(PROGNAME)-$(VERSION).tar-lst
	$(GZIP) <$(PROGNAME)-$(VERSION).tar \
		>$(ftpdir)/$(PROGNAME)-$(VERSION).tar.gz
	$(CP) $(PROGNAME)-$(VERSION).zip $(ftpdir)
	$(CP) $(PROGNAME)-$(VERSION).zip-lst $(ftpdir)
	$(CP) $(PROGNAME)-$(VERSION).zoo $(ftpdir)
	$(CP) $(PROGNAME)-$(VERSION).zoo-lst $(ftpdir)
	$(LS) -l $(ftpdir)/$(PROGNAME)-$(VERSION).*

maintainer-clean:	distclean
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."
	-$(RM) $(PROGNAME).hlp
	-$(RM) $(PROGNAME).html
	-$(RM) $(PROGNAME).pdf
	-$(RM) $(PROGNAME).ps
	-$(RM) $(PROGNAME).txt
	-$(RM) configure

mostlyclean:	clean

reconfigure:
	$(AUTOCONF)
	./configure

## Check the spelling in the bibsort script and manual pages, leaving
## exceptions in $(PROGNAME).ser.  Both spell and ispell are used.
SPELL-FILTER = cat $(PROGNAME).man $(PROGNAME).sh | $(SED) -e "s/[^a-zA-Z'-]/ /g"
spell $(PROGNAME).ser:
	-if [ ! -f $(PROGNAME).sok ] ; then touch $(PROGNAME).sok ; fi
	-$(SPELL-FILTER) | $(SPELL) +$(PROGNAME).sok >/tmp/$(PROGNAME).ser
	-$(SPELL-FILTER) | $(ISPELL) -l -p $(PROGNAME).sok >>/tmp/$(PROGNAME).ser
	-$(SORT) -u /tmp/$(PROGNAME).ser >$(PROGNAME).ser
	-if [ ! -s $(PROGNAME).ser ] ; then $(RM) $(PROGNAME).ser ; fi
	-$(RM) /tmp/$(PROGNAME).ser

test-version:
	@echo "Version number is ""'"$(VERSION)"'"

uninstall:	uninstall-exe uninstall-html uninstall-man

uninstall-exe:
	-$(RM) $(bindir)/$(PROGNAME) $(bindir)/$(PROGNAME)-$(VERSION)

uninstall-html:
	-$(RM) $(htmlmandir)/$(PROGNAME).html

uninstall-man:
	-$(RM) $(mandir)/$(PROGNAME).$(manext)
	-$(RM) $(catdir)/$(PROGNAME).$(manext)

uninstall-ftp:
	-$(RM) $(ftpdir)/$(PROGNAME)-$(VERSION).tar.gz
	-$(RM) $(ftpdir)/$(PROGNAME)-$(VERSION).tar-lst
	-$(RM) $(ftpdir)/$(PROGNAME)-$(VERSION).zip
	-$(RM) $(ftpdir)/$(PROGNAME)-$(VERSION).zip-lst
	-$(RM) $(ftpdir)/$(PROGNAME)-$(VERSION).zoo
	-$(RM) $(ftpdir)/$(PROGNAME)-$(VERSION).zoo-lst
