# Generated automatically from Makefile.in by configure.
# This file makes Metafont 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

objs=$(fileioo) mf0.o mf1.o mf2.o mf3.o mf4.o mf5.o mf6.o mf7.o mf8.o mf9.o
iobjs=iextra.o inimf.o
vobjs=vextra.o imf.o

# Where the trap files are.
mfsrcdir = ../$(srcdir)/mf
trapdir = $(mfsrcdir)/MFtrap


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

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

wlibs =  -lXt -lX11
xincludedir = 
xlibdir = 
windowlib = MFwindow/window.a
windowlibs = $(xlibdir) $(windowlib) $(wlibs)

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

LN = ln -s
RANLIB = ranlib


# The bases we know how to make.
bases = plain.base cmmf.base

# Name of the file that defines the local devices.
localmodes = modes.mf

# And how to make them.
inimf = MFPOOL=. ./inimf


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


.SUFFIXES:
.SUFFIXES: .o .c
.c.o:
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $*.c


default: all
all: inimf virmf
triptrap: trapmf


# It is just a waste of disk space to have window support in inimf.
# 
inimf: $(iobjs) $(objs) $(commono)
	$(CCLD) -o inimf $(LDFLAGS) $(iobjs) $(objs) $(libs)

virmf: $(vobjs) $(objs) $(windowlib) $(commono)
	$(CCLD) -o virmf $(LDFLAGS) $(vobjs) $(objs) $(windowlibs) $(libs)

check: run-trap
run-trap: trapmf 
	rm -f trap.mf
	-$(LN) $(trapdir)/trap.mf .
	-$(SHELL) -c '. ./trapenv; \
	  ./trapmf < $(trapdir)/trap1.in > /dev/null 2>&1'
	-diff $(trapdir)/trapin.log trap.log
	-$(SHELL) -c '. ./trapenv; ./trapmf < $(trapdir)/trap2.in > trap.fot'
	-diff $(trapdir)/trap.log trap.log
	-diff $(trapdir)/trap.fot trap.fot
	../fontutil/tftopl ./trap.tfm trap.pl
	-diff $(trapdir)/trap.pl trap.pl
	$(SHELL) -c '. ./trapenv; \
	  ../fontutil/gftype -m -i ./trap.72270gf > trap.typ'
	-diff $(trapdir)/trap.typ trap.typ


# Make base files automatically.
bases: $(bases)

mf.base: inimf
	$(inimf) 'plain; input $(localmodes); dump'
	mv plain.base mf.base
	mv plain.log mf.log

cmmf.base: mf.base
	$(inimf) \&./mf cmbase dump
	mv cmbase.base cmmf.base
	mv cmbase.log cmmf.log


# The `ini_to_trap' script changes mfd.h, instead of the change file, so
# retangling is not necessary.  After changing constants, making a
# trapmf means making an inimf.
# 
trapmf: stamp-trap
	$(MAKE) $(makeargs) inimf
	mv inimf trapmf

stamp-trap: mfd.h $(mfsrcdir)/trap.sed
	rm -f *.o temp
	sed -f $(mfsrcdir)/trap.sed < mfd.h > temp
	mv mfd.h mfd.h.bak
	mv temp mfd.h
	touch stamp-trap

clean-trap:
	rm -f *.o mfd.h trapmf stamp-trap
	if test -f mfd.h.bak; then mv mfd.h.bak mfd.h; fi

mf.p mf.pool: mf.web cmf.ch
	../web/tangle mf.web cmf.ch

cmf.ch: $(mfsrcdir)/mf.ch
	rm -f cmf.ch
	cp $(mfsrcdir)/mf.ch cmf.ch
	chmod 444 cmf.ch

# The convert script produces the following files:
mf0.c mf1.c mf2.c mf3.c mf4.c mf5.c mf6.c mf7.c mf8.c mf9.c \
imf.c coerce.h mfd.h: mf.p fixcoerce.h $(commondefines)
	$(SHELL) $(mfsrcdir)/convert

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

inimf.o: inimf.c
	$(CC) $(CPPFLAGS) -DINIMF $(CFLAGS) -c inimf.c

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

inimf.c: imf.c
	rm -f inimf.c
	$(LN) imf.c inimf.c

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

openinout.c: $(fileioc)
	$(LN) $(fileioc) openinout.c

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

mf0.o: mf0.c $(commonh)
mf1.o: mf1.c $(commonh)
mf2.o: mf2.c $(commonh)
mf3.o: mf3.c $(commonh)
mf4.o: mf4.c $(commonh)
mf5.o: mf5.c $(commonh)
mf6.o: mf6.c $(commonh)
mf7.o: mf7.c $(commonh)
mf8.o: mf8.c $(commonh)
mf9.o: mf9.c $(commonh)

$(windowlib): mfd.h
	cd MFwindow; $(MAKE) $(makeargs) xincludedir='$(xincludedir)'


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

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


c-sources: mfd.h
.PHONY: c-sources

install: install-exec install-data

install-exec: all
	$(INSTALL_PROGRAM) virmf $(bindir)/virmf
	$(INSTALL_PROGRAM) inimf $(bindir)/inimf

install-data: mf.pool
	-if test -d $(mfpooldir); then true; else mkdir $(mfpooldir); fi
	-if test -s mf.pool; then \
	  $(INSTALL_DATA) mf.pool $(mfpooldir)/mf.pool; else true; fi

mostlyclean: 
	rm -f stamp-* *.o trapmf inimf virmf
	rm -f mfd.h mfd.h.bak coerce.h *.log *.base
	rm -f trap.72270gf trap.fot trap.tfm trap.typ trap.pl trap.mf
	cd MFwindow; $(MAKE) mostlyclean

clean: mostlyclean
	rm -f inimf.c iextra.c vextra.c openinout.c
	rm -f mf?.c imf.c mf.p mf.pool
	cd MFwindow; $(MAKE) clean

distclean: clean
	rm -f cmf.ch Makefile
	cd MFwindow; $(MAKE) distclean

extraclean: distclean
	rm -f *~ *\#* patch* *.orig *.rej *.bak *.ckp
	rm -f *.dvi *.log *.aux *gf *pk *.tfm core a.out
	rm -f mfput.* temp*
	cd MFwindow; $(MAKE) extraclean

realclean: distclean
