ifeq ($(CCS_HOST_OS),linux)
    CHECK_PYTHON3 = $(shell command -v python3 2>/dev/null)
    ifeq ($(CHECK_PYTHON3), )
        PYTHON := python
    else
        PYTHON := python3
    endif
	RENAME  := mv
    DELETE  := rm
    COPY    := cp
else ifeq ($(CCS_HOST_OS),win32)
	PYTHON  := py
    RENAME  := ren
    DELETE  := del
    COPY    := copy
else
    PYTHON  := python3
	RENAME  := mv
    DELETE  := rm
    COPY    := cp
endif

ifeq ($(CCS_HOST_OS),win32)
    CPU2APP_REL_PATH        := ..\\..\\cpu2App.bin
    CPU3APP_PATH            := ..\\..\\cpu3App.bin
    CPU3APP_REL_PATH        := ..\\..\\cpu3App.bin ..\\..\\cpu3App.cert.bin
    CPU3APP_CERT_REL_PATH   := ..\\..\\cpu3App.cert.bin
    SECCFGCPU3_REL_PATH     := ..\\..\\seccfgCpu3.bin
    SECCFGCPU2_REL_PATH     := ..\\..\\seccfgCpu2.bin
    DUMMY_CERT_RAM          := ..\\dummy_cert_ram.cert
    DUMMY_CERT_FLASH        := ..\\dummy_cert_flash.cert
    DUMMY_CERT_FLASH_CPU3   := ..\\dummy_cert_flash_cpu3.cert
    UPDATEDUMMYCERT         := updateDummyCert.exe
    UPDATESYSCFG            := updateSysCfg.exe
    CONCAT                  := type
else
    CPU2APP_REL_PATH        := ../../cpu2App.bin
    CPU3APP_PATH            := ../../cpu3App.bin
    CPU3APP_REL_PATH        := ../../cpu3App.bin ../../cpu3App.cert.bin
    CPU3APP_CERT_REL_PATH   := ../../cpu3App.cert.bin
    SECCFGCPU3_REL_PATH     := ../../seccfgCpu3.bin
    SECCFGCPU2_REL_PATH     := ../../seccfgCpu2.bin
    DUMMY_CERT_RAM          := ../dummy_cert_ram.cert
    DUMMY_CERT_FLASH        := ../dummy_cert_flash.cert
    DUMMY_CERT_FLASH_CPU3   := ../dummy_cert_flash_cpu3.cert
    UPDATEDUMMYCERT         := updateDummyCert.bin
    UPDATESYSCFG            := updateSysCfg.bin
    CONCAT                  := cat
endif

ifeq ($(CCS_HOST_OS),win32)
    define CREATE_DIAGRAM
        $(eval $@_FLAG= $(1))
        $(eval $@_NODE_TOOL= $(2))
        $(eval $@_COM_TI_MCU_SDK_INSTALL_DIR= $(3))
        $(eval $@_BuildDirectory= $(4))
        if ${$@_FLAG} == 1  ${$@_NODE_TOOL} "${$@_COM_TI_MCU_SDK_INSTALL_DIR}/tools/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js"  "${$@_COM_TI_MCU_SDK_INSTALL_DIR}/tools/clb_tool/clb_syscfg/" "${$@_BuildDirectory}/syscfg" "${$@_BuildDirectory}/syscfg/clb.dot"
        if ${$@_FLAG} == 1  rm -r "${$@_BuildDirectory}/diagrams"
        if ${$@_FLAG} == 1  mkdir "${$@_BuildDirectory}/diagrams"
        if ${$@_FLAG} == 1  ${$@_NODE_TOOL} "${$@_COM_TI_MCU_SDK_INSTALL_DIR}/source/driverlib/.meta/generate_diagrams.js" "${$@_COM_TI_MCU_SDK_INSTALL_DIR}" "${$@_BuildDirectory}/diagrams" "${$@_BuildDirectory}/syscfg"
    endef
else
    define CREATE_DIAGRAM
        $(eval $@_FLAG= $(1))
        $(eval $@_NODE_TOOL= $(2))
        $(eval $@_COM_TI_MCU_SDK_INSTALL_DIR= $(3))
        $(eval $@_BuildDirectory= $(4))
        [ ${$@_FLAG} -eq 1 ] && ${$@_NODE_TOOL} "${$@_COM_TI_MCU_SDK_INSTALL_DIR}/tools/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js" "${$@_COM_TI_MCU_SDK_INSTALL_DIR}/tools/clb_tool/clb_syscfg/" "${$@_BuildDirectory}/syscfg" "${$@_BuildDirectory}/syscfg/clb.dot" || :
        [ ${$@_FLAG} -eq 1 ] &&  rm -r "${$@_BuildDirectory}/diagrams" || :
        [ ${$@_FLAG} -eq 1 ] &&  mkdir "${$@_BuildDirectory}/diagrams" || :
        [ ${$@_FLAG} -eq 1 ] && ${$@_NODE_TOOL} "${$@_COM_TI_MCU_SDK_INSTALL_DIR}/source/driverlib/.meta/generate_diagrams.js" "${$@_COM_TI_MCU_SDK_INSTALL_DIR}" "${$@_BuildDirectory}/diagrams" "${$@_BuildDirectory}/syscfg" || :
    endef
endif

ALGORITHM := RSA4k

ifeq ($(ALGORITHM),RSA4k)
        SIGNING_KEY=tools/boot/signing/mcu_custMpk.pem
endif
ifeq ($(ALGORITHM),ECDSA256R1)
        SIGNING_KEY=tools/boot/signing/mcu_custMpk_secp256r1.pem
endif
ifeq ($(ALGORITHM),ECDSA384R1)
        SIGNING_KEY=tools/boot/signing/mcu_custMpk_secp384r1.pem
endif
ifeq ($(ALGORITHM),ECDSA521R1)
        SIGNING_KEY=tools/boot/signing/mcu_custMpk_secp521r1.pem
endif
ifeq ($(ALGORITHM),BRAINPOOL512)
        SIGNING_KEY=tools/boot/signing/mcu_custMpk_brainpool512.pem
endif