|
1 | 1 | # SPDX-FileCopyrightText: (C) 2025 Intel Corporation |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
| 4 | +SHELL := bash -eu -o pipefail |
| 5 | + |
4 | 6 | SUBPROJECTS := host networking maintenance os-resource telemetry attestationstatus |
5 | 7 |
|
6 | 8 | .DEFAULT_GOAL := help |
7 | 9 | .PHONY: all build clean clean-all help lint test |
8 | 10 |
|
9 | | -all: build lint test |
10 | | - @# Help: Runs build, lint, test stages for all subprojects |
| 11 | +# Repo root directory, where base makefiles are located |
| 12 | +REPO_ROOT := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) |
| 13 | + |
| 14 | +#### Python venv Target #### |
| 15 | +VENV_DIR := venv_managers |
| 16 | + |
| 17 | +$(VENV_DIR): requirements.txt ## Create Python venv |
| 18 | + python3 -m venv $@ ;\ |
| 19 | + set +u; . ./$@/bin/activate; set -u ;\ |
| 20 | + python -m pip install --upgrade pip ;\ |
| 21 | + python -m pip install -r requirements.txt |
| 22 | + |
| 23 | +all: build lint test ## Runs build, lint, test stages for all subprojects |
| 24 | + |
| 25 | +dependency-check: $(VENV_DIR) |
| 26 | + |
| 27 | +lint: $(VENV_DIR) mdlint license ## lint common and all subprojects |
| 28 | + for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir lint; done |
| 29 | + |
| 30 | +MD_FILES := $(shell find . -type f \( -name '*.md' \) -print ) |
| 31 | +mdlint: ## lint all markdown README.md files |
| 32 | + markdownlint --version |
| 33 | + markdownlint *.md |
| 34 | + |
| 35 | +license: $(VENV_DIR) ## Check licensing with the reuse tool |
| 36 | + set +u; . ./$</bin/activate; set -u ;\ |
| 37 | + reuse --version ;\ |
| 38 | + reuse --root . lint |
11 | 39 |
|
12 | | -build: |
13 | | - @# Help: Runs build stage in all subprojects |
14 | | - @echo "---MAKEFILE BUILD---" |
| 40 | +build: ## build in all subprojects |
15 | 41 | for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir build; done |
16 | | - @echo "---END MAKEFILE Build---" |
17 | | - |
18 | | -lint: |
19 | | - @# Help: Runs lint stage in all subprojects |
20 | | - @echo "---MAKEFILE LINT---" |
21 | | - @for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir lint; done |
22 | | - @echo "---END MAKEFILE LINT---" |
23 | | - |
24 | | -mdlint: |
25 | | - @# Help: Runs md files linting |
26 | | - @echo "---MAKEFILE LINT README---" |
27 | | - @markdownlint --version |
28 | | - @markdownlint "*.md" |
29 | | - @echo "---END MAKEFILE LINT README---" |
30 | | - |
31 | | -test: |
32 | | - @# Help: Runs test stage in all subprojects |
33 | | - @echo "---MAKEFILE TEST---" |
| 42 | + |
| 43 | +docker-build: ## build all docker containers |
| 44 | + for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir $@; done |
| 45 | + |
| 46 | +docker-push: ## push all docker containers |
| 47 | + for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir $@; done |
| 48 | + |
| 49 | +docker-list: ## list all docker containers |
| 50 | + @echo "images:" |
| 51 | + @for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir $@; done |
| 52 | + |
| 53 | +test: ## test in all subprojects |
34 | 54 | for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir test; done |
35 | | - @echo "---END MAKEFILE TEST---" |
36 | 55 |
|
37 | | -clean: |
38 | | - @# Help: Runs clean stage in all subprojects |
39 | | - @echo "---MAKEFILE CLEAN---" |
| 56 | +clean: ## clean in all subprojects |
40 | 57 | for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir clean; done |
41 | | - @echo "---END MAKEFILE CLEAN---" |
42 | 58 |
|
43 | | -clean-all: |
44 | | - @# Help: Runs clean-all stage in all subprojects |
45 | | - @echo "---MAKEFILE CLEAN-ALL---" |
| 59 | +clean-all: ## clean-all in all subprojects, and delete virtualenv |
46 | 60 | for dir in $(SUBPROJECTS); do $(MAKE) -C $$dir clean-all; done |
47 | | - @echo "---END MAKEFILE CLEAN-ALL---" |
| 61 | + rm -rf $(VENV_DIR) |
48 | 62 |
|
49 | | -h-%: |
50 | | - @# Help: Runs host subproject's tasks, e.g. h-test |
| 63 | +h-%: ## Runs host subproject's tasks, e.g. h-test |
51 | 64 | $(MAKE) -C host $* |
52 | 65 |
|
53 | | -n-%: |
54 | | - @# Help: Runs networking subproject's tasks, e.g. n-test |
| 66 | +n-%: ## Runs networking subproject's tasks, e.g. n-test |
55 | 67 | $(MAKE) -C networking $* |
56 | 68 |
|
57 | | -m-%: |
58 | | - @# Help: Runs maintenance subproject's tasks, e.g. m-test |
| 69 | +m-%: ## Runs maintenance subproject's tasks, e.g. m-test |
59 | 70 | $(MAKE) -C maintenance $* |
60 | 71 |
|
61 | | -osr-%: |
62 | | - @# Help: Runs os-resource subproject's tasks, e.g. osr-test |
| 72 | +osr-%: ## Runs os-resource subproject's tasks, e.g. osr-test |
63 | 73 | $(MAKE) -C os-resource $* |
64 | 74 |
|
65 | | -t-%: |
66 | | - @# Help: Runs telemetry subproject's tasks, e.g. t-test |
| 75 | +t-%: ## Runs telemetry subproject's tasks, e.g. t-test |
67 | 76 | $(MAKE) -C telemetry $* |
68 | 77 |
|
69 | | -a-%: |
70 | | - @# Help: Runs attestation subproject's tasks, e.g. a-test |
| 78 | +a-%: ## Runs attestationstatus subproject's tasks, e.g. a-test |
71 | 79 | $(MAKE) -C attestationstatus $* |
72 | 80 |
|
73 | | -# TODO: move to a common file shared with common.mk |
74 | | -venv_infra: requirements.txt ## Create Python venv |
75 | | - python3 -m venv $@ ;\ |
76 | | - set +u; . ./$@/bin/activate; set -u ;\ |
77 | | - python -m pip install --upgrade pip ;\ |
78 | | - python -m pip install -r requirements.txt |
79 | | - |
80 | | -license: venv_infra ## Check licensing with the reuse tool |
81 | | - set +u; . ./$</bin/activate; set -u ;\ |
82 | | - reuse --version ;\ |
83 | | - reuse --root . lint |
84 | | - |
85 | | -dependency-check: |
86 | | - echo "No-op to enable CI to pass" |
87 | | - |
88 | | -help: |
89 | | - @printf "%-20s %s\n" "Target" "Description" |
90 | | - @printf "%-20s %s\n" "------" "-----------" |
91 | | - @grep -E '^[a-zA-Z0-9_%-]+:|^[[:space:]]+@# Help:' Makefile | \ |
92 | | - awk '\ |
93 | | - /^[a-zA-Z0-9_%-]+:/ { \ |
94 | | - target = $$1; \ |
95 | | - sub(":", "", target); \ |
96 | | - } \ |
97 | | - /^[[:space:]]+@# Help:/ { \ |
98 | | - if (target != "") { \ |
99 | | - help_line = $$0; \ |
100 | | - sub("^[[:space:]]+@# Help: ", "", help_line); \ |
101 | | - printf "%-20s %s\n", target, help_line; \ |
102 | | - target = ""; \ |
103 | | - } \ |
104 | | - }' |
| 81 | +#### Help Target #### |
| 82 | +help: ## print help for each target |
| 83 | + @echo infra-managers make targets |
| 84 | + @echo "Target Makefile:Line Description" |
| 85 | + @echo "-------------------- ---------------- -----------------------------------------" |
| 86 | + @grep -H -n '^[[:alnum:]%_-]*:.* ##' $(MAKEFILE_LIST) \ |
| 87 | + | sort -t ":" -k 3 \ |
| 88 | + | awk 'BEGIN {FS=":"}; {sub(".* ## ", "", $$4)}; {printf "%-20s %-16s %s\n", $$3, $$1 ":" $$2, $$4};' |
0 commit comments