summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-02-21 16:01:58 +1100
committerDamien George <damien@micropython.org>2023-02-23 09:47:08 +1100
commit69b93527d555c45185e7bd933ed0725f4b7230c9 (patch)
tree86e7b2e89eeca4b08ce28b64abda00a1f573724c
parentb11026689724830fcfcb5060df2c5a17cb4dbc65 (diff)
ports: Make BOARD default from BOARD_DIR in Makefile's.
This allows: $ make BOARD_DIR=path/to/board to infer BOARD=board, rather than the previous behavior that required additionally setting BOARD explicitly. Also makes the same change for VARIANT_DIR -> VARIANT on Unix. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/esp8266/Makefile18
-rw-r--r--ports/mimxrt/Makefile16
-rw-r--r--ports/nrf/Makefile14
-rw-r--r--ports/renesas-ra/Makefile18
-rw-r--r--ports/samd/Makefile17
-rw-r--r--ports/stm32/Makefile18
-rwxr-xr-xports/stm32/mboot/Makefile14
-rw-r--r--ports/unix/Makefile17
-rw-r--r--ports/windows/Makefile17
9 files changed, 105 insertions, 44 deletions
diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile
index 168d1d9f6..c5eb63fad 100644
--- a/ports/esp8266/Makefile
+++ b/ports/esp8266/Makefile
@@ -1,15 +1,21 @@
-# Select the board to build for: if not given on the command line,
-# then default to GENERIC.
+# Select the board to build for:
+ifdef BOARD_DIR
+# Custom board path - remove trailing slash and get the final component of
+# the path as the board name.
+BOARD ?= $(notdir $(BOARD_DIR:/=))
+else
+# If not given on the command line, then default to GENERIC.
BOARD ?= GENERIC
-
-# If the build directory is not given, make it reflect the board name.
-BUILD ?= build-$(BOARD)
-
BOARD_DIR ?= boards/$(BOARD)
+endif
+
ifeq ($(wildcard $(BOARD_DIR)/.),)
$(error Invalid BOARD specified: $(BOARD_DIR))
endif
+# If the build directory is not given, make it reflect the board name.
+BUILD ?= build-$(BOARD)
+
include ../../py/mkenv.mk
# Optional
diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile
index bcddeb2d8..e5a14d010 100644
--- a/ports/mimxrt/Makefile
+++ b/ports/mimxrt/Makefile
@@ -2,8 +2,21 @@
# Parameter Configuration
# =============================================================================
+# Select the board to build for:
+ifdef BOARD_DIR
+# Custom board path - remove trailing slash and get the final component of
+# the path as the board name.
+BOARD ?= $(notdir $(BOARD_DIR:/=))
+else
+# If not given on the command line, then default to TEENSY40.
BOARD ?= TEENSY40
BOARD_DIR ?= boards/$(BOARD)
+endif
+
+ifeq ($(wildcard $(BOARD_DIR)/.),)
+ $(error Invalid BOARD specified: $(BOARD_DIR))
+endif
+
BUILD ?= build-$(BOARD)
PORT ?= /dev/ttyACM0
CROSS_COMPILE ?= arm-none-eabi-
@@ -25,9 +38,6 @@ MAKE_FLEXRAM_LD = boards/make-flexram-config.py
include ../../py/mkenv.mk
# Include micropython configuration board makefile
-ifeq ($(wildcard $(BOARD_DIR)/.),)
- $(error Invalid BOARD specified: $(BOARD_DIR))
-endif
include $(BOARD_DIR)/mpconfigboard.mk
# File containing description of content to be frozen into firmware.
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 5cb2fc031..9ba626757 100644
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -1,12 +1,18 @@
-# Select the board to build for: if not given on the command line,
-# then default to pca10040.
+# Select the board to build for:
+ifdef BOARD_DIR
+# Custom board path - remove trailing slash and get the final component of
+# the path as the board name.
+BOARD ?= $(notdir $(BOARD_DIR:/=))
+else
+# If not given on the command line, then default to pca10040.
BOARD ?= pca10040
+BOARD_DIR ?= boards/$(BOARD)
+endif
+
ifeq ($(wildcard boards/$(BOARD)/.),)
$(error Invalid BOARD specified)
endif
-BOARD_DIR ?= boards/$(BOARD)
-
# If SoftDevice is selected, try to use that one.
SD ?=
SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
diff --git a/ports/renesas-ra/Makefile b/ports/renesas-ra/Makefile
index 17ec58ae0..dc4b15848 100644
--- a/ports/renesas-ra/Makefile
+++ b/ports/renesas-ra/Makefile
@@ -1,15 +1,21 @@
-# Select the board to build for: if not given on the command line,
-# then default to RA6M2_EK.
+# Select the board to build for:
+ifdef BOARD_DIR
+# Custom board path - remove trailing slash and get the final component of
+# the path as the board name.
+BOARD ?= $(notdir $(BOARD_DIR:/=))
+else
+# If not given on the command line, then default to RA6M2_EK.
BOARD ?= RA6M2_EK
-
-# If the build directory is not given, make it reflect the board name.
-BUILD ?= build-$(BOARD)
-
BOARD_DIR ?= boards/$(BOARD)
+endif
+
ifeq ($(wildcard $(BOARD_DIR)/.),)
$(error Invalid BOARD specified: $(BOARD_DIR))
endif
+# If the build directory is not given, make it reflect the board name.
+BUILD ?= build-$(BOARD)
+
ifeq ($(BOARD),RA4M1_CLICKER)
BOARD_LOW = ra4m1_ek
CMSIS_MCU_LOW = ra4m1
diff --git a/ports/samd/Makefile b/ports/samd/Makefile
index fc5fa9e43..465a70a61 100644
--- a/ports/samd/Makefile
+++ b/ports/samd/Makefile
@@ -1,14 +1,23 @@
+# Select the board to build for:
+ifdef BOARD_DIR
+# Custom board path - remove trailing slash and get the final component of
+# the path as the board name.
+BOARD ?= $(notdir $(BOARD_DIR:/=))
+else
+# If not given on the command line, then default to ADAFRUIT_ITSYBITSY_M4_EXPRESS.
BOARD ?= ADAFRUIT_ITSYBITSY_M4_EXPRESS
BOARD_DIR ?= boards/$(BOARD)
-BUILD ?= build-$(BOARD)
-
-CROSS_COMPILE ?= arm-none-eabi-
-UF2CONV ?= $(TOP)/tools/uf2conv.py
+endif
ifeq ($(wildcard $(BOARD_DIR)/.),)
$(error Invalid BOARD specified: $(BOARD_DIR))
endif
+BUILD ?= build-$(BOARD)
+
+CROSS_COMPILE ?= arm-none-eabi-
+UF2CONV ?= $(TOP)/tools/uf2conv.py
+
MCU_SERIES_LOWER = $(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]')
include ../../py/mkenv.mk
diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile
index d57e72a6c..5774f9de5 100644
--- a/ports/stm32/Makefile
+++ b/ports/stm32/Makefile
@@ -1,15 +1,21 @@
-# Select the board to build for: if not given on the command line,
-# then default to PYBV10.
+# Select the board to build for:
+ifdef BOARD_DIR
+# Custom board path - remove trailing slash and get the final component of
+# the path as the board name.
+BOARD ?= $(notdir $(BOARD_DIR:/=))
+else
+# If not given on the command line, then default to PYBV10.
BOARD ?= PYBV10
-
-# If the build directory is not given, make it reflect the board name.
-BUILD ?= build-$(BOARD)
-
BOARD_DIR ?= boards/$(BOARD)
+endif
+
ifeq ($(wildcard $(BOARD_DIR)/.),)
$(error Invalid BOARD specified: $(BOARD_DIR))
endif
+# If the build directory is not given, make it reflect the board name.
+BUILD ?= build-$(BOARD)
+
include ../../py/mkenv.mk
-include mpconfigport.mk
include $(BOARD_DIR)/mpconfigboard.mk
diff --git a/ports/stm32/mboot/Makefile b/ports/stm32/mboot/Makefile
index 12ffdbc7e..053b317e1 100755
--- a/ports/stm32/mboot/Makefile
+++ b/ports/stm32/mboot/Makefile
@@ -1,13 +1,17 @@
-# Select the board to build for: if not given on the command line,
-# then default to PYBV10.
+# Select the board to build for:
+ifdef BOARD_DIR
+# Custom board path - remove trailing slash and get the final component of
+# the path as the board name.
+BOARD ?= $(notdir $(BOARD_DIR:/=))
+else
+# If not given on the command line, then default to PYBV10.
BOARD ?= PYBV10
+BOARD_DIR ?= $(abspath ../boards/$(BOARD))
+endif
# If the build directory is not given, make it reflect the board name.
BUILD ?= build-$(BOARD)
-# Allow the directory containing the board configuration to be specified
-BOARD_DIR ?= $(abspath ../boards/$(BOARD))
-
# Set USE_MBOOT to 1 so that TEXT0_ADDR gets set properly for those boards
# that can be built with or without mboot.
USE_MBOOT ?= 1
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index 8e9094b40..403405dcc 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -1,14 +1,21 @@
-# Select the variant to build for.
+# Select the variant to build for:
+ifdef VARIANT_DIR
+# Custom variant path - remove trailing slash and get the final component of
+# the path as the variant name.
+VARIANT ?= $(notdir $(VARIANT_DIR:/=))
+else
+# If not given on the command line, then default to standard.
VARIANT ?= standard
-
-# If the build directory is not given, make it reflect the variant name.
-BUILD ?= build-$(VARIANT)
-
VARIANT_DIR ?= variants/$(VARIANT)
+endif
+
ifeq ($(wildcard $(VARIANT_DIR)/.),)
$(error Invalid VARIANT specified: $(VARIANT_DIR))
endif
+# If the build directory is not given, make it reflect the variant name.
+BUILD ?= build-$(VARIANT)
+
include ../../py/mkenv.mk
-include mpconfigport.mk
include $(VARIANT_DIR)/mpconfigvariant.mk
diff --git a/ports/windows/Makefile b/ports/windows/Makefile
index e7f0f2ff6..b366e03bf 100644
--- a/ports/windows/Makefile
+++ b/ports/windows/Makefile
@@ -1,14 +1,21 @@
-# Select the variant to build for.
+# Select the variant to build for:
+ifdef VARIANT_DIR
+# Custom variant path - remove trailing slash and get the final component of
+# the path as the variant name.
+VARIANT ?= $(notdir $(VARIANT_DIR:/=))
+else
+# If not given on the command line, then default to standard.
VARIANT ?= standard
-
-# If the build directory is not given, make it reflect the variant name.
-BUILD ?= build-$(VARIANT)
-
VARIANT_DIR ?= variants/$(VARIANT)
+endif
+
ifeq ($(wildcard $(VARIANT_DIR)/.),)
$(error Invalid VARIANT specified: $(VARIANT_DIR))
endif
+# If the build directory is not given, make it reflect the variant name.
+BUILD ?= build-$(VARIANT)
+
include ../../py/mkenv.mk
-include mpconfigport.mk
include $(VARIANT_DIR)/mpconfigvariant.mk