Skip to content

Commit c3c1717

Browse files
committed
refactor common port specific Makefile code
1 parent e2a3597 commit c3c1717

File tree

10 files changed

+107
-363
lines changed

10 files changed

+107
-363
lines changed

ports/atmel-samd/Makefile

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,7 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25-
# Select the board to build for.
26-
define show_board_error
27-
boardlist =
28-
$(info Valid boards:)
29-
$(shell printf '%s\n' $(patsubst boards/%/mpconfigboard.mk,%,$(wildcard boards/*/mpconfigboard.mk)) | column -xc $$(tput cols || echo 80) 1>&2)
30-
$(error Rerun with $(MAKE) BOARD=<board>)
31-
endef
32-
33-
ifeq ($(BOARD),)
34-
$(info No BOARD specified)
35-
$(call show_board_error)
36-
else
37-
ifeq ($(wildcard boards/$(BOARD)/.),)
38-
$(info Invalid BOARD specified)
39-
$(call show_board_error)
40-
endif
41-
endif
42-
43-
# If the build directory is not given, make it reflect the board name.
44-
BUILD ?= build-$(BOARD)
45-
46-
include ../../py/mkenv.mk
47-
# Board-specific
48-
include boards/$(BOARD)/mpconfigboard.mk
49-
# Port-specific
50-
include mpconfigport.mk
51-
# CircuitPython-specific
52-
include $(TOP)/py/circuitpy_mpconfig.mk
53-
54-
# qstr definitions (must come before including py.mk)
55-
QSTR_DEFS = qstrdefsport.h
56-
57-
# include py core make definitions
58-
include $(TOP)/py/py.mk
59-
60-
include $(TOP)/supervisor/supervisor.mk
61-
62-
# Include make rules and variables common across CircuitPython builds.
63-
include $(TOP)/py/circuitpy_defns.mk
25+
include ../../py/circuitpy_mkenv.mk
6426

6527
CROSS_COMPILE = arm-none-eabi-
6628

ports/broadcom/Makefile

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
1-
# Select the board to build for.
2-
define show_board_error
3-
boardlist =
4-
$(info Valid boards:)
5-
$(shell printf '%s\n' $(patsubst boards/%/mpconfigboard.mk,%,$(wildcard boards/*/mpconfigboard.mk)) | column -xc $$(tput cols || echo 80) 1>&2)
6-
$(error Rerun with $(MAKE) BOARD=<board>)
7-
endef
8-
9-
ifeq ($(BOARD),)
10-
$(info No BOARD specified)
11-
$(call show_board_error)
12-
else
13-
ifeq ($(wildcard boards/$(BOARD)/.),)
14-
$(info Invalid BOARD specified)
15-
$(call show_board_error)
16-
endif
17-
endif
18-
19-
# If the build directory is not given, make it reflect the board name.
20-
BUILD ?= build-$(BOARD)
21-
22-
include ../../py/mkenv.mk
23-
# Board-specific
24-
include boards/$(BOARD)/mpconfigboard.mk
25-
# Port-specific
26-
include mpconfigport.mk
27-
# CircuitPython-specific
28-
include $(TOP)/py/circuitpy_mpconfig.mk
29-
30-
# qstr definitions (must come before including py.mk)
31-
QSTR_DEFS = qstrdefsport.h
32-
33-
# include py core make definitions
34-
include $(TOP)/py/py.mk
35-
36-
include $(TOP)/supervisor/supervisor.mk
37-
38-
# Include make rules and variables common across CircuitPython builds.
39-
include $(TOP)/py/circuitpy_defns.mk
1+
# This file is part of the MicroPython project, http://micropython.org/
2+
#
3+
# The MIT License (MIT)
4+
#
5+
# SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in
15+
# all copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
# THE SOFTWARE.
24+
25+
include ../../py/circuitpy_mkenv.mk
4026

4127
ifeq ($(CHIP_VARIANT), "bcm2711")
4228
CFLAGS += -mcpu=cortex-a72 -DBCM_VERSION=2711

ports/cxd56/Makefile

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,7 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25-
# Select the board to build for.
26-
define show_board_error
27-
boardlist =
28-
$(info Valid boards:)
29-
$(shell printf '%s\n' $(patsubst boards/%/mpconfigboard.mk,%,$(wildcard boards/*/mpconfigboard.mk)) | column -xc $$(tput cols || echo 80) 1>&2)
30-
$(error Rerun with $(MAKE) BOARD=<board>)
31-
endef
32-
33-
ifeq ($(BOARD),)
34-
$(info No BOARD specified)
35-
$(call show_board_error)
36-
else
37-
ifeq ($(wildcard boards/$(BOARD)/.),)
38-
$(info Invalid BOARD specified)
39-
$(call show_board_error)
40-
endif
41-
endif
42-
43-
# If the build directory is not given, make it reflect the board name.
44-
BUILD ?= build-$(BOARD)
45-
46-
include ../../py/mkenv.mk
47-
48-
# Board-specific
49-
include boards/$(BOARD)/mpconfigboard.mk
50-
51-
# Port-specific
52-
include mpconfigport.mk
53-
54-
# CircuitPython-specific
55-
include $(TOP)/py/circuitpy_mpconfig.mk
56-
57-
# qstr definitions (must come before including py.mk)
58-
QSTR_DEFS = qstrdefsport.h
59-
60-
# include py core make definitions
61-
include $(TOP)/py/py.mk
62-
63-
include $(TOP)/supervisor/supervisor.mk
64-
65-
# Include make rules and variables common across CircuitPython builds.
66-
include $(TOP)/py/circuitpy_defns.mk
25+
include ../../py/circuitpy_mkenv.mk
6726

6827
CROSS_COMPILE = arm-none-eabi-
6928

ports/espressif/Makefile

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,7 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25-
# Select the board to build for.
26-
define show_board_error
27-
boardlist =
28-
$(info Valid boards:)
29-
$(shell printf '%s\n' $(patsubst boards/%/mpconfigboard.mk,%,$(wildcard boards/*/mpconfigboard.mk)) | column -xc $$(tput cols || echo 80) 1>&2)
30-
$(error Rerun with $(MAKE) BOARD=<board>)
31-
endef
32-
33-
ifeq ($(BOARD),)
34-
$(info No BOARD specified)
35-
$(call show_board_error)
36-
else
37-
ifeq ($(wildcard boards/$(BOARD)/.),)
38-
$(info Invalid BOARD specified)
39-
$(call show_board_error)
40-
endif
41-
endif
42-
43-
# If the flash PORT is not given, use the default /dev/tty.SLAB_USBtoUART.
44-
PORT ?= /dev/tty.SLAB_USBtoUART
45-
46-
# If the build directory is not given, make it reflect the board name.
47-
BUILD ?= build-$(BOARD)
48-
49-
include ../../py/mkenv.mk
50-
51-
# Board-specific
52-
include boards/$(BOARD)/mpconfigboard.mk
53-
54-
# Port-specific
55-
include mpconfigport.mk
56-
57-
# CircuitPython-specific
58-
include $(TOP)/py/circuitpy_mpconfig.mk
59-
60-
# qstr definitions (must come before including py.mk)
61-
QSTR_DEFS = qstrdefsport.h
62-
63-
# include py core make definitions
64-
include $(TOP)/py/py.mk
65-
66-
include $(TOP)/supervisor/supervisor.mk
67-
68-
# Include make rules and variables common across CircuitPython builds.
69-
include $(TOP)/py/circuitpy_defns.mk
25+
include ../../py/circuitpy_mkenv.mk
7026

7127
ifeq ($(IDF_TARGET),esp32c3)
7228
IDF_TARGET_ARCH = riscv

ports/litex/Makefile

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,7 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25-
# Select the board to build for.
26-
define show_board_error
27-
boardlist =
28-
$(info Valid boards:)
29-
$(shell printf '%s\n' $(patsubst boards/%/mpconfigboard.mk,%,$(wildcard boards/*/mpconfigboard.mk)) | column -xc $$(tput cols || echo 80) 1>&2)
30-
$(error Rerun with $(MAKE) BOARD=<board>)
31-
endef
32-
33-
ifeq ($(BOARD),)
34-
$(info No BOARD specified)
35-
$(call show_board_error)
36-
else
37-
ifeq ($(wildcard boards/$(BOARD)/.),)
38-
$(info Invalid BOARD specified)
39-
$(call show_board_error)
40-
endif
41-
endif
42-
43-
# If the build directory is not given, make it reflect the board name.
44-
BUILD ?= build-$(BOARD)
45-
46-
include ../../py/mkenv.mk
47-
# Board-specific
48-
include boards/$(BOARD)/mpconfigboard.mk
49-
# Port-specific
50-
include mpconfigport.mk
51-
52-
# CircuitPython-specific
53-
include $(TOP)/py/circuitpy_mpconfig.mk
54-
55-
# qstr definitions (must come before including py.mk)
56-
QSTR_DEFS = qstrdefsport.h
57-
58-
# include py core make definitions
59-
include $(TOP)/py/py.mk
60-
61-
include $(TOP)/supervisor/supervisor.mk
62-
63-
# Include make rules and variables common across CircuitPython builds.
64-
include $(TOP)/py/circuitpy_defns.mk
25+
include ../../py/circuitpy_mkenv.mk
6526

6627
CROSS_COMPILE = riscv64-unknown-elf-
6728

ports/mimxrt10xx/Makefile

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,7 @@
2323
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
# THE SOFTWARE.
2525

26-
# Select the board to build for.
27-
define show_board_error
28-
boardlist =
29-
$(info Valid boards:)
30-
$(shell printf '%s\n' $(patsubst boards/%/mpconfigboard.mk,%,$(wildcard boards/*/mpconfigboard.mk)) | column -xc $$(tput cols || echo 80) 1>&2)
31-
$(error Rerun with $(MAKE) BOARD=<board>)
32-
endef
33-
34-
ifeq ($(BOARD),)
35-
$(info No BOARD specified)
36-
$(call show_board_error)
37-
else
38-
ifeq ($(wildcard boards/$(BOARD)/.),)
39-
$(info Invalid BOARD specified)
40-
$(call show_board_error)
41-
endif
42-
endif
43-
44-
# If the build directory is not given, make it reflect the board name.
45-
BUILD ?= build-$(BOARD)
46-
47-
include ../../py/mkenv.mk
48-
# Board-specific
49-
include boards/$(BOARD)/mpconfigboard.mk
50-
# Port-specific
51-
include mpconfigport.mk
52-
# CircuitPython-specific
53-
include $(TOP)/py/circuitpy_mpconfig.mk
54-
55-
# qstr definitions (must come before including py.mk)
56-
QSTR_DEFS = qstrdefsport.h
57-
58-
# include py core make definitions
59-
include $(TOP)/py/py.mk
60-
61-
include $(TOP)/supervisor/supervisor.mk
62-
63-
# Include make rules and variables common across CircuitPython builds.
64-
include $(TOP)/py/circuitpy_defns.mk
26+
include ../../py/circuitpy_mkenv.mk
6527

6628
CROSS_COMPILE = arm-none-eabi-
6729

ports/nrf/Makefile

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,16 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25-
# Select the board to build for.
26-
define show_board_error
27-
boardlist =
28-
$(info Valid boards:)
29-
$(shell printf '%s\n' $(patsubst boards/%/mpconfigboard.mk,%,$(wildcard boards/*/mpconfigboard.mk)) | column -xc $$(tput cols || echo 80) 1>&2)
30-
$(error Rerun with $(MAKE) BOARD=<board>)
31-
endef
32-
33-
ifeq ($(BOARD),)
34-
$(info No BOARD specified)
35-
$(call show_board_error)
36-
else
37-
ifeq ($(wildcard boards/$(BOARD)/.),)
38-
$(info Invalid BOARD specified)
39-
$(call show_board_error)
40-
endif
41-
endif
25+
include ../../py/circuitpy_mkenv.mk
4226

43-
CLI_SD := $(SD)
4427
SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
4528

46-
# Build directory with SD if it's different from the default.
47-
BUILD ?= $(if $(CLI_SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD))
48-
49-
include ../../py/mkenv.mk
50-
# Board-specific
51-
include boards/$(BOARD)/mpconfigboard.mk
52-
# Port-specific
53-
include mpconfigport.mk
54-
# CircuitPython-specific
55-
include $(TOP)/py/circuitpy_mpconfig.mk
56-
57-
# qstr definitions (must come before including py.mk)
58-
QSTR_DEFS = qstrdefsport.h
59-
60-
# include py core make definitions
61-
include $(TOP)/py/py.mk
62-
63-
include $(TOP)/supervisor/supervisor.mk
64-
65-
# Include make rules and variables common across CircuitPython builds.
66-
include $(TOP)/py/circuitpy_defns.mk
67-
6829
ifneq ($(SD), )
6930
include bluetooth/bluetooth_common.mk
31+
ifeq ($(BUILD), build-$(BOARD))
32+
# Build directory with SD if it's different from the default.
33+
BUILD = build-$(BOARD)-$(SD_LOWER)
34+
endif
7035
endif
7136

7237
CROSS_COMPILE = arm-none-eabi-

0 commit comments

Comments
 (0)