##******************************* Makefile *********************************
##           #######
##           ##  ##
##           #  ##    ####   #####    #####  ##  ##   #####
##             ##    ##  ##  ##  ##  ##      ##  ##  ##
##            ##  #  ######  ##  ##   ####   ##  ##   ####
##           ##  ##  ##      ##  ##      ##   #####      ##
##          #######   ####   ##  ##  #####       ##  #####
##                                           #####
##          Z-Wave, the wireless language.
##
##              Copyright (c) 2001
##              Zensys A/S
##              Denmark
##
##              All Rights Reserved
##
##    This source file is subject to the terms and conditions of the
##    Zensys Software License Agreement which restricts the manner
##    in which it may be used.
##
##---------------------------------------------------------------------------
##
## Description:
##    Makefile for the ZW0x0x development kit development controller
##    This makefile defines the targets built
##
## Author:   Erik Friis Harck
##
## Last Changed By:  $Author: psh $
## Revision:         $Revision: 22659 $
## Last Changed:     $Date: 2012-05-02 17:09:49 +0200 (Wed, 02 May 2012) $
##
##***************************************************************************/

#---------------------------------------------------------------------------------------------------------
# HOW-TO: Specifying which subset of "everything", you wan't to build:
#
# You can specify a single frequency to build for in 3 different ways:
# 1. By specifying the frequency in your command line, like:
#    > make FREQUENCY=EU ....
# 2. By uncommenting and correcting the following line:
#FREQUENCY:=EU
# 3. Alternativly you can do the same by setting your environment with:
#    > SET FREQUENCY=EU
#    Remember to UNSET this when you jump to work on other things.
#
# You can specify a single code memory mode to build for in 3 different ways:
# 1. By specifying the code memory mode in your command line, like:
#    > make CODE_MEMORY_MODE=devmode_patch ....
# 2. By uncommenting and correcting the following line:
#CODE_MEMORY_MODE:=normal
# 3. Alternativly you can do the same by setting your environment with:
#    > SET CODE_MEMORY_MODE=normal
#    Remember to UNSET this when you jump to work on other things.
#
# You can specify a single library to build for in 3 different ways:
# 1. By specifying the library in your command line, like:
#    > make LIBRARY=controller_portable ....
# 2. By uncommenting and correcting the following line:
LIBRARY:=controller_portable
# 3. Alternativly you can do the same by setting your environment with:
#    > SET LIBRARY=controller_portable
#    Remember to UNSET this when you jump to work on other things.
#
# You can specify a single host interface to build for in 3 different ways:
# 1. By specifying the host interface in your command line, like:
#    > make HOST_INTERFACE=UART ....
# 2. By uncommenting and correcting the following line:
HOST_INTERFACE:=UART
# 3. Alternativly you can do the same by setting your environment with:
#    > SET HOST_INTERFACE=UART
#    Remember to UNSET this when you jump to work on other things.
#
# You can specify a single sensor type to build for in 3 different ways:
# 1. By specifying the sensor type in your command line, like:
#    > make SENSOR_TYPE=NON_BATT ....
# 2. By uncommenting and correcting the following line:
SENSOR_TYPE:=NON_BATT
# 3. Alternativly you can do the same by setting your environment with:
#    > SET SENSOR_TYPE=NON_BATT
#    Remember to UNSET this when you jump to work on other things.
#
# You can specify a single board type to build for in 3 different ways:
# 1. By specifying the board type in your command line, like:
#    > make BOARD=ZDP03A ....
# 2. By uncommenting and correcting the following line:
BOARD:=ZDP03A
# 3. Alternativly you can do the same by setting your environment with:
#    > SET BOARD=ZDP03A
#    Remember to UNSET this when you jump to work on other things.
#
# And yes... You can combine these methods in any way.
#
# If you do nothing of the above, you will be building target code for all combinations of frequencies and
# code memory modes in the lists below.
#
# And yes... You can of course manipulate the lists below, if you have special needs for ranges of targets.
#---------------------------------------------------------------------------------------------------------

# Full list of all supported frequencies can be found in $(ZWLIBROOT)\Common\Makefile.common
# Downgraded list of supported frequencies for dev_ctrl.
LIST_OF_FREQUENCIES:=US EU ANZ HK MY IN JP

#---------------------------------------------------------------------------------------------------------

# If not supplied by application here, the name of the application will be set equal to it's directory name.
APP_NAME:=dev_ctrl

# Target name (Name of your target directory and base name of your target files)
TARGET:=$(APP)_$(CHIP)_$(COUNTRY)$(TEST)

#---------------------------------------------------------------------------------------------------------

# List of object modules constituting the program for the different code memory modes.

ifeq ($(CODE_MEMORY_MODE),normal)
# build the project the original way for OTP. "dev_ctrl"
RELFILES:=\
 dev_ctrl.obj\
 eeprom.obj\
 p_button.obj\
 ctrl_learn.obj\
 App_RFSetup.obj
endif

ifeq ($(CODE_MEMORY_MODE),devmode)
# build the project for development mode for OTP. "dev_ctrl_devmode"
RELFILES:=\
 dev_ctrl.obj\
 eeprom.obj\
 p_button.obj\
 ctrl_learn.obj\
 App_RFSetup.obj
endif

ifeq ($(CODE_MEMORY_MODE),devmode_patch)
# build patch code for development mode RAM. "dev_ctrl_devmode_patch" (all patched modules)
RELFILES:=\
 dev_ctrl_patch.obj\
 eeprom_patch.obj\
 p_button_patch.obj
endif

ifeq ($(CODE_MEMORY_MODE),starter_devmode)
# build the project for development mode for OTP. "starter_devmode" (empty program with library)
RELFILES:=\
 starter.obj\
 App_RFSetup.obj
endif

ifeq ($(CODE_MEMORY_MODE),starter_devmode_patch)
# build patch code for development mode RAM. "starter_devmode_dev_ctrl_patch" (all application except library)
RELFILES:=\
 dev_ctrl_patch.obj\
 eeprom_patch.obj\
 p_button_patch.obj\
 starter_patch.obj\
 ctrl_learn.obj
endif

#---------------------------------------------------------------------------------------------------------

# Find the current directory
# used as a base for all other paths.
BASEDIR=$(shell cd)

# Find the product name from the subdirectoryname
BASEDIRWORDLIST=$(subst \, ,$(BASEDIR))
BASEDIRLASTWORDINDEX=$(words $(BASEDIRWORDLIST))
PRODUCTDIR=$(word $(BASEDIRLASTWORDINDEX),$(BASEDIRWORDLIST))

# Find the Z-Wave library location (if not forced by setting the environment variable ZWLIBROOT)
ifndef ZWLIBROOT
ZWLIBROOT:=$(subst \$(PRODUCTDIR),,$(subst \Product,\Z-Wave,$(BASEDIR)))
endif

# Library location when making release of application
ifdef SVNLIBRELEASEDIRBIN
ZWLIBROOT:=$(SVNLIBRELEASEDIRBIN)
endif

# Export the variables declared above to the other makefiles.
export BASEDIR ZWLIBROOT UNDERSTAND_C ZM4102

include $(ZWLIBROOT)\Common\Makefile.common

CDEFINES+=,\
 APPL_PROD_TEST
