From 23ed4efea33ceff9b1a4b2413186195a8caf5d6d Mon Sep 17 00:00:00 2001 From: Dmitry Ilyin Date: Sun, 14 Aug 2022 12:52:36 +0300 Subject: [PATCH] Infer PLATFORM variable in make when nothing is provided --- Makefile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Makefile b/Makefile index da1e2662..2469728e 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,22 @@ ROOT_DIR := $(CURDIR) BR_VER := 2021.02.12 BR_DIR := $(ROOT_DIR)/buildroot-$(BR_VER) + +ifeq ($(PLATFORM),) + ifeq ($(BOARD),) + BOARD = $(error BOARD must be set) + endif + + FULL_PATH := $(shell find br-ext-chip-* -name "$(BOARD)*_defconfig") + ifeq ($(FULL_PATH),) + FULL_PATH := $(error Cannot find anything for $(BOARD)) + else ifneq ($(shell echo $(FULL_PATH) | wc -w), 1) + FULL_PATH := $(error For provided '$(BOARD)' multiple options found: $(FULL_PATH)) + endif + + PLATFORM := $(shell echo $(FULL_PATH) | cut -d '/' -f 1 | cut -d '-' -f 4 ) +endif + BR_EXT_DIR := $(ROOT_DIR)/br-ext-chip-$(PLATFORM) SCRIPTS_DIR := $(ROOT_DIR)/scripts #BOARDS := $(shell ls -1 $(BR_EXT_DIR)/configs)