OBJS = hello-world.o

PREFIX = /usr/local
CC = $(PREFIX)/bin/m68k-palmos-coff-gcc

#uncomment this if you want to build a gdb debuggable version
#DEFINES = -DDEBUG

CSFLAGS = -O2 -S $(DEFINES)
CFLAGS = -O2 -g $(DEFINES)

LIBS = -lgdb -lc

PILRC = ../pilrc
TXT2BITM = ../txt2bitm
OBJRES = ../obj-res
BUILDPRC = ../build-prc

ICONTEXT = "GNU Rules!"
APPID = gnuh

all: gnuhello.prc

.S.o:
	$(CC) $(TARGETFLAGS) -c $<

.c.s:
	$(CC) $(CSFLAGS) $<

gnuhello.prc: code0000.hello.bin code0001.hello.bin data0000.hello.bin bin.res
	$(BUILDPRC) gnuhello.prc $(ICONTEXT) $(APPID) code0001.hello.grc code0000.hello.grc data0000.hello.grc *.bin pref0000.hello.grc

code0000.hello.bin: hello
	$(OBJRES) hello

code0001.hello.bin: code0000.hello.bin

data0000.hello.bin: code0000.hello.bin

bin.res: hello-world.rcp
	$(PILRC) hello-world.rcp .
	$(TXT2BITM) gnu.pbitm
	touch bin.res

hello: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o hello $(LIBS)

clean:
	rm -rf *.[oa] hello *.bin bin.res *.[pg]rc
