#######################################################################
# Makefile sample for a project built from VC++
# Commonly used  Automatic Variables:
#	  $< represents the first dependency
#	  $^ represents all dependencies
#	  $? represents all dependencies that are newer than the target
#	  $@ represents the target
#	  $* represents the target without the extention
#######################################################################
all:
	make $(OUTPUTDIR)$(APP).prc

#######################################################################
# Enter information relative to your project here
#######################################################################
PROGDBNAME=ClockEveryWhere
PROGCREATOR=RMal 
APP=ClockEveryWhere
RCPFILE=$(APP).rcp
RSRCINC=ResourceDefines.h

SRCDIR=../Src/
RSRCDIR=../Rsc/
OUTPUTDIR=../Obj/
SYSINCSDIR=../SysIncs/
BUILDDIR=../Build/

SDKVERSION= -palmos3.5
#SDKVERSION= -palmos4

# Enter all .o files for your project
OBJS=$(OUTPUTDIR)utils.o $(OUTPUTDIR)code03e8.o $(OUTPUTDIR)code03e9.o $(OUTPUTDIR)code07d0.o

# Define CFLAGS to either DEBUGCFLAGS or RELEASECFLAGS and PRCFLAGS
DEBUGCFLAGS = $(SDKVERSION) -DDEBUG_BUILD -Wall -DCMD_LINE_BUILD -DEMULATION_LEVEL=0
RELEASECFLAGS = $(SDKVERSION) -O3 -Wall -DCMD_LINE_BUILD -DEMULATION_LEVEL=0

# DEBUG Build
CFLAGS = $(DEBUGCFLAGS)
#CFLAGS = $(RELEASECFLAGS)

PRCFLAGS      = --backup -t HACK -v 1

#######################################################################
# Define Dependencies here
#######################################################################
$(OUTPUTDIR)utils.o: $(BUILDDIR)Makefile $(RSRCDIR)$(RSRCINC) $(SRCDIR)utils.h
$(OUTPUTDIR)code03e8.o: $(BUILDDIR)Makefile $(RSRCDIR)$(RSRCINC) $(SRCDIR)utils.h $(SRCDIR)ClockEveryWhere.h
$(OUTPUTDIR)code03e9.o: $(BUILDDIR)Makefile $(RSRCDIR)$(RSRCINC) $(SRCDIR)utils.h $(SRCDIR)ClockEveryWhere.h
$(OUTPUTDIR)code03e9.o: $(BUILDDIR)Makefile $(RSRCDIR)$(RSRCINC) $(SRCDIR)utils.h $(SRCDIR)ClockEveryWhere.h

#######################################################################
# DO NOT CHANGE HERE
#######################################################################
CC = m68k-palmos-gcc

#$(OUTPUTDIR)$(APP).prc: $(OUTPUTDIR)$(APP) $(OUTPUTDIR)bin.stamp $(BUILDDIR)$(APP).def
#	(cd $(OUTPUTDIR); build-prc $(BUILDDIR)$(APP).def $(APP) *.bin -o $(APP).prc)
$(OUTPUTDIR)$(APP).prc: $(OUTPUTDIR)$(APP).code.1.sym $(OUTPUTDIR)bin.stamp
	(cd $(OUTPUTDIR); build-prc $(PRCFLAGS) $(APP).prc $(PROGDBNAME) $(PROGCREATOR) $(APP).code.1.sym *.bin)

$(OUTPUTDIR)$(APP).code.1.sym: $(OBJS)
	$(CC) -nostartfiles $(CFLAGS) -o $@ $(OBJS)

$(OUTPUTDIR)%.o: $(SRCDIR)%.c 
	$(CC) -nostartfiles $(CFLAGS) -c $< -o $@ -I $(RSRCDIR) -I $(SYSINCSDIR) 2>&1 | errmsgs -vs

$(OUTPUTDIR)bin.stamp: $(RSRCDIR)$(RCPFILE) $(RSRCDIR)$(RSRCINC)
	( cd $(OUTPUTDIR); rm *.bin; pilrc -V -I $(SRCDIR) -I $(RSRCDIR) $(RSRCDIR)$(RCPFILE) ; touch bin.stamp)

clean:
	rm -f $(OBJS) $(OUTPUTDIR)$(APP).* $(OUTPUTDIR)*.bin $(OUTPUTDIR)bin.stamp
