# Generated automatically from Makefile.in by configure.
# This file makes TeX in its various incarnations.

SHELL = /bin/sh

srcdir = .
VPATH = .

# Routines used everywhere.
commondefines=../$(srcdir)/lib/common.defines ../$(srcdir)/lib/texmf.defines
commonh=../$(srcdir)/lib/common.h ../$(srcdir)/lib/texmfmem.h
commono=../lib/lib.a

# Routines used in TeX and Metafont.
extrac=../$(srcdir)/lib/texmf.c
extrah=../$(srcdir)/lib/texmf.h

# Routines used in TeX, Metafont, and BibTeX.
fileioc=../$(srcdir)/lib/openinout.c
fileioo=openinout.o

# If you have applied patches to make Michael Ferguson's multi-lingual
# TeX, or perhaps other patches as well, uncomment the next line.
#tex9_o = tex9.o
objs=$(fileioo) tex0.o tex1.o tex2.o tex3.o tex4.o tex5.o tex6.o tex7.o \
     tex8.o $(tex9_o)
iobjs=iextra.o initex.o
vobjs=vextra.o itex.o

# Where the trip files are.
texsrcdir = ../$(srcdir)/tex
tripdir = $(texsrcdir)/TeXtrip


CC = gcc
CFLAGS = -g
CPPFLAGS = -DTeX -I../$(srcdir)/lib

CCLD = $(CC)
LDFLAGS = $(CFLAGS) $(XLDFLAGS)
LIBS =  $(extralibs)
libs = $(commono) $(LIBS)

INSTALL = cp
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL)

LN = ln -s

# spiff -r5e-8 gives cleaner results than just `diff', but because it
# also produces backspaces and other verbiage, I haven't taught
# configure about it.
DIFF = diff
DIFFFLAGS =

# The formats we know how to make.
formats=amslatex.fmt amstex.fmt etex.fmt inrstex.fmt latex.fmt picplus.fmt \
slitex.fmt tex.fmt texinfo.fmt 

# And how to make them.
initex = TEXPOOL=. ./initex


# What to pass to submakes.
makeargs=SHELL='$(SHELL)' CC='$(CC)' CFLAGS='$(CFLAGS)' CCLD='$(CCLD)' \
LDFLAGS='$(LDFLAGS)' LIBS='$(libs)' LN='$(LN)'


# Need the web rules for patgen.
.SUFFIXES:
.SUFFIXES: .o .c .p .ch
.p.c:
	$(SHELL) ../$(srcdir)/lib/convert $*.p $*.c
.ch.p:
	../web/tangle $*.web $*.ch
.c.o:
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $*.c


default: all
all: initex virtex patgen
triptrap: triptex

initex: $(iobjs) $(objs) $(commono)
	$(CCLD) -o initex $(LDFLAGS) $(iobjs) $(objs) $(libs)

virtex: $(vobjs) $(objs) $(commono)
	$(CCLD) -o virtex $(LDFLAGS) $(vobjs) $(objs) $(libs)

check: run-trip
run-trip: triptex
	rm -f trip.tex
	-$(LN) $(tripdir)/trip.tex .
	../fontutil/pltotf $(tripdir)/trip.pl trip.tfm
	../fontutil/tftopl ./trip.tfm trip.pl
	-diff $(tripdir)/trip.pl trip.pl
	-$(SHELL) -c '. ./tripenv; \
          ./triptex < $(tripdir)/trip1.in >/dev/null 2>&1'
	-diff $(tripdir)/tripin.log trip.log
	-$(SHELL) -c '. ./tripenv; ./triptex < $(tripdir)/trip2.in > trip.fot'
# 
# We use $(DIFF) instead of `diff' only for those files where there
# might actually be legitimate numerical differences.
	-$(DIFF) $(DIFFFLAGS) $(tripdir)/trip.log trip.log
	-diff $(tripdir)/trip.fot trip.fot
	$(SHELL) -c '. ./tripenv; \
	  ../dviutil/dvitype trip.dvi < $(tripdir)/dvitype.in > trip.typ'
	-$(DIFF) $(DIFFFLAGS) $(tripdir)/trip.typ trip.typ


# Make format files automatically.
formats: $(formats)

# AMSLaTeX requires that you
# 1) move Lamport's lfonts.tex out of TeX's way (I use the lfonts.tex I
# distribute with the sauter CM parameter files, and call it lfonts.sauter),
# 2) say `lfonts.new' when lplain.tex can't find lfonts.tex,
# 3) choose a ``fontdef'' file (I use fontdef.ori),
# 4) a ``preload'' file, (I use preload.ori),
# 5) and a ``basefont'' file.  (I use basefont).
# How automatic, huh?  I can hardly wait for LaTeX 3.
amslatex.fmt: initex
	$(initex) lplain \\dump
	mv lplain.fmt amslatex.fmt
	mv lplain.log amslatex.log

# As of AMSTeX 2.1, the initialization file is named `amstex.ini'.
# Because it explicitly reads plain.tex, we cannot use &./tex; that
# produces the `Too late for \patterns' error.
amstex.fmt: initex
	$(initex) amstex.ini

etex.fmt: tex.fmt
	touch eplain.aux # Makes cross-reference warnings work right.
	$(initex) \&./tex eplain \\dump
	mv eplain.fmt etex.fmt
	mv eplain.log etex.log

inrstex.fmt: initex
	$(initex) inrstex \\dump

latex.fmt: initex
	$(initex) lplain \\dump
	mv lplain.fmt latex.fmt
	mv lplain.log latex.log

picplus.fmt: tex.fmt
	$(initex) \&./tex picplus \\dump

slitex.fmt: initex
	$(initex) splain \\dump
	mv splain.fmt slitex.fmt
	mv splain.log slitex.log

tex.fmt: initex
	$(initex) plain \\dump
	mv plain.fmt tex.fmt
	mv plain.log tex.log

# Texinfo changes the escape character from `\' to `@'.
texinfo.fmt: tex.fmt
	$(initex) \&./tex texinfo @dump


# We change texd.h instead of the change file, to avoid retangling.
triptex: stamp-trip
	$(MAKE) $(makeargs) initex
	mv initex triptex

stamp-trip: texd.h $(texsrcdir)/trip.sed
	rm -f *.o texd.h.bak temp
	sed -f $(texsrcdir)/trip.sed < texd.h > temp
	mv texd.h texd.h.bak
	mv temp texd.h
	touch stamp-trip

clean-trip:
	rm -f *.o texd.h tripmf stamp-trip
	if test -f texd.h.bak; then mv texd.h.bak texd.h; fi

tex.p: tex.web ctex.ch
	../web/tangle tex.web ctex.ch

ctex.ch: $(texsrcdir)/tex.ch
	rm -f ctex.ch
	cp $(texsrcdir)/tex.ch ctex.ch
	chmod 444 ctex.ch

# The convert script produces the following:
tex0.c tex1.c tex2.c tex3.c tex4.c tex5.c tex6.c tex7.c tex8.c tex9.c \
itex.c coerce.h texd.h: tex.p fixcoerce.h $(commondefines)
	$(SHELL) $(texsrcdir)/convert

# The (hand-coded) file $(extrac) and the (generated) file itex.c have
# #ifdefs for INITEX, so we compile them differently.
iextra.o: iextra.c
	$(CC) $(CPPFLAGS) -DINITEX -DINI $(CFLAGS) -c iextra.c

initex.o: initex.c
	$(CC) $(CPPFLAGS) -DINITEX $(CFLAGS) -c initex.c

# Avoid compiling files in another directory.
iextra.c: $(extrac)
	rm -f iextra.c
	$(LN) $(extrac) iextra.c

initex.c: itex.c
	rm -f initex.c
	$(LN) itex.c initex.c

vextra.c: $(extrac)
	rm -f vextra.c
	$(LN) $(extrac) vextra.c

openinout.c: $(fileioc)
	rm -f openinout.c
	$(LN) $(fileioc) openinout.c

$(iobjs) $(vobjs) $(objs): texd.h

tex0.o: tex0.c $(commonh)
tex1.o: tex1.c $(commonh)
tex2.o: tex2.c $(commonh)
tex3.o: tex3.c $(commonh)
tex4.o: tex4.c $(commonh)
tex5.o: tex5.c $(commonh)
tex6.o: tex6.c $(commonh)
tex7.o: tex7.c $(commonh)
tex8.o: tex8.c $(commonh)
tex9.o: tex8.c $(commonh)


patgen: patgen2.o $(commono)
	$(CCLD) -o patgen $(LDFLAGS) patgen2.o $(libs)
patgen2.o: patgen2.c $(commonh)
patgen2.c: patgen2.p $(commondefines)
patgen2.p: patgen2.web patgen2.ch


Makefile: Makefile.in ../config.status
	(cd ..; sh config.status)

# Prevent GNU make 3 from overflowing arg limit on system V.
.NOEXPORT:


c-sources: texd.h patgen.c
.PHONY: c-sources

install: install-exec install-data

install-exec: all
	-mkdir $(texpooldir) $(texdatadir) $(texfontdir) >/dev/null 2>&1
	$(INSTALL_PROGRAM) initex $(bindir)/initex
	$(INSTALL_PROGRAM) virtex $(bindir)/virtex
	$(INSTALL_PROGRAM) patgen $(bindir)/patgen

# The dependency should really be tex.pool, but can't do that in suffix rules.
install-data: tex0.c
	-if test -d $(texpooldir); then true; else mkdir $(texpooldir); fi
	-if test -s tex.pool; then \
	  $(INSTALL_DATA) tex.pool $(texpooldir)/tex.pool; else true; fi
	if test ! -f $(texfontdir)/texfonts.map				\
	   || grep 'original texfonts.map --' $(texfontdir)/texfonts.map\
              >/dev/null 2>&1; then					\
         $(INSTALL_DATA) $(texsrcdir)/texfonts.map $(texfontdir)/texfonts.map;\
        else true; fi

mostlyclean: 
	rm -f stamp-* *.o patgen triptex initex virtex
	rm -f texd.h texd.h.bak coerce.h *.log *.fmt *.aux
	rm -f 8terminal.tex tripos.tex trip.typ trip.dvi trip.fot
	rm -f trip.pl trip.tfm trip.tex

clean: mostlyclean
	rm -f iextra.c initex.c vextra.c openinout.c
	rm -f tex?.c itex.c tex.p tex.pool patgen2.c patgen2.h patgen2.p

distclean: clean
	rm -f ctex.ch Makefile

extraclean: distclean
	rm -f *~ *\#* patch* *.orig *.rej *.bak *.ckp
	rm -f *.dvi *.log *.aux *gf *pk *.tfm core a.out
	rm -f texput.* temp

realclean: distclean
