# Generated automatically from Makefile.in by configure.
#=======================================================================
# Makefile for bibcheck, a BibTeX bibliography file heuristic check
# utility.
#
# Current target list:
#	all			make bibcheck and documentation files
#	bibcheck.hlp		VAX VMS HELP file of manual pages
#	bibcheck.ps		PostScript file of typeset manual pages
#	bibcheck.ser		spelling error file
#	bibcheck.shar		UNIX shar bundle for e-mail distribution
#	bibcheck.tar		UNIX tar archive bundle
#	bibcheck.txt		ASCII text file of manual pages
#	bibcheck.zip		Info-ZIP archive bundle
#	bibcheck.zoo		Zoo archive bundle
#	check			perform validation tests
#	check-version		test extraction of version number
#	clean			remove temporary files
#	clobber			remove all automatically recreatable files
#	configure		create configure script (needs GNU autoconf!)
#	distclean		remove all automatically recreatable
#				files, including biblex.c
#	install			install bibcheck on system
#	install-ftp		install bibcheck on anonymous ftp directory
#	maintainer-clean	more than distclean (do NOT use!)
#	mostlyclean		same as clobber
#	spell			check spelling (with two spellers)
#	uninstall		remove installed executable and man pages
#	uninstall-ftp		remove installed files in anonymous ftp
#				directory
#
# [16-Oct-1995]
#=======================================================================

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

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

# Change these two directories to match local conventions if you
# wish to do "make install" and "make install-ftp":
CATDIR		= $(prefix)/man/cat1
MANDIR		= $(prefix)/man/man1
MANEXT		= 1
FTPDIR		= /usr/spool/ftp/pub/tex/bib
FTPDIR		= /u/ftp/pub/tex/bib

CC              = cc
CXX             = c++
CFLAGS          = -g $(OPT) $(INCDIRS) $(DEFINES)
CXXFLAGS	= -g -O2 $(OPT) $(INCDIRS) $(DEFINES)

DEFINES		= -D__EXTERN_C__
INCDIRS		= -I. -I$(srcdir)
LDFLAGS         = $(OPT) $(MALLOCDEBUG)
LEX		= flex
LFLAGS		= -l
MALLOCDEBUG	= 

OPT		=


# Need new awk (nawk) or gawk here:
AWK		= mawk

# Path name to bibcheck from test subdirectory
BIBCHECK	= ../bibcheck

# This variable lists the basenames of the test files.  Those with
# extension .in are input files for bibcheck, those with extension
# .ook contain correct stdout output from bibcheck for comparison with
# the .out files created by "make check", and those with extension
# .eok contain correct stderr output from bibcheck for comparison with
# the .err files created by "make check"
CHECKFILES	= check001

CHMOD		= chmod

COL		= col -b

COMPRESS	= compress

CP		= /bin/cp

DIFF		= diff

DIST-FILES      = CHANGELOG COPYING Makefile.in README bibcheck.awk \
		  bibcheck.c bibcheck.man bibcheck.hlp bibcheck.ps \
		  bibcheck.sh bibcheck.sok bibcheck.txt biblex.l bibtest1.bib \
		  bibyydcl.h config.hin configure configure.in configure.sed \
		  custom.h hash.c hash.h man2ps regexp/Makefile regexp/README \
		  regexp/args.h regexp/regerror.c regexp/regexp.3 \
		  regexp/regexp.c regexp/regexp.h regexp/regmagic.h \
		  regexp/regsub.c regexp/tests regexp/timer.c regexp/try.c \
		  regexp/try.errs rofvms.awk strdup.c stricm.c strnic.c \
		  xalloc.c xalloc.h xctype.h xerrno.h xstddef.h xstdlib.h \
		  xstring.h xtypes.h xunistd.h save/config.h save/Makefile \
		  save/configure test/check001.eok test/check001.in \
		  test/check001.ook



# Extra flags for gcc and g++ to get maximal checking
GCCFLAGS	= -Wall -Wshadow -Wcast-qual -Wpointer-arith \
		  -Wwrite-strings

ISPELL		= ispell

LDFLAGS		=

LIBS		=  -L$(libdir) -lfl -lfl

LN		= ln -s

MAN2PS		= ./man2ps

MKDIR		= mkdir

NROFF		= nroff

RM		= /bin/rm -f

RMDIR		= rmdir

SED		= sed

SHELL		= /bin/sh

SORT		= sort

SPELL		= spell

TAGS-FILES      = bibcheck.c bibyydcl.h config.h custom.h hash.c \
		  hash.h strdup.c stricm.c strnic.c xalloc.c xalloc.h \
		  xctype.h xerrno.h xstddef.h xstdlib.h xstring.h \
		  xtypes.h xunistd.h

UNZIP		= unzip

# NB: The version number of the FTP bibcheck archive files is extracted
# from that of bibcheck.awk.
# VERSION	= `$(AWK) '/^\#\#\#[ \t]*version *= *"[0-9.]+", *$$/ \
#		{ gsub(/[^0-9.]/,"",$$4); print $$4 }' bibcheck.awk`
# The version number comes from bibcheck.c, starting with version 0.08.
VERSION		= `$(AWK) '/^[ \t]*version *= *"[0-9.]+", *$$/ \
		{ gsub(/[^0-9.]/,"",$$3); print $$3 }' bibcheck.c`

ZIP		= zip

ZOO		= zoo

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

.SUFFIXES:	.i .c .l

# We need an explicit rule here because of a bug in IBM RS/6000 AIX
# 3.2.5 make: the $(LFLAGS) part is missing, sigh...  It is remotely
# possible that the -t flag may not be universally supported by older
# lex implementations, but this has not been a problem on recent UNIX
# versions from the major vendors.  If you get a error from this rule,
# just replace it by one suitable for your system (hint: make -p will
# show you the defaults if you comment this one out), and then inform
# the author of this program.
.l.c:
	$(LEX) $(LFLAGS) -t $< >$@

# Preprocess only and eliminate lines with only white space.
.c.i:
	$(CC) -E $(CPPFLAGS) $(CFLAGS) $< | grep -v '^[ 	]*$$' >$*.i

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

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

all:	bibcheck bibcheck.txt bibcheck.hlp

BIBCHECK_OBJS = bibcheck.o biblex.o hash.o strdup.o stricm.o strnic.o \
		xalloc.o regexp/regexp.o regexp/regerror.o

bibcheck:	$(BIBCHECK_OBJS)
	$(CC) $(CFLAGS) -o $@ $(BIBCHECK_OBJS) $(LDFLAGS) $(LIBS)

regexp/regexp.o:	 regexp/regexp.c regexp/regexp.h regexp/regmagic.h
	(cd regexp ; $(MAKE) CC='$(CC)' CFLAGS='$(CFLAGS) -I..' regexp.o)

regexp/regerror.o:	 regexp/regerror.c
	(cd regexp ; $(MAKE) CC='$(CC)' CFLAGS='$(CFLAGS) -I..' regerror.o)

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

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

bibcheck.shar:	$(DIST-FILES)
	shar -b -c -v $(DIST-FILES) >bibcheck.shar

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

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

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

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

check:	check-version bibcheck
	@echo "bibcheck was built with:"
	@echo "	CC = $(CC)"
	@echo "	CFLAGS = $(CFLAGS)"
	@echo "	LEX = $(LEX)"
	@echo
	@echo "The following checks should produce no output other than their names"
	@cd test ; \
	for f in $(CHECKFILES) ; \
	do \
		echo $$f ; \
		$(BIBCHECK) $$f.in >$$f.out 2>$$f.err ; \
		if cmp $$f.eok $$f.err ; \
		then $(RM) $$f.err ; \
		else \
			echo Failure on $$f.err ... ; \
			ls -l $$f.eok $$f.err ; \
			$(DIFF) $$f.eok $$f.err ; \
		fi ; \
		if cmp $$f.ook $$f.out ; \
		then $(RM) $$f.out ; \
		else \
			echo Failure on $$f.out ... ; \
			ls -l $$f.ook $$f.out ; \
			test -s $$f.out && $(DIFF) $$f.ook $$f.out ; \
		fi ; \
	done

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

clean:
	-$(RM) *.i
	-$(RM) *.o
	-$(RM) *.log
	-$(RM) *.shar
	-$(RM) *.tar
	-$(RM) *.tar-lst
	-$(RM) *.zip
	-$(RM) *.zip-lst
	-$(RM) *.zoo
	-$(RM) *.zoo-lst
	-$(RM) *~
	-$(RM) \#*
	-$(RM) a.out
	-$(RM) core
	-$(RM) test/core
	-$(RM) test/*.err
	-$(RM) test/*.out
	(cd regexp; $(MAKE) clean)

clobber mostlyclean:	clean
	-$(RM) bibcheck
	-$(RM) bibcheck.hlp
	-$(RM) bibcheck.txt
	-$(RM) bibcheck.ps
	-$(RM) bibcheck.ser
	(cd regexp; $(MAKE) clobber)

configure: configure.in configure.sed
	-$(RM) config.cache
	-$(RM) config.log
	-$(RM) config.status
	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

# The C code from lex is generally system-dependent, sigh...
distclean:	clobber
	-$(RM) biblex.c
	-$(RM) Makefile
	-$(RM) config.status
	-$(RM) config.cache
	(cd regexp; $(MAKE) distclean)

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

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

install:	bibcheck
	$(CP) bibcheck $(bindir)/bibcheck
	$(CHMOD) 755 $(bindir)/bibcheck
	$(CP) bibcheck.man $(MANDIR)/bibcheck.$(MANEXT)
	-$(RM) $(CATDIR)/bibcheck.$(MANEXT)
	$(CHMOD) 644 $(MANDIR)/bibcheck.$(MANEXT)

# This step is obsolete, but is retained in case the C version
# cannot be installed.
install-obsolete-awk-version:
	if [ ! -d $(libdir)/bibcheck ] ; then $(MKDIR) $(libdir)/bibcheck; fi
	$(CP) bibcheck.awk $(libdir)/bibcheck/bibcheck.awk
	$(SED) -e "s=@LIBDIR@=$(libdir)=" \
		-e "s=mawk=$(AWK)=" \
		-e "s=@PWD@=`pwd`=" \
		-e "s=@DATE@=`date`=" \
		-e "s=@USER@=$$LOGNAME=" \
		-e "s=@HOSTNAME@=`hostname`=" \
		bibcheck.sh > $(bindir)/bibcheck
	$(CHMOD) 755 $(bindir)/bibcheck
	$(CP) bibcheck.man $(MANDIR)/bibcheck.$(MANEXT)
	-$(RM) $(CATDIR)/bibcheck.$(MANEXT)
	$(CHMOD) 644 $(MANDIR)/bibcheck.$(MANEXT)

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

# Check the spelling in the bibcheck script and manual pages, leaving
# exceptions in bibcheck.ser.  Both spell and ispell are used.
SPELL-FILTER = cat bibcheck.awk bibcheck.man bibcheck.sh
spell:	bibcheck.ser

bibcheck.ser:
	-if [ ! -f bibcheck.sok ] ; then touch bibcheck.sok ; fi
	-$(SPELL-FILTER) | $(SPELL) +bibcheck.sok >/tmp/bibcheck.ser
	-$(SPELL-FILTER) | $(ISPELL) -l -p bibcheck.sok >>/tmp/bibcheck.ser
	-$(SORT) -u /tmp/bibcheck.ser >bibcheck.ser
	-if [ ! -s bibcheck.ser ] ; then $(RM) bibcheck.ser ; fi
	-$(RM) /tmp/bibcheck.ser

uninstall:
	-$(RM) $(bindir)/bibcheck
	-$(RM) $(libdir)/bibcheck/bibcheck.awk
	-$(RM) $(CATDIR)/bibcheck.$(MANEXT)
	-$(RM) $(MANDIR)/bibcheck.$(MANEXT)
	-$(RMDIR) $(libdir)/bibcheck

uninstall-ftp:
	-$(RM) $(FTPDIR)/bibcheck-$(VERSION).tar.z
	-$(RM) $(FTPDIR)/bibcheck-$(VERSION).tar-lst
	-$(RM) $(FTPDIR)/bibcheck-$(VERSION).zip
	-$(RM) $(FTPDIR)/bibcheck-$(VERSION).zip-lst
	-$(RM) $(FTPDIR)/bibcheck-$(VERSION).zoo
	-$(RM) $(FTPDIR)/bibcheck-$(VERSION).zoo-lst

CONFIG_H	= config.h custom.h

bibcheck.i:     bibcheck.c $(CONFIG_H) xstring.h xstdlib.h xctype.h \
		hash.h regexp/regexp.h Makefile

bibcheck.o:     bibcheck.c $(CONFIG_H) xstring.h xstdlib.h xctype.h \
		hash.h regexp/regexp.h

biblex.i:       biblex.c bibyydcl.h $(CONFIG_H) xctype.h xstdlib.h \
		xstring.h Makefile

biblex.o:	biblex.c bibyydcl.h $(CONFIG_H) xctype.h xstdlib.h \
		xstring.h

hash.i:         hash.c $(CONFIG_H) xstring.h xalloc.h xctype.h \
		hash.h Makefile

hash.o:		hash.c $(CONFIG_H) xstring.h xalloc.h xctype.h \
		hash.h

strdup.i:       strdup.c $(CONFIG_H) xstdlib.h xstring.h xunistd.h \
		Makefile

strdup.o:       strdup.c $(CONFIG_H) xstdlib.h xstring.h xunistd.h

stricm.i:       stricm.c $(CONFIG_H) xctype.h xstdlib.h xstring.h \
		Makefile

stricm.o:       stricm.c $(CONFIG_H) xctype.h xstdlib.h xstring.h

strnic.i:       strnic.c $(CONFIG_H) xctype.h xstdlib.h xstring.h \
		Makefile

strnic.o:       strnic.c $(CONFIG_H) xctype.h xstdlib.h xstring.h

xalloc.i:       xalloc.c $(CONFIG_H) xstdlib.h xunistd.h Makefile

xalloc.o:	xalloc.c $(CONFIG_H) xstdlib.h xunistd.h

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