mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-05 18:40:28 +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
|
||||
#
|
||||
# ---------------------------------------
|
||||
|
||||
# Compiler
|
||||
ifeq ($(BOARD), msp_exp430f5529lp)
|
||||
CROSS_COMPILE = msp430-elf-
|
||||
else ifeq ($(BOARD), fomu)
|
||||
CROSS_COMPILE = riscv-none-embed-
|
||||
else
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
#-------------- Select the board to build for. ------------
|
||||
BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.))))
|
||||
|
||||
ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD=', supported boards are:)
|
||||
$(foreach b,$(BOARD_LIST),$(info - $(b)))
|
||||
$(error Invalid BOARD specified)
|
||||
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
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
@ -18,38 +37,8 @@ MKDIR = mkdir
|
||||
SED = sed
|
||||
CP = cp
|
||||
RM = rm
|
||||
PYTHON ?= python
|
||||
|
||||
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))))
|
||||
|
||||
|
||||
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
|
||||
#-------------- Source files and compiler flags --------------
|
||||
|
||||
# Include all source C in board folder
|
||||
SRC_C += hw/bsp/board.c
|
||||
|
@ -5,6 +5,9 @@ CFLAGS += \
|
||||
-nostdlib \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_VALENTYUSB_EPTRI
|
||||
|
||||
# Cross Compiler for RISC-V
|
||||
CROSS_COMPILE = riscv-none-embed-
|
||||
|
||||
MCU_DIR = hw/mcu/fomu
|
||||
BSP_DIR = hw/bsp/fomu
|
||||
|
||||
|
@ -6,6 +6,9 @@ CFLAGS += \
|
||||
|
||||
#-mmcu=msp430f5529
|
||||
|
||||
# Cross Compiler for MSP430
|
||||
CROSS_COMPILE = msp430-elf-
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE = hw/mcu/ti/msp430/msp430-gcc-support-files/include/msp430f5529.ld
|
||||
LDINC += $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include
|
||||
|
@ -88,7 +88,7 @@ for example in all_examples:
|
||||
fail_count += 1
|
||||
|
||||
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:
|
||||
print(build_result.stdout.decode("utf-8"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user