/* メイクファイル <Makefile>  */

# ====================================================
# 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

# Compiler Flags
CFLAGS   = $(PalmCFlags) -I$(rscDir)

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

# Target info
progName   = Tex2Hex
progDBName   = "Text to Hex"
progCreator   = TxHx
progPrcFile   = $(progName)App.prc
progTestFile  = $(progName)Test.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 install clean help

# Set the default install directory if not passed down to us
#  from the parent makefile
ifndef InstallDir
  InstallDir = $(PALMTOOLSU)/bin/Device
endif
 

#############################################################
# Master Builds
#############################################################
all:  $(objDir)/$(progPrcFile)
 $(MAKE) install

install:
 cp $(objDir)/$(progPrcFile) $(InstallDir)

clean:
 rm -f $(objDir)/*

check:
 cmp $(objDir)/$(progTestFile) $(testsDir)/$(progPrcFile)

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

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

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

objList = $(objDir)/Tex2Hex.o

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

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

 # The $(progTestFile) PRC has zero creation and mod dates for comparison
 # purposes
 $(PALMRC) -rcp $(rscDir)/$(progName).rcp \
  -gccApp $(objDir)/$(progDBName).code.1.sym \
  -I $(srcDir) -I $(rscDir) \
  -o $(objDir)/$(progTestFile) \
  -name $(progDBName) -cr $(progCreator) \
  -zCrDate -zModDate
 ls -l $(objDir)/*.prc