mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-03-05 04:43:48 +01:00
This change introduce a way to modify BINPATH outside makefile when compiling, allowing developer to choose from where toolchain is coming and at same time avoiding to pollute upstream.
218 lines
5.6 KiB
Makefile
218 lines
5.6 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 = 0
|
|
# 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_stm32g431xx.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=0 \
|
|
-DFW_PATCH=0 \
|
|
-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 -fmessage-length=0 -ffunction-sections -fdata-sections -c
|
|
CXXFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fmessage-length=0 -ffunction-sections -fdata-sections -c -fno-exceptions -fno-rtti
|
|
|
|
|
|
|
|
|
|
# Generate dependency information
|
|
CFLAGS += -MMD -MP
|
|
CXXFLAGS += -MMD -MP
|
|
|
|
|
|
#######################################
|
|
# LDFLAGS
|
|
#######################################
|
|
# link script
|
|
LDSCRIPT = STM32G431CBUx_FLASH.ld
|
|
|
|
# libraries
|
|
LIBS = -lm -l:USBPDCORE_PD3_FULL_CM4_wc32.a
|
|
LIBDIR = -LMiddlewares/ST/STM32_USBPD_Library/Core/lib
|
|
LDFLAGS = $(MCU) -specs=nosys.specs -specs=nano.specs $(LIBDIR) -T$(LDSCRIPT) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map -Wl,--gc-sections -fno-exceptions -fno-rtti
|
|
|
|
# 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 ***
|