# ====================================================
# Include the common Make variables for PalmOS executables
# ====================================================
# This one is constant
include $(PALMTOOLSU)/bin/Palm-DefaultVars.make

# This one can be modified for different build options
#  and is optional 
-include $(PALMTOOLSU)/bin/Palm-CustomVars.make

# The shell to use
SHELL		  = /bin/sh

# Directory paths
objDir			= ../Obj
srcDir			= ../Src
rscDir			= ../Rsc


# Compile options
CFLAGS			= $(PalmCFlags)			\
				  -I$(rscDir)			\
				  -save-temps			


CODESEGCFLAGS	= $(CFLAGS) -Winline -nostartfiles 

# Target info
progName	  = amclock16
progDBName	  = "AmanoClock for Prism"
progCreator	  = amHC
progPrcFile	  = $(progName).prc


# These are fake targets used to perform certain actions. Use the .PHONY
#  command to make sure they don't get confused with actual filenames
.PHONY : all clean makeObjDir


#############################################################
# Master Builds
#############################################################
all: makeObjDir	$(objDir)/$(progPrcFile)

clean:
	rm -f $(objDir)/*

makeObjDir :
	if [ ! -e $(objDir) ]; then	 mkdir $(objDir); fi


#############################################################
# Implicit build rules
#############################################################
$(objDir)/%.o :  $(srcDir)/%.c
	$(CC) $(CFLAGS) -c $< -o $@


#############################################################
# Program Build
#############################################################

# ------------------------------------------------------------
# Compile objects 
# ------------------------------------------------------------
hdrList = \
		$(srcDir)/amclock16.h					

objList = \
		$(objDir)/amclock16.o 					\

rscList :=  $(wildcard $(rscDir)/*)

$(objDir)/amclock16.o: $(srcDir)/amclock16.c $(hdrList)


# ------------------------------------------------------------
# Link and combine with resources. 
# ------------------------------------------------------------
$(objDir)/$(progPrcFile): $(objList) $(rscDir)/$(progName).rcp \
					 $(objList) \
					 $(rscList) \
					 Makefile
	$(CC) $(CFLAGS) $(objList) -o $(objDir)/$(progDBName).code.1.sym
	$(PALMRC) $(PalmRCFlags) -rcp $(rscDir)/$(progName).rcp \
		-gccApp $(objDir)/$(progDBName).code.1.sym \
		-I $(srcDir) -I $(rscDir) \
		-o $(objDir)/$(progPrcFile) \
		-ignoreDups \
		-name $(progDBName) -cr $(progCreator) \
		-version 10

