#
#  makefile
#

CC	= gcc
LINK 	= gcc

INCLUDE = 
LIBS    = -lalleg

#CCOPTS  = -g -m486
CCOPTS  = -mpentium -fstrength-reduce -fomit-frame-pointer -O3 -funroll-loops

CFLAGS	= -DBYTEORD_LSBFIRST $(INCLUDE) $(CCOPTS)

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

all: $(TARGETS) $(OBJS)

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

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

h6280.o: h6280.c h6280.h globals.h defs.h hardware.h interupt.h pallette.h
	$(CC) $(CFLAGS) -c h6280.c

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

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

impl.o: impl.c impl.h defs.h
	$(CC) $(CFLAGS) -c impl.c

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

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

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

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

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

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

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

sim.exe: $(OBJS)
	$(CC) $(CFLAGS) -o sim.exe $(OBJS) $(LIBS)
