## Makefile for TeX (Win32 version)		-*- Makefile -*-
## Time-stamp: "97/08/04 00:12:52 mik"

!include ..\miktex.inc

srcdir = .
formatdir = $(prefix)\miktex\fmt
tex_web = $(srcdir)\tex.web

.c.obj:
	$(CC) -c -I$(srcdir) -I$(libdir) -DMIKTEX_DLL $(release_info) \
		-MD -Od $(cflags) $(CFLAGS) $<
#		-MD -O2 -Gr -Gy $(cflags) $(CFLAGS) $<

all: tex.pool initex.exe virtex.exe plain.fmt triptest

tex.pool: tex.win32-changes $(tex_web)
	$(TANGLE) $(tex_web) $(srcdir)\tex.win32-changes nul $@

triptex.exe: triptex.obj $(libdir)\miktex.lib triptex.res
	link $(ldflags) $(LDFLAGS) -out:$@ $**

triptex.res: triptex.rc $(libdir)\miktex.version $(libdir)\version.h
	rc -I$(libdir) triptex.rc

initex.exe: initex.obj $(libdir)\miktex.lib initex.res
	link $(ldflags) $(LDFLAGS) -out:$@ $**

initex.res: initex.rc $(libdir)\miktex.version $(libdir)\version.h
	rc -I$(libdir) initex.rc

virtex.exe: virtex.obj $(libdir)\miktex.lib virtex.res virtex.prf
	link $(ldflags) $(LDFLAGS) -out:$@ \
		virtex.obj $(libdir)\miktex.lib \
		virtex.res
#	link $(ldflags) $(LDFLAGS) -out:$@ -map:virtex.map \
#		-order:@virtex.prf virtex.obj $(libdir)\miktex.lib \
#		virtex.res

virtex.res: virtex.rc $(libdir)\miktex.version $(libdir)\version.h
	rc -I$(libdir) virtex.rc

triptex.c triptex.h: triptex.p $(libdir)\texmf-common.c deoptimize.sed
	$(C4P) $(C4PFLAGS) --rename link --rename index \
		--one=triptex --include-filename=miktex.h triptex.p
	type $(libdir)\texmf-common.c >> triptex.c
#	sed -f deoptimize.sed triptex.c > xxx.c
#	del triptex.c
#	move xxx.c triptex.c

triptex.p: $(tex_web) triptex.win32-changes
	$(TANGLE) $(tex_web) triptex.win32-changes triptex.p nul

triptex.win32-changes: tex.win32-changes ini2trip.sed
	sed -f $(srcdir)\ini2trip.sed $(srcdir)\tex.win32-changes > $@

initex.c initex.h: initex.p $(libdir)\texmf-common.c deoptimize.sed
	$(C4P) $(C4PFLAGS) --rename link --rename index \
		--one=initex --include-filename=miktex.h initex.p
	type $(libdir)\texmf-common.c >> initex.c
#	sed -f deoptimize.sed initex.c > xxx.c
#	del initex.c
#	move xxx.c initex.c

initex.p: $(tex_web) tex.win32-changes
	$(TANGLE) $(tex_web) tex.win32-changes initex.p nul

virtex.c virtex.h: virtex.p $(libdir)\texmf-common.c deoptimize.sed
	$(C4P) $(C4PFLAGS) --rename link --rename index \
		--one=virtex --include-filename=miktex.h virtex.p
	type $(libdir)\texmf-common.c >> virtex.c
#	sed -f deoptimize.sed virtex.c > xxx.c
#	del virtex.c
#	move xxx.c virtex.c

virtex.p: $(tex_web) virtex.win32-changes
	$(TANGLE) $(tex_web) virtex.win32-changes virtex.p nul

virtex.win32-changes: tex.win32-changes ini2vir.sed
	sed -f $(srcdir)\ini2vir.sed $(srcdir)\tex.win32-changes > $@

triptest: tex.pool triptex.exe
	$(PLTOTF) trip\trip.pl trip.tfm
	$(TFTOPL) trip.tfm tmp.pl
	-diff trip\trip.pl tmp.pl
	copy trip\trip.tex .>nul
	-.\triptex <trip\triptest.s3 >nul
	-diff trip\tripin.log trip.log
	-.\triptex <trip\triptest.s4 >trip.fot
	-diff trip\trip.fot trip.fot
	-diff trip\trip.log trip.log
	$(DVITYPE) trip.dvi <trip\triptest.s6 >trip.typ
	-diff  trip\trip.typ trip.typ

plain.fmt: initex.exe
	.\initex plain \dump

install: tex.pool initex.exe virtex.exe plain.fmt triptest
	$(INSTALL_DATA) tex.pool $(formatdir)\tex.pool
	$(INSTALL_DATA) plain.fmt $(formatdir)\plain.fmt
	$(INSTALL_PROGRAM) initex.exe $(bindir)\initex.exe
	$(INSTALL_PROGRAM) virtex.exe $(bindir)\virtex.exe

unistall:

triptest-clean:
	-del 8terminal.tex
	-del tmp.pl
	-del trip.dvi
	-del trip.fmt
	-del trip.fot
	-del trip.log
	-del trip.tex
	-del trip.tfm
	-del trip.typ
	-del tripos.tex

mostlyclean: triptest-clean
	-del *.obj
	-del *.res
	-del triptex.win32-changes
	-del virtex.win32-changes
	-del initex.c
	-del initex.h
	-del triptex.c
	-del triptex.h
	-del virtex.c
	-del virtex.h
	-del *.p
	-del *.log
	-del makefile.win32.bak

clean: mostlyclean
	-del tex.pool
	-del *.map
	-del *.exe
	-del *.fmt
	-del *.ilk
	-del *.pdb

distclean: clean
	-del *.opt

realclean: distclean
	-del trip\triptest.log

depend: triptex.c initex.c virtex.c
	makedepend -f makefile.win32 -I. -I..\lib $**

# DO NOT DELETE

triptex.obj: ..\lib/miktex.h ..\lib/c4plib.h triptex.h ..\lib/miktex.version
triptex.obj: ..\lib/version.h
initex.obj: ..\lib/miktex.h ..\lib/c4plib.h initex.h ..\lib/miktex.version
initex.obj: ..\lib/version.h
virtex.obj: ..\lib/miktex.h ..\lib/c4plib.h virtex.h ..\lib/miktex.version
virtex.obj: ..\lib/version.h
