|
1 | 1 | #!/usr/bin/env -S make -f |
2 | | - |
3 | | -# SPDX-FileCopyrightText: (c) 2024 ale5000 |
| 2 | +# SPDX-FileCopyrightText: 2024 ale5000 |
4 | 3 | # SPDX-License-Identifier: GPL-3.0-or-later |
5 | 4 |
|
6 | 5 | .POSIX: |
7 | 6 |
|
8 | | -all: buildota buildotaoss ; |
| 7 | +# --- Performance optimizations & global config --- |
| 8 | +# Disable the default inference rule for .sh files early to speed up parsing |
| 9 | +.sh: |
| 10 | + @: |
| 11 | + |
| 12 | +# --- Configurations && shell commands --- |
| 13 | +GET_PROJECT_NAME = (git 2> /dev/null rev-parse --show-toplevel | xargs 2> /dev/null basename) || basename '$(CURDIR)' |
| 14 | +OUTPUT_DIR = output |
9 | 15 |
|
10 | | -.PHONY: all clean test check distcheck build |
| 16 | +REUSE_TOOL = reuse |
| 17 | + |
| 18 | +# --- Target descriptions (for help logic) --- |
| 19 | +DESCRIPTION_TARGET_BUILDOTA = 🚀 Build the flashable zip [Full edition] |
| 20 | +DESCRIPTION_TARGET_BUILDOTAOSS = 🚀 Build the flashable zip [OSS edition] |
| 21 | +DESCRIPTION_TARGET_INSTALLTEST = 🧪 Test the flashable zip in a simulated Android recovery environment on your PC |
| 22 | +DESCRIPTION_TARGET_CLEAN = 🧹 Remove build artifacts |
| 23 | +DESCRIPTION_TARGET_REUSE_LINT = ⚖️ Verify license and copyright compliance (REUSE) |
| 24 | +DESCRIPTION_TARGET_SPDX = 📄 Generate the SBOM in SPDX format |
| 25 | +DESCRIPTION_TARGET_HELP = ❓ Display this help |
| 26 | + |
| 27 | +# --- Primary targets --- |
| 28 | +.PHONY: all buildota buildotaoss installtest clean help |
| 29 | + |
| 30 | +all: buildota buildotaoss ; |
11 | 31 |
|
12 | 32 | buildota: |
13 | | - BUILD_TYPE=full "$(CURDIR)/build.sh" --no-default-build-type --no-pause $(ARGS) |
| 33 | + BUILD_TYPE=full '$(CURDIR)/build.sh' --no-default-build-type --no-pause $(ARGS) |
14 | 34 |
|
15 | 35 | buildotaoss: |
16 | | - BUILD_TYPE=oss "$(CURDIR)/build.sh" --no-default-build-type --no-pause $(ARGS) |
17 | | -build: buildotaoss ; |
| 36 | + BUILD_TYPE=oss '$(CURDIR)/build.sh' --no-default-build-type --no-pause $(ARGS) |
18 | 37 |
|
19 | | -test: |
20 | | - "$(CURDIR)/recovery-simulator/recovery.sh" "$(CURDIR)"/output/*.zip |
21 | | -check: test ; |
22 | | -distcheck: check ; |
| 38 | +installtest: |
| 39 | + @'$(CURDIR)/recovery-simulator/recovery.sh' '$(CURDIR)'/output/*.zip |
23 | 40 |
|
24 | 41 | clean: |
25 | | - rm -f "$(CURDIR)"/output/*.zip |
26 | | - rm -f "$(CURDIR)"/output/*.zip.md5 |
27 | | - rm -f "$(CURDIR)"/output/*.zip.sha256 |
| 42 | + rm -f '$(CURDIR)'/output/*.zip |
| 43 | + rm -f '$(CURDIR)'/output/*.zip.md5 |
| 44 | + rm -f '$(CURDIR)'/output/*.zip.sha256 |
28 | 45 |
|
29 | | -# Disable the default inference rule for .sh files |
30 | | -.sh: |
31 | | - @: |
| 46 | +# --- Compliance targets --- |
| 47 | +.PHONY: reuse-lint spdx |
| 48 | + |
| 49 | +reuse-lint: |
| 50 | + @echo 'Checking REUSE compliance...' |
| 51 | + @'$(REUSE_TOOL)' lint |
| 52 | + |
| 53 | +spdx: reuse-lint |
| 54 | + @echo '' |
| 55 | + @PROJECT_NAME="$$( $(GET_PROJECT_NAME) )"; \ |
| 56 | + echo 'Generating SPDX SBOM at $(OUTPUT_DIR)/'"$${PROJECT_NAME:?}.spdx..."; \ |
| 57 | + '$(REUSE_TOOL)' spdx --creator-person ale5000 --add-license-concluded -o '$(CURDIR)/$(OUTPUT_DIR)/'"$${PROJECT_NAME:?}.spdx" |
| 58 | + @echo 'Done.' |
| 59 | + |
| 60 | +# --- Aliases & compatibility --- |
| 61 | +.PHONY: build test check distcheck sbom |
| 62 | +build: buildotaoss ; |
| 63 | +test: installtest ; |
| 64 | +check: test ; |
| 65 | +distcheck: test ; |
| 66 | +sbom: spdx ; |
| 67 | + |
| 68 | +# --- Help system --- |
| 69 | +# Hide specific targets from the help list |
| 70 | +.hide: build test check distcheck sbom |
| 71 | + |
| 72 | +help: |
| 73 | + @'$(MAKE)' 2>/dev/null -qnrp | awk \ |
| 74 | + '/^DESCRIPTION_TARGET_[A-Z0-9_]+[[:space:]]*=/ { k=tolower(substr($$1,20)); gsub(/_/,"-",k); desc[k]=substr($$0,index($$0,"=")+2) } \ |
| 75 | + /^\.hide:/ { n=split(substr($$0,7),a); for(i=1;i<=n;i++) hide[a[i]]=1 } \ |
| 76 | + /^[a-zA-Z_][a-zA-Z0-9_-]*:/{ t=substr($$0,1,index($$0,":")-1); if(tolower(t)!="makefile") tgt[t]=1 } \ |
| 77 | + END { n=0; for(t in tgt){ if(t in hide) continue; i=n; while(i>0&&keys[i]>t){ keys[i+1]=keys[i]; i-- }; keys[i+1]=t; n++ }; for(i=1;i<=n;i++){ if(keys[i] in desc) printf "%-15s %s\n",keys[i],desc[keys[i]]; else print keys[i] } }' |
0 commit comments