mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-06 03:40:18 +00:00
makefile clean up
allow board to define CROSS_COMPILE (default to arm gcc)
This commit is contained in:
parent
435485b524
commit
d74a92bf45
@ -1,15 +1,34 @@
|
|||||||
#
|
# ---------------------------------------
|
||||||
# Common make definition for all examples
|
# Common make definition for all examples
|
||||||
#
|
# ---------------------------------------
|
||||||
|
|
||||||
# Compiler
|
#-------------- Select the board to build for. ------------
|
||||||
ifeq ($(BOARD), msp_exp430f5529lp)
|
BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.))))
|
||||||
CROSS_COMPILE = msp430-elf-
|
|
||||||
else ifeq ($(BOARD), fomu)
|
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
||||||
CROSS_COMPILE = riscv-none-embed-
|
$(info You must provide a BOARD parameter with 'BOARD=', supported boards are:)
|
||||||
else
|
$(foreach b,$(BOARD_LIST),$(info - $(b)))
|
||||||
CROSS_COMPILE = arm-none-eabi-
|
$(error Invalid BOARD specified)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Handy check parameter function
|
||||||
|
check_defined = \
|
||||||
|
$(strip $(foreach 1,$1, \
|
||||||
|
$(call __check_defined,$1,$(strip $(value 2)))))
|
||||||
|
__check_defined = \
|
||||||
|
$(if $(value $1),, \
|
||||||
|
$(error Undefined make flag: $1$(if $2, ($2))))
|
||||||
|
|
||||||
|
# Build directory
|
||||||
|
BUILD = _build/build-$(BOARD)
|
||||||
|
|
||||||
|
# Board specific define
|
||||||
|
include $(TOP)/hw/bsp/$(BOARD)/board.mk
|
||||||
|
|
||||||
|
#-------------- Cross Compiler ------------
|
||||||
|
# Can be set by board, default to ARM GCC
|
||||||
|
CROSS_COMPILE ?= arm-none-eabi-
|
||||||
|
|
||||||
CC = $(CROSS_COMPILE)gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
CXX = $(CROSS_COMPILE)g++
|
CXX = $(CROSS_COMPILE)g++
|
||||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||||
@ -18,38 +37,8 @@ MKDIR = mkdir
|
|||||||
SED = sed
|
SED = sed
|
||||||
CP = cp
|
CP = cp
|
||||||
RM = rm
|
RM = rm
|
||||||
PYTHON ?= python
|
|
||||||
|
|
||||||
check_defined = \
|
#-------------- Source files and compiler flags --------------
|
||||||
$(strip $(foreach 1,$1, \
|
|
||||||
$(call __check_defined,$1,$(strip $(value 2)))))
|
|
||||||
__check_defined = \
|
|
||||||
$(if $(value $1),, \
|
|
||||||
$(error Undefined make flag: $1$(if $2, ($2))))
|
|
||||||
|
|
||||||
|
|
||||||
define newline
|
|
||||||
|
|
||||||
|
|
||||||
endef
|
|
||||||
|
|
||||||
# Select the board to build for.
|
|
||||||
ifeq ($(BOARD),)
|
|
||||||
$(info You must provide a BOARD parameter with 'BOARD=')
|
|
||||||
$(info Supported boards are:)
|
|
||||||
$(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/, $(newline)-,$(wildcard $(TOP)/hw/bsp/*/.)))))
|
|
||||||
$(error BOARD not defined)
|
|
||||||
else
|
|
||||||
ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
|
|
||||||
$(error Invalid BOARD specified)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Build directory
|
|
||||||
BUILD = _build/build-$(BOARD)
|
|
||||||
|
|
||||||
# Board specific
|
|
||||||
include $(TOP)/hw/bsp/$(BOARD)/board.mk
|
|
||||||
|
|
||||||
# Include all source C in board folder
|
# Include all source C in board folder
|
||||||
SRC_C += hw/bsp/board.c
|
SRC_C += hw/bsp/board.c
|
||||||
|
@ -5,6 +5,9 @@ CFLAGS += \
|
|||||||
-nostdlib \
|
-nostdlib \
|
||||||
-DCFG_TUSB_MCU=OPT_MCU_VALENTYUSB_EPTRI
|
-DCFG_TUSB_MCU=OPT_MCU_VALENTYUSB_EPTRI
|
||||||
|
|
||||||
|
# Cross Compiler for RISC-V
|
||||||
|
CROSS_COMPILE = riscv-none-embed-
|
||||||
|
|
||||||
MCU_DIR = hw/mcu/fomu
|
MCU_DIR = hw/mcu/fomu
|
||||||
BSP_DIR = hw/bsp/fomu
|
BSP_DIR = hw/bsp/fomu
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ CFLAGS += \
|
|||||||
|
|
||||||
#-mmcu=msp430f5529
|
#-mmcu=msp430f5529
|
||||||
|
|
||||||
|
# Cross Compiler for MSP430
|
||||||
|
CROSS_COMPILE = msp430-elf-
|
||||||
|
|
||||||
# All source paths should be relative to the top level.
|
# All source paths should be relative to the top level.
|
||||||
LD_FILE = hw/mcu/ti/msp430/msp430-gcc-support-files/include/msp430f5529.ld
|
LD_FILE = hw/mcu/ti/msp430/msp430-gcc-support-files/include/msp430f5529.ld
|
||||||
LDINC += $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include
|
LDINC += $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include
|
||||||
|
@ -88,7 +88,7 @@ for example in all_examples:
|
|||||||
fail_count += 1
|
fail_count += 1
|
||||||
|
|
||||||
build_duration = time.monotonic() - start_time
|
build_duration = time.monotonic() - start_time
|
||||||
print(build_format.format(example, board, success, "{:.2f}".format(build_duration), flash_size, sram_size))
|
print(build_format.format(example, board, success, "{:.2f}s".format(build_duration), flash_size, sram_size))
|
||||||
|
|
||||||
if build_result.returncode != 0:
|
if build_result.returncode != 0:
|
||||||
print(build_result.stdout.decode("utf-8"))
|
print(build_result.stdout.decode("utf-8"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user