# Makefile for Arnold

CC = @CC@
BIND = $(CC)
#   CFLAGS    flags for C compile
#   LFLAGS1   flags after output file spec, before obj file list
#   LFLAGS2   flags after obj file list (libraries, etc)

#use this for RedHat/SuSE Linux
X11INC = -I@x_includes@
X11LIB = -L@x_libraries@

# Use this for Solaris 2.5.1 with OpenWin
#X11INC = -I/usr/X11R6/include -I/usr/openwin/share/include
#X11LIB = -L/usr/X11R6/lib -L/usr/openwin/lib

X11LIBS = $(X11LIB) -lX11 -lXext

# Comment to following two lines to disable GTK+
GTKINC = @GTK_CFLAGS@
GTKLIB = @GTK_LIBS@

# Comment to following two lines to disable SDL
SDLINC = @SDL_CFLAGS@
SDLLIB = @SDL_LIBS@

#-Wall for max warnings!
CFLAGS = @CPPFLAGS@ @CFLAGS@ $(GTKINC) $(SDLINC) @DEFS@ $(X11INC) -I. -DUNIX -Wall -Wno-unused
#-g3 -pg -dm -dp -a
LFLAGS1 = @LDFLAGS@ @LIBS@ $(GTKLIB) $(SDLLIB) $(X11LIBS)
#debug
LFLAGS2 = -s 
#LFLAGS2= -g3 -pg -dm -dp -a
#normal
#LFLAGS2 = -s

TARGET_CPU = @target_cpu@

CPC_O=	cpc/arnold.o cpc/asic.o cpc/audioevent.o cpc/bmp.o cpc/cpc.o \
	cpc/crtc.o cpc/dumpym.o cpc/fdc.o cpc/fdd.o cpc/fdi.o \
	cpc/garray.o cpc/multface.o cpc/printer.o cpc/psgplay.o \
	cpc/psg.o cpc/render.o cpc/render5.o cpc/scrsnap.o \
	cpc/snapshot.o cpc/sampload.o cpc/spo256.o cpc/pal.o \
	cpc/voc.o cpc/tzxold.o cpc/wav.o cpc/westpha.o cpc/yiq.o \
	cpc/z8536.o cpc/csw.o cpc/cassette.o cpc/amsdos.o \
	cpc/debugger/gdebug.o cpc/debugger/breakpt.o \
	cpc/diskimage/diskimg.o cpc/ramrom.o \
	cpc/diskimage/dsk.o cpc/diskimage/extdsk.o \
	cpc/diskimage/iextdsk.o cpc/diskimage/maketrk.o \
	cpc/z80/z80.o cpc/debugger/memdump.o \
	cpc/riff.o cpc/snapv3.o \
	cpc/cheatsys.o cpc/cpcdbg.o cpc/messages.o

UNIX_O= unix/main.o unix/host.o unix/global.o \
	unix/display.o unix/display_sdl.o unix/gtkui.o unix/sdlsound.o \
	unix/configfile.o unix/roms.o unix/ifacegen.o

ROMS_BIN=	roms/amsdose/amsdos.rom,roms/cpc464e/os.rom,roms/cpc464e/basic.rom,roms/cpc664e/os.rom,roms/cpc664e/basic.rom,roms/cpc6128e/os.rom,roms/cpc6128e/basic.rom,roms/cpcplus/system.cpr,roms/kcc/kccos.rom,roms/kcc/kccbas.rom

arnold:  conditionals roms $(CPC_O) $(UNIX_O)
	$(BIND) -Wl,-b,binary,$(ROMS_BIN),-b,$(TARGET_FMT) -o arnold $(LFLAGS1) $(CPC_O) \
	$(UNIX_O) $(LFLAGS2)
	mv arnold ..

conditionals:
ifeq ($(TARGET_CPU),ppc)
TARGET_FMT=elf32-ppc
else
TARGET_FMT=elf32-i386
endif

roms:
	ln -s ../roms .

ctags:
	ctags -R
clean:
	rm -rf cpc/*.o
	rm -rf ifacegen/*.o
	rm -rf unix/*.o
	rm -rf cpc/debugger/*.o
	rm -rf cpc/diskimage/*.o
	rm -rf cpc/z80/*.o
	rm -rf tags
distclean: clean
	rm -rf *~ */*~
	rm Makefile
	rm config.cache
	rm config.log
	rm config.status
realclean: distclean
	rm aclocal.m4
	rm configure
archive:
	$(clean)
	cp makefile unix/makefile.unx
	zip -r cpccore.zip cpc
	zip -r ifacegen.zip ifacegen
	zip -r unix.zip unix
	zip -r roms.zip roms

# C compile rules
#.c.o:
#	$(CC) -c $(CFLAGS) $<

#CPC Core
#arnold.o: cpc/arnold.o
#asic.o: cpc/asic.o
#audioevent.o: cpc/audioevent.o
#bmp.o: cpc/bmp.o
#cpc.o: cpc/cpc.o
#crtc.o: cpc/crtc.o
#debugmain.o: cpc/debugmain.o
#dirstuff.o: cpc/dirstuff.o
#dumpym.o: cpc/dumpym.o
#fdc.o: cpc/fdc.o
#garray.o: cpc/garray.o
#multface.o: cpc/multface.o
#printer.o: cpc/printer.o
#psg.o: cpc/psg.o
#render.o: cpc/render.o
#render5.o: cpc/render5.o
#scrsnap.o: cpc/scrsnap.o
#snapshot.o: cpc/snapshot.o
#spo256.o: cpc/spo256.o
#tapefile.o: cpc/tapefile.o
#tzx.o: cpc/tzx.o
#wav.o: cpc/wav.o
#westpha.o: cpc/westpha.o
#yiq.o: cpc/yiq.o
#debug.o: cpc/debugger/debug.o
#gdebug.o: cpc/debugger/gdebug.o
#diskimg.o: cpc/diskimage/diskimg.o
#dsk.o: cpc/diskimage/dsk.o
#extdsk.o: cpc/diskimage/extdsk.o
#iextdsk.o: cpc/diskimage/iextdsk.o
#z80.o: cpc/myz80/z80.o
#riff.o: cpc/riff.o

#Generic Interface
#ifacegen.o: ifacegen/ifacegen.o
#fnp.o: ifacegen/fnp.o
#romfn.o: ifacegen/romfn.o
#filetool.o: ifacegen/filetool.o

#Linux specific host code
#main.o: unix/main.o
#host.o: unix/host.o
#global.o: unix/global.o
#settings.o: unix/settings.o
#display.o: unix/display.o

