move make to examples/build_system
add -Wl,--no-warn-rwx-segment for gcc 12+
This commit is contained in:
9
examples/build_system/make/cpu/arm1176.mk
Normal file
9
examples/build_system/make/cpu/arm1176.mk
Normal file
@@ -0,0 +1,9 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mcpu=arm1176jzf-s \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
#CFLAGS += --cpu cortex-a53
|
||||
#ASFLAGS += --cpu cortex-a53
|
||||
|
||||
endif
|
12
examples/build_system/make/cpu/cortex-a53.mk
Normal file
12
examples/build_system/make/cpu/cortex-a53.mk
Normal file
@@ -0,0 +1,12 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mcpu=cortex-a53 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += \
|
||||
--cpu cortex-a53 \
|
||||
|
||||
ASFLAGS += \
|
||||
--cpu cortex-a53 \
|
||||
|
||||
endif
|
12
examples/build_system/make/cpu/cortex-a72.mk
Normal file
12
examples/build_system/make/cpu/cortex-a72.mk
Normal file
@@ -0,0 +1,12 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mcpu=cortex-a72 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += \
|
||||
--cpu cortex-a72 \
|
||||
|
||||
ASFLAGS += \
|
||||
--cpu cortex-a72 \
|
||||
|
||||
endif
|
14
examples/build_system/make/cpu/cortex-m0.mk
Normal file
14
examples/build_system/make/cpu/cortex-m0.mk
Normal file
@@ -0,0 +1,14 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mcpu=cortex-m0 \
|
||||
-mfloat-abi=soft \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
# IAR Flags
|
||||
CFLAGS += --cpu cortex-m0
|
||||
ASFLAGS += --cpu cortex-m0
|
||||
endif
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM0
|
14
examples/build_system/make/cpu/cortex-m0plus.mk
Normal file
14
examples/build_system/make/cpu/cortex-m0plus.mk
Normal file
@@ -0,0 +1,14 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mcpu=cortex-m0plus \
|
||||
-mfloat-abi=soft \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
# IAR Flags
|
||||
CFLAGS += --cpu cortex-m0+
|
||||
ASFLAGS += --cpu cortex-m0+
|
||||
endif
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM0
|
17
examples/build_system/make/cpu/cortex-m3.mk
Normal file
17
examples/build_system/make/cpu/cortex-m3.mk
Normal file
@@ -0,0 +1,17 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mcpu=cortex-m3 \
|
||||
-mfloat-abi=soft \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
# IAR Flags
|
||||
CFLAGS += \
|
||||
--cpu cortex-m3 \
|
||||
|
||||
ASFLAGS += \
|
||||
--cpu cortex-m3
|
||||
endif
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM3
|
19
examples/build_system/make/cpu/cortex-m33.mk
Normal file
19
examples/build_system/make/cpu/cortex-m33.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mcpu=cortex-m33 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv5-sp-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += \
|
||||
--cpu cortex-m33 \
|
||||
--fpu VFPv5-SP \
|
||||
|
||||
ASFLAGS += \
|
||||
--cpu cortex-m33 \
|
||||
--fpu VFPv5-SP \
|
||||
|
||||
endif
|
||||
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM33_NTZ/non_secure
|
13
examples/build_system/make/cpu/cortex-m4.mk
Normal file
13
examples/build_system/make/cpu/cortex-m4.mk
Normal file
@@ -0,0 +1,13 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += --cpu cortex-m4 --fpu VFPv4
|
||||
ASFLAGS += --cpu cortex-m4 --fpu VFPv4
|
||||
endif
|
||||
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM4F
|
19
examples/build_system/make/cpu/cortex-m7.mk
Normal file
19
examples/build_system/make/cpu/cortex-m7.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
CFLAGS += \
|
||||
-mthumb \
|
||||
-mcpu=cortex-m7 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv5-d16 \
|
||||
|
||||
else ifeq ($(TOOLCHAIN),iar)
|
||||
CFLAGS += \
|
||||
--cpu cortex-m7 \
|
||||
--fpu VFPv5_D16 \
|
||||
|
||||
ASFLAGS += \
|
||||
--cpu cortex-m7 \
|
||||
--fpu VFPv5_D16 \
|
||||
|
||||
endif
|
||||
|
||||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM7/r0p1
|
78
examples/build_system/make/toolchain/arm_gcc.mk
Normal file
78
examples/build_system/make/toolchain/arm_gcc.mk
Normal file
@@ -0,0 +1,78 @@
|
||||
# makefile for arm gcc toolchain
|
||||
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
AS = $(CC) -x assembler-with-cpp
|
||||
LD = $(CC)
|
||||
|
||||
GDB = $(CROSS_COMPILE)gdb
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
|
||||
CC_VERSION := $(shell $(CC) -dumpversion)
|
||||
|
||||
# ---------------------------------------
|
||||
# Compiler Flags
|
||||
# ---------------------------------------
|
||||
CFLAGS += \
|
||||
-MD \
|
||||
-ggdb \
|
||||
-fdata-sections \
|
||||
-ffunction-sections \
|
||||
-fsingle-precision-constant \
|
||||
-fno-strict-aliasing \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-Wfatal-errors \
|
||||
-Wdouble-promotion \
|
||||
-Wstrict-prototypes \
|
||||
-Wstrict-overflow \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wunreachable-code \
|
||||
-Wcast-align \
|
||||
-Wcast-function-type \
|
||||
-Wcast-qual \
|
||||
-Wnull-dereference \
|
||||
-Wuninitialized \
|
||||
-Wunused \
|
||||
-Wreturn-type \
|
||||
-Wredundant-decls \
|
||||
|
||||
# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
|
||||
# -Wconversion
|
||||
|
||||
# Size Optimization as default
|
||||
CFLAGS_OPTIMIZED ?= -Os
|
||||
|
||||
# Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0
|
||||
NO_LTO = 1
|
||||
else
|
||||
CFLAGS += $(CFLAGS_OPTIMIZED)
|
||||
endif
|
||||
|
||||
# ---------------------------------------
|
||||
# Linker Flags
|
||||
# ---------------------------------------
|
||||
LDFLAGS += \
|
||||
-Wl,-Map=$@.map \
|
||||
-Wl,-cref \
|
||||
-Wl,-gc-sections \
|
||||
|
||||
# renesas rx does not support --print-memory-usage flags
|
||||
ifneq ($(FAMILY),rx)
|
||||
LDFLAGS += -Wl,--print-memory-usage
|
||||
endif
|
||||
|
||||
# from version 12
|
||||
ifeq (12,$(firstword $(sort 12 $(CC_VERSION))))
|
||||
LDFLAGS += -Wl,--no-warn-rwx-segment
|
||||
endif
|
79
examples/build_system/make/toolchain/arm_gcc_rules.mk
Normal file
79
examples/build_system/make/toolchain/arm_gcc_rules.mk
Normal file
@@ -0,0 +1,79 @@
|
||||
SRC_S += $(SRC_S_GCC)
|
||||
|
||||
# Assembly files can be name with upper case .S, convert it to .s
|
||||
SRC_S := $(SRC_S:.S=.s)
|
||||
|
||||
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
|
||||
# assembly file should be placed first in linking order
|
||||
# '_asm' suffix is added to object of assembly file
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=_asm.o))
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o))
|
||||
|
||||
CFLAGS += $(CFLAGS_GCC) -MD
|
||||
|
||||
# LTO makes it difficult to analyze map file for optimizing size purpose
|
||||
# We will run this option in ci
|
||||
ifeq ($(NO_LTO),1)
|
||||
CFLAGS := $(filter-out -flto,$(CFLAGS))
|
||||
endif
|
||||
|
||||
ifneq ($(CFLAGS_SKIP),)
|
||||
CFLAGS := $(filter-out $(CFLAGS_SKIP),$(CFLAGS))
|
||||
endif
|
||||
|
||||
LDFLAGS += $(CFLAGS) $(LDFLAGS_GCC)
|
||||
|
||||
ifdef LD_FILE
|
||||
LDFLAGS += -Wl,-T,$(TOP)/$(LD_FILE)
|
||||
endif
|
||||
|
||||
ifdef LD_FILE_GCC
|
||||
LDFLAGS += -Wl,-T,$(TOP)/$(LD_FILE_GCC)
|
||||
endif
|
||||
|
||||
ifneq ($(SKIP_NANOLIB), 1)
|
||||
LDFLAGS += --specs=nosys.specs --specs=nano.specs
|
||||
endif
|
||||
|
||||
ASFLAGS += $(CFLAGS)
|
||||
|
||||
LIBS_GCC ?= -lgcc -lm -lnosys
|
||||
|
||||
# libc
|
||||
LIBS += $(LIBS_GCC)
|
||||
|
||||
ifneq ($(BOARD), spresense)
|
||||
LIBS += -lc
|
||||
endif
|
||||
|
||||
# ---------------------------------------
|
||||
# Rules
|
||||
# ---------------------------------------
|
||||
|
||||
# Compile .c file
|
||||
$(BUILD)/obj/%.o: %.c
|
||||
@echo CC $(notdir $@)
|
||||
@$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources lower case .s
|
||||
$(BUILD)/obj/%_asm.o: %.s
|
||||
@echo AS $(notdir $@)
|
||||
@$(AS) $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources upper case .S
|
||||
$(BUILD)/obj/%_asm.o: %.S
|
||||
@echo AS $(notdir $@)
|
||||
@$(AS) $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
OBJCOPY_BIN_OPTION ?=
|
||||
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
|
||||
@echo CREATE $@
|
||||
$(OBJCOPY) -O binary $(OBJCOPY_BIN_OPTION) $^ $@
|
||||
|
||||
$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O ihex $^ $@
|
||||
|
||||
$(BUILD)/$(PROJECT).elf: $(OBJ)
|
||||
@echo LINK $@
|
||||
@$(LD) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
11
examples/build_system/make/toolchain/arm_iar.mk
Normal file
11
examples/build_system/make/toolchain/arm_iar.mk
Normal file
@@ -0,0 +1,11 @@
|
||||
# makefile for arm iar toolchain
|
||||
AS = iasmarm
|
||||
LD = ilinkarm
|
||||
OBJCOPY = ielftool --silent
|
||||
SIZE = size
|
||||
|
||||
# Enable extension mode (gcc compatible)
|
||||
CFLAGS += -e --debug --silent
|
||||
|
||||
# silent mode
|
||||
ASFLAGS += -S $(addprefix -I,$(INC))
|
44
examples/build_system/make/toolchain/arm_iar_rules.mk
Normal file
44
examples/build_system/make/toolchain/arm_iar_rules.mk
Normal file
@@ -0,0 +1,44 @@
|
||||
SRC_S += $(SRC_S_IAR)
|
||||
|
||||
# Assembly files can be name with upper case .S, convert it to .s
|
||||
SRC_S := $(SRC_S:.S=.s)
|
||||
|
||||
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
|
||||
# assembly file should be placed first in linking order
|
||||
# '_asm' suffix is added to object of assembly file
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=_asm.o))
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o))
|
||||
|
||||
# Linker script
|
||||
LDFLAGS += --config $(TOP)/$(LD_FILE_IAR)
|
||||
|
||||
# ---------------------------------------
|
||||
# Rules
|
||||
# ---------------------------------------
|
||||
|
||||
# Compile .c file
|
||||
$(BUILD)/obj/%.o: %.c
|
||||
@echo CC $(notdir $@)
|
||||
@$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources lower case .s
|
||||
$(BUILD)/obj/%_asm.o: %.s
|
||||
@echo AS $(notdir $@)
|
||||
@$(AS) $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources upper case .S
|
||||
$(BUILD)/obj/%_asm.o: %.S
|
||||
@echo AS $(notdir $@)
|
||||
@$(AS) $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) --bin $^ $@
|
||||
|
||||
$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) --ihex $^ $@
|
||||
|
||||
$(BUILD)/$(PROJECT).elf: $(OBJ)
|
||||
@echo LINK $@
|
||||
@$(LD) -o $@ $(LDFLAGS) $^
|
@@ -2,14 +2,10 @@
|
||||
# Common make definition for all examples
|
||||
# ---------------------------------------
|
||||
|
||||
# Supported toolchain: gcc, iar
|
||||
TOOLCHAIN ?= gcc
|
||||
|
||||
#-------------- TOP and CURRENT_PATH ------------
|
||||
|
||||
# Set TOP to be the path to get from the current directory (where make was
|
||||
# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns
|
||||
# the name of this makefile relative to where make was invoked.
|
||||
# Set TOP to be the path to get from the current directory (where make was invoked) to the top of the tree.
|
||||
# $(lastword $(MAKEFILE_LIST)) returns the name of this makefile relative to where make was invoked.
|
||||
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
# strip off /tools/top.mk to get for example ../../..
|
||||
@@ -38,7 +34,6 @@ __check_defined = \
|
||||
$(if $(value $1),, \
|
||||
$(error Undefined make flag: $1$(if $2, ($2))))
|
||||
|
||||
|
||||
# Build directory
|
||||
BUILD := _build/$(BOARD)
|
||||
|
||||
@@ -73,7 +68,10 @@ else
|
||||
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
|
||||
endif
|
||||
|
||||
#-------------- Cross Compiler ------------
|
||||
#-------------- Toolchain ------------
|
||||
|
||||
# Supported toolchain: gcc, iar
|
||||
TOOLCHAIN ?= gcc
|
||||
|
||||
# Can be set by board, default to ARM GCC
|
||||
CROSS_COMPILE ?= arm-none-eabi-
|
||||
@@ -139,8 +137,8 @@ endif
|
||||
|
||||
# CPU specific flags
|
||||
ifdef CPU_CORE
|
||||
include $(TOP)/tools/make/cpu/$(CPU_CORE).mk
|
||||
include ${TOP}/examples/build_system/make/cpu/$(CPU_CORE).mk
|
||||
endif
|
||||
|
||||
# toolchain specific
|
||||
include $(TOP)/tools/make/toolchain/arm_$(TOOLCHAIN).mk
|
||||
include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN).mk
|
||||
|
@@ -37,7 +37,7 @@ vpath %.c . $(TOP)
|
||||
vpath %.s . $(TOP)
|
||||
vpath %.S . $(TOP)
|
||||
|
||||
include $(TOP)/tools/make/toolchain/arm_$(TOOLCHAIN)_rules.mk
|
||||
include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN)_rules.mk
|
||||
|
||||
|
||||
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
||||
|
Reference in New Issue
Block a user