#   Makefile for MMIXware under DOS
#   Comments to andreas.scherer@pobox.com
#   If you're using nmake, you'll need to save the Unix makefile and 
#   rename this file to makefile, as in:
#               ren Makefile Makefile.unix
#               ren Makefile.dos Makefile
#       Then use nmake normally.

#   Be sure that CWEB version 3.0 or greater is installed before proceeding!
#   In fact, CWEB 3.6 is recommended for making hardcopy or PDF documentation.

#   If you prefer optimization to debugging, change /Zi to something like /GB:

.SUFFIXES: .dvi .tex .w .ps .pdf

        tex $*.tex

        pdftex $*.tex

        dvips $* -o $*.ps

    if exist $*.ch ctangle $*.w $*.ch
    if not exist $*.ch ctangle $*.w

    if exist $*.ch cweave $*.w $*.ch
    if not exist $*.ch cweave $*.w

        $(MAKE)  $*.c
        $(MAKE)  $*.obj

        $(MAKE)  $*.c
        $(MAKE)  $*.exe

        $(MAKE)  $*.tex
        $(MAKE)  $*.dvi

        $(MAKE)  $*.dvi
        $(MAKE)  $*.ps

        $(MAKE)  $*.tex
        $(MAKE)  $*.pdf

WEBFILES = mmix-def.w mmixal.w "mmix-arith.w" mmix-sim.w mmix-io.w mmix-mem.w \
        mmotype.w abstime.w mmix-doc.w "mmix-config.w" mmix-pipe.w mmmix.w
TESTFILES = *.mms silly.run silly.out *.mmconfig *.mmix
MISCFILES = Makefile makefile.dos README mmix.mp mmix.1

basic:  mmixal.exe mmix.exe

doc:    mmix-doc.ps mmixal.ps mmix-sim.ps abstime.ps

all:    mmixal.exe mmix.exe mmotype.exe mmmix.exe

        del *~
        del *.obj
        del *.c
        del *.h
        del *.tex
        del *.log
        del *.dvi 
        del *.toc
        del *.idx
        del *.scn
        del *.ps
        del *.pdf
        del *.ilk
        del *.pdb

abstime.exe: abstime.obj
    $(CC) $(CFLAGS) abstime.obj /Feabstime.exe

"mmix-pipe.obj": "mmix-pipe.c" abstime.exe
        .\abstime >abstime.h
        $(CC) $(CFLAGS) -c mmix-pipe.c

mmmix.exe:  "mmix-arith.obj" "mmix-pipe.obj" "mmix-config.obj" \
            "mmix-mem.obj" "mmix-io.obj" mmmix.c
        $(CC) $(CFLAGS) mmmix.c \
          "mmix-arith.obj" "mmix-pipe.obj" "mmix-config.obj" "mmix-mem.obj" \
      "mmix-io.obj" /Femmmix.exe

mmixal.exe: "mmix-arith.obj" mmixal.c
        $(CC) $(CFLAGS) mmixal.c "mmix-arith.obj" /Femmixal.exe

mmix.exe:  "mmix-arith.obj" mmix-io.obj mmix-sim.c abstime.exe
        .\abstime >abstime.h
        $(CC) $(CFLAGS) mmix-sim.c \
                     "mmix-arith.obj" mmix-io.obj /Femmix.exe

mmotype.exe: mmotype.obj
        $(CC) $(CFLAGS) mmotype.obj /Femmotype.exe

tarfile: $(ALL)
        tar cvf /tmp/mmix.tar $(ALL)
        gzip -9 /tmp/mmix.tar