219 lines
5.7 KiB
Makefile
219 lines
5.7 KiB
Makefile
##########################################################################################################################
|
|
# File automatically-generated by tool: [projectgenerator] version: [2.25.0] date: [Sat Sep 16 14:17:13 CEST 2017]
|
|
##########################################################################################################################
|
|
|
|
# ------------------------------------------------
|
|
# Generic Makefile (based on gcc)
|
|
#
|
|
# ChangeLog :
|
|
# 2017-02-10 - Several enhancements + project update mode
|
|
# 2015-07-22 - first version
|
|
# ------------------------------------------------
|
|
|
|
######################################
|
|
# target
|
|
######################################
|
|
TARGET = VNA_embedded
|
|
|
|
|
|
######################################
|
|
# building variables
|
|
######################################
|
|
# debug build?
|
|
DEBUG = 1
|
|
# optimization
|
|
OPT = -O2
|
|
|
|
|
|
#######################################
|
|
# paths
|
|
#######################################
|
|
# source path
|
|
SOURCES_DIR = \
|
|
Application \
|
|
Application/Communication \
|
|
Application/Drivers \
|
|
Application/Drivers/FPGA \
|
|
Application/Drivers/USB \
|
|
Application/Drivers/USB/Core/Src \
|
|
Drivers/STM32G4xx_HAL_Driver/Src \
|
|
Middlewares/Third_Party/FreeRTOS/Source \
|
|
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS \
|
|
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
|
|
Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang \
|
|
Middlewares/ST/STM32_USBPD_Library/Core/src \
|
|
Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/src \
|
|
Src
|
|
|
|
# Build path
|
|
BUILD_DIR = build
|
|
|
|
######################################
|
|
# source
|
|
######################################
|
|
# C sources
|
|
C_SOURCES := $(foreach sdir,$(SOURCES_DIR),$(wildcard $(sdir)/*.c))
|
|
CXX_SOURCES := $(foreach sdir,$(SOURCES_DIR),$(wildcard $(sdir)/*.cpp))
|
|
|
|
|
|
# ASM sources
|
|
ASM_SOURCES = \
|
|
Startup/startup_stm32g431cbux.s
|
|
|
|
|
|
######################################
|
|
# firmware library
|
|
######################################
|
|
PERIFLIB_SOURCES =
|
|
|
|
|
|
#######################################
|
|
# binaries
|
|
#######################################
|
|
BINPATH ?= /usr/bin
|
|
PREFIX = arm-none-eabi-
|
|
CC = $(BINPATH)/$(PREFIX)gcc
|
|
CXX = $(BINPATH)/$(PREFIX)g++
|
|
AS = $(BINPATH)/$(PREFIX)as
|
|
CP = $(BINPATH)/$(PREFIX)objcopy
|
|
AR = $(BINPATH)/$(PREFIX)ar
|
|
SZ = $(BINPATH)/$(PREFIX)size
|
|
HEX = $(CP) -O ihex
|
|
BIN = $(CP) -O binary
|
|
|
|
#######################################
|
|
# CFLAGS
|
|
#######################################
|
|
# cpu
|
|
CPU = -mcpu=cortex-m4
|
|
|
|
# fpu
|
|
FPU = -mfpu=fpv4-sp-d16
|
|
|
|
# float-abi
|
|
FLOAT-ABI = -mfloat-abi=hard
|
|
|
|
|
|
# mcu
|
|
MCU = $(CPU) -mthumb $(FLOAT-ABI) $(FPU)
|
|
|
|
# C defines
|
|
C_DEFS = \
|
|
-DFW_MAJOR=1 \
|
|
-DFW_MINOR=5 \
|
|
-DFW_PATCH=1 \
|
|
-DDEBUG \
|
|
-DUSE_FULL_LL_DRIVER \
|
|
-DHW_REVISION="'B'" \
|
|
-D__weak="__attribute__((weak))" \
|
|
-DUSBPD_PORT_COUNT=1 \
|
|
-DUSBPDCORE_LIB_PD3_FULL \
|
|
-D_RTOS \
|
|
-D_SNK \
|
|
-DUSE_HAL_DRIVER \
|
|
-DSTM32G431xx \
|
|
-D__packed="__attribute__((__packed__))"
|
|
|
|
# C includes
|
|
C_INCLUDES = \
|
|
-IInc \
|
|
-IApplication/Communication \
|
|
-IApplication \
|
|
-IApplication/Drivers \
|
|
-IApplication/Drivers/USB \
|
|
-IApplication/Drivers/USB/Core/Inc \
|
|
-IApplication/Drivers/FPGA \
|
|
-IDrivers/STM32G4xx_HAL_Driver/Inc \
|
|
-IDrivers/STM32G4xx_HAL_Driver/Inc/Legacy \
|
|
-IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
|
|
-IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc \
|
|
-IDrivers/CMSIS/Device/ST/STM32G4xx/Include \
|
|
-IDrivers/CMSIS/Include \
|
|
-IMiddlewares/Third_Party/FreeRTOS/Source/include \
|
|
-IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS \
|
|
-IMiddlewares/ST/STM32_USBPD_Library/Core/inc \
|
|
-IMiddlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/inc
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
OPT += -g3 #-gdwarf-2
|
|
endif
|
|
|
|
# compile gcc flags
|
|
ASFLAGS = $(MCU) -g
|
|
|
|
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -ffunction-sections -fdata-sections -c --specs=nano.specs -fstack-usage
|
|
CXXFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fmessage-length=0 -ffunction-sections -fdata-sections -c -fno-exceptions -fno-rtti --specs=nano.specs -fno-use-cxa-atexit -fstack-usage
|
|
|
|
|
|
|
|
|
|
# Generate dependency information
|
|
CFLAGS += -MMD -MP
|
|
CXXFLAGS += -MMD -MP
|
|
|
|
|
|
#######################################
|
|
# LDFLAGS
|
|
#######################################
|
|
# link script
|
|
LDSCRIPT = STM32G431CBUX_FLASH.ld
|
|
|
|
# libraries
|
|
LIBS = -lc -lm -lstdc++ -lsupc++
|
|
#LIBDIR = -LMiddlewares/ST/STM32_USBPD_Library/Core/lib
|
|
LDFLAGS = $(MCU) -static -specs=nano.specs $(LIBDIR) -T$(LDSCRIPT) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map -Wl,--gc-sections -fno-exceptions -fno-rtti -Wl,--start-group -Wl,--end-group
|
|
|
|
# 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)))
|
|
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CXX_SOURCES:.cpp=.o)))
|
|
vpath %.cpp $(sort $(dir $(CXX_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 Makefile | $(BUILD_DIR)
|
|
$(CC) $(CFLAGS) $< -o $@
|
|
|
|
$(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
|
|
$(CXX) $(CXXFLAGS) $< -o $@
|
|
|
|
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
|
$(AS) $(ASFLAGS) $< -o $@
|
|
|
|
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
|
$(CXX) $(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 -fR $(BUILD_DIR)
|
|
|
|
#######################################
|
|
# dependencies
|
|
#######################################
|
|
DEPS := $(OBJECTS:.o=.d)
|
|
|
|
-include $(DEPS)
|
|
|
|
# *** EOF ***
|