#
# Makefile for vMac/DOS 0.1.9.4 
# (c) Yoav Shadmi, 1997-1998
#

# Compile options for MS-DOS
#CC=gcc
CC=redir -ea compile.log gcc
CFLAGS= -DREGPARAM=""           \
	-D__inline__=inline 	\
        -DX86_ASSEMBLY          \
        -O3                     \
	-ffast-math         	\
        -fstrength-reduce       \
	-finline-functions  	\
        -m486                   \
	-Wall               	\
	-Wno-unused         	\
	-Wno-format         	\
	-W                  	\
        -Wstrict-prototypes

DEFINES = CC='$(CC)' CFLAGS='$(CFLAGS)'

.SUFFIXES: .o .c .h .m

INCLUDES= -IHardware -IIncludes -IUnix -IDos -I.

# change this to where your libm.a is located. [note: if you are not compiling
# to 68020/68881 you should comment this line, and uncomment line after -
# there really is no need for libm.a without fpu emulation.]
#MATHLIB = /djgpp/lib/libm.a
MATHLIB =

OBJS =  custom.o debug.o driver.o \
        main.o prefs.o trap.o     \
        Hardware/Interfac.o       \
        Hardware/Interrup.o       \
        Hardware/IWM.o            \
        Hardware/Keyboard.o       \
        Hardware/Mouse.o          \
        Hardware/Nmemory.o        \
        Hardware/Native.o         \
        Hardware/PatchMGR.o       \
        Hardware/RAM.o            \
        Hardware/ROM.o            \
        Hardware/RTC.o            \
        Hardware/SCC.o            \
        Hardware/screen.o         \
        Hardware/SCSI.o           \
        Hardware/Sony.o           \
        Hardware/Sound.o          \
        Hardware/VIA.o            \
        dos/IBM-DISK.o            \
        dos/IBM-SCC.o             \
        dos/IBM-SND.o             \
        dos/IBM-TIME.o            \
        dos/IBM-UI.o              \
        dos/IBM-VGA.o

all: vMac

CPU/libCPU.a:
	cd CPU
	$(MAKE) $(DEFINES)
	cd ..

vMac: $(OBJS) CPU/libCPU.a
	$(CC) $(CFLAGS) $(OBJS) -L ./CPU -lalleg -lCPU $(MATHLIB) -o vMac
	strip vMac
	coff2exe vMac

cleana:
	del cpu\libCPU.a

clean: halfclean
	del vMac
	del vMac.exe

halfclean:
	del *.o
	del Hardware\*.o
	del dos\*.o
	del cpu\machdep\*.o
	cd CPU
	$(MAKE) clean
	cd ..

.m.o:
	$(CC) $(INCLUDES) -c $(CFLAGS) $*.m
.c.o:
	$(CC) $(INCLUDES) -c $(CFLAGS) $*.c -o $@
.c.s:
	$(CC) $(INCLUDES) -S $(CFLAGS) $*.c
.c.i:
	$(CC) $(INCLUDES) -E $(CFLAGS) $*.c > $@
.S.o:
	$(CC) $(INCLUDES) -c $(CFLAGS) $*.S
.s.o:
	$(CC) $(INCLUDES) -c $(CFLAGS) $*.s

# dependancies
screen.o   : screen.h
mouse.o    : screen.h
patchmgr.o : screen.h

# Saves recompiling...
touch:
	touch *.o
	touch hardware\*.o
	touch dos\*.o
	touch cpu\*.o
	touch cpu\*.a
	touch cpu\cpu?.c
	touch cpu\cputbl.h
	touch cpu\cpustbl.c
