 dce070ebe0
			
		
	
	dce070ebe0
	
	
	
		
			
			When BOARD=fomu, use the riscv cross-compiler.  Otherwise, use the
default arm compiler.  This can be overridden by passing
CROSS_COMIPLE on the command line.
Note that there are now three common risc-v prefixes:
    - riscv32-unknown-elf- : Common for users who compile their own
    - riscv64-unknown-elf- : Upstream multiarch toolchain from SiFive
    - riscv-none-embed-    : xPack embedded version of SiFive toolchain
Here we assume users are using the `riscv-none-embed-` toolchain from
xPack, because it appears to be growing more common.  Additionally,
there is much confusion surrounding `riscv64-unknown-elf-`, which
actually includes both 32- and 64-bit runtimes and can generate software
for both.
Signed-off-by: Sean Cross <sean@xobs.io>
		
	
		
			
				
	
	
		
			99 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			99 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
| #
 | |
| # Common make definition for all examples
 | |
| #
 | |
| 
 | |
| # Compiler
 | |
| ifeq ($(BOARD), fomu)
 | |
| CROSS_COMPILE = riscv-none-embed-
 | |
| else
 | |
| CROSS_COMPILE = arm-none-eabi-
 | |
| endif
 | |
| CC = $(CROSS_COMPILE)gcc
 | |
| CXX = $(CROSS_COMPILE)g++
 | |
| OBJCOPY = $(CROSS_COMPILE)objcopy
 | |
| SIZE = $(CROSS_COMPILE)size
 | |
| 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
 | |
| 
 | |
| # Include all source C in board folder
 | |
| SRC_C += hw/bsp/board.c
 | |
| SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
 | |
| 
 | |
| # Compiler Flags
 | |
| CFLAGS += \
 | |
| 	-fsingle-precision-constant \
 | |
| 	-fno-strict-aliasing \
 | |
| 	-Wdouble-promotion \
 | |
| 	-Wno-endif-labels \
 | |
| 	-Wstrict-prototypes \
 | |
| 	-Wall \
 | |
| 	-Wextra \
 | |
| 	-Werror \
 | |
| 	-Werror-implicit-function-declaration \
 | |
| 	-Wfatal-errors \
 | |
| 	-Wfloat-equal \
 | |
| 	-Wundef \
 | |
| 	-Wshadow \
 | |
| 	-Wwrite-strings \
 | |
| 	-Wsign-compare \
 | |
| 	-Wmissing-format-attribute \
 | |
| 	-Wno-deprecated-declarations \
 | |
| 	-Wnested-externs \
 | |
| 	-Wunreachable-code \
 | |
| 	-Wno-error=lto-type-mismatch \
 | |
| 	-ffunction-sections \
 | |
| 	-fdata-sections
 | |
| 
 | |
| # This causes lots of warning with nrf5x build due to nrfx code
 | |
| # CFLAGS += -Wcast-align
 | |
| 
 | |
| # Debugging/Optimization
 | |
| ifeq ($(DEBUG), 1)
 | |
|   CFLAGS += -Og -ggdb
 | |
| else
 | |
|   ifneq ($(BOARD),spresense)
 | |
|     CFLAGS += -flto -Os
 | |
|   else
 | |
|     CFLAGS += -Os
 | |
|   endif
 | |
| endif
 | |
| 
 | |
| # TUSB Logging option
 | |
| ifneq ($(LOG),)
 | |
|   CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
 | |
| endif
 |