# 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        = linkhistoryhack
HACKNAME    = "Link History Hack"
HACKID      = LMHH  # make sure this matches what's in the source files
HACKSRC     = code03e8.c code03e9.c code07d0.c
HACKRES     = $(HACK).rcp linkhistoryhackRsc.h

DEBUGCFLAGS     = -g -Wall -O2
RELEASECFLAGS   = -O2 -Wall

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

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

debug:
	make CFLAGS="$(DEBUGCFLAGS)" all

release:
	make CFLAGS="$(RELEASECFLAGS)" all

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

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

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

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