diff --git a/Makefile.include b/Makefile.include index 884b24be01..9b18c6a0fe 100644 --- a/Makefile.include +++ b/Makefile.include @@ -158,6 +158,20 @@ else all: link +# Include Board and CPU configuration, if BOARD is not found in BOARDSDIR +# e.g. when set by the environment fallback to searching in RIOTBOARD +ifeq (,$(wildcard $(BOARDSDIR)/$(BOARD)/.)) + ifneq ($(RIOTBOARD),$(BOARDSDIR)) + # The specified board $(BOARD) was not found in $(BOARDSDIR) fallback to RIOTBOARD + BOARDSDIR = $(RIOTBOARD) + endif + ifeq ($(RIOTBOARD),$(BOARDSDIR)) + ifeq (,$(wildcard $(BOARDSDIR)/$(BOARD)/.)) + $(error The specified board $(BOARD) does not exist.) + endif + endif +endif + include $(RIOTMAKE)/info.inc.mk # Static code analysis tools provided by LLVM @@ -263,9 +277,6 @@ LAZYSPONGE_FLAGS ?= $(if $(filter 1,$(QUIET)),,--verbose) ifeq (, $(APPLICATION)) $(error An application name must be specified as APPLICATION.) endif -ifneq (0,$(shell test -d $(BOARDSDIR)/$(BOARD); echo $$?)) - $(error The specified board $(BOARD) does not exist.) -endif # Use TOOLCHAIN environment variable to select the toolchain to use. # Default for macOS: llvm; for other OS: gnu diff --git a/makefiles/boards.inc.mk b/makefiles/boards.inc.mk index 7a56a238fc..27fe0b3836 100644 --- a/makefiles/boards.inc.mk +++ b/makefiles/boards.inc.mk @@ -1,10 +1,18 @@ # Default when RIOTBASE is not set and is executed from the RIOT directory BOARDSDIR ?= $(or $(RIOTBASE),$(CURDIR))/boards -# List all boards. +# List all boards in a directory # By default, all directories in BOARDSDIR except 'common' # use 'wildcard */.' to only list directories -ALLBOARDS ?= $(sort $(filter-out common,$(patsubst $(BOARDSDIR)/%/.,%,$(wildcard $(BOARDSDIR)/*/.)))) +_get_boards_in_directory = $(filter-out common,$(patsubst $1/%/.,%,$(wildcard $1/*/.))) + +# If BOARDSDIR is not in RIOTBOARD also list BOARDS in RIOTBOARD +ifneq ($(RIOTBOARD),$(BOARDSDIR)) + ALLBOARDS_RIOTBOARD ?= $(call _get_boards_in_directory,$(RIOTBOARD)) +endif + +# Get all boards +ALLBOARDS ?= $(sort $(call _get_boards_in_directory,$(BOARDSDIR)) $(ALLBOARDS_RIOTBOARD)) # Set the default value from `BOARDS` BOARDS ?= $(ALLBOARDS) diff --git a/makefiles/info-global.inc.mk b/makefiles/info-global.inc.mk index c51b2a1237..b99eda1096 100644 --- a/makefiles/info-global.inc.mk +++ b/makefiles/info-global.inc.mk @@ -1,6 +1,7 @@ .PHONY: info-buildsizes info-buildsizes-diff info-features-missing \ info-boards-features-missing +BOARDSDIR_GLOBAL := $(BOARDSDIR) USEMODULE_GLOBAL := $(USEMODULE) USEPKG_GLOBAL := $(USEPKG) FEATURES_REQUIRED_GLOBAL := $(FEATURES_REQUIRED) @@ -13,6 +14,7 @@ FEATURES_BLACKLIST_GLOBAL := $(FEATURES_BLACKLIST) define board_unsatisfied_features BOARD := $(1) + BOARDSDIR := $(BOARDSDIR_GLOBAL) USEMODULE := $(USEMODULE_GLOBAL) USEPKG := $(USEPKG_GLOBAL) DISABLE_MODULE := $(DISABLE_MODULE_GLOBAL) @@ -31,6 +33,12 @@ define board_unsatisfied_features undefine CPU undefine CPU_MODEL + # Replicate Makefile.include handling that sets BOARDSDIR to RIOTBOARD + # when BOARD is not found in BOARDSDIR + ifeq (,$(wildcard $(BOARDSDIR_GLOBAL)/$(BOARD)/.)) + BOARDSDIR = $(RIOTBOARD) + endif + include $(RIOTBASE)/Makefile.features include $(RIOTMAKE)/defaultmodules.inc.mk diff --git a/tests/external_board_native/Makefile b/tests/external_board_native/Makefile index 94c1ef91bf..a8dab58549 100644 --- a/tests/external_board_native/Makefile +++ b/tests/external_board_native/Makefile @@ -9,6 +9,10 @@ RIOTBASE ?= $(CURDIR)/../../ # In practice it should be something else BOARD ?= native +# Require arch_native feature so this is not compiled for other boards in +# $(RIOTBOARD)/ +FEATURES_REQUIRED += arch_native + # Set without '?=' to also verify the docker integration when set with = BOARDSDIR = $(CURDIR)/external_boards