# Makefile for "eNeRgetic"
# A music player for Sony Clie NR70
# http://woz.gs/tim/energetic.php
#
# Based on Rich McNeary's example makefile
# http://home.eznet.net/~rlmsmw/palmos/palmos.htm
#
# Compiled using:
# prc-tools 2.1
# PalmOS SDK-4
# Sony SDK-3

APP	=eNeRgy

RCP		=$(APP).rcp
DEF		=$(APP).def
PRC		=$(APP).prc
BIN		=$(APP).bin
LNOBJECT	=$(APP).o
SECTIONS	=$(APP).s

# The object created from each .c file
OBJ             =pilotmain.o mainform.o

# Application shortcuts
CC		=m68k-palmos-gcc
AS		=m68k-palmos-as
PILRC		=pilrc
BUILDPRC	=build-prc

LDFLAGS			= -g
CFLAGS			=-O2 -w
#CFLAGS			=-O2 -Wall -D_DEBUG_ -g
#CFLAGS			=-O2 -D_DEBUG_ -D_TRACE_ -g

LD                              =$(APP).ld

# Make everything
all : $(PRC)


# Bind the resources together as a PalmOS executable
$(PRC) : $(APP) bin.stamp;
	$(BUILDPRC) -o $(PRC) $(DEF) $(APP) *.bin


# Stamp the resource binaries
bin.stamp : $(RCP) ;
	$(PILRC) $(RCP)
	touch $@


# Create the BFD executable file from the O, and LD files
$(APP) : $(LD) $(LNOBJECT) $(OBJ)
	$(CC) $(CFLAGS) -o $(APP) $(OBJ) $(LNOBJECT) $(LD)


# Using the C files create the object files
%.o : %.cpp
	$(CC) $(CFLAGS) -c $< -o $@


# Create the link object from the sections file
$(LNOBJECT) : $(SECTIONS)
#	$(AS) -o $(LNOBJECT) $(SECTIONS)


# Create the linker script from the definition file
$(LD) $(SECTIONS) : $(DEF)
	multigen -b $(APP) $(DEF)


.Phony : clean
clean :
	rm *.o $(APP) *.bin *.stamp *.ld *.s
