% let obj = args.project;
% let projectName = `${obj.name}_${obj.board}_${obj.cpu}_${obj.os}_${obj.cgt}`;
% let projectPath = `${obj.relpath}/${obj.board}/${obj.cpu}_${obj.os}/${obj.cgt}`;
################################################################################
# Automatically-generated file. Do not edit!
################################################################################

#   Required input arguments:
#   MOTOR_CONTROL_SDK_PATH=${MOTOR_CONTROL_SDK_PATH}	sdk_dir_path
#   CCS_INSTALL_DIR=${CCS_INSTALL_DIR}          		ccs_dir_path
#   CCS_PROJECT_DEBUG=${CWD}       						project_debug_dir_path

SHELL = cmd.exe
CCS_PATH?=$(CCS_INSTALL_DIR)/ccs_base/pru/include
CG_TOOL_ROOT := C:/ti/ti-cgt-pru_2.3.3
SYSCFG_DIR := $(CCS_PROJECT_DEBUG)/syscfg

GEN_OPTS__FLAG :=
GEN_CMDS__FLAG :=

ORDERED_OBJS += \
"./`obj.pru_main_file`.obj" \
"${MOTOR_CONTROL_SDK_PATH}/`projectPath`/`obj.pru_linker_file`.cmd" \
$(GEN_CMDS__FLAG) \
-llibc.a \

% // review these include files
-include ../makefile.init

RM := DEL /F
RMDIR := RMDIR /S/Q

# Every subdirectory with source files must be described here
SUBDIRS := \
. \

# Add inputs and outputs from these tool invocations to the build variables
CMD_SRCS += \
${MOTOR_CONTROL_SDK_PATH}/`projectPath`/`obj.pru_linker_file`.cmd \

ASM_SRCS += \
${MOTOR_CONTROL_SDK_PATH}/`obj.relpath`/`obj.pru_main_file`.asm

OBJS += \
./`obj.pru_main_file`.obj

ASM_DEPS += \
./`obj.pru_main_file`.d

OBJS__QUOTED += \
"`obj.pru_main_file`.obj"

ASM_DEPS__QUOTED += \
"`obj.pru_main_file`.d"

ASM_SRCS__QUOTED += \
"${MOTOR_CONTROL_SDK_PATH}/`obj.relpath`/`obj.pru_main_file`.asm"

% let commandString = "";
% let cflags = obj.cflags;
% for (let prop in cflags) {
    % if ( cflags.hasOwnProperty(prop) && Array.isArray(cflags[prop]) && prop == 'common') {
        % for(let val of cflags[prop]) {
            % commandString += `${val} `;
        % }
    % }
% }
% let defines = obj.defines;
% for (let prop in defines) {
    % if ( defines.hasOwnProperty(prop) && Array.isArray(defines[prop]) && prop == 'common') {
        % for(let val of defines[prop]) {
            % commandString += `--define=${val} `;
        % }
    % }
% }
% let cmdSubStr = commandString;
% commandString += `--include_path="$(CCS_PATH)" `;
% if ("postBuildSteps" in obj || obj["defaultPruPostBuildSteps"]) {
    % commandString += `--include_path="$(SYSCFG_DIR)" `;
% }
% let includes = obj.includes;
% for (let prop in includes) {
    % if ( includes.hasOwnProperty(prop) && Array.isArray(includes[prop]) && prop == 'common') {
        % for(let val of includes[prop]) {
            % commandString += `--include_path="${val}" `;
        % }
    % }
% }
# Each subdirectory must supply rules for building sources it contributes
`obj.pru_main_file`.obj: ${MOTOR_CONTROL_SDK_PATH}/`obj.relpath`/`obj.pru_main_file`.asm $(GEN_OPTS) | $(GEN_FILES) $(GEN_MISC_FILES)
	@echo 'Building file: "$<"'
	@echo 'Invoking: PRU Compiler'
	"$(CG_TOOL_ROOT)/bin/clpru" `commandString` --define=_DEBUG_=1 -g --diag_warning=225 --diag_wrap=off --display_error_number --endian=little --preproc_with_compile --preproc_dependency="$(basename $(<F)).d_raw" $(GEN_OPTS__FLAG) "$<"
	@echo 'Finished building: "$<"'
	@echo ' '

LIBS := -llibc.a

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables
EXE_OUTPUTS += \
`projectName`.out \

EXE_OUTPUTS__QUOTED += \
"`projectName`.out" \

BIN_OUTPUTS += \
`projectName`.hex \

BIN_OUTPUTS__QUOTED += \
"`projectName`.hex" \


# All Target
all: $(OBJS) $(CMD_SRCS) $(GEN_CMDS)
	@$(MAKE) --no-print-directory -Onone "`projectName`.out"

# Tool invocations
% // # TODO: ti-cgt specific settings
`projectName`.out: $(OBJS) $(CMD_SRCS) $(GEN_CMDS)
	@echo 'Building target: "$@"'
	@echo 'Invoking: PRU Linker'
	"$(CG_TOOL_ROOT)/bin/clpru" `cmdSubStr` --define=_DEBUG_=1 -g --diag_warning=225 --diag_wrap=off --display_error_number --endian=little -z -m"`projectName`.map" -i"$(CG_TOOL_ROOT)/lib" --diag_wrap=off --display_error_number --warn_sections --xml_link_info="`projectName`_linkInfo.xml" --rom_model -o "`projectName`.out" $(ORDERED_OBJS)
	@echo 'Finished building target: "$@"'
	@echo ' '
	@$(MAKE) --no-print-directory post-build

`projectName`.hex: $(EXE_OUTPUTS)
	@echo 'Building secondary target: "$@"'
	@echo 'Invoking: PRU Hex Utility'
	"$(CG_TOOL_ROOT)/bin/hexpru" -o "`projectName`.hex" $(EXE_OUTPUTS__QUOTED)
	@echo 'Finished building secondary target: "$@"'
	@echo ' '
	@$(MAKE) --no-print-directory post-build

# Other Targets
clean:
	-$(RM) $(BIN_OUTPUTS__QUOTED)$(EXE_OUTPUTS__QUOTED)
	-$(RM) "`obj.pru_main_file`.obj"
	-$(RM) "`obj.pru_main_file`.d"
	-@echo 'Finished clean'
	-@echo ' '

% if("postBuildSteps" in obj) {
post-build:
	% steps = obj.postBuildSteps;
	% for (let step of steps) {
	-`step.slice(0, step.length-1)`
	% }
	-@echo ' '
% }
% if(obj["defaultPruPostBuildSteps"]) {
post-build:
	-$(CG_TOOL_ROOT)/bin/hexpru.exe ${MOTOR_CONTROL_SDK_PATH}/`projectPath`/hexpru.cmd `projectName`.out
	-${MOTOR_CONTROL_SDK_PATH}/mcu_plus_sdk/tools/bin2header/bin2header.exe `projectName`.b00 pru_load_bin.h PRUFirmware 4
	-@echo ' '
% }

.PHONY: all clean dependents
.SECONDARY:

-include ../makefile.targets
