###########################################################################
#  Makefile
#			Makefile, needs GNUmake
#
###########################################################################
#
# PalmSpec,
# Spectrum emulator for PalmOS(R)
#
# (c)2002 Alex Bassas Serramia
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
###########################################################################

INCD = /opt/palmdev/sdk-5r3/include

CC = m68k-palmos-gcc

ARMCC = arm-palmos-gcc

INC = -I $(INCD) -I $(INCD)/Core -I $(INCD)/Core/System -I $(INCD)/Core/Hardware -I $(INCD)/Core/UI 

INC += -Iinclude

CFLAGS = -Wall

LFLAGS = -Wall -g -lcrt

OPT = -O2

all: armpalmspec.prc

armpalmspec.prc: palmspec bin.stamp armrefresh z80
	build-prc armpalmspec.prc "ArmPalmSpec" PSPe palmspec armrefresh z80 *.bin

palmspec: palmspec.o palmstd.o
	$(CC) $(LFLAGS) -o palmspec palmspec.o palmstd.o palmspec.ld

palmspec.o: palmspec.c plusk.c game.c snapshot.c
	$(CC) $(CFLAGS) -c $(INC) $(OPT) palmspec.c

palmstd.o: palmstd.c
	$(CC) $(CFLAGS) -c $(INC) $(OPT) palmstd.c

bin.stamp: palmspec.rcp
	pilrc -I include palmspec.rcp
	touch bin.stamp

armrefresh: armrefresh.o
	$(ARMCC) -nostartfiles -o armrefresh armrefresh.o

armrefresh.o: armrefresh.c 
	$(ARMCC) $(CFLAGS) $(INC) $(OPT) -c armrefresh.c

z80.o: z81/z80.c z81/z80ops.c z81/z80.h z81/edops.c z81/cbops.c
	$(ARMCC) $(CFLAGS) $(INC) -Iz81 $(OPT) -c z81/z80.c

z80: z80.o
	$(ARMCC) -nostartfiles -o z80 z80.o
			
clean:
	rm -f *.[oai] palmspec *.bin *.stamp *.[pg]rc armrefresh z80

distclean:
	rm -f *.[oai] palmspec *.bin *.stamp armrefresh z80
