# Makefile - Main build script for sbc-harness project # # Copyright (C) 2024 Luke T. Shumaker # SPDX-Licence-Identifier: AGPL-3.0-or-later linux.git = $(HOME)/src/github.com/torvalds/linux all: build .PHONY: all .NOTINTERMEDIATE: .DELETE_ON_ERROR: ################################################################################ generate/files = generate/files += 3rd-party/linux-errno.txt 3rd-party/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/*.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 ./$^ ################################################################################ platforms := $(shell sed -nE 's/if *\(PICO_PLATFORM STREQUAL "(.*)"\)/\1/p' cmd/*/CMakeLists.txt) build: $(foreach p,$(platforms),build/$p/build) .PHONY: build $(foreach p,$(platforms),build/$p/Makefile): build/%/Makefile: mkdir -p $(@D) && cd $(@D) && cmake -DCMAKE_BUILD_TYPE=Debug -DPICO_PLATFORM=$* ../.. $(foreach p,$(platforms),build/$p/build): build/%/build: build/%/Makefile $(MAKE) -C $($@.tmp if ! cmp -s $@.tmp $@; then mv $@.tmp $@; fi -include .sources.mk sources_all := $(foreach v,$(filter sources_%,$(.VARIABLES)),$($v)) # lint ############# lint: $(MAKE) -k $(patsubst sources_%,lint/%,$(filter sources_%,$(.VARIABLES))) lint/sh lint/bash: lint/%: shellcheck $(sources_$*) lint/python3: lint/%: mypy --strict --scripts-are-modules $(sources_$*) black --check $(sources_$*) isort --check $(sources_$*) lint/c: lint/%: @: TODO lint/make lint/cmake lint/gitignore lint/ini lint/9p lint/markdown: lint/%: @: lint/unknown: lint/%: @printf "%s: cannot lint unknown file type\n" $(sources_$*) >&2 lint/all: lint/%: $(eval export sources_$*) @find $$(printf '%s\n' $${sources_$*} | grep -vE '^cmd/[^/]+/static/') \ -maxdepth 0 -type f | \ { r=0; while read -r filename; do \ if ! grep -q 'Copyright (C) 2024 Luke T. Shumaker' $$filename; then \ echo "$$filename is missing a copyright statement"; r=1; \ fi; \ dscname=$$(sed -n '1,3{ /^#!/d; /^