#********************************  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: Make file for the ZW0102/ZW0201 Production Test application
#
#  Author:   Peter Shorty
#
#  Last Changed By:  $Author: efh $
#  Revision:         $Revision: 21416 $
#  Last Changed:     $Date: 2011-09-27 16:44:10 +0200 (Tue, 27 Sep 2011) $
#
#****************************************************************************

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

# The command to make dependencies from the headerfiles
# included by a file.
INCDEP=python $(subst \,\\,$(TOOLSDIR)\IncDep\incdep.py)

# 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 INCDEP ZWLIBROOT UNDERSTAND_C

BDIRS=build


ZW0x0x: ZW020x ZW030x
ZW030x: ZW0301_eu ZW0301_us ZW0301_anz ZW0301_hk ZW0301_my ZW0301_in
ZW020x: ZW0201_eu ZW0201_us ZW0201_anz ZW0201_hk ZW0201_my ZW0201_in



default: ZW0x0x

all: default

# Include test targets (if any)
-include Makefile.TestTargets
-include Makefile.Testdefines

dirs: $(BDIRS)

MAKEOPTS=--no-print-directory -C

# Makes the dependency lines from included headerfiles.

# ZW010x dependency targets, this target is used for building
# dependencies before the code is compiled.

#ZW0201 TARGETS
ZW0201_eu:MAKELINE=CHIP=ZW020x COUNTRY=EU RF=EU
ZW0201_eu:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0201_us:MAKELINE=CHIP=ZW020x COUNTRY=US RF=US
ZW0201_us:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0201_anz:MAKELINE=CHIP=ZW020x COUNTRY=ANZ RF=ANZ
ZW0201_anz:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0201_hk:MAKELINE=CHIP=ZW020x COUNTRY=HK RF=HK
ZW0201_hk:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0201_my:MAKELINE=CHIP=ZW020x COUNTRY=MY RF=MY
ZW0201_my:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0201_in:MAKELINE=CHIP=ZW020x COUNTRY=IN RF=IN
ZW0201_in:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

#ZW0301 TARGETS
ZW0301_eu:MAKELINE=CHIP=ZW030x COUNTRY=EU RF=EU
ZW0301_eu:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0301_us:MAKELINE=CHIP=ZW030x COUNTRY=US RF=US
ZW0301_us:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0301_anz:MAKELINE=CHIP=ZW030x COUNTRY=ANZ RF=ANZ
ZW0301_anz:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0301_hk:MAKELINE=CHIP=ZW030x COUNTRY=HK RF=HK
ZW0301_hk:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0301_my:MAKELINE=CHIP=ZW030x COUNTRY=MY RF=MY
ZW0301_my:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common

ZW0301_in:MAKELINE=CHIP=ZW030x COUNTRY=IN RF=IN
ZW0301_in:
	$(MAKE) depend $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common
	$(MAKE) $(MAKEOPTS) . $(MAKELINE) -f Makefile.prodtestdut_common


clean:
ifeq ($(OS), Windows_NT)
	@cmd /c "if exist build\NUL rd build /s /q"
else
	@deltree /Y $(subst \,\\,build)
endif

# Catch all targets which we do not handle and tell world that
%:
	@echo Could not find rule for target '$@'
	@echo Some of the known targets are :
	@echo   ZW0201 : ZW020x slave target
	@echo   ZW0301 : ZW030x slave target

.PHONY: dirs clean depend all default world ZW020x ZW030x ZW0x0x
