1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# Makefile - Main build script for sbc-harness project
#
# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
# 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 $(<D)
.PHONY: cmd/%/build
build/%/Makefile: cmd/%/CMakeLists.txt
mkdir -p $(@D) && cd $(@D) && cmake -DCMAKE_BUILD_TYPE=Debug -D_UBUILD_CMD=$* $(shell if grep -q pico_sdk_init $<; then echo ' -D_UBUILD_USE_PICO_SDK=1 '; fi) ../..
generate: $(generate/files)
.PHONY: generate
generate-clean:
rm -f -- $(generate/files)
.PHONY: generate-clean
sources_sh = 3rd-party/linux-errno.txt.gen
sources_sh += libusb/include/libusb/tusb_helpers.h.gen
sources_py = lib9p/idl.gen
sources_py += lib9p/include/lib9p/linux-errno.h.gen
lint:
shellcheck $(sources_sh)
mypy --strict --scripts-are-modules $(sources_py)
black --check $(sources_py)
isort --check $(sources_py)
r=0; find $$(git ls-files -- $(foreach f,$(generate/files),:!$f) :!cmd/*/static/*) -maxdepth 0 -type f | while read -r filename; do \
grep -q 'Copyright (C) 2024 Luke T. Shumaker' $$filename || \
{ echo "$$filename is missing a copyright statement"; r=1; continue; }; \
dscname=$$(sed -n '1,3{ /^#!/d; /^<!--$$/d; /-\*- .* -\*-/d; s,[/*# ]*,,; s/ - .*//;p; q; }' $$filename); \
filename_alt1=$$(echo "$$filename" | sed \
-e 's,^cmd/,,' \
-e 's,.*/include/,,' \
-e 's,^lib9p/idl/,,' \
-e 's/\.wip$$//'); \
filename_alt2=$$(echo "$$filename_alt1" | sed \
-e 's,^sbc_harness/,,' \
-e 's,^srv9p/,,'); \
[ "$$dscname" == "$$filename" ] || [ "$$dscname" == "$$filename_alt1" ] || [ "$$dscname" == "$$filename_alt2" ] || \
{ echo "$$filename self-identifies as $$dscname"; r=1; continue; }; \
done; exit $$r
format:
black $(sources_py)
isort $(sources_py)
.PHONY: lint format
|