## Makefile fir MetaPost (Win32 version)		-*- Makefile -*-
## Time-stamp: "97/08/10 21:16:21 mik"

!include ..\..\miktex.inc

srcdir = .
memdir = $(prefix)\miktex\mem
mp_web = mp.web

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

all: mp.pool inimp.exe virmp.exe plain.mem mfplain.mem traptest mpost.bat

mp.pool: mp.win32-changes $(mp_web)
	$(TANGLE) $(mp_web) $(srcdir)\mp.win32-changes nul $@

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

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

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

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

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

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

trapmp.c trapmp.h: trapmp.p $(srcdir)\..\..\lib\texmf-common.c
	$(C4P) $(C4PFLAGS) --rename link --rename index \
		--include-filename=miktex.h --one=trapmp trapmp.p
	type $(srcdir)\..\..\lib\texmf-common.c >> trapmp.c

trapmp.p: $(mp_web) trapmp.ch
	$(TANGLE) $(mp_web) trapmp.ch trapmp.p nul

trapmp.ch: mp.win32-changes ini2trap.sed
	sed -f $(srcdir)\ini2trap.sed $(srcdir)\mp.win32-changes > $@

inimp.c inimp.h: inimp.p $(srcdir)\..\..\lib\texmf-common.c
	$(C4P) $(C4PFLAGS) --rename link --rename index \
		--include-filename=miktex.h --one=inimp inimp.p
	type $(srcdir)\..\..\lib\texmf-common.c >> inimp.c

inimp.p: $(mp_web) mp.win32-changes
	$(TANGLE) $(mp_web) mp.win32-changes inimp.p nul

virmp.c virmp.h: virmp.p $(srcdir)\..\..\lib\texmf-common.c
	$(C4P) $(C4PFLAGS) --rename link --rename index \
		--include-filename=miktex.h --one=virmp virmp.p
	type $(srcdir)\..\..\lib\texmf-common.c >> virmp.c

virmp.p: $(mp_web) virmp.ch
	$(TANGLE) $(mp_web) virmp.ch virmp.p nul

virmp.ch: mp.win32-changes ini2vir.sed
	sed -f $(srcdir)\ini2vir.sed $(srcdir)\mp.win32-changes > $@

traptest: mp.pool trapmp.exe
	copy trapdir\mtrap.mp .
	$(PLTOTF) trapdir\trapf.pl trapf.tfm
	-.\trapmp mtrap
	-diff trapdir\mtrap.log mtrap.log
	-diff trapdir\mtrap.0 mtrap.0
	-diff trapdir\mtrap.1 mtrap.1
	-diff trapdir\writeo writeo
	-diff trapdir\writeo.2 writeo.2
	copy trapdir\trap.mp .
	type trapdir\trap.mpx > trap.mpx
	-.\trapmp <trapdir\trap1.in >nul
	if exist trapin.log del trapin.log 
	move trap.log  trapin.log
	-diff trapdir\trapin.log trapin.log
	-.\trapmp <trapdir\trap2.in >trap.fot
	-diff trapdir\trap.log trap.log
	-diff trapdir\trap.fot trap.fot
	-diff trapdir\trap.5 trap.5
	-diff trapdir\trap.6 trap.6
	-diff trapdir\trap.148 trap.148
	-diff trapdir\trap.149 trap.149
	-diff trapdir\trap.150 trap.150
	-diff trapdir\trap.151 trap.151
	-diff trapdir\trap.197 trap.197
	-diff trapdir\trap.200 trap.200
	$(TFTOPL) trap.tfm trap.pl
	-diff trapdir\trap.pl trap.pl

plain.mem: inimp.exe
	.\inimp plain dump

mfplain.mem: inimp.exe
	.\inimp mfplain dump

install: mp.pool inimp.exe virmp.exe mpost.bat plain.mem mfplain.mem traptest
	$(INSTALL_DATA) mp.pool $(memdir)\mp.pool
	$(INSTALL_DATA) plain.mem $(memdir)\plain.mem
	$(INSTALL_DATA) mfplain.mem $(memdir)\mfplain.mem
	$(INSTALL_PROGRAM) inimp.exe $(bindir)\inimp.exe
	$(INSTALL_PROGRAM) virmp.exe $(bindir)\virmp.exe
	$(INSTALL_PROGRAM) mpost.bat $(bindir)\mpost.bat

uninstall:

mostlyclean:
	-del *.obj
	-del trapmp.ch
	-del virmp.ch
	-del trapmp.c
	-del trapmp.h
	-del virmp.c
	-del virmp.h
	-del inimp.c
	-del inimp.h
	-del *.p
	-del *.res
	-del trap.*
	-del trapin.log
	-del trapf.tfm
	-del makefile.win32.bak

clean: mostlyclean
	-del mp.pool
	-del mtrap.* writeo writeo.2 *.mem
	-del plain.log
	-del mfplain.log
	-del *.exe
	-del *.ilk
	-del *.pdb

distclean: clean
	-del *.opt

realclean: distclean
	-del trap\traptest.log

depend: trapmp.c inimp.c virmp.c
	makedepend -f makefile.win32 -I. -I..\..\lib $**

# DO NOT DELETE

trapmp.obj: ..\..\lib\miktex.h ..\..\lib\c4plib.h trapmp.h
inimp.obj: ..\..\lib\miktex.h ..\..\lib\c4plib.h inimp.h
virmp.obj: ..\..\lib\miktex.h ..\..\lib\c4plib.h virmp.h
