OBJS = hello-world.o

TTY = /dev/ttyS1

CC = m68k-palmos-coff-gcc
GDB = m68k-palmos-coff-gdb

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

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

#LIBS = -lgdb -lc
LIBS = -lc

PILRC = pilrc
TXT2BITM = txt2bitm
OBJRES = m68k-palmos-coff-obj-res
BUILDPRC = build-prc
PILOTXFER = pilot-xfer

ICONTEXT = "GNU Test!"
APPID = gtst

all: gnuhello.prc

debug: gnuhello.prc
	echo "Press hotsync to install..."
	$(PILOTXFER) $(TTY) -i gnuhello.prc
	echo target remote $(TTY) > .gdbinit
	stty speed 38400 < $(TTY)
	echo "Start GNUHello on pilot"
	$(GDB) hello

.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 .gdbinit
