# Generated automatically from Makefile.in by configure.
# Makefile for web2c --kb@mail.tug.org. Public domain.
version = 2010

# These lines define the memory dumps that fmts/bases/mems will make and
# install-fmts/install-bases/install-mems will install. plain.* is
# created automatically (as a link).  See the Formats node in
# doc/web2c.texi for details on the fmts.
#fmts = jlatex.fmt jlatex209.fmt # amsjtex.fmt jeplain.fmt texinfo.fmt
#E#efmts = #elatex.efmt
#C#cfmts = #latex.efmt
#P#pdffmts = #pdflatex.fmt
#P#pdfefmts = #pdfelatex.efmt
#O#ofmts = #lambda.fmt
bases = # I do not recommend building cmmf.base.
mems =  # mfplain.mem is probably not generally useful.

# The name of the file that defines your local devices for Metafont.
# (Only relevant during `make bases'.)  I recommend `modes.mf', which
# defines all known modes, plus useful definitions for all fonts.  It's
# available from ftp://ftp.tug.org/tex/modes.mf, among other places.
localmodes = modes

prefix = c:/usr/local
exec_prefix = ${prefix}

# Architecture-dependent executables.
bindir = ${exec_prefix}/bin

# Architecture-independent executables.
scriptdir = $(bindir)

# Architecture-dependent files, such as lib*.lib files.
libdir = ${exec_prefix}/lib

# Architecture-independent files.
datadir = ${prefix}/share

# Header files.
includedir = ${prefix}/include

# GNU .info* files.
infodir = ${prefix}/info

# Unix man pages.
manext = 1
mandir = ${prefix}/man/man$(manext)

# TeX system-specific directories. Not all of the following are relevant
# for all programs, but it seems cleaner to collect everything in one place.

# The default paths are now in kpathsea/texmf.in. Passing all the
# paths to sub-makes can make the arg list too long on system V.
# Note that if you make changes below, you will have to make the
# corresponding changes to texmf.in or texmf.cnf yourself.

# The root of the main tree.
texmf = c:/usr/local/share/texmf

# The directory used by varfonts.
vartexfonts = c:/var/tex/fonts

# Regular input files.
texinputdir = $(texmf)/tex
mfinputdir = $(texmf)/metafont
mpinputdir = $(texmf)/metapost
mftinputdir = $(texmf)/mft

# dvips's epsf.tex, rotate.tex, etc. get installed here;
# ditto for dvilj's fonts support.
dvips_plain_macrodir = $(texinputdir)/plain/dvips
dvilj_latex2e_macrodir = $(texinputdir)/latex/dvilj

# mktex.cnf, texmf.cnf, etc.
web2cdir = $(texmf)/web2c

# The top-level font directory.
fontdir = $(texmf)/fonts

# Memory dumps (.fmt/.base/.mem).
fmtdir = $(web2cdir)
basedir = $(fmtdir)
memdir = $(fmtdir)

# Pool files.
texpooldir = $(web2cdir)
mfpooldir = $(texpooldir)
mppooldir = $(texpooldir)

# Where the .map files from fontname are installed.
fontnamedir = $(texmf)/fontname

# For dvips configuration files, psfonts.map, etc.
dvipsdir = $(texmf)/dvips

# For dvips .pro files, gsftopk's render.ps, etc.
psheaderdir = $(dvipsdir)

# If a font can't be found close enough to its stated size, we look for
# each of these sizes in the order given.  This colon-separated list is
# overridden by the envvar TEXSIZES, and by a program-specific variable
# (e.g., XDVISIZES), and perhaps by a config file (e.g., in dvips).
# This list must be sorted in ascending order.
default_texsizes = 300:600

# End of paths.mk.
# 
texmflcl = c:/usr/local/share/texmf.local
web2c_lcl_dir = $(texmflcl)/web2c
fmt_lcl_dir = $(web2c_lcl_dir)
texpool_lcl_dir = $(web2c_lcl_dir)

# Used for triptrap.
DIFF = diff
DIFFFLAGS =

.SUFFIXES: # get rid of .p.obj
# common.mk -- used by all Makefiles.
SHELL = sh
MAKE=make
top_srcdir = .
srcdir = .

WD = setargv.obj

CC = cl
#CFLAGS = -nologo -MD -Od -Zi -DWIN32=1 -I. -I.. $(XCFLAGS)
#KDEBUG = /DEBUG:FULL
CFLAGS = -nologo -W3 -MD -O2 -DWIN32=1 -I. -I.. $(XCFLAGS)
LKDEBUG =

CPPFLAGS =  $(XCPPFLAGS)

YDEFS = -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE \
-D_CRT_OBSOLETE_NO_DEPRECATE -D_SECURE_SCL=0

DEFS = -DHAVE_CONFIG_H $(XDEFS) $(YDEFS)

# Kpathsea needs this for compiling, programs need it for linking.
LIBTOOL = $(kpathsea_srcdir_parent)/klibtool

# You can change [X]CPPFLAGS, [X]CFLAGS, or [X]DEFS, but
# please don't change ALL_CPPFLAGS or ALL_CFLAGS.
# prog_cflags is set by subdirectories of web2c.
ALL_CPPFLAGS = $(DEFS) -I. -I$(srcdir) \
  -I$(kpathsea_parent) -I$(kpathsea_srcdir_parent) \
  $(prog_cflags) $(CPPFLAGS)
ALL_CFLAGS = $(ALL_CPPFLAGS) $(CFLAGS) -c
compile = $(CC) $(ALL_CFLAGS)

.SUFFIXES:
.SUFFIXES: .c .obj # in case the suffix list has been cleared, e.g., by web2c
.c.obj:
	$(compile) $<

# Installation.
INSTALL = cp
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = $(INSTALL_PROGRAM)
INSTALL_DATA = ${INSTALL}
INSTALL_LIBTOOL_LIBS =
INSTALL_LIBTOOL_PROG =

# Creating (symbolic) links.
LN = cp

# We use these for many things.
kpathsea_parent = ../..
kpathsea_dir = $(kpathsea_parent)/kpathsea
kpathsea_srcdir_parent = $(top_srcdir)/..
kpathsea_srcdir = $(kpathsea_srcdir_parent)/kpathsea
kpathsea = $(kpathsea_dir)/kpathsealib.lib

#M#ifeq ($(CC), gcc)
#M#XDEFS = -Wpointer-arith $(warn_more)
#M#CFLAGS = -pipe -g $(XCFLAGS)
#M#endif
# End of common.mk.
# programs.mk -- used by Makefiles for executables only.

# Don't include $(CFLAGS), since ld -g under Linux forces
# static libraries, e.g., libc.lib and libX*.lib.
XLDFLAGS = -link /SUBSYSTEM:CONSOLE /STACK:0x300000
LDFLAGS =  $(XLDFLAGS)

# proglib is for web2c; 
# XLOADLIBES is for the installer.
LIBS = user32.lib advapi32.lib wsock32.lib 
LOADLIBES = $(proglib) $(kpathsea) $(LIBS) $(XLOADLIBES)

# May as well separate linking from compiling, just in case.
CCLD = $(CC)
link_command = $(CCLD) -Fe$@

# When we link with Kpathsea, have to take account that it might be a
# shared library, etc.
kpathsea_link = $(link_command)
# End of programs.mk.

CXX = cl
CXXLD = $(CXX)
cxx_link_command = $(CXXLD) -Fe$@ $(LDFLAGS) 
kpathsea_cxx_link = $(cxx_link_command)

#M#ifeq ($(CC), gcc)
#M#XDEFS = -Wimplicit -Wreturn-type -Wcomment -Wformat
#M#endif

# Make `#include <X11/...>' and `-lX...' work.
# This matches xdvik.
# wlibs is substituted by web2c's configure, LIBS by general configure
# routines, and the others by AC_PATH_XTRA.
# All the x_... variables will be empty if we aren't supporting X.
x_cppflags = 
x_ldflags = 
x_pre_libs = 
x_extra_libs = 
x_tool_libs = 
x_ext_lib = 
wlibs = 
# Follow the library order used in X11R6 itself:
#   -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 (some may not be present).
windowlink = $(windowlib) $(x_ldflags) $(x_tool_libs) $(x_pre_libs) $(x_ext_lib) $(wlibs) $(x_extra_libs)

# With --enable-ipc, TeX may need to link with -lsocket.
socketlibs = 

common_makeargs = $(MFLAGS) CC='$(CC)' CFLAGS='$(CFLAGS)' $(XMAKEARGS)
window_makeargs = x_cppflags='$(x_cppflags)' $(common_makeargs)
install_makeargs = INSTALL='$(INSTALL)' INSTALL_DATA='$(INSTALL_DATA)' \
  INSTALL_PROGRAM='$(INSTALL_PROGRAM)' \
  $(makevars) $(common_makeargs)  

proglib = ../lib/lib.lib
windowlib = ../window/window.lib
#P#ZLIBDIR=../../libs/zlib
#P#ZLIBSRCDIR=$(srcdir)/$(ZLIBDIR)
#P#LIBPNGDIR=../../libs/libpng
#P#LIBPNGSRCDIR=$(srcdir)/$(LIBPNGDIR)
#P#pdflib = pdftexdir/libpdf.lib
#P#LIBPNGDEP = @LIBPNGDEP@
#P#LDLIBPNG = @LDLIBPNG@
#P#LDZLIB = @LDZLIB@
#P#ZLIBDEP = @ZLIBDEP@
#P#xpdfroot = pdftexdir/xpdf-0.80
#P#xpdfdir  = $(xpdfroot)/xpdf
#P#xpdflib  = $(xpdfdir)/pdftoepdf.lib
#P#xpdfextradir = $(xpdfroot)/goo
#P#xpdfextralib = $(xpdfextradir)/libGoo.lib
#P#pdftexlibs = $(pdflib) $(LDLIBPNG) $(LDZLIB) $(xpdflib) $(xpdfextralib)
#P#pdftexlibsdep = $(pdflib) $(LIBPNGDEP) $(ZLIBDEP) $(xpdflib) $(xpdfextralib)

# The sh script that does the conversion:
web2c = srcdir=$(srcdir) $(shared_env) $(SHELL) $(srcdir)/web2c/jconvert
# Additional dependencies:
web2c_aux = web2c/jconvert ../web2c/common.defines
web2c_programs = #../web2c/fixwrites ../web2c/splitup ../web2c/web2c

# Unfortunately, suffix rules can't have dependencies, or multiple
# targets, and we can't assume all makes supports pattern rules.
.SUFFIXES: .p .c .ch .p
.p.c: # really depends on $(web2c_programs), and generates .h.
	$(web2c) $*
.ch.p: # really depends on ./tangle; for mf/mp/tex, also generates .pool
	$(shared_env) ../tangle ../$*.web $<

# These definitions have to come before the rules that expand them.
# The *{ini,[0-2]}.c files are created by splitup, run as part of convert.
# {mf,mp,tex}extra.c are created from lib/texmfmp.c, below.
#mf_c = mfini.c mf0.c
#mf_o = mfini.obj mf0.obj mfextra.obj
#mf_nowin_o = mfini.obj mf0.obj mfnowin.obj
#mp_c = mpini.c mp0.c
#mp_o = mpini.obj mp0.obj mpextra.obj
tex_c = texini.c tex0.c
tex_o = texini.obj tex0.obj texextra.obj \
        texkanji.obj jlib.obj jtex-pool.obj
dlltex_o = texini.obj tex0.obj nttdll.obj \
        texkanji.obj jlib.obj jtex-pool.obj
bibtex_o = jbibtex.obj bibkanji.obj jbib.obj jbiblib.obj

other_c = jbibtex.c
all_c = $(other_c) $(tex_c)


# Prevent Make from deleting the intermediate forms.
.PRECIOUS: %.ch %.p %.c

tex = tex

programs = nttjtex.dll jbibtex.exe
#programs = nttjtex.dll

#O#otps_programs = otps/otp2ocp otps/outocp

#  
default all: programs #dumps manpages doc/web2c.info
programs: $(programs) #$(mpware) $(otps_programs)

# Makefile fragments:

# Rules to link each program. I wish we could use a suffix rule for
# this, since it's so repetitive, but null suffixes don't work. And old
# makes don't support pattern rules. Doomed to forever cater to obsolesence.
jbibtex.exe: $(bibtex_o) $(kpathsea)
	$(kpathsea_link) $(bibtex_o) $(WD) $(LOADLIBES) $(LDFLAGS) $(LKDEBUG)

jtex.exe: $(tex_o) $(kpathsea)
	$(kpathsea_link) $(tex_o) $(socketlibs) $(WD) $(LOADLIBES) $(LDFLAGS) $(LKDEBUG)

nttjtex.dll: $(dlltex_o) $(kpathsea)
	cl -LD -Fe$@ $(dlltex_o) $(socketlibs) $(LOADLIBES) $(LDFLAGS)

# Additional dependencies for retangling.
tex.p: ../tangle.exe
# We need to be explicit for a number of programs because there is a
# $(srcdir) in the suffix rule.  This also means we can use a different
# suffix for the change file than .ch, if we want to.

bibtex.p: bibtex.web jbibtex.ch
	$(shared_env) ../tangle bibtex.web jbibtex.ch

bibtex.web: ../bibtex.web ../bibtex.ch
	../tie -m $@ ../bibtex.web ../bibtex.ch

#
# old one by manual work to include tex.ch (jtex-tryone.ch)
#
#tex.p jtex.pool: ../tex.web jtex-fin.ch
#	$(shared_env) ../tangle ../tex.web jtex-fin.ch
#	mv tex.pool jtex.pool
#jtex-fin.ch: ../tie.exe ../tex.web jtex-tryone.ch
#	../tie -c jtex-fin.ch ../tex.web jtex-tryone.ch

#
# new one with almost full tex.ch (H. Kitagawa 2016, jtex.ch)
#
tex.p jtex.pool: tex.web jtex-fin.ch
	$(shared_env) ../tangle tex.web jtex-fin.ch
	mv tex.pool jtex.pool

tex.web: ../tex.web ../tex.ch
	../tie -m $@ ../tex.web ../tex.ch

jtex-fin.ch: ../tie.exe tex.web jtex.ch ../tex-binpool.ch
	../tie -c jtex-fin.ch tex.web jtex.ch ../tex-binpool.ch

MAKECPOOL = ../web2c/makecpool.exe

jtex-pool.c: jtex.pool texd.h $(MAKECPOOL)
	$(MAKECPOOL) jtex >jtex-pool.c

# Additional dependencies for reconverting to C.
$(other_c): $(web2c_aux) $(web2c_programs)
bibtex.c: ../web2c/cvtbib.sed
c-sources: $(all_c)

jbibtex.c: bibtex.c
	cp bibtex.c $@

# Metafont and TeX generate more than .c file.
web2c_texmf = $(web2c_aux) $(web2c_programs) \
  ../web2c/texmf.defines ../web2c/coerce.h

$(tex_c) texcoerce.h texd.h: tex.p $(web2c_texmf)
	$(web2c) tex

# As long as we have to have separate rules to create these, might as well do
# a little work to avoid separate compilation rules, too.
texextra.obj: texextra.c
	$(compile) texextra.c -Fo$@
texextra.c: lib/texmfmp.c
	cp lib/texmfmp.c $@

texkanji.c: lib/kanji.c kanji.h
	sed s/TEX-OR-BIB/tex/ $(srcdir)/lib/kanji.c >$@
bibkanji.c: lib/kanji.c kanji.h
	sed s/TEX-OR-BIB/bib/ $(srcdir)/lib/kanji.c >$@
jbib.obj: lib/jbib.c
	$(compile) lib/jbib.c -Fo$@
jlib.obj: lib/jlib.c
	$(compile) lib/jlib.c -Fo$@
jbiblib.obj: lib/jlib.c
	$(compile) -DBIBTEX lib/jlib.c -Fo$@
nttdll.obj: nttdll.c
	$(compile) nttdll.c
nttdll.c: texextra.c
	sed 's/int main(int ac, string \*av)/__declspec(dllexport) int dllnttjtexmain (int ac, string *av)/' texextra.c >$@

# Additional dependencies for recompiling the C code are generated
# automatically, included at the end.

# Additional dependencies for relinking.
#$(web2c_programs) $(programs) otangle otangleboot tangle tangleboot: \
#  $(kpathsea) $(proglib)

# Making dumps.
all_fmts = jtex.fmt $(fmts)
#E#all_efmts = #etex.efmt $(efmts)
#C#all_cfmts = #tex.efmt $(cfmts)
#O#all_ofmts = #omega.fmt $(ofmts)
#P#all_pdffmts = #pdftex.fmt $(pdffmts)
#P#all_pdfefmts = #pdfetex.efmt $(pdfefmts)
all_formats = $(all_fmts) $(all_efmts) $(all_cfmts) $(all_ofmts) $(all_pdffmts) $(all_pdfefmts)
all_bases = #mf.base $(bases)
all_mems = #mpost.mem $(mems)

#dumpenv = TEXMFCNF=../kpathsea TEXMF=$(texmf)
newtexmf = $(srcdir)/../../texmf
newtexmflcl = $(srcdir)/../../texmf.local
texin = $(newtexmf)/tex//
jtexin = $(newtexmflcl)/{jtex,tex}//
texfonts = $(newtexmf)/fonts/tfm//:$(newtexmflcl)/fonts/tfm//
dumpenv = TEXMFCNF=../kpathsea TEXINPUTS=$(jtexin):$(texin): TEXFONTS=$(texfonts):

dumps: fmts efmts cfmts ofmts pdffmts pdfefmts bases mems
fmts: $(all_fmts)
efmts: $(all_efmts)
cfmts: $(all_cfmts)
ofmts: $(all_ofmts)
pdffmts: $(all_pdffmts)
pdfefmts: $(all_pdfefmts)
bases: $(all_bases)
mems: $(all_mems)

jtex.fmt: jtex
	$(dumpenv) $(MAKE) $(makeargs) files="--progname=jtex jplain.tex dmjhira10.tfm" prereq-check
	$(dumpenv) ./jtex --fmt=jtex --ini \\input jplain \\dump <nul

jlatex.fmt: jtex
	$(dumpenv) $(MAKE) $(makeargs) files="--progname=jlatex jlatex.ltx" prereq-check
	$(dumpenv) ./jtex --progname=jlatex --ini \\input jlatex.ltx <nul

jlatex209.fmt: jtex
	$(dumpenv) $(MAKE) $(makeargs) files="--progname=jlatex209 jlplain.tex" prereq-check
	$(dumpenv) ./jtex --fmt=jlatex209 --ini \\input jlplain \\dump <nul

etex.efmt: etex
	$(dumpenv) $(MAKE) files="--progname=etex etex.src plain.tex cmr10.tfm" prereq-check
	$(dumpenv) ./etex --efmt=etex --ini \*\\input etex.src \\dump <nul

elatex.efmt: etex
	$(dumpenv) $(MAKE) files="--progname=elatex latex.ltx" prereq-check
	$(dumpenv) ./etex --efmt=elatex --ini \*\\input latex.ltx <nul

tex.efmt: etex
	$(dumpenv) $(MAKE) files="--progname=tex plain.tex cmr10.tfm" prereq-check
	$(dumpenv) ./etex --efmt=tex --ini \\input plain \\dump <nul

latex.efmt: etex
	$(dumpenv) $(MAKE) files="--progname=latex latex.ltx" prereq-check
	$(dumpenv) ./etex --progname=latex --ini \\input latex.ltx <nul

omega.fmt: omega
	$(dumpenv) $(MAKE) files="--progname=omega omega.tex" prereq-check
	$(dumpenv) ./omega --ini \\input omega.tex \\dump <nul

lambda.fmt: omega
	$(dumpenv) $(MAKE) files="--progname=lambda lambda.tex" prereq-check
	$(dumpenv) ./omega --ini --progname=lambda \\input lambda.tex <nul

pdftex.fmt: pdftex
	$(dumpenv) $(MAKE) files="--progname=pdftex plain.tex cmr10.tfm" prereq-check
	$(dumpenv) ./pdftex --fmt=pdftex --ini \\pdfoutput=1 \\input plain \\dump <nul

pdflatex.fmt: pdftex
	$(dumpenv) $(MAKE) files="--progname=pdflatex latex.ltx" prereq-check
	$(dumpenv) ./pdftex --fmt=pdflatex --ini \\pdfoutput=1 \\input latex.ltx <nul

pdftexinfo.fmt: pdftex
	$(dumpenv) $(MAKE) files="--progname=pdftexinfo pdftexinfo.ini" prereq-check
	$(dumpenv) ./pdftex --progname=pdftexinfo --ini pdftexinfo.ini <nul

pdfetex.efmt: pdfetex
	$(dumpenv) $(MAKE) files="--progname=pdfetex etex.src plain.tex cmr10.tfm" prereq-check
	$(dumpenv) ./pdfetex --efmt=pdfetex --ini \*\\pdfoutput=1\\input etex.src \\dump <nul

pdfelatex.efmt: pdfetex
	$(dumpenv) $(MAKE) files="--progname=pdfelatex latex.ltx" prereq-check
	$(dumpenv) ./pdfetex --efmt=pdfelatex --ini \*\\pdfoutput=1\\input latex.ltx <nul

mltex.fmt: tex
	$(dumpenv) $(MAKE) files="--progname=mltex plain.tex cmr10.tfm" prereq-check
	$(dumpenv) ./tex --mltex --fmt=mltex --ini \\input plain \\dump <nul

mllatex.fmt: tex
	$(dumpenv) $(MAKE) files="--progname=mllatex latex.ltx" prereq-check
	$(dumpenv) ./tex --mltex --fmt=mllatex --ini \\input latex.ltx <nul

mf.base: mf
	$(dumpenv) $(MAKE) $(makeargs) files="plain.mf cmr10.mf $(localmodes).mf" prereq-check
	$(dumpenv) ./mf --base=mf --ini \\input plain input $(localmodes) dump <nul

mpost.mem: mpost
	$(dumpenv) $(MAKE) $(makeargs) files=plain.mp prereq-check
	$(dumpenv) ./mpost --mem=mpost --ini \\input plain dump <nul

# This is meant to be called recursively, with $(files) set.
prereq-check: $(kpathsea_dir)/kpsewhich
	$(kpathsea_dir)/kpsewhich $(files) >nul || $(MAKE) prereq-lose >nul

prereq-lose:
	@echo "You seem to be missing input files necessary to make the" >&2
	@echo "basic formats (some or all of: $(files))." >&2
	@echo "Perhaps you've defined the default paths incorrectly, or" >&2
	@echo "perhaps you have environment variables set pointing" >&2
	@echo "to an incorrect location.  See ../kpathsea/BUGS." >&2
	@echo >&2
	@echo "If you simply do not have the files, you can" >&2
	@echo "retrieve a minimal set of input files from" >&2
	@echo "ftp://ftp.tug.org/tex/texklib.tar.gz, mirrored on" >&2
	@echo "CTAN hosts in systems/web2c." >&2
	false

$(kpathsea_dir)/kpsewhich: $(kpathsea)

amsjtex.fmt: jtex
	$(dumpenv) ./jtex --progname=amsjtex --ini amsjtex.ini <nul

# Texinfo changes the escape character from `\' to `@'.
texinfo.fmt: tex.fmt
	$(dumpenv) ./tex --progname=texinfo --ini texinfo @dump <nul

jeplain.fmt: jtex.fmt
	touch jeplain.aux # Makes cross-reference warnings work right.
	$(dumpenv) ./jtex --fmt=jeplain --ini \&./jtex eplain \\dump <nul

# 
NBINS=nttjtex.dll jbibtex.exe
install: $(NBINS)
	cp -p $(NBINS) c:/usr/local/txdir/w32tex/bin/
	cp -p $(NBINS) c:/usr/work/edrive/wk/dist/JTEX/bin/

install-exec:: install-links
install-data:: install-dumps

# The actual binary executables and pool files.
install-programs: $(programs)
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir) $(texpool_lcl_dir)
#	  $(mfpooldir) $(mppooldir)
#	cd mpware && $(MAKE) $(install_makeargs) install-exec
	for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $(bindir) $$p; done
#O#	cd otps && $(MAKE) $(install_makeargs) install-programs

# The links to {mf,mp,tex} for each format and for {ini,vir}{mf,mp,tex},
# plus the equivalents for e-TeX, Omega, pdfTeX, and pdfeTeX.
install-links: install-programs
	cd $(bindir) && (rm -f inijtex virjtex; \
	  $(LN) jtex inijtex; $(LN) jtex virjtex)
#E#	cd $(bindir) && (rm -f einitex evirtex; \
#E#	  $(LN) etex einitex; $(LN) etex evirtex)
#C#	cd $(bindir) && (rm -f tex initex virtex; \
#C#	  $(LN) etex tex; $(LN) etex initex; $(LN) etex virtex)
#O#	cd $(bindir) && (rm -f iniomega viromega; \
#O#	  $(LN) omega iniomega; $(LN) omega viromega)
#P#	cd $(bindir) && (rm -f pdfinitex pdfvirtex; \
#P#	  $(LN) pdftex pdfinitex; $(LN) pdftex pdfvirtex)
#P#	cd $(bindir) && (rm -f pdfeinitex pdfevirtex; \
#P#	  $(LN) pdfetex pdfeinitex; $(LN) pdfetex pdfevirtex)
#	cd $(bindir) && (rm -f inimf virmf; \
#	  $(LN) mf inimf; $(LN) mf virmf)
#	cd $(bindir) && (rm -f inimpost virmpost; \
#	  $(LN) mpost inimpost; $(LN) mpost virmpost)
# The ugly "" avoids a syntax error in case the lists are empty.
	test -z "$(fmts)" || \
	  for f in ""$(fmts); do base=`basename $$f .fmt`; \
	    (cd $(bindir) && (rm -f $$base; $(LN) jtex $$base)); done
	test -z "$(efmts)" || \
	  for f in ""$(efmts); do base=`basename $$f .efmt`; \
	    (cd $(bindir) && (rm -f $$base; $(LN) etex $$base)); done
	test -z "$(cfmts)" || \
	  for f in ""$(cfmts); do base=`basename $$f .efmt`; \
	    (cd $(bindir) && (rm -f $$base; $(LN) etex $$base)); done
	test -z "$(ofmts)" || \
	  for f in ""$(ofmts); do base=`basename $$f .fmt`; \
	    (cd $(bindir) && (rm -f $$base; $(LN) omega $$base)); done
	test -z "$(pdffmts)" || \
	  for f in ""$(pdffmts); do base=`basename $$f .fmt`; \
	    (cd $(bindir) && (rm -f $$base; $(LN) pdftex $$base)); done
	test -z "$(pdfefmts)" || \
	  for f in ""$(pdfefmts); do base=`basename $$f .efmt`; \
	    (cd $(bindir) && (rm -f $$base; $(LN) pdfetex $$base)); done
	test -z "$(bases)" || \
	  for f in ""$(bases); do base=`basename $$f .base`;\
	    (cd $(bindir) && (rm -f $$base; $(LN) mf $$base)); done
	test -z "$(mems)" || \
	  for f in ""$(mems); do base=`basename $$f .mem`; \
            (cd $(bindir) && (rm -f $$base; $(LN) mpost $$base)); done

# Always do plain.*, so examples from the TeXbook (etc.) will work.
install-dumps: install-fmts #install-bases install-mems
install-fmts: $(all_formats)
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(fmt_lcl_dir)
	echo "$(all_formats)" | grep '^[ ]*$$' >nul || \
	  for f in ""$(all_formats); do $(INSTALL_DATA) $$f $(fmt_lcl_dir)/$$f; done
	#cd $(fmtdir) && (rm -f plain.fmt; $(LN) tex.fmt plain.fmt)
#C#	#cd $(fmtdir) && (rm -f plain.efmt; $(LN) tex.efmt plain.efmt)

install-bases: $(all_bases)
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(basedir)
	test -z "$(all_bases)" || \
	  for f in ""$(all_bases); do $(INSTALL_DATA) $$f $(basedir)/$$f; done
	#cd $(basedir) && (rm -f plain.base; $(LN) mf.base plain.base)

install-mems: $(all_mems)
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(memdir)
	test -z "$(all_mems)" || \
	  for f in ""$(all_mems); do $(INSTALL_DATA) $$f $(memdir)/$$f; done
	#cd $(memdir) && (rm -f plain.mem; $(LN) mpost.mem plain.mem)

# Auxiliary files.
install-data::
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(texpool_lcl_dir) #$(mfpooldir) $(mppooldir) $(web2cdir) $(fontnamedir)
	$(INSTALL_DATA) jtex.pool $(texpool_lcl_dir)/jtex.pool
#E#	$(INSTALL_DATA) etex.pool $(texpooldir)/etex.pool
#O#	$(INSTALL_DATA) omega.pool $(texpooldir)/omega.pool
#P#	$(INSTALL_DATA) pdftex.pool $(texpooldir)/pdftex.pool
#P#	$(INSTALL_DATA) pdfetex.pool $(texpooldir)/pdfetex.pool
#	$(INSTALL_DATA) mf.pool $(mfpooldir)/mf.pool
#	$(INSTALL_DATA) mp.pool $(mppooldir)/mp.pool
#	cd $(srcdir)/share && for f in *.tcx; do \
#	  $(INSTALL_DATA) $$f $(web2cdir)/$$f; done
#	cd $(srcdir)/share && for f in *.map; do \
#	  $(INSTALL_DATA) $$f $(fontnamedir)/$$f; done
#	cd doc && $(MAKE) $(install_makeargs) install-data
#	cd man && $(MAKE) $(install_makeargs) install-data
#	$(INSTALL_DATA) $(srcdir)/tiedir/tie.1 $(mandir)/tie.$(manext)
#	$(INSTALL_DATA) fmtutil.cnf $(web2cdir)/fmtutil.cnf

# The distribution comes with up-to-date .info* files,
# so this should never be used unless something goes wrong
# with the unpacking, or you modify the manual.
doc/web2c.info:
	cd doc && $(MAKE) info
info dvi:
	cd doc && $(MAKE) $@

# Manual pages
manpages:
	cd man && $(MAKE) all

# 
# make dist won't work for anyone but me. Sorry.

#config.status: $(srcdir)/configure
#	$(SHELL) $@ --recheck

#Makefile: config.status $(srcdir)/Makefile.in $(top_srcdir)/../make/*.mk
#	$(SHELL) $<

# than c-auto.h when we don't need to remake the latter.
c-auto.h: stamp-auto
stamp-auto: $(srcdir)/c-auto.in
	$(SHELL) config.status
	date >stamp-auto

# End of config.mk.

# 
# Testing, including triptrap. The `x' filenames are for output.
tex_check = tex-check
#E#etex_check = etex-check
check: bibtex-check dvicopy-check dvitomp-check dvitype-check \
       $(etex_check) gftodvi-check gftopk-check gftype-check \
       mf-check mft-check mpost-check patgen-check pktogf-check \
       pktype-check pltotf-check pooltype-check $(tex_check) tftopl-check \
       vftovp-check vptovf-check weave-check

trip = trip
#E#etrip = etrip
triptrap: $(trip) trap mptrap $(etrip)
testdir = $(srcdir)/triptrap
testenv = TEXMFCNF=$(testdir)-j
dvitype_args = -output-level=2 -dpi=72.27 -page-start='*.*.*.*.*.*.*.*.*.*'
#trip: pltotf tftopl tex dvitype
trip: jtex
	@echo ">>> See $(testdir)/trip.diffs for example of acceptable diffs." >&2
	pltotf $(testdir)/trip.pl trip.tfm
	tftopl ./trip.tfm trip.pl
	-diff $(testdir)/trip.pl trip.pl
	rm -f trip.tex; $(LN) $(testdir)/trip.tex . # get same filename in log
	-$(SHELL) -c '$(testenv) ./jtex --progname=inijtex <$(testdir)/trip1.in >tripin.fot'
	mv trip.log tripin.log
	-diff $(testdir)/tripin.log tripin.log
# May as well test non-ini second time through.
	-$(SHELL) -c '$(testenv) ./jtex <$(testdir)/trip2.in >trip.fot'
	-diff $(testdir)/trip.fot trip.fot
# We use $(DIFF) instead of `diff' only for those files where there
# might actually be legitimate numerical differences.
	-$(DIFF) $(DIFFFLAGS) $(testdir)/trip.log trip.log
	$(SHELL) -c '$(testenv) dvitype $(dvitype_args) trip.dvi >trip.typ'
	-$(DIFF) $(DIFFFLAGS) $(testdir)/trip.typ trip.typ

# Can't run trap and mptrap in parallel, because both write trap.{log,tfm}.
trap: mf tftopl gftype
	@echo ">>> See $(testdir)/mftrap.diffs for example of acceptable diffs." >&2
	rm -f trap.mf; $(LN) $(testdir)/trap.mf . # get same filename in log
	-$(SHELL) -c '$(testenv) ./mf --progname=inimf <$(testdir)/mftrap1.in >mftrapin.fot'
	mv trap.log mftrapin.log
	-diff $(testdir)/mftrapin.log mftrapin.log
	-$(SHELL) -c '$(testenv) ./mf <$(testdir)/mftrap2.in >mftrap.fot'
	mv trap.log mftrap.log
	mv trap.tfm mftrap.tfm
	-diff $(testdir)/mftrap.fot mftrap.fot
	-diff $(testdir)/mftrap.log mftrap.log
	./tftopl ./mftrap.tfm mftrap.pl
	-diff $(testdir)/mftrap.pl mftrap.pl
	$(SHELL) -c '$(testenv) ./gftype -m -i ./trap.72270gf >trap.typ'
	-diff $(testdir)/trap.typ trap.typ

mptrap: pltotf mpost tftopl
	@echo ">>> See $(testdir)/mptrap.diffs for example of acceptable diffs." >&2
	rm -f mtrap.mp; $(LN) $(testdir)/mtrap.mp . # get same filename in log
	./pltotf $(testdir)/trapf.pl trapf.tfm
	-$(SHELL) -c '$(testenv) ./mpost --progname=inimpost mtrap'
	-diff $(testdir)/mtrap.log mtrap.log
	-diff $(testdir)/mtrap.0 mtrap.0
	-diff $(testdir)/mtrap.1 mtrap.1
	-diff $(testdir)/writeo writeo
	-diff $(testdir)/writeo.2 writeo.2
	rm -f trap.mp; $(LN) $(testdir)/trap.mp .
	rm -f trap.mpx; $(LN) $(testdir)/trap.mpx .
	-$(SHELL) -c '$(testenv) ./mpost --progname=inimpost <$(testdir)/mptrap1.in >mptrapin.fot'
	mv trap.log mptrapin.log
	-diff $(testdir)/mptrapin.log mptrapin.log
# Must run inimp or font_name[null_font] is not initialized, leading to diffs.
	-$(SHELL) -c '$(testenv) ./mpost --progname=inimpost <$(testdir)/mptrap2.in >mptrap.fot'
	mv trap.log mptrap.log
	mv trap.tfm mptrap.tfm
	-diff $(testdir)/mptrap.fot mptrap.fot
	-diff $(testdir)/mptrap.log mptrap.log
	-diff $(testdir)/trap.5 trap.5
	-diff $(testdir)/trap.6 trap.6
	-diff $(testdir)/trap.148 trap.148
	-diff $(testdir)/trap.149 trap.149
	-diff $(testdir)/trap.150 trap.150
	-diff $(testdir)/trap.151 trap.151
	-diff $(testdir)/trap.197 trap.197
	-diff $(testdir)/trap.200 trap.200
	./tftopl ./mptrap.tfm mptrap.pl
	-diff $(testdir)/mptrap.pl mptrap.pl

# Ad hoc tests.
bibtex-check: bibtex
	test -f tests/exampl.aux || \
	  cp $(srcdir)/tests/exampl.aux tests/exampl.aux
	BSTINPUTS=$(srcdir)/tests ./bibtex tests/exampl

dvicopy-check: dvicopy
	./dvicopy $(srcdir)/tests/story tests/xstory.dvi
# Redirect stderr so the terminal output will end up in the log file.
	(TFMFONTS=$(srcdir)/tests: ./dvicopy <$(srcdir)/tests/pplr.dvi \
	  >tests/xpplr.dvi) 2>&1

dvitomp-check: dvitomp
	./dvitomp $(srcdir)/tests/story.dvi tests/xstory.mpx
	TFMFONTS=$(srcdir)/tests: VFFONTS=$(srcdir)/tests: \
	  ./dvitomp $(srcdir)/tests/ptmr 
	mv ptmr.mpx tests/xptmr.mpx

dvitype-check: dvitype
	./dvitype -show-opcodes $(srcdir)/tests/story >tests/xstory.dvityp
	./dvitype --p=\*.\*.2 $(srcdir)/tests/pagenum.dvi >tests/xpagenum.typ

gftodvi-check: gftodvi
	TFMFONTS=$(srcdir)/tests: ./gftodvi -verbose \
	  $(srcdir)/tests/cmr10.600gf
	mv cmr10.dvi tests/xcmr10.dvi

gftopk-check: gftopk
	./gftopk -verbose $(srcdir)/tests/cmr10.600gf tests/xcmr10.pk
	./gftopk $(srcdir)/tests/cmr10.600gf cmr10.pk && rm cmr10.pk

gftype-check: gftype
	./gftype $(srcdir)/tests/cmr10.600gf >tests/xcmr10.gft1
	./gftype -m -i $(srcdir)/tests/cmr10.600gf >tests/xcmr10.gft2

mf-check: trap mf.base
	./mf '&./mf \tracingstats:=1; end.'
	./mf $(srcdir)/tests/online
	./mf $(srcdir)/tests/one.two
	./mf $(srcdir)/tests/uno.dos

mft-check: mft
	./mft $(srcdir)/tests/io; mv io.tex tests/io.tex

mpost-check: mptrap mpost.mem
	./mpost '&./mpost \tracingstats:=1; end.'
	MAKEMPX_BINDIR=`pwd`:`pwd`/mpware MPXCOMMAND=mpware/makempx \
	  ./mpost $(srcdir)/tests/mptest
	./mpost $(srcdir)/tests/one.two
	./mpost $(srcdir)/tests/uno.dos

patgen-check: patgen
	./patgen $(srcdir)/tests/dict $(srcdir)/tests/patterns tests/xout \
	   $(srcdir)/tests/translate <$(srcdir)/tests/patgen.in

pktogf-check: pktogf
	./pktogf -verbose $(srcdir)/tests/cmr10.pk tests/xcmr10.600gf
	./pktogf $(srcdir)/tests/cmr10.pk && rm cmr10.gf

pktype-check: pktype
	./pktype $(srcdir)/tests/cmr10.pk >tests/xcmr10.pktyp

pltotf-check: pltotf
	./pltotf -verbose $(srcdir)/tests/cmr10 tests/xcmr10

# When tex.pool has not been generated we pooltype etex.pool
pooltype-check: pooltype
	./pooltype tex.pool >tests/xtexpool.typ
#C#	./pooltype etex.pool >tests/xtexpool.typ

# No need for tangle-check, since we run it to make everything else.

tex-check: trip tex.fmt
# Test truncation (but don't bother showing the warning msg).
	./tex --output-comment="`cat $(srcdir)/PROJECTS`" \
	    $(srcdir)/tests/hello 2>nul \
	  && ./dvitype hello.dvi | grep olaf@infovore.xs4all.nl >nul
# \openout should show up in \write's.
	./tex $(srcdir)/tests/openout && grep xfoo openout.log
# one.two.tex -> one.two.log
	./tex $(srcdir)/tests/one.two && ls -l one.two.log
# uno.dos -> uno.log
	./tex $(srcdir)/tests/uno.dos && ls -l uno.log
	./tex $(srcdir)/tests/just.texi && ls -l just.log
	-./tex $(srcdir)/tests/batch.tex
	./tex --shell $(srcdir)/tests/write18 | grep echo
# tcx files test (to be included)
#	./tex --translate-file=$(srcdir)/share/isol1-t1.tcx \
#	  $(srcdir)/tests/eight && ./dvitype eight.dvi >eigh.typ
	./tex --mltex --progname=initex $(srcdir)/tests/mltextst
	-./tex <nul
	-PATH=`pwd`:$(kpathsea_dir):$(kpathsea_srcdir):$$PATH \
	  WEB2C=$(kpathsea_srcdir) TMPDIR=.. \
	  ./tex '\nonstopmode\font\foo=nonesuch\end'

tftopl-check: tftopl
	./tftopl -verbose $(srcdir)/tests/cmr10 tests/xcmr10

vftovp-check: vftovp
	TFMFONTS=$(srcdir)/tests ./vftovp -verbose $(srcdir)/tests/ptmr ptmr tests/xptmr

vptovf-check: vptovf
	./vptovf $(srcdir)/tests/ptmr tests/xptmr tests/xptmr

weave-check: weave
	./weave $(srcdir)/pooltype

installcheck:
	cd $(srcdir)/tests && bibtex allbib
	mf '\mode:=ljfour; input logo10' && tftopl logo10.tfm >nul
	tex '\nonstopmode \tracingstats=1 \input story \bye'

# 
# Cleaning.
#P#pdftexdir = pdftexdir
#P#pdfetexdir = pdfetexdir
#O#otps = otps
all_subdirs = doc lib man mpware web2c window $(otps) $(pdftexdir) $(pdfetexdir) $(xpdfdir) $(xpdfextradir)

# Having a multiple-target rule with the subdir loop fails because of
# the dependencies introduced by clean.mk.  Yet, we want the
# dependencies here at the top level so that distclean will run the
# clean rules, etc.  So, sigh, put the subdir loop in each target and
# only run it if we have a Makefile.  Alternatively, we could do as
# Automake does.

mostlyclean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done
	rm -f otangleboot tangleboot
clean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done
	rm -f *.aux *.c *.dvi *.fot *.log *.pl *.tfm *.typ 
	rm -f *.base *.fmt *.efmt *.mem
	rm -rf tfm
# Have to list generated .h's explicitly since our real headers,
# e.g., help.h, are in this directory too.
	rm -f *coerce.h *d.h bibtex.h dvicopy.h dvitomp.h dvitype.h gftodvi.h
	rm -f gftopk.h gftype.h mft.h odvicopy.h odvitype.h ofm2opl.h
	rm -f opl2ofm.h otangle.h ovf2ovp.h ovp2ovf.h patgen.h pktogf.h
	rm -f pktype.h pltotf.h pooltype.h tangle.h tftopl.h vftovp.h vptovf.h
	rm -f weave.h
# Cleanup from triptrap.
	rm -f trip.tex trap.mf mtrap.mp trap.mp trap.mpx
	rm -f trip.* tripin.* tripos.tex 8terminal.tex
	rm -f trap.* mftrap.* mftrapin.* mptrap.* mptrapin.*
	rm -f trapf.* mtrap.* writeo* missfont.log
distclean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done
	rm -f *.pool *extra.c *.fm
# Have to list .p's explicitly because we can't remove tangleboot.p.
	rm -f bibtex.p dvicopy.p dvitomp.p dvitype.p etex.p gftodvi.p gftopk.p
	rm -f gftype.p mf.p mft.p mp.p odvicopy.p odvitype.p ofm2opl.p omega.p
	rm -f opl2ofm.p otangle.p ovf2ovp.p ovp2ovf.p patgen.p pdftex.p
	rm -f pdfetex.p pktogf.p pktype.p pltotf.p pooltype.p tangle.p
	rm -f tex.p tftopl.p vftovp.p vptovf.p weave.p
	rm -f otangleboot.c otangleboot.h tangleboot.c tangleboot.h
# And we clean up generated web and change files.
	rm -f etex.web omega.web pdftex.web pdfetex.web
	rm -f etex.ch  omega.ch  pdftex.ch  pdfetex.ch
	rm -f odvicopy.web odvitype.web ofm2opl.web opl2ofm.web otangle.web
	rm -f odvicopy.ch  odvitype.ch  ofm2opl.ch  opl2ofm.ch  otangle.ch 
	rm -f ovf2ovp.web ovp2ovf.web
	rm -f ovf2ovp.ch  ovp2ovf.ch
# And some miscellaneous files
	rm -f etrip.tex otangleboot.p omega.c omegamem.h
#P#	rm -f macnames.c ttf2afm.c; cd $(xpdfroot); rm -f c++-auto.h c-auto.h config.log config.status xpdf/pdftoepdf.cc xpdf/epdf.h
	rm -f fmtutil.cnf

extraclean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done
# Remove triptrap junk here too.
	rm -f trip.tex trap.mf mtrap.mp trap.mp trap.mpx
	rm -f trip.* tripin.* tripos.tex 8terminal.tex
	rm -f trap.* mftrap.* mftrapin.* mptrap.* mptrapin.*
	rm -f trapf.* mtrap.* writeo* missfont.log
	rm -f *.out *.typ *.fot
# And etrip junk as well.
	rm -f etrip.tex
	rm -f etrip.* etripin.*
maintainer-clean::
	test ! -r lib/Makefile \
	  || for d in $(all_subdirs); do (cd $$d && $(MAKE) $@); done

# clean.mk -- cleaning.
mostlyclean::
	rm -f *.obj

clean:: mostlyclean
	rm -f $(program) $(programs) squeeze lib$(library).* $(library).lib *.bad
	rm -f *.exe *.dvi *.lj

distclean:: extraclean clean
	rm -f Makefile
	rm -f config.status config.log config.cache c-auto.h
	rm -f stamp-auto stamp-tangle stamp-otangle

# Although we can remake configure and c-auto.in, we don't remove
# them, since many people may lack Autoconf.  Use configclean for that.
maintainer-clean:: distclean
	rm -f *.info*

extraclean::
	rm -f *.aux *.bak *.bbl *.blg *.dvi *.log *.pl *.tfm *.vf *.vpl
	rm -f *.*pk *.*gf *.mpx *.i *.s *~ *.orig  *.rej *\#*
	rm -f CONTENTS.tex a.out core mfput.* texput.* mpout.*

configclean:
	rm -f configure c-auto.in c-auto.h stamp-*
# End of clean.mk.

# Let's stick a rule for TAGS here, just in case someone wants them.
# (We don't put them in the distributions, to keep them smaller.)
TAGS: *.c *.h
	pwd | grep kpathsea >nul && append=../kpathsea/TAGS; \
	  etags $$append *.[ch]

# Prevent GNU make 3.[59,63) from overflowing arg limit on system V.
.NOEXPORT:

# End of rdepend.mk.

# 
# Local variables:
# page-delimiter: "^# \f"
# End:
