#
#  makefile
#

CC	= bcc
LINK 	= bcc
#CFLAGS	= -4 -P -ml -v -DHUCARD
CFLAGS	= -4 -P -ml -O2 -Oi -k- -v- -DHUCARD

EXE	= sim.exe
TARGETS = $(EXE)
OBJS1	= sim.obj format.obj display.obj exe.obj grph.obj hardware.obj
OBJS2   = pallette.obj video.obj interupt.obj joy.obj psg.obj impl.obj timer.obj
OBJS    = $(OBJS1) $(OBJS2)

#LIBS    = cl.lib mathl.lib emu.lib graphics.lib

all: $(TARGETS) $(OBJS)

display.obj: display.c display.h defs.h format.h globals.h
	$(CC) $(CFLAGS) -c display.c

format.obj: format.c format.h defs.h
	$(CC) $(CFLAGS) -c format.c

exe.obj: exe.c exe.h globals.h defs.h hardware.h interupt.h pallette.h
	$(CC) $(CFLAGS) -c exe.c

grph.obj: grph.c grph.h defs.h
	$(CC) $(CFLAGS) -c grph.c

hardware.obj: hardware.c hardware.h globals.h defs.h \
              pallette.h video.h interupt.h joy.h psg.h
	$(CC) $(CFLAGS) -c hardware.c

impl.obj: impl.c impl.h joy.h globals.h defs.h
	$(CC) $(CFLAGS) -c impl.c

interupt.obj: interupt.c interupt.h globals.h defs.h
	$(CC) $(CFLAGS) -c interupt.c

joy.obj: joy.c joy.h globals.h defs.h impl.h
	$(CC) $(CFLAGS) -c joy.c

pallette.obj: pallette.c pallette.h globals.h defs.h
	$(CC) $(CFLAGS) -c pallette.c

psg.obj: psg.c psg.h globals.h defs.h
	$(CC) $(CFLAGS) -c psg.c

sim.obj: sim.c defs.h dis.h format.h exe.h display.h grph.h
	$(CC) $(CFLAGS) -c sim.c

timer.obj: timer.c timer.h globals.h defs.h
	$(CC) $(CFLAGS) -c timer.c

video.obj: video.c video.h globals.h defs.h
	$(CC) $(CFLAGS) -c video.c

$(TARGETS): $(OBJS)
	echo $(OBJS1)      >resp
	echo $(OBJS2)      >>resp
#	echo $(LIBS)      >>resp
	$(LINK) $(CFLAGS) @resp
	del resp

#	echo c0fl.obj $(OBJS)            > objs
#	echo $(LIBS)                    > libs
#	tlink @objs, $(EXE),, @libs
#	del objs
#	del libs
