# Makefile for UAE (Un*x Amiga Emulator)
#
# Copyright 1995,1996 Bernd Schmidt
# Copyright 1996 Ed Hanway

#.SUFFIXES: .o .c .h .m

# If you have a Pentium, you can get (marginally) better code if you use the
# commented line.
# Only gcc 2.7.x understands this. Leave it commented out if you use
# gcc <= 2.6.x, or a non-x86 architecture.
#PENTIUMOPT = -malign-jumps=0 -malign-loops=0

# One function has been optimized by rewriting it in x86 assembly. If you
# - use an x86 CPU, for x > 3 (a 386 won't do)
# - have an ELF system
# you can uncomment the following lines:
#ASSEMBLYCFLAGS=-DUSE_ASSEMBLY
#ASSEMBLYOBJS=X86.o

# If you want to use the AF System to play sound, set theese to the
# correct paths. If not, leave them commented out.
# (Don't forget to define AF_SOUND in config.h)
#AFINCLUDE=-I/usr/local/vol/AudioFile/include
#AFLDFLAGS=-L/usr/local/vol/AudioFile/lib -lAF

# Don't change anything below this line, except maybe the search paths
# for X11 (X11R6 could be X11R5 on your system)

#INCLUDES=-Iinclude

CFLAGS = idir=include cpu=040 nostackcheck structureequivalence data=far code=far debug=line \
         ignore=85,93,105,181,306 optinlocal optimize opttime optdepth=4 params=register \
         idir=cybergfx define=_CYBERGFX

OBJS = main.o newcpu.o memory.o debug.o custom.o cia.o disk.o amiga.o \
       autoconf.o os.o ersatz.o filesys.o hardfile.o keybuf.o expansion.o \
       readcpu.o cpudefs.o gfxutil.o gfxlib.o \
       cpu0.o cpu1.o cpu2.o cpu3.o cpu4.o cpu5.o cpu6.o cpu7.o \
       cpu8.o cpu9.o cpuA.o cpuB.o cpuC.o cpuD.o cpuE.o cpuF.o cpustbl.o

all: uae readdisk

install:

readdisk: readdisk.o
	slink lib:c.o readdisk.o to $@ lib lib:scnb.lib lib:amiga.lib nodebug

uae: $(OBJS)
	slink lib:c.o $(OBJS) to $@ lib lib:scnb.lib lib:amiga.lib nodebug

clean:
	-delete  \#?.o uae readdisk
	-delete  gencpu genblitter build68k cpudefs.c
	-delete  cpu?.c blit.h
	-delete  cputbl.h cpustbl.c

halfclean:
	-delete  $(OBJS) $(GFXOBJS)

blit.h: genblitter
	genblitter >blit.h

genblitter: genblitter.c
	sc link $(CFLAGS) genblitter
build68k: build68k.c
	sc link $(CFLAGS) build68k
gencpu: gencpu.c readcpu.c cpudefs.c
	sc link $(CFLAGS) gencpu readcpu cpudefs

custom.o: blit.h

cpudefs.o: cpudefs.c

cpudefs.c: build68k table68k
	build68k >cpudefs.c
cpustbl.c: gencpu
	gencpu s >cpustbl.c
cputbl.c: gencpu
	gencpu t >cputbl.c
cputbl.h: gencpu
	gencpu h >cputbl.h

cpu0.c: gencpu
	gencpu f 0 >cpu0.c
cpu1.c: gencpu
	gencpu f 1 >cpu1.c
cpu2.c: gencpu
	gencpu f 2 >cpu2.c
cpu3.c: gencpu
	gencpu f 3 >cpu3.c
cpu4.c: gencpu
	gencpu f 4 >cpu4.c
cpu5.c: gencpu
	gencpu f 5 >cpu5.c
cpu6.c: gencpu
	gencpu f 6 >cpu6.c
cpu7.c: gencpu
	gencpu f 7 >cpu7.c
cpu8.c: gencpu
	gencpu f 8 >cpu8.c
cpu9.c: gencpu
	gencpu f 9 >cpu9.c
cpuA.c: gencpu
	gencpu f 10 >cpuA.c
cpuB.c: gencpu
	gencpu f 11 >cpuB.c
cpuC.c: gencpu
	gencpu f 12 >cpuC.c
cpuD.c: gencpu
	gencpu f 13 >cpuD.c
cpuE.c: gencpu
	gencpu f 14 >cpuE.c
cpuF.c: gencpu
	gencpu f 15 >cpuF.c

cpu0.o: cpu0.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu1.o: cpu1.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu2.o: cpu2.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu3.o: cpu3.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu4.o: cpu4.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu5.o: cpu5.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu6.o: cpu6.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu7.o: cpu7.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu8.o: cpu8.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpu9.o: cpu9.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpuA.o: cpuA.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpuB.o: cpuB.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpuC.o: cpuC.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpuD.o: cpuD.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpuE.o: cpuE.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c
cpuF.o: cpuF.c
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $*.c

bebox.o: bebox.cpp
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $(DEBUGFLAGS) bebox.cpp

.m.o:
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $(DEBUGFLAGS) $*.m
.c.o:
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $(DEBUGFLAGS) $(ASSEMBLYCFLAGS) $*.c
.c.s:
	$(CC) $(INCLUDES) -S $(INCDIRS) $(CFLAGS) $*.c
.S.o:
	$(CC) $(INCLUDES) $(INCDIRS) $(CFLAGS) $(DEBUGFLAGS) $(ASSEMBLYCFLAGS) $*.S

# Saves recompiling...
touch:
	touch *.o; touch build68k; touch cpudefs.c; touch cpudefs.o; touch gencpu genblitter; touch cpu?.c cpu*tbl.[ch]; touch cpu?.o cpu*tbl.o

# Some more dependencies...
cpu0.o: cputbl.h
cpu1.o: cputbl.h
cpu2.o: cputbl.h
cpu3.o: cputbl.h
cpu4.o: cputbl.h
cpu5.o: cputbl.h
cpu6.o: cputbl.h
cpu7.o: cputbl.h
cpu8.o: cputbl.h
cpu9.o: cputbl.h
cpuA.o: cputbl.h
cpuB.o: cputbl.h
cpuC.o: cputbl.h
cpuD.o: cputbl.h
cpuE.o: cputbl.h
cpuF.o: cputbl.h
cpustbl.o: cputbl.h cpustbl.c
cputbl.o: cputbl.h cputbl.c

build68k.o: include/readcpu.h
readcpu.o: include/readcpu.h

main.o: config.h
cia.o: config.h
custom.o: config.h
newcpu.o: config.h
autoconf.o: config.h
expansion.o: config.h
xwin.o: config.h
svga.o: config.h
bebox.o: config.h
os.o: config.h
memory.o: config.h
debug.o: config.h
ersatz.o: config.h
disk.o: config.h

