From c514bede796f9ecca7f36c4ad99081e556f66c5e Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Fri, 11 Jan 2019 09:40:15 -0800 Subject: Add Makefile arguments for out-of-tree BSPs and programs --- Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 491a3dd..4efa50c 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,9 @@ BOARD ?= sifive-hifive1 endif # $(BSP) +BOARD_ROOT ?= $(abspath .) +PROGRAM_ROOT ?= $(abspath .) + # Variables the user probably shouldn't override. ############################################################# # BSP Loading @@ -40,7 +43,7 @@ endif # $(BSP) # Finds the directory in which this BSP is located, ensuring that there is # exactly one. -board_dir := $(wildcard bsp/$(BSP_SUBDIR)/$(BOARD)) +board_dir := $(wildcard $(BOARD_ROOT)/bsp/$(BSP_SUBDIR)/$(BOARD)) ifeq ($(words $(board_dir)),0) $(error Unable to find BSP for $(BOARD), expected to find either "bsp/$(BOARD)" or "bsp-addons/$(BOARD)") endif @@ -151,7 +154,7 @@ endif ############################################################# ifeq ($(BSP),mee) MEE_SOURCE_PATH ?= freedom-mee -MEE_BSP_PATH = bsp/$(BOARD) +MEE_BSP_PATH = $(BOARD_ROOT)/bsp/$(BOARD) MEE_LDSCRIPT = $(MEE_BSP_PATH)/mee.lds MEE_HEADER = $(MEE_BSP_PATH)/mee.h @@ -218,8 +221,8 @@ clean: clean-elf2hex ############################################################# # This Section is for Software Compilation ############################################################# -PROGRAM_ELF = software/$(PROGRAM)/$(PROGRAM) -PROGRAM_HEX = software/$(PROGRAM)/$(PROGRAM).hex +PROGRAM_ELF = $(PROGRAM_ROOT)/software/$(PROGRAM)/$(PROGRAM) +PROGRAM_HEX = $(PROGRAM_ROOT)/software/$(PROGRAM)/$(PROGRAM).hex ifeq ($(BSP),mee) .PHONY: software @@ -230,7 +233,7 @@ software: $(PROGRAM_HEX) endif $(PROGRAM_ELF): \ - $(addprefix software/$(PROGRAM)/,$(shell git -C software/$(PROGRAM) ls-files)) \ + $(addprefix $(PROGRAM_ROOT)/software/$(PROGRAM)/,$(shell git -C $(PROGRAM_ROOT)/software/$(PROGRAM) ls-files)) \ $(MEE_BSP_PATH)/install/lib/libmee.a \ $(MEE_BSP_PATH)/install/lib/libmee-gloss.a \ $(MEE_BSP_PATH)/mee.lds -- cgit v1.2.3