2021-01-20 08:34:08 -05:00
|
|
|
# Makefile for micropython on Raspberry Pi RP2
|
|
|
|
#
|
|
|
|
# This is a simple wrapper around cmake
|
|
|
|
|
2023-02-21 00:24:17 -05:00
|
|
|
# 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
|
2023-08-15 23:13:01 -04:00
|
|
|
# If not given on the command line, then default to RPI_PICO.
|
|
|
|
BOARD ?= RPI_PICO
|
2023-02-21 00:24:17 -05:00
|
|
|
BOARD_DIR ?= boards/$(BOARD)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(wildcard $(BOARD_DIR)/.),)
|
2023-08-15 23:13:01 -04:00
|
|
|
ifeq ($(findstring boards/PICO,$(BOARD_DIR)),boards/PICO)
|
|
|
|
$(warning The PICO* boards have been renamed to RPI_PICO*)
|
|
|
|
endif
|
2023-02-21 00:24:17 -05:00
|
|
|
$(error Invalid BOARD specified: $(BOARD_DIR))
|
|
|
|
endif
|
2023-08-15 09:30:22 -04:00
|
|
|
|
|
|
|
# If the build directory is not given, make it reflect the board name (and
|
|
|
|
# optionally the board variant).
|
|
|
|
ifneq ($(BOARD_VARIANT),)
|
|
|
|
BUILD ?= build-$(BOARD)-$(BOARD_VARIANT)
|
|
|
|
else
|
2021-04-05 16:57:18 -04:00
|
|
|
BUILD ?= build-$(BOARD)
|
2023-08-15 09:30:22 -04:00
|
|
|
endif
|
2021-01-20 08:34:08 -05:00
|
|
|
|
|
|
|
$(VERBOSE)MAKESILENT = -s
|
|
|
|
|
2023-02-21 00:24:17 -05:00
|
|
|
CMAKE_ARGS = -DMICROPY_BOARD=$(BOARD) -DMICROPY_BOARD_DIR=$(abspath $(BOARD_DIR))
|
2021-02-23 17:57:14 -05:00
|
|
|
|
|
|
|
ifdef USER_C_MODULES
|
|
|
|
CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
|
|
|
|
endif
|
|
|
|
|
2022-02-09 06:58:56 -05:00
|
|
|
ifneq ($(FROZEN_MANIFEST),)
|
|
|
|
CMAKE_ARGS += -DMICROPY_FROZEN_MANIFEST=${FROZEN_MANIFEST}
|
|
|
|
endif
|
|
|
|
|
2022-04-27 04:43:26 -04:00
|
|
|
ifeq ($(DEBUG),1)
|
|
|
|
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug
|
|
|
|
endif
|
|
|
|
|
2022-09-10 21:40:59 -04:00
|
|
|
ifdef BOARD_VARIANT
|
2023-07-31 03:32:27 -04:00
|
|
|
CMAKE_ARGS += -DMICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
|
2022-09-10 21:40:59 -04:00
|
|
|
endif
|
|
|
|
|
2022-09-13 20:08:59 -04:00
|
|
|
HELP_BUILD_ERROR ?= "See \033[1;31mhttps://github.com/micropython/micropython/wiki/Build-Troubleshooting\033[0m"
|
|
|
|
|
2021-01-20 08:34:08 -05:00
|
|
|
all:
|
2022-07-03 21:14:47 -04:00
|
|
|
[ -e $(BUILD)/Makefile ] || cmake -S . -B $(BUILD) -DPICO_BUILD_DOCS=0 ${CMAKE_ARGS}
|
2022-09-13 20:08:59 -04:00
|
|
|
$(MAKE) $(MAKESILENT) -C $(BUILD) || (echo -e $(HELP_BUILD_ERROR); false)
|
2021-01-20 08:34:08 -05:00
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) -rf $(BUILD)
|
2021-08-17 06:40:20 -04:00
|
|
|
|
2022-07-08 01:26:06 -04:00
|
|
|
# First ensure that pico-sdk is initialised, then use cmake to pick everything
|
|
|
|
# else (including board-specific dependencies).
|
2023-07-31 03:24:38 -04:00
|
|
|
# Running the build with ECHO_SUBMODULES set will trigger py/mkrules.cmake to
|
|
|
|
# print out the value of the GIT_SUBMODULES variable, prefixed with
|
|
|
|
# "GIT_SUBMODULES", and then abort. This extracts out that line from the cmake
|
|
|
|
# output and passes the list of submodules to py/mkrules.mk which does the
|
|
|
|
# `git submodule init` on each.
|
2021-08-17 06:40:20 -04:00
|
|
|
submodules:
|
2022-06-30 02:01:02 -04:00
|
|
|
$(MAKE) -f ../../py/mkrules.mk GIT_SUBMODULES="lib/pico-sdk" submodules
|
2023-07-31 03:24:38 -04:00
|
|
|
@GIT_SUBMODULES=$$(cmake -B $(BUILD)/submodules -DECHO_SUBMODULES=1 ${CMAKE_ARGS} -S . 2>&1 | \
|
2022-07-08 01:26:06 -04:00
|
|
|
grep '^GIT_SUBMODULES=' | cut -d= -f2); \
|
2022-04-28 15:49:20 -04:00
|
|
|
$(MAKE) -f ../../py/mkrules.mk GIT_SUBMODULES="$${GIT_SUBMODULES}" submodules
|