# Generated automatically from Makefile.in by configure.
#=======================================================================
# Makefile for BibTeX .bib file prettyprinter
#
# Current target list: (these include all GNU Project standard targets)
#	all			build bibclean
#	bclproto		obsolete; build an early prototype of bibclean
#	bibclean		executable for bibclean
#	bibclean.h		documentation strings for help() function
#	bibclean.hlp		VAX VMS help file (automatically converted
#				from bibclean.txt)
#	bibclean.html		HTML version of formatted manual pages
#	bibclean.i		C preprocessor output from bibclean.c
#	bibclean.pdf		Adobe Portable Document Format version 
#				of bibclean.man
#	bibclean.ps		PostScript version of bibclean.man
#	bibclean.tar		tar archive file for ftp distribution
#	bibclean.txt		nroff'ed bibclean.man manual page file
#	bibclean.zip		Info-zip archive file for ftp distribution
#	bibclean.zoo		zoo archive file for ftp distribution
#	check			same as test (see below)
#	clean			clean up all but executables and time stamps
#	clobber			clean up everything
#	distclean		remove everything make can rebuild at remote site
#	docs			make bibclean.txt, bibclean.hlp, and bibclean.ps
#	install			install executable and man pages
#	install.time		internal target for install
#	install-exe		install executable
#	install-man		install man pages
#	install-ftp		install .tar, .zip, and .zoo files in ftp tree
#	install-ftp.time	internal target for install-ftp
#	lint			check for code problems
#	mostlyclean		same as clean
#	maintainer-clean	for program author only: remove everything
#				make can rebuild at author's site
#	romtol			build and run test program for romtol()
#	TAGS			GNU Emacs tags file
#	test			test bibclean on BibTeX and Scribe
#				bibliographies
#	test-bibtex		test 1,2,3 bibclean on BibTeX bibliographies
#	test-bibtex-1		test 1 bibclean on BibTeX bibliographies
#	test-bibtex-2		test 2 bibclean on BibTeX bibliographies
#	test-bibtex-3		test 3 ISBN and ISSN verification
#	test-scribe		test 1,2,3 bibclean on Scribe bibliographies
#	test-scribe-1		test 1 bibclean on Scribe bibliographies
#	test-scribe-2		test 2 bibclean on Scribe bibliographies
#	test-scribe-3		test 3 bibclean on Scribe bibliographies
#	test-version		test extraction of version number
#	uninstall		remove files installed by "make install"
#	uninstall-ftp		remove installed files in anonymous ftp
#				directory
#
# [01-Jul-1996] -- add targets bibclean.pdf and DISTILL macro, and update
# 		   DIST-FILES list
# [03-May-1996] -- add targets match, romtol, test-match, and test-romtol,
#		   and update DIST-FILES list for version 2.11.3 release
# [25-Apr-1996] -- add target for bibclean.html, with associated
#		   support Makefile variables
# [20-Sep-1995] -- revise to use GNU autoconf and configure
# [08-Mar-1995] -- Change TARGET to TARGETS to avoid conflict with
#		   built-in macro on Cray systems. Add -D_POSIX_SOURCE
#		   to dec-alpha-osf1-c++ CC definition to work around
#		   bug in C++ signal.h header file on OSF/1 3.x.
# [21-Nov-1994] -- add cray-el94 target
# [11-Nov-1994] -- add sun-sparc-solaris2-lcc and sun-sparc-sunos5-lcc
# 		   targets
# [18-Oct-1994] -- add isbn.[co] to file lists
# [16-Oct-1994] -- add strist.[co] to file lists
# [04-Jun-1994] -- update for version 2.10
#		   add lint target
# [31-Dec-1993] -- final polishing of Makefile for public release
#                  after TUGboat publication
# [24-Sep-1993]
#=======================================================================
#### Start of system configuration section. ####

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

bindir          = $(exec_prefix)/bin
datadir         = $(prefix)/lib
infodir         = $(prefix)/info
libdir          = $(prefix)/lib
srcdir          = .

# This setting is specific to the developer's site, and not needed elsewhere
FTPDIR		= /u/ftp/pub/tex/bib

# Need new awk (nawk) or gawk here:
AWK		= /usr/local/bin/gawk
CC              = CC
CXX             = c++
CFLAGS          = -g $(OPT)
CHARSET         = @CHARSET@
CXXFLAGS	= -g -O2 $(OPT)

DEFS            = -DHAVE_CONFIG_H

INSTALL         = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA    = @INSTALL_DATA@

LDFLAGS         = $(OPT)
LIBOBJS		=  strtol.o
LIBS            = 

OPT		=


# Where to install the manual pages.
mandir          = $(prefix)/man/man1
# Extension (not including `.') for the installed manual page filenames.
manext          = 1

#### End of system configuration section. ####

# For testing purposes, make sure we always have the same
# initialization file
BIBCLEAN	= ./bibclean -init-file bibclean.ini

BIBTEX		= bibtex

BIBTEX-TESTS	= testbib1.org testbib2.org testbib3.org testbib4.org \
		  testbib5.org testbib6.org testisxn.org testcodn.org

# This program is freely available at ftp://ftp.math.utah.edu/pub/misc/checksum-x-y.*
CHECKSUM	= checksum

CHMOD		= chmod

COMPRESS	= compress

# Use the -p flag where available to preserve file time stamps
# All known UNIX implementations have an rcp that supports -p,
# but not all have similar support in cp.
CP		= /bin/cp -p
CP		= /bin/cp
CP		= rcp -p

DIST-FILES      = ChangeLog README Makefile Makefile.in bibclean.c \
		  bibclean.h bibclean.hlp bibclean.html bibclean.ini \
		  bibclean.man bibclean.pdf bibclean.ps bibclean.reg \
		  bibclean.txt build-all.sh ch.h chek.c config.h \
		  config.hin configure configure.in configure.sed \
		  custom.h delete.h do.c fix.c fndfil.c isbn.c \
		  keybrd.c keybrd.h match.c match.dat match.h \
		  match.lok option.c pattern.h rofvms.awk romtol.c \
		  romtol.dat romtol.lok strist.c strtol.c token.h \
		  toklst.h vaxvms.c vmswild.c xctype.h xerrno.h \
		  xlimits.h xpwd.h xstat.h xstdlib.h xstring.h \
		  xtypes.h xunistd.h yesorno.h $(BIBTEX-TESTS) \
		  $(BIBTEX-TESTS:.org=.bok) $(BIBTEX-TESTS:.org=.eok) \
		  testbib2.ltx $(SCRIBE-TESTS) \
		  $(SCRIBE-TESTS:.org=.bok) $(SCRIBE-TESTS:.org=.eok) \
		  testscr2.bo2 testscr2.eo2 doc/Makefile \
		  doc/bibclean.aux doc/bibclean.bbl doc/bibclean.bib \
		  doc/bibclean.blg doc/bibclean.dvi doc/bibclean.idx \
		  doc/bibclean.ilg doc/bibclean.ind doc/bibclean.log \
		  doc/bibclean.lot doc/bibclean.ltx doc/bibclean.sok \
		  doc/bibclean.sty doc/bibclean.toc doc/is-plain.bst \
		  doc/ltugboat.sty doc/path.sty doc/texnames.sty \
		  doc/tugboat.cmn ibmpc/dos/README \
		  ibmpc/dos/msc5p1/bibclean.exe \
		  ibmpc/dos/msc5p1/config.h \
		  ibmpc/dos/msc5p1/ibmclean.bat \
		  ibmpc/dos/msc5p1/ibmtest.bat \
		  ibmpc/dos/msc5p1/msc51bld.bat \
		  ibmpc/dos/msc5p1/msc51pth.bat \
		  ibmpc/dos/msc6p0/bibclean.exe \
		  ibmpc/dos/msc6p0/bibclean.map \
		  ibmpc/dos/msc6p0/config.h \
		  ibmpc/dos/msc6p0/ibmclean.bat \
		  ibmpc/dos/msc6p0/ibmtest.bat \
		  ibmpc/dos/msc6p0/msc60bld.bat \
		  ibmpc/dos/msc6p0/msc60pth.bat \
		  ibmpc/dos/msc7p0/config.h \
		  ibmpc/dos/msc7p0/ibmclean.bat \
		  ibmpc/dos/msc7p0/ibmtest.bat \
		  ibmpc/dos/msc7p0/msc70bld.bat \
		  ibmpc/dos/msc7p0/msc70pth.bat \
		  ibmpc/dos/tcc2p0/bibclean.exe \
		  ibmpc/dos/tcc2p0/config.h \
		  ibmpc/dos/tcc2p0/ibmclean.bat \
		  ibmpc/dos/tcc2p0/ibmtest.bat \
		  ibmpc/dos/tcc2p0/tcc20bld.bat \
		  ibmpc/dos/tcc2p0/tcc20pth.bat \
		  ibmpc/dos/tcc3p0/bibclean.exe \
		  ibmpc/dos/tcc3p0/config.h \
		  ibmpc/dos/tcc3p0/ibmclean.bat \
		  ibmpc/dos/tcc3p0/ibmtest.bat \
		  ibmpc/dos/tcc3p0/tcc30bld.bat \
		  ibmpc/dos/tcc3p0/tcc30pth.bat \
		  ibmpc/dos/tpp3p0/bibclean.exe \
		  ibmpc/dos/tpp3p0/config.h \
		  ibmpc/dos/tpp3p0/ibmclean.bat \
		  ibmpc/dos/tpp3p0/ibmtest.bat \
		  ibmpc/dos/tpp3p0/tcc30pth.bat \
		  ibmpc/dos/tpp3p0/tpp30bld.bat \
		  ibmpc/dos/wat10/wcc/bibclean.exe \
		  ibmpc/dos/wat10/wcc/bibclean.map \
		  ibmpc/dos/wat10/wcc/config.h \
		  ibmpc/dos/wat10/wcc/ibmclean.bat \
		  ibmpc/dos/wat10/wcc/ibmtest.bat \
		  ibmpc/dos/wat10/wcc/watcpp.bat \
		  ibmpc/dos/wat10/wcc/watpath.bat \
		  ibmpc/dos/wat10/wcc/watwcc.bat \
		  ibmpc/dos/wat10/wcc386/bibclean.exe \
		  ibmpc/dos/wat10/wcc386/config.h \
		  ibmpc/dos/wat10/wcc386/dos4gw.doc \
		  ibmpc/dos/wat10/wcc386/dos4gw.exe \
		  ibmpc/dos/wat10/wcc386/ibmclean.bat \
		  ibmpc/dos/wat10/wcc386/ibmtest.bat \
		  ibmpc/dos/wat10/wcc386/wat10bld.bat \
		  ibmpc/dos/wat10/wcc386/watpath.bat \
		  ibmpc/dos/wat10/wpp386/bibclean.exe \
		  ibmpc/dos/wat10/wpp386/config.h \
		  ibmpc/dos/wat10/wpp386/dos4gw.doc \
		  ibmpc/dos/wat10/wpp386/dos4gw.exe \
		  ibmpc/dos/wat10/wpp386/ibmclean.bat \
		  ibmpc/dos/wat10/wpp386/ibmtest.bat \
		  ibmpc/dos/wat10/wpp386/w386cpp.bat \
		  ibmpc/dos/wat10/wpp386/watpath.bat ibmpc/linux/bibclean \
		  save/Makefile save/config.h save/configure \
		  vms/alpha/recomp.com vms/alpha/vmsclean.com \
		  vms/alpha/vmsmake.com vms/alpha/vmstest.com vms/vax/README \
		  vms/vax/bibclean.exe vms/vax/bibclean.obj vms/vax/chek.obj \
		  vms/vax/config.h vms/vax/do.obj vms/vax/fix.obj \
		  vms/vax/fndfil.obj vms/vax/getoneheader.com \
		  vms/vax/getvmsheaders.com vms/vax/isbn.obj \
		  vms/vax/keybrd.obj vms/vax/match.obj vms/vax/option.obj \
		  vms/vax/recomp.com vms/vax/romtol.obj vms/vax/strist.obj \
		  vms/vax/vaxvms.obj vms/vax/vmsclean.com vms/vax/vmsmake.com \
		  vms/vax/vmstest.com vms/vax/vmswild.obj

DISTILL		= distill

DITROFF		= ditroff	## AT&T
DITROFF		= groff		## GNU

# Some systems define HOST or HOSTNAME, but others don't, so we
# generate it at compile time with the hostname utility.
HOST		= `hostname`

# This program is freely available at ftp://ftp.math.utah.edu/pub/sgml/sp-*
HTML-NCHECK	= html-ncheck

# This program is freely available at ftp://ftp.math.utah.edu/pub/sgml/htmlpty-x.y.*
HTML-PRETTY	= html-pretty

LATEX		= latex

LINT		= lint

LINTFLAGS	= -bchx -I.

LN		= ln

# This program will not likely be available at other than the author's
# site, so the .html file is preserved unless a "make maintainer-clean"
# is done.  It may be freely distributed at some point, so if you want
# it, ask the author about its status.
MAN2HTML	= $(AWK) -f $$HOME/public_html/support/myman2html/man2html.awk

MV		= /bin/mv

NROFF		= nroff

RM		= /bin/rm -f

SCRIBE-TESTS-1	= testscr1.org testscr2.org

# Do NOT use SCRIBE-TESTS-1 in this list, because MIPS 6280 RISCos 5.0
# make then fails to correctly expand $(SCRIBE-TESTS:.org=.xyz).
SCRIBE-TESTS	= testscr1.org testscr2.org testscr3.org

SED		= /bin/sed

SHELL		= /bin/sh

SRC             = bibclean.c chek.c do.c fix.c fndfil.c isbn.c \
		  keybrd.c match.c option.c romtol.c strist.c strtol.c

STRIP		= strip

# Only the subdirectories with Makefiles are listed here
SUBDIRS		= doc

TAGS-FILES      = bibclean.c bibclean.h ch.h chek.c config.h custom.h \
		  delete.h do.c fix.c fndfil.c isbn.c keybrd.c \
		  keybrd.h match.c match.h option.c pattern.h romtol.c \
		  strist.c strtol.c token.h toklst.h vaxvms.c \
		  vmswild.c xctype.h xerrno.h xlimits.h xpwd.h xstat.h \
		  xstdlib.h xstring.h xtypes.h xunistd.h yesorno.h

UNZIP		= unzip

VERSION		= `$(AWK) '/^[ \t]*version *= *"[0-9.]+", *$$/ \
		{ gsub(/[^0-9.]/,"",$$3); print $$3 }' bibclean.c`

ZIP		= zip

ZOO		= zoo

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

.SUFFIXES:

.SUFFIXES: .o .i .c .bib-new .bib-old .bib

.bib.bib-new:
	-$(BIBCLEAN) <$< >$@

.bib.bib-old:
	./bclproto <$< >$@

.c.i:
	$(CC) -E -I. -I$(srcdir) $(DEFS) $(CPPFLAGS) $(CFLAGS) $< 2>&1 | \
		grep -v '^[ 	]*$$' >$@

.c.o:
	$(CC) -c -I. -I$(srcdir) $(DEFS) $(CPPFLAGS) $(CFLAGS) $<

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

all: bibclean

### bibclean-specific building targets ###

bibclean.dvi: bibclean.texi
	cd $(srcdir); texi2dvi bibclean.texi

bibclean.html:	bibclean.man
	-$(CHMOD) u+w $@
	$(MAN2HTML) $$PWD/$< | $(HTML-PRETTY)  -f $$PWD/$@ | $(CHECKSUM) >$@
	$(CHMOD) a-w $@
	$(HTML-NCHECK) $@

bibclean.info: bibclean.texi
	cd $(srcdir); makeinfo bibclean.texi

BIBCLEAN-OBJS   = bibclean.o chek.o do.o fix.o fndfil.o isbn.o \
		  keybrd.o match.o option.o romtol.o strist.o \
		  $(LIBOBJS)

bibclean:         $(BIBCLEAN-OBJS)
	$(CC) -o bibclean $(CFLAGS) $(BIBCLEAN-OBJS) $(LIBS)

# This target converts the option descriptions from the manual pages
# to C code for inclusion in bibclean.c.  The first awk command
# augments the bibclean.man file in a pipe with some small changes
# after the .TH line (which sets page dimensions) to get longer
# unhyphenated ragged-right lines without page headers, and reduces
# the option description indentation.
#
# Here are the magic nroff incantations:
#
# .pl 100i	set page length to 100in
# .nr LL 7.2i	set LL register (page width) to 7.2in
# .nh		no hyphenation
# .na		no right-adjusting
#
# That output feeds into nroff for formatting, col for removal of
# underlining and escape sequences, expand for tab removal, sed to
# backslash all quotes, and a final awk step to select the lines
# between OPTIONS and ERROR headers for conversion to C code.

bibclean.h:	bibclean.man
	-$(RM) $@
	echo '/* WARNING: Do NOT edit this file.  It was created automatically'\
		>$@
	echo '   with the command "make bibclean.h" by '$$USER@`hostname` \
		>>$@
	echo '   in '$$PWD' on '`date`' */' >>$@
	echo >>$@
	$(AWK) '{ if ($$0 ~ /^.TH/) \
		printf("%s\n.pl 100i\n.nr LL 7.2i\n.nh\n.na",$$0); \
	    else if ($$0 ~ /^.TP .*remove-OPT-prefixes.*/) \
		print ".TP 1in"; \
	    else \
			print $$0}' <bibclean.man | \
	$(NROFF) -man | col -b | expand | $(SED) -e 's/"/\\"/g' | \
		$(SED) -e 's/\\n/|n/g' -e 's/\\"/|"/g' \
			-e 's/\\/\\\\/g' -e 's/|n/\\n/g' -e 's/|"/\\"/g' | \
		$(AWK) '/^OPTION/,/^ERROR/ {if ($$0 !~ /^[A-Z]/) \
			printf("\t\"%s\\n\",\n",substr($$0,6))}' >>$@
	echo '	(const char*)NULL,' >>$@

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

bibclean.i:	bibclean.c ch.h config.h custom.h delete.h keybrd.h \
		match.h pattern.h token.h toklst.h xctype.h \
		xlimits.h xstdlib.h xstring.h xtypes.h xunistd.h \
		Makefile

bibclean.o:     bibclean.c ch.h config.h custom.h delete.h keybrd.h \
		match.h pattern.h token.h toklst.h xctype.h \
		xlimits.h xstdlib.h xstring.h xtypes.h xunistd.h

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

bibclean.ps:	bibclean.man
	$(DITROFF) -Tps -man $? >$@

bibclean.tar:	subdist $(DIST-FILES)
	-$(RM) bibclean.tar bibclean.tar-lst
	tar chf bibclean.tar $(DIST-FILES)
	-mkdir bibclean-$(VERSION)
	cd bibclean-$(VERSION); tar xf ../bibclean.tar
	tar cf bibclean-$(VERSION).tar bibclean-$(VERSION)
	-$(RM) -r bibclean-$(VERSION)
	-$(RM) bibclean.tar
	$(LN) bibclean-$(VERSION).tar bibclean.tar

bibclean.txt:	bibclean.man
	$(NROFF) -man bibclean.man | col -b | expand >$@

bibclean.zip:	subdist $(DIST-FILES)
	-$(RM) bibclean*.zip
	-$(RM) bibclean*.zip-lst
	$(ZIP) bibclean-$(VERSION).zip $(DIST-FILES)
	$(UNZIP) -v bibclean-$(VERSION).zip >bibclean-$(VERSION).zip-lst
	$(LN) bibclean-$(VERSION).zip bibclean.zip

bibclean.zoo:	subdist $(DIST-FILES)
	-$(RM) bibclean*.zoo
	-$(RM) bibclean*.zoo-lst
	$(ZOO) a bibclean-$(VERSION).zoo $(DIST-FILES)
	$(ZOO) v bibclean-$(VERSION).zoo >bibclean-$(VERSION).zoo-lst
	$(LN) bibclean-$(VERSION).zoo bibclean.zoo

clean:
	-$(RM) $(BIBTEX-TESTS:.org=.bib)
	-$(RM) $(SCRIBE-TESTS:.org=.bib)
	-$(RM) *.aux
	-$(RM) *.bbl
	-$(RM) *.blg
	-$(RM) *.dvi
	-$(RM) *.err
	-$(RM) *.i
	-$(RM) *.log
	-$(RM) *.o
	-$(RM) *~
	-$(RM) \#*
	-$(RM) bibclean.tar bibclean-?.??.tar
	-$(RM) bibclean.tar-lst
	-$(RM) bibclean-$(VERSION).tar
	-$(RM) bibclean.zip bibclean-?.??.zip
	-$(RM) bibclean.zip-lst bibclean-?.??.zip-lst
	-$(RM) bibclean.zoo bibclean-?.??.zoo
	-$(RM) bibclean.zoo-lst bibclean-?.??.zoo-lst
	-$(RM) configure.tmp
	-$(RM) core
	-$(RM) match match.lst
	-$(RM) romtol romtol.lst
	-$(RM) testcodn.bib
	-$(RM) testisxn.bib
	-$(RM) testscr2.bi2 testscr2.er2
	-for d in $(SUBDIRS) ; do (cd $$d ; make clean ) ; done

clobber:	clean
	-$(RM) bclproto bibclean match
	-$(RM) bibclean.hlp
	-$(RM) bibclean.ps
	-$(RM) bibclean.txt
	-$(RM) install.time install-ftp.time
	-for d in $(SUBDIRS) ; do (cd $$d ; make clobber ) ; done

docs:	bibclean.txt bibclean.hlp bibclean.ps

chek.i:		chek.c config.h custom.h match.h token.h xctype.h \
		xstat.h xstring.h yesorno.h Makefile

chek.o:		chek.c config.h custom.h match.h token.h xctype.h \
		xstat.h xstring.h yesorno.h

do.i:		do.c ch.h config.h custom.h delete.h keybrd.h \
		match.h pattern.h token.h toklst.h xctype.h \
		xstdlib.h xstring.h xunistd.h yesorno.h Makefile

do.o:		do.c ch.h config.h custom.h delete.h keybrd.h \
		match.h pattern.h token.h toklst.h xctype.h \
		xstdlib.h xstring.h xunistd.h yesorno.h

fix.i:		fix.c config.h custom.h token.h xctype.h xstring.h \
		yesorno.h Makefile

fix.o:		fix.c config.h custom.h token.h xctype.h xstring.h \
		yesorno.h

fndfil.i:	fndfil.c config.h custom.h xctype.h xpwd.h xstdlib.h \
		xstring.h xunistd.h Makefile

fndfil.o:	fndfil.c config.h custom.h xpwd.h xstdlib.h \
		xstring.h xunistd.h

isbn.i:		isbn.c config.h custom.h xctype.h xstring.h xstdlib.h \
		Makefile

isbn.o:		isbn.c config.h custom.h xctype.h xstring.h xstdlib.h

keybrd.i:	ch.h config.h custom.h xstring.h xunistd.h yesorno.h \
		Makefile

keybrd.o:	ch.h config.h custom.h xctype.h xstring.h xunistd.h yesorno.h

# Build a test program for match()
match:	match.c romtol.o
	-$(RM) match.O
	if [ -f match.o ] ; then $(MV) match.o match.O ; fi
	-$(RM) match.o
	$(CC) -I. -I$(srcdir) $(DEFS) $(CPPFLAGS) $(CFLAGS) -DTEST -o match \
		match.c romtol.o
	-$(RM) match.o
	if [ -f match.O ] ; then $(MV) match.O match.o ; fi


match.i:	match.c config.h custom.h match.h xctype.h xstdlib.h \
		xstring.h Makefile

match.o:	match.c config.h custom.h match.h xctype.h xstdlib.h \
		xstring.h

mostlyclean:	clean
	-for d in $(SUBDIRS) ; do (cd $$d ; make mostlyclean ) ; done

option.i:	option.c bibclean.h ch.h config.h custom.h xstdlib.h \
		xstring.h yesorno.h Makefile

# When HOST, USER, __DATE__, and __TIME__ are available,
# bibclean preserves them for its version output
option.o:	option.c bibclean.h ch.h config.h custom.h xstdlib.h \
		xstring.h yesorno.h
	$(CC) -I. -I$(srcdir) $(CFLAGS) -c -DHOST=\"$(HOST)\" -DUSER=\"$(USER)\" option.c

# Build a test program for romtol()
romtol:	romtol.c
	-$(RM) romtol.O
	if [ -f romtol.o ] ; then $(MV) romtol.o romtol.O ; fi
	-$(RM) romtol.o
	$(CC) -I. -I$(srcdir) $(DEFS) $(CPPFLAGS) $(CFLAGS) -DTEST -o romtol romtol.c
	-$(RM) romtol.o
	if [ -f romtol.O ] ; then $(MV) romtol.O romtol.o ; fi

romtol.i:	romtol.c config.h custom.h xctype.h xstring.h xstdlib.h \
		Makefile

romtol.o:	romtol.c config.h custom.h xctype.h xstring.h xstdlib.h

strist.i:	strist.c config.h custom.h xctype.h xstring.h Makefile

strist.o:	strist.c config.h custom.h xctype.h xstring.h

strtol.i:	strtol.c config.h custom.h xctype.h xstdlib.h xstring.h \
		Makefile

strtol.o:	strtol.c config.h custom.h xctype.h xstdlib.h xstring.h

# Subdirectory makes needed for distribution file creation
subdist:
	-for d in $(SUBDIRS) ; do (cd $$d ; make ) ; done

#=======================================================================
### targets required by GNU Coding standards ###

Makefile: Makefile.in config.status
	./config.status

config.status: configure
	$(srcdir)/configure --srcdir=$(srcdir) --no-create

configure: configure.in configure.sed
	cd $(srcdir); autoconf
# Apply needed fixup for C++ with configure
	mv configure configure.tmp
	$(SED) -f configure.sed <configure.tmp >configure
	-$(RM) configure.tmp
	$(CHMOD) +x configure

distclean: clobber
	-$(RM) Makefile
	-$(RM) config.status
	-$(RM) config.cache
	-for d in $(SUBDIRS) ; do (cd $$d ; make distclean ) ; done

maintainer-clean: distclean
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."
	-$(CHMOD) u+w bibclean.html
	-$(RM) bibclean.html
	-$(RM) bibclean.pdf
	-$(RM) TAGS
	-$(RM) configure
	-for d in $(SUBDIRS) ; do (cd $$d ; make maintainer-clean ) ; done

TAGS:	Makefile $(TAGS-FILES)
	cd $(srcdir); etags $(TAGS-FILES)

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

install:	install.time

install.time:	install-exe install-man
	touch install.time

install-exe:	bibclean
	if test -f $(bindir)/bibclean ; \
	then \
		$(MV) $(bindir)/bibclean $(bindir)/bibclean.old ; \
	fi
	-$(RM) $(bindir)/bibclean-$(VERSION)
	$(CP) bibclean $(bindir)/bibclean
	-$(STRIP) $(bindir)/bibclean
	$(LN) $(bindir)/bibclean $(bindir)/bibclean-$(VERSION)
	$(CHMOD) 775 $(bindir)/bibclean
	$(CP) bibclean.ini $(bindir)/.bibcleanrc
	$(CHMOD) 664 $(bindir)/.bibcleanrc

install-man:	bibclean.man
	if test -f $(mandir)/bibclean.$(manext) ; \
	then \
		$(MV) $(mandir)/bibclean.$(manext) $(mandir)/bibclean.old.$(manext) ; \
	fi
	$(CP) bibclean.man $(mandir)/bibclean.$(manext)
	-$(RM) $(mandir)/../cat$(manext)/bibclean.$(manext)
	-$(RM) $(mandir)/bibclean-$(VERSION).$(manext)
	$(LN) $(mandir)/bibclean.$(manext) $(mandir)/bibclean-$(VERSION).$(manext)
	$(CHMOD) 664 $(mandir)/bibclean.$(manext)

install-ftp:	install-ftp.time

install-ftp.time:	bibclean.tar bibclean.zip bibclean.zoo
	tar tvf bibclean-$(VERSION).tar >$(FTPDIR)/bibclean-$(VERSION).tar-lst
	$(COMPRESS) <bibclean-$(VERSION).tar \
		>$(FTPDIR)/bibclean-$(VERSION).tar.gz
	$(CP) bibclean-$(VERSION).zip $(FTPDIR)
	$(CP) bibclean-$(VERSION).zip-lst $(FTPDIR)
	$(CP) bibclean-$(VERSION).zoo $(FTPDIR)
	$(CP) bibclean-$(VERSION).zoo-lst $(FTPDIR)
	ls -l $(FTPDIR)/bibclean*
	date >install-ftp.time

lint:
	$(LINT) $(LINTFLAGS) $(SRC)

test check:	test-match test-romtol test-bibtex test-scribe

# Test bibclean on Part 1 of the Reduce bibliography, testbib2.org.  The
# output file, testbib2.bib, is compared against a correct output file,
# testbib2.bok, from the author's site, and then the bibliography is
# additionally tested by LaTeX and BibTeX.

test-bibtex:	bibclean test-bibtex-1 test-bibtex-2 test-bibtex-3 \
		test-bibtex-4 test-bibtex-5 test-bibtex-6 test-bibtex-7 \
		test-bibtex-8

test-bibtex-1:	bibclean testbib1.org
	@echo
	@echo "==================== begin BibTeX test 1 ====================="
	@echo
	-@$(RM) testbib1.err testbib1.bib
	@echo
	-$(BIBCLEAN) testbib1.org >testbib1.bib 2>testbib1.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib1.bok testbib1.bib"
	-@if diff testbib1.bok testbib1.bib ; then $(RM) testbib1.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib1.eok testbib1.err"
	-@if diff testbib1.eok testbib1.err ; then $(RM) testbib1.err ; fi
	@echo
	@echo "===================== end BibTeX test 1 ======================"
	@echo

test-bibtex-2:	bibclean testbib2.org
	@echo
	@echo "==================== begin BibTeX test 2 ====================="
	@echo
	@-$(RM) testbib2.aux testbib2.bbl testbib2.bib testbib2.blg \
		testbib2.dvi testbib2.log
	@echo
	-$(BIBCLEAN) -no-check-values testbib2.org >testbib2.bib 2>testbib2.err
	@echo
	@echo "There should be no differences found:"
	-diff testbib2.bok testbib2.bib
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib2.eok testbib2.err"
	-@if diff testbib2.eok testbib2.err ; then $(RM) testbib2.err ; fi
	@echo
	$(LATEX) testbib2.ltx >/dev/null
	@echo
	@echo "Expect 6 BibTeX warnings:"
	-$(BIBTEX) testbib2
	@if cmp testbib2.bok testbib2.bib 2>/dev/null ; \
		then $(RM) testbib2.bib ; fi
	@echo
	$(LATEX) testbib2.ltx >/dev/null
	@echo
	$(LATEX) testbib2.ltx
	@echo
	@echo "===================== end BibTeX test 2 ======================"
	@echo

test-bibtex-3:	bibclean testbib3.org
	@echo
	@echo "==================== begin BibTeX test 3 ====================="
	@echo
	@-$(RM) testbib3.bib testbib3.err
	@echo
	-$(BIBCLEAN) -fix-font-change testbib3.org >testbib3.bib 2>testbib3.err
	@echo
	@echo "There should be no differences found:"
	-@if diff testbib3.bok testbib3.bib ; then $(RM) testbib3.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib3.eok testbib3.err"
	-@if diff testbib3.eok testbib3.err ; then $(RM) testbib3.err ; fi
	@echo
	@echo "===================== end BibTeX test 3 ======================"
	@echo

test-bibtex-4:	bibclean testbib4.org
	@echo
	@echo "==================== begin BibTeX test 4 ====================="
	@echo
	@-$(RM) testbib4.bib testbib4.err
	@echo
	-$(BIBCLEAN) -fix-font-change testbib4.org >testbib4.bib 2>testbib4.err
	@echo
	@echo "There should be no differences found:"
	-@if diff testbib4.bok testbib4.bib ; then $(RM) testbib4.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib4.eok testbib4.err"
	-@if diff testbib4.eok testbib4.err ; then $(RM) testbib4.err ; fi
	@echo
	@echo "===================== end BibTeX test 4 ======================"
	@echo

test-bibtex-5:	bibclean testbib5.org
	@echo
	@echo "==================== begin BibTeX test 5 ====================="
	@echo
	@-$(RM) testbib5.bib testbib5.err
	@echo
	-$(BIBCLEAN) -German-style testbib5.org >testbib5.bib 2>testbib5.err
	@echo
	@echo "There should be no differences found:"
	-@if diff testbib5.bok testbib5.bib ; then $(RM) testbib5.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib5.eok testbib5.err"
	-@if diff testbib5.eok testbib5.err ; then $(RM) testbib5.err ; fi
	@echo
	@echo "===================== end BibTeX test 5 ======================"
	@echo

test-bibtex-6:	bibclean testbib6.org
	@echo
	@echo "==================== begin BibTeX test 6 ====================="
	@echo
	-$(BIBCLEAN) testbib6.org >testbib6.bib 2>testbib6.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib6.bok testbib6.bib"
	-@if diff testbib6.bok testbib6.bib ; then $(RM) testbib6.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testbib6.eok testbib6.err"
	-@if diff testbib6.eok testbib6.err ; then $(RM) testbib6.err ; fi
	@echo
	@echo "===================== end BibTeX test 6 ======================"
	@echo

# Test bibclean verification of ISBN and ISSN values.  The test file,
# testisxn.org, contains several hundred correct values, and also
# several hundred erroneous values.  We therefore discard error and
# warning messages, we ignore the return code, and we don't try to use
# the output with LaTeX or BibTeX.
test-bibtex-7:	bibclean testisxn.org
	@echo
	@echo "==================== begin BibTeX test 7 ====================="
	@echo
	-$(BIBCLEAN) testisxn.org >testisxn.bib 2>testisxn.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testisxn.bok testisxn.bib"
	-@if diff testisxn.bok testisxn.bib ; then $(RM) testisxn.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testisxn.eok testisxn.err"
	-@if diff testisxn.eok testisxn.err ; then $(RM) testisxn.err ; fi
	@echo
	@echo "===================== end BibTeX test 7 ======================"
	@echo

# Test bibclean verification of CODEN values.  The test file,
# testcodn.org, contains about 1200 correct values, and also several
# hundred erroneous values.  We therefore discard error and warning
# messages, we ignore the return code, and we don't try to use the
# output with LaTeX or BibTeX.
test-bibtex-8:	bibclean testcodn.org
	@echo
	@echo "==================== begin BibTeX test 8 ====================="
	@echo
	-$(BIBCLEAN) testcodn.org >testcodn.bib 2>testcodn.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testcodn.bok testcodn.bib"
	-@if diff testcodn.bok testcodn.bib ; then $(RM) testcodn.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testcodn.eok testcodn.err"
	-@if diff testcodn.eok testcodn.err ; then $(RM) testcodn.err ; fi
	@echo
	@echo "===================== end BibTeX test 8 ======================"
	@echo

test-match:	match
	@echo
	@echo "===================== begin match test ======================="
	@echo
	./match <match.dat >match.lst
	@echo "There should be no differences found:"
	diff match.lok match.lst
	@if cmp match.lok match.lst 2>/dev/null ; then $(RM) match.lst ; fi
	@echo
	@echo "====================== end match test ========================"
	@echo

test-romtol:	romtol
	@echo
	@echo "===================== begin romtol test ======================"
	@echo
	./romtol <romtol.dat >romtol.lst
	@echo "There should be no differences found:"
	diff romtol.lok romtol.lst
	@if cmp romtol.lok romtol.lst 2>/dev/null ; then $(RM) romtol.lst ; fi
	@echo
	@echo "====================== end romtol test ======================="
	@echo

# Test bibclean on a collection of Scribe bibliographies containing
# test cases to exhibit variations in Scribe bibliography syntax.

test-scribe:	bibclean test-scribe-1 test-scribe-2 test-scribe-3

# The peculiar step using tr to prepare the .aux files is needed to
# overcome inconsistencies in the handling of backslashes by the IBM
# RS/6000 shell.  The documented behavior in the SunOS 4.1.1 manual
# pages is (emphasis mine):
#     All characters enclosed between a pair of single quote marks
#     (''), except a single quote, are quoted by the shell.  BACKSLASH
#     HAS NO SPECIAL MEANING INSIDE A PAIR OF SINGLE QUOTES.  A single
#     quote may be quoted inside a pair of double quote marks (for
#     example, "'").
# On SunOS, HP UX, IBM 3090 AIX, NeXT Mach, and SGI IRIX, the shells
# csh, sh, bash, and ksh agree with this.  However, on IBM RS/6000
# AIX 3.2, backslashes in single quotes are untouched by csh, but
# expanded by sh and ksh.  This is clearly a bug, because the INFO
# hypertext node on bsh/rsh says:
#     All characters, except the enclosing single quotation marks, are
#     taken literally, with any special meaning removed.
#
test-scribe-1:	bibclean $(SCRIBE-TESTS-1)
	@echo
	@echo "==================== begin Scribe test 1 ====================="
	@echo
	-@for f in $(SCRIBE-TESTS-1) ; \
	do \
		BASENAME=`basename $$f .org` ; \
		echo ; \
		echo "----------------------------------------------------" ; \
		echo ; \
		echo "$(BIBCLEAN) -scribe -no-check $$f >$$BASENAME.bib" ; \
		$(BIBCLEAN) -scribe -no-check $$f >$$BASENAME.bib \
			2>$$BASENAME.err; \
		echo ; \
		echo "There should be no differences found:" ; \
		echo "diff $$BASENAME.bok $$BASENAME.bib" ; \
		diff $$BASENAME.bok $$BASENAME.bib ; \
		echo ; \
		echo "There should be no differences found:" ; \
		echo "diff $$BASENAME.eok $$BASENAME.err" ; \
		if diff $$BASENAME.eok $$BASENAME.err ; \
			then $(RM) $$BASENAME.err ; fi ; \
		echo ; \
		echo 'Bbibstyle{plain}NBcitation{*}NBbibdata{'$$BASENAME'}' | \
			tr BN '\134\012' >$$BASENAME.aux ; \
		if [ "$$BASENAME" = "testscr1" ] ; \
			then echo "Expect 5 BibTeX warnings" ; fi ; \
		if [ "$$BASENAME" = "testscr2" ] ; \
			then echo "There should be no BibTeX warnings:" ; fi ; \
		echo "$(BIBTEX) $$BASENAME" ; \
		$(BIBTEX) $$BASENAME; \
		if cmp $$BASENAME.bok $$BASENAME.bib 2>/dev/null ; \
			then $(RM) $$BASENAME.bib ; fi ; \
	done
	@echo "===================== end Scribe test 1 ======================"
	@echo

test-scribe-2:	bibclean testscr2.org
	@echo
	@echo "==================== begin Scribe test 2 ====================="
	@echo
	-$(BIBCLEAN) -scribe -file -no-check testscr2.org \
		>testscr2.bib 2>testscr2.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr2.bok testscr2.bib"
	-@if diff testscr2.bok testscr2.bib ; then $(RM) testscr2.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr2.eok testscr2.err"
	-@if diff testscr2.eok testscr2.err ; then $(RM) testscr2.err ; fi
	@echo
	@echo
	-$(BIBCLEAN) -scribe -file -no-check -no-par testscr2.org \
		>testscr2.bi2 2>testscr2.er2
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr2.bo2 testscr2.bi2"
	-@if diff testscr2.bo2 testscr2.bi2 ; then $(RM) testscr2.bi2 ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr2.eo2 testscr2.er2"
	-@if diff testscr2.eo2 testscr2.er2 ; then $(RM) testscr2.er2 ; fi
	@echo
	@echo "===================== end Scribe test 2 ======================"
	@echo

test-scribe-3:	bibclean testscr3.org
	@echo
	@echo "==================== begin Scribe test 3 ====================="
	@echo
	-$(BIBCLEAN) -scribe -no-check testscr3.org >testscr3.bib 2>testscr3.err
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr3.bok testscr3.bib"
	-@if diff testscr3.bok testscr3.bib ; then $(RM) testscr3.bib ; fi
	@echo
	@echo "There should be no differences found:"
	@echo "diff testscr3.eok testscr3.err"
	-@if diff testscr3.eok testscr3.err ; then $(RM) testscr3.err ; fi
	@echo
	@echo "===================== end Scribe test 3 ======================"
	@echo

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

uninstall:
	-$(RM) $(bindir)/bibclean $(bindir)/bibclean-$(VERSION) \
		$(bindir)/.bibcleanrc \
		$(mandir)/bibclean.$(manext) \
		$(mandir)/bibclean-$(VERSION).$(manext) \
		$(mandir)/../cat$(manext)/bibclean.$(manext) \
		$(mandir)/../cat$(manext)/bibclean-$(VERSION).$(manext)
	-$(RM) install.time

uninstall-ftp:
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).tar
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).tar-lst
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).zip
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).zip-lst
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).zoo
	-$(RM) $(FTPDIR)/bibclean-$(VERSION).zoo-lst
	-$(RM) install-ftp.time

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
