##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.17.1] date: [Tue Oct 31 22:08:45 CST 2023]
##########################################################################################################################

# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
#	2017-02-10 - Several enhancements + project update mode
#   2015-07-22 - first version
# ------------------------------------------------

######################################
# target
######################################
TARGET = checker_slave_boot


# this file name
SELF_NAME = Makeboot

######################################
# building variables
######################################
# debug build?
DEBUG = 1
# optimization
OPT = -Og


#######################################
# paths
#######################################
# Build path
BUILD_DIR = build/boot

######################################
# source
######################################
# C sources
C_SOURCES =  \
source/main/main.c \
source/core/core_cm3.c \
source/core/system_stm32f10x.c \
source/stm32lib/src/misc.c \
source/stm32lib/src/stm32f10x_adc.c \
source/stm32lib/src/stm32f10x_bkp.c \
source/stm32lib/src/stm32f10x_can.c \
source/stm32lib/src/stm32f10x_cec.c \
source/stm32lib/src/stm32f10x_crc.c \
source/stm32lib/src/stm32f10x_dac.c \
source/stm32lib/src/stm32f10x_dbgmcu.c \
source/stm32lib/src/stm32f10x_dma.c \
source/stm32lib/src/stm32f10x_exti.c \
source/stm32lib/src/stm32f10x_flash.c \
source/stm32lib/src/stm32f10x_fsmc.c \
source/stm32lib/src/stm32f10x_gpio.c \
source/stm32lib/src/stm32f10x_i2c.c \
source/stm32lib/src/stm32f10x_iwdg.c \
source/stm32lib/src/stm32f10x_pwr.c \
source/stm32lib/src/stm32f10x_rcc.c \
source/stm32lib/src/stm32f10x_rtc.c \
source/stm32lib/src/stm32f10x_sdio.c \
source/stm32lib/src/stm32f10x_spi.c \
source/stm32lib/src/stm32f10x_tim.c \
source/stm32lib/src/stm32f10x_usart.c \
source/stm32lib/src/stm32f10x_wwdg.c \
source/interface/if_rtt.c \
source/interface/if_gpioout.c \
source/dev/dev_flash.c \
source/dev/dev_backup.c \
source/dev/dev_watchdog.c \
source/rtt/SEGGER_RTT.c \
source/rtt/SEGGER_RTT_printf.c \
source/rt_thread/board.c \
source/rt_thread/core_delay.c \
source/soft/buff.c \
source/soft/debug.c \
source/soft/crc.c \



# ASM sources
ASM_SOURCES =  \
source/core/startup_stm32f103xe.s \
source/core/cortex_m4_gcc.s \


#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
 
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m3

# fpu
# NONE for Cortex-M0/M0+/M3

# float-abi


# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

# macros for gcc
# AS defines
AS_DEFS = 

# C defines
C_DEFS =  \
-DSTM32F10X_HD \
-DUSE_STDPERIPH_DRIVER


# AS includes
AS_INCLUDES = 

# C includes
C_INCLUDES =  \
-Isource/codec \
-Isource/coder \
-Isource/core \
-Isource/dev \
-Isource/elec_det \
-Isource/interface \
-Isource/main \
-Isource/rt_thread \
-Isource/rt_thread/include \
-Isource/RTT \
-Isource/soft \
-Isource/stm32lib/inc \
-Isource/task \


# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif


# ignore warnings
CFLAGS += -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-variable


# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"


#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = stm32_boot.ld

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = 
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections

# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin


#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))

$(BUILD_DIR)/%.o: %.c $(SELF_NAME) | $(BUILD_DIR) 
	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.s $(SELF_NAME) | $(BUILD_DIR)
	$(AS) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) $(SELF_NAME)
	$(CC) $(OBJECTS) $(LDFLAGS) -o $@
	$(SZ) $@

$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
	$(HEX) $< $@
	
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
	$(BIN) $< $@	
	
$(BUILD_DIR):
	mkdir $@		

#######################################
# clean up
#######################################
clean:
	-rm -R $(BUILD_DIR)

#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

# *** EOF ***