#
# Makefile for vMac/DOS 0.1.9.1
# (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                  	\
	-Wmissing-prototypes	\
	-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 than 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 main.o prefs.o	debug.o	\
	Hardware/IWM.o			\
	Hardware/Keyboard.o		\
	Hardware/Mouse.o		\
	Hardware/Nmemory.o		\
	Hardware/Native.o		\
	Hardware/RAM.o			\
	Hardware/ROM.o			\
	Hardware/RTC.o			\
	Hardware/SCC.o			\
	Hardware/SCSI.o			\
	Hardware/Sony.o			\
	Hardware/Sound.o		\
	Hardware/VIA.o			\
	Hardware/Interrup.o             \
	Hardware/Interfac.o             \
	trap.o				\
	dos/screen.o

all: vMac

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

vMac: $(OBJS) CPU/libCPU.a
	$(CC) $(CFLAGS) $(OBJS) -L ./CPU -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

# 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
