# GNUmakefile - Main build script for sbc-harness project # # Copyright (C) 2024-2025 Luke T. Shumaker # SPDX-License-Identifier: AGPL-3.0-or-later # Project configuration ######################################################## linux.git = $(HOME)/src/github.com/torvalds/linux all: build .PHONY: all # Configure GNU Make itself #################################################### ifeq ($(filter notintermediate,$(.FEATURES)),) $(error This $(firstword $(MAKEFILE_LIST)) requies GNU Make 4.4 or later for .NOTINTERMEDIATE) endif .NOTINTERMEDIATE: .DELETE_ON_ERROR: .PHONY: FORCE # `generate` ################################################################### generate/files = generate/files += COPYING.txt COPYING.txt: wget --no-use-server-timestamps -O $@ https://www.gnu.org/licenses/agpl-3.0.txt generate/files += 3rd-party/COPYING.newlib.txt 3rd-party/COPYING.newlib.txt: /usr/share/licenses/arm-none-eabi-newlib/COPYING.NEWLIB cp $< $@ generate/files += 3rd-party/linux-errno.txt 3rd-party/linux-errno.txt: build-aux/linux-errno.txt.gen $< $(linux.git) $@ generate/files += lib9p/include/lib9p/linux-errno.h lib9p/include/lib9p/linux-errno.h: %: %.gen 3rd-party/linux-errno.txt $^ >$@ generate/files += lib9p/9p.generated.c lib9p/include/lib9p/9p.generated.h lib9p/9p.generated.c lib9p/include/lib9p/9p.generated.h &: lib9p/idl.gen lib9p/idl/__init__.py lib9p/idl lib9p/idl/*.9p $< $(filter %.9p,$^) generate/files += libusb/include/libusb/tusb_helpers.h 3rd-party/MS-LCID.pdf 3rd-party/MS-LCID.txt libusb/include/libusb/tusb_helpers.h 3rd-party/MS-LCID.pdf 3rd-party/MS-LCID.txt &: libusb/include/libusb/tusb_helpers.h.gen $^ generate/files += build-aux/sources.mk ifeq ($(INNER),) build-aux/sources.mk: $(if $(wildcard .git),FORCE) git ls-files | grep -vFx $(foreach f,$(generate/files),-e $f) \ | sed 's,^,$(CURDIR)/,' | xargs editorconfig \ | sed -nE -e 's,\[$(CURDIR)/(.*)\],\1,p' -e 's/^_mode=//p' \ | sed -E '{N;s/(.*)\n(.*)/sources_\2 += \1/;}' \ | sort \ >$@.tmp if ! cmp -s $@.tmp $@; then mv $@.tmp $@; fi @echo '################################################################################' endif generate: $(generate/files) .PHONY: generate generate-clean: rm -f -- $(generate/files) .PHONY: generate-clean # `build` and `check` ########################################################## platforms := rp2040 host # $(shell sed -nE 's/if *\(PICO_PLATFORM STREQUAL "(.*)"\)/\1/p' cmd/*/CMakeLists.txt) build_types = Debug Release RelWithDebInfo MinSizeRel build: $(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/build)) .PHONY: build $(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/Makefile)): build/%/Makefile: mkdir -p $(@D) && cd $(@D) && cmake -DPICO_PLATFORM=$(firstword $(subst -, ,$*)) -DCMAKE_BUILD_TYPE=$(lastword $(subst -, ,$*)) ../.. $(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/build)): build/%/build: build/%/Makefile generate $(MAKE) -C $(