# Makefile for Link History Hack
# Please read the readme.txt file that came in the Sample Hack package

# Add .bin to the list of suffixes that make recognizes
.SUFFIXES:  .bin

HACK        = fanfHack
HACKNAME    = "Fix AN Find Hack"
HACKID      = FANF  # make sure this matches what's in the source files
HACKSRC     = code03e8.c
HACKRES     = $(HACK).rcp $(HACK)Rsc.h
VERSION     = 1.0

CFLAGS   = -O2 -Wall

# You shouldn't have to change anything below this line

CC      = m68k-palmos-coff-gcc
OBJRES  = m68k-palmos-coff-obj-res

all:    $(HACK).prc

HACKBIN = $(HACKSRC:.c=.bin)

# This rule builds a standalone code resource (.bin) from a C source file
.c.bin:
	$(CC) $(CFLAGS) -nostartfiles -o $(*F) $<
	$(OBJRES) $(*F)
	cp code0001.$(*F).grc $@
	rm $(*F)

$(HACK).prc: hackresbin $(HACKBIN)
	build-prc -t HACK $@ $(HACKNAME) $(HACKID) *.bin
	ls -l $@

hackresbin: $(HACKRES)
	pilrc $(HACK).rcp
	touch $@

$(HACKBIN): $(HACK).h $(HACK)Rsc.h

clean:
	rm -f *.grc *.bin $(HACK).prc hackresbin

send: $(HACK).prc
	pilot-xfer -i $(HACK).prc

dist: $(HACK).prc
	zip $(HACK)-$(VERSION).zip $(HACK).prc index.htm ChangeLog
	tar cvf $(HACK)-src-$(VERSION).tar $(HACK).prc index.htm *.c *.h *.rcp Makefile *.bmp ChangeLog
	gzip -9 $(HACK)-src-$(VERSION).tar

