# 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 ./$^ ################################################################################ commands := $(patsubst cmd/%/CMakeLists.txt,%,$(wildcard cmd/*/CMakeLists.txt)) build: $(foreach c,$(commands),cmd/$c/build) .PHONY: build cmd/%/build: build/%/Makefile $(generate/files) $(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; continue; \ fi; \ dscname=$$(sed -n '1,3{ /^#!/d; /^