#Makefile for gcc PalmPilot crosscompiler m68k-palmos-coff-gcc package.
# Change the strings from APP to BUILDPRC to match your own
# system configuration.
# Place the file into the developping directory.
# "make clean" removes all generated files, even the ".prc".
# Note - if you are building this on your system, you may need to edit
# the makeBuildInfo file (or comment out the makeBuildInfo line and
# create your own AboutBuild.txt), esp. if you're not using unix.

APP		=AppView
ICONNAME	="App View"
APPID		=AppV
VERSIONFILE	=VERSION
VERS		=`cat VERSION`
DBName		="AppView-${APPID}"
RCP		=$(APP).rcp
RCPSRC		=$(APP).rcp.src
PRC		=$(APP).prc
PRCVERS	=$(APP)_v$(VERS).prc
SRC		=$(APP).c
GRC		=$(APP).grc
BIN		=$(APP).bin

#Edit these to match your build system
CC		=m68k-palmos-coff-gcc
PILRC		=pilrc
TXT2BITM	=txt2bitm
OBJRES		=m68k-palmos-coff-obj-res
BUILDPRC	=build-prc
SRC2RCP	=./src2rcp.pl

# uncomment this if you want to build a gdb debuggable version
# -On: n=Optimization-level (0=none), -g: needed for debugging
CFLAGS          = -O2 $(DEFINES) $(INCLUDES)

all:            $(PRC)

$(PRC):       grc.stamp bin.stamp ;
	$(BUILDPRC) $(PRCVERS) $(DBName) $(APPID) *.grc *.bin $(LINKFILES) 
	cp $(PRCVERS) $(PRC)
	ls -l *.prc

grc.stamp:    $(APP) ;
	$(OBJRES) $(APP)
	touch $@

$(APP):       $(SRC:.c=.o) ProfilerHandler.o aboutbox.o;
	$(CC) $(CFLAGS) $^ -o $@

aboutbox.o: aboutbox.c Resources.h
	$(CC) $(CFLAGS) -c aboutbox.c -o aboutbox.o

Resources.h: $(RCP) $(VERSIONFILE) aboutbox.stamp
	$(PILRC) -H Resources.h $(APP).rcp

$(RCP): $(RCPSRC) $(VERSIONFILE)
	$(SRC2RCP) -f$(RCPSRC) VERS=$(VERS) APPID=$(APPID) ICONNAME=$(ICONNAME)

bin.stamp: Resources.h
	touch $@

aboutbox.stamp: AboutHome.txt AboutRogue.txt AboutTeam.txt AboutLicense.txt AboutBuild.txt
	touch $@

AboutBuild.txt: VERSION
	./makeBuildInfo $(APP) $(VERS) > AboutBuild.txt

#bin.stamp:    $(RCP) ;
#	$(PILRC) $^ $(BINDIR)
#	touch $@

%.o:  %.c Resources.h;
	$(CC) $(CFLAGS) -c $< -o $@
	#               touch $<
	# enable this line if you want to compile EVERY time.

#tAIB03e9.bin: skull-small.txt
#	txt2bitm -I1001 skull-small.txt

depend dep: ;
	$(CC) -M $(SRC) > .dependencies


clean:
	rm -rf *.o $(APP) $(RCP) *.bin *.grc $(PRC) *.stamp Resources.h AboutBuild.txt *~

pristine: clean
	rm -rf *.prc
