Transform main c file into main c++ file
This commit is contained in:
19
Makefile
19
Makefile
@@ -5,13 +5,16 @@ OPT = -O0
|
||||
|
||||
BUILD_DIR = build
|
||||
|
||||
C_SOURCES = \
|
||||
Core/Src/main.c \
|
||||
CC_SOURCES = \
|
||||
Core/Src/main.cc \
|
||||
|
||||
C_SOURCES = \
|
||||
Core/Src/stm32g0xx_it.c \
|
||||
Core/Src/stm32g0xx_hal_msp.c \
|
||||
Core/Src/system_stm32g0xx.c \
|
||||
Core/Src/syscalls.c \
|
||||
Core/Src/sysmem.c \
|
||||
Core/Src/print.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c \
|
||||
@@ -37,6 +40,7 @@ Core/Startup/startup_stm32g071rbtx.s
|
||||
|
||||
PREFIX = arm-none-eabi-
|
||||
CC = $(PREFIX)gcc
|
||||
CXX = $(PREFIX)g++
|
||||
AS = $(PREFIX)gcc -x assembler-with-cpp
|
||||
CP = $(PREFIX)objcopy
|
||||
SZ = $(PREFIX)size
|
||||
@@ -81,12 +85,18 @@ LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BU
|
||||
|
||||
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
|
||||
|
||||
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
|
||||
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CC_SOURCES:.cc=.o)))
|
||||
vpath %.cc $(sort $(dir $(CC_SOURCES)))
|
||||
|
||||
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
|
||||
vpath %.c $(sort $(dir $(C_SOURCES)))
|
||||
|
||||
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
||||
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
||||
|
||||
$(BUILD_DIR)/%.o: %.cc Makefile | $(BUILD_DIR)
|
||||
$(CXX) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cc=.lst)) $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
||||
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
||||
|
||||
@@ -94,7 +104,8 @@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
||||
$(AS) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
||||
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
# $(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
$(SZ) $@
|
||||
|
||||
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
|
Reference in New Issue
Block a user