OBJS = gps.o garmin.o file.o host.o
NAME = gypsy

PREFIX=/usr/local/gnu
TOOLDIR = $(PREFIX)/bin
INCDIR = $(PREFIX)/m68k-palmos-coff/include
LIBDIR = $(PREFIX)/m68k-palmos-coff/lib
CC = $(TOOLDIR)/m68k-palmos-coff-gcc

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

CSFLAGS = -O2 -S $(DEFINES) $(INCLUDES)
CFLAGS = -Wall -O2 $(DEFINES) $(INCLUDES)

PILRC = $(TOOLDIR)/pilrc
TXT2BITM = $(TOOLDIR)/txt2bitm
OBJRES = $(TOOLDIR)/m68k-palmos-coff-obj-res
BUILDPRC = $(TOOLDIR)/build-prc

ICONTEXT = "Gypsy"
APPID = fRCS
PRC = $(NAME).prc

all: $(PRC)

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

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

$(PRC): code.stamp bin.stamp
	$(BUILDPRC) $@ $(ICONTEXT) $(APPID) *.grc *.bin

code.stamp: $(NAME)
	$(OBJRES) $(NAME)
	touch code.stamp

bin.stamp: gps.rcp gps.h
	$(PILRC) gps.rcp
	touch bin.stamp

$(NAME): $(OBJS) 
	./make_versions.sh
	$(CC) $(TARGETFLAGS) -c versions.c
	$(CC) $(CFLAGS) $(OBJS) versions.o $(LIBS) -o $@

clean:
	rm -rf *.[oa] $(NAME) *.bin *.stamp *.[pg]rc

rcs:
	ci -l gps.c garmin.c gps.h globals.h gps.rcp Makefile callback.h file.c make_versions.sh host.c

gps.o:	gps.h globals.h callback.h Makefile

garmin.o: gps.h globals.h callback.h Makefile

file.o:	gps.h globals.h callback.h Makefile

host.o:	gps.h globals.h callback.h Makefile

tar:
	tar cvf gypsy.tar gps.c garmin.c gps.h globals.h gps.rcp Makefile callback.h file.c make_versions.sh host.c gps.rcp gps.bmp
	gzip gypsy.tar

