# Makefile for Amylaar
# 
# DJGPP's ms-dos port
#
CC=gcc
#
# Berkeley parser generator
#
YACC=yacc
YACCTAB=y_tab.
#
# Dos 6 system calls
#
RM=del
MV=move
CP=copy
#
# Use Satoria's malloc.
#
MALLOC=smalloc
#
#
#
PROFIL=
#
#Enable warnings from the compiler, if wanted.
#
WARN=
#WARN= -Dlint
#
# Debug Info
#
DEBUG=
#DEBUG= -DDEBUG -DTRACE_CODE
#
#
FLAGS=-g -O -fstrength-reduce -fomit-frame-pointer -DMSDOS -Dconst= 
CFLAGS=$(FLAGS) -DMALLOC_$(MALLOC) $(WARN)$(PROFIL)$(DEBUG)
#
LIBS=-lpc -lm -lc
#
LDFLAGS=-g
#
#
#
SRC=lex.c main.c interpret.c simulate.c object.c backend.c array.c\
    comm1.c ed.c regexp.c mapping.c wiz_list.c swap.c $(MALLOC).c\
    call_out.c otable.c dumpstat.c stralloc.c hash.c indentp.c port.c\
    access_check.c parse_old.c parse.c prolang.y\
    simul_efun.c sprintf.c gcollect.c closure.c
OBJ=lang.o lex.o main.o interpret.o simulate.o object.o backend.o array.o\
    comm1.o ed.o regexp.o mapping.o wiz_list.o swap.o $(MALLOC).o\
    call_out.o otable.o dumpstat.o stralloc.o hash.o indentp.o port.o\
    access_check.o parse_old.o parse.o simul_efun.o sprintf.o\
    gcollect.o closure.o hosts/msdos/c_msdos.o\
    hosts/msdos/msdos.o hosts/msdos/vcon.o hosts/msdos/serial.o

amylaar.exe: amylaar
     strip amylaar
     if exist amylaar.exe $(MV) amylaar.exe amyl_old.exe
     coff2exe amylaar
     if exist amylaar $(RM) amylaar
     copy amylaar.exe \lpmud\bin

amylaar: $(OBJ)
     $(CC) $(LDFLAGS) -o amylaar @lpmud.lk1 @lpmud.lk2 $(LIBS)

lint: *.c
     lint *.c

make_func.c: make_func.y
     $(YACC) make_func.y
     $(MV) $(YACCTAB)c make_func.c

make_func.exe: make_func.o hash.o exec.h
     $(CC) $(LDFLAGS) make_func.o hash.o -o make_func
     coff2exe make_func
     if exist make_func $(RM) make_func

lang.y efun_defs.c instrs.h: func_spec make_func.exe prolang.y config.h
     if exist efun_defs.c $(RM) efun_defs.c
     if exist lang.y $(RM) lang.y
     make_func.exe > efun_defs.c

lang.c lang.h: lang.y
     $(YACC) -d -v lang.y
     $(MV) $(YACCTAB)c lang.c
     $(MV) $(YACCTAB)h lang.h

$(MALLOC).o: $(MALLOC).c lint.h config.h machine.h
     if exist smalloc.o $(RM) smalloc.o
     if exist gmalloc.o $(RM) gmalloc.o
     if exist sysmalloc.o $(RM) sysmalloc.o
     if exist malloc.o $(RM) malloc.o
     $(CC) $(CFLAGS) -c $(MALLOC).c

access_check.o: access_check.c lint.h config.h machine.h comm.h interpret.h
        $(CC) $(CFLAGS) -c access_check.c

alloca.o: alloca.c
        $(CC) $(CFLAGS) -c alloca.c

array.o: array.c config.h machine.h lint.h interpret.h object.h wiz_list.h \
  regexp.h exec.h lang.h instrs.h stralloc.h
        $(CC) $(CFLAGS) -c array.c

backend.o: backend.c lint.h config.h machine.h interpret.h object.h \
  wiz_list.h exec.h comm.h
        $(CC) $(CFLAGS) -c backend.c

call_out.o: call_out.c lint.h config.h machine.h interpret.h object.h comm.h \
  stralloc.h exec.h wiz_list.h
        $(CC) $(CFLAGS) -c call_out.c

closure.o: closure.c lint.h config.h machine.h lex.h exec.h interpret.h \
  object.h lang.h instrs.h
        $(CC) $(CFLAGS) -c closure.c
                                 
comm1.o: comm1.c config.h machine.h lint.h interpret.h comm.h object.h \
  sent.h patchlevel.h wiz_list.h
        $(CC) $(CFLAGS) -c comm1.c

dumpstat.o: dumpstat.c lint.h config.h machine.h interpret.h object.h exec.h \
  smalloc.h lang.h instrs.h
        $(CC) $(CFLAGS) -c dumpstat.c

ed.o: ed.c lint.h config.h machine.h regexp.h interpret.h object.h comm.h
        $(CC) $(CFLAGS) -c ed.c

gcollect.o: gcollect.c lint.h config.h machine.h interpret.h object.h exec.h \
  sent.h comm.h smalloc.h instrs.h lang.h wiz_list.h stralloc.h
        $(CC) $(CFLAGS) -c gcollect.c

hash.o: hash.c
        $(CC) $(CFLAGS) -c hash.c

indentp.o: indentp.c
        $(CC) $(CFLAGS) -c indentp.c

interpret.o: interpret.c lint.h config.h machine.h interpret.h lang.h exec.h \
  object.h wiz_list.h instrs.h comm.h sent.h switch.h smalloc.h stralloc.h
        $(CC) $(CFLAGS) -c interpret.c

lang.o: lang.c lint.h config.h machine.h lex.h interpret.h object.h exec.h \
  instrs.h incralloc.h switch.h stralloc.h
        $(CC) $(CFLAGS) -c lang.c

lex.o: lex.c lint.h config.h machine.h interpret.h lang.h exec.h lex.h \
  instrs.h patchlevel.h stralloc.h efun_defs.c
        $(CC) $(CFLAGS) -c lex.c

main.o: main.c lint.h config.h machine.h interpret.h object.h lex.h \
  patchlevel.h
        $(CC) $(CFLAGS) -c main.c

make_func.o: make_func.c lint.h config.h machine.h
     $(CC) $(CFLAGS) -c make_func.c

mapping.o: mapping.c config.h machine.h lint.h interpret.h lang.h instrs.h \
  object.h wiz_list.h regexp.h stralloc.h smalloc.h
        $(CC) $(CFLAGS) -c mapping.c

object.o: object.c lint.h config.h machine.h comm.h interpret.h object.h \
  sent.h wiz_list.h exec.h
        $(CC) $(CFLAGS) -c object.c

otable.o: otable.c lint.h config.h machine.h interpret.h object.h
        $(CC) $(CFLAGS) -c otable.c

parse.o: parse.c lint.h config.h machine.h interpret.h object.h wiz_list.h
        $(CC) $(CFLAGS) -c parse.c

parse_old.o: parse_old.c lint.h config.h machine.h interpret.h object.h \
  wiz_list.h
        $(CC) $(CFLAGS) -c parse_old.c

port.o: port.c lint.h config.h machine.h
        $(CC) $(CFLAGS) -c port.c

regexp.o: regexp.c regexp.h lint.h config.h machine.h
        $(CC) $(CFLAGS) -c regexp.c

simul_efun.o: simul_efun.c lint.h config.h machine.h interpret.h object.h \
  exec.h lex.h lang.h instrs.h stralloc.h
        $(CC) $(CFLAGS) -c simul_efun.c

simulate.o: simulate.c lint.h config.h machine.h interpret.h instrs.h lang.h \
  object.h sent.h wiz_list.h exec.h comm.h stralloc.h
        $(CC) $(CFLAGS) -c simulate.c

sprintf.o: sprintf.c config.h machine.h lint.h interpret.h lang.h instrs.h \
  exec.h object.h sent.h
        $(CC) $(CFLAGS) -c sprintf.c

stralloc.o: stralloc.c stralloc.h config.h machine.h lint.h
        $(CC) $(CFLAGS) -c stralloc.c

swap.o: swap.c lint.h config.h machine.h interpret.h object.h exec.h
        $(CC) $(CFLAGS) -c swap.c

wiz_list.o: wiz_list.c config.h machine.h lint.h interpret.h object.h \
  wiz_list.h stralloc.h lang.h instrs.h
        $(CC) $(CFLAGS) -c wiz_list.c
#
# MSDOS
#
          
hosts/msdos/c_msdos.o: hosts/msdos/c_msdos.c hosts/msdos/pcdef.h\
     hosts/msdos/c_msdos.h 
     cd hosts\msdos | $(CC) $(FLAGS) -c c_msdos.c | cd ..\..

hosts/msdos/msdos.o: hosts/msdos/msdos.c
     cd hosts\msdos | $(CC) $(FLAGS) -c msdos.c | cd ..\..


hosts/msdos/serial.o: hosts/msdos/serial.c hosts/msdos/pcdef.h\
     hosts/msdos/c_msdos.h 
     cd hosts\msdos | $(CC) $(FLAGS) -c serial.c | cd ..\..

hosts/msdos/vcon.o: config.h hosts/msdos/vcon.c hosts/msdos/pcdef.h\
     hosts/msdos/c_msdos.h 
     cd hosts\msdos | $(CC) $(FLAGS) -c vcon.c | cd ..\..

#
#hosts/msdos/comdrv: hosts/msdos/comdrv.com
#
#
#hosts/msdos/comdrv.com: hosts/msdos/comdrv.exe
#    (cd hosts\msdos;
#    exe2bin comdrv.exe comdrv.com;
#    cd ..\..)
#
#
#hosts/msdos/comdrv.exe: hosts/msdos/comdrv.obj
#    (cd hosts\msdos;
#    link comdrv,comdrv;
#    cd ..\..)
#
#
#hosts/msdos/comdrv.obj: hosts/msdos/comdrv.asm hosts/msdos/clip.inc
#     (cd hosts\msdos;
#     masm comdrv,comdrv;
#     cd ..\..)
