-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
147 lines (107 loc) · 4.55 KB
/
Makefile
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
## SPDX-License-Identifier: GPL-2.0-only
export SHELL := env bash
include make/Makefile.targets
include make/Makefile.models
include make/Makefile.nsh_script
include make/Makefile.metadata
.SILENT: help $(BUILD_DIR)/startup.nsh $(BUILD_DIR)/$(sku).metadata.xml
all: help
date = $(shell date '+%Y-%m-%d')
OUTPUT_DIR = $(subst $() $(),/,$(name))/$(target)/$(version)
$(OUTPUT_DIR):
mkdir -p $@
ifeq ($(target),coreboot)
$(version).rom:
sed -i 's/CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION="$(version)"/' ../coreboot/configs/config.starlabs_$(model)
make -C ../coreboot distclean
make -C ../coreboot defconfig KBUILD_DEFCONFIG=configs/config.starlabs_$(model)
make -C ../coreboot
mv ../coreboot/build/coreboot.rom $@
# Just the binary
$(OUTPUT_DIR)/$(version).rom: $(version).rom
mv $(version).rom $@
else
$(OUTPUT_DIR)/$(version).rom:
mv $(version).rom $@
endif
$(OUTPUT_DIR)/$(version).cap: $(subst $() $(),/,$(name))/$(target)-flashrom/$(version)/$(version).rom
./binaries/header.py --guid $(uefi) --bin $< --cap $@
# Standard CAB
$(OUTPUT_DIR)/$(sku).$(target).metainfo.xml: $(OUTPUT_DIR)
printf '$(metadata)' > $@
$(OUTPUT_DIR)/$(target)-$(sku).cab: $(OUTPUT_DIR)/$(sku).$(target).metainfo.xml \
$(OUTPUT_DIR)/$(version).$(file_type)
gcab -cn $@ $^
# EFI Shell
$(OUTPUT_DIR)/startup.nsh: $(OUTPUT_DIR)
printf '$(nsh_script)' > $@
$(OUTPUT_DIR)/efi-$(sku).zip: $(OUTPUT_DIR)/startup.nsh \
$(OUTPUT_DIR)/$(version).rom \
binaries/$(nsh_tool).efi
zip -rj $@ $^
# Release notes
$(OUTPUT_DIR)/release_notes.md: $(OUTPUT_DIR)
nano $(OUTPUT_DIR)/release_notes.md
meta_release_notes = $(shell while IFS= read -r line; do \
if echo "$$line" | grep -q '^[*]'; then \
printf '\\t\\t\\t\\t\\t\\t<li>%s</li>\\n' "$${line#* }"; \
elif [ -n "$$line" ]; then \
printf '\\t\\t\\t\\t\\t\\t<p>%s</p>\\n\\t\\t\\t\\t\\t\\t<ul>\\n' "$$line"; \
else \
printf '\\t\\t\\t\\t\\t\\t</ul>\\n\\n\\n'; \
fi; \
done < $(OUTPUT_DIR)/release_notes.md)
nsh_release_notes = $(shell while IFS= read -r line; do \
printf 'echo "%s"\\n' "$$line"; \
done <$(OUTPUT_DIR)/release_notes.md)
readme_release_notes = $(shell while IFS= read -r line; do \
printf '> %s\\n' "$$line"; \
done <$(OUTPUT_DIR)/release_notes.md)
link = https://github.com/StarLabsLtd/firmware/raw/master/$(OUTPUT_DIR)
push_to_git:
printf "\n#### $(target): [$(version)](https://support.starlabs.systems/kb/firmware/getting-started) $(date)\n" >> $(subst $() $(),/,$(name))/README.md
printf '$(readme_release_notes)\n' >> $(subst $() $(),/,$(name))/README.md
git add $(OUTPUT_DIR) $(subst $() $(),/,$(name))/README.md
git commit -m "Added $(name) $(target) $(version)" -m "$(readme_release_notes)"
DEPENDENCIES = \
$(OUTPUT_DIR) \
$(OUTPUT_DIR)/release_notes.md \
$(OUTPUT_DIR)/$(version).$(file_type)
# Master recipes to be called
ami-flashrom: $(DEPENDENCIES) \
$(OUTPUT_DIR)/efi-$(sku).zip \
$(OUTPUT_DIR)/$(target)-$(sku).cab
$(MAKE) target_link="$(link)/$(version).$(file_type)" push_to_git
ami: $(DEPENDENCIES) \
$(OUTPUT_DIR)/$(target)-$(sku).cab
$(MAKE) target_link="$(link)/$(version).$(file_type)" push_to_git
coreboot: $(DEPENDENCIES) \
$(OUTPUT_DIR)/$(target)-$(sku).cab
$(MAKE) target_link="$(link)/$(version).$(file_type)" push_to_git
ite: $(DEPENDENCIES) \
$(OUTPUT_DIR)/efi-$(sku).zip
$(MAKE) target_link="$(link)/$(version).$(file_type)" push_to_git
help:
printf "Star Labs Firmware\n\n"
printf "Usage\n"
printf "\ntarget:\n"
printf "%-25s %s\n" "ami" "Create an AMI UEFI Capsule cabinet"
printf "%-25s %s\n" "ami-flashrom" "Create an AMI flashrom cabinet"
printf "%-25s %s\n" "coreboot" "Create an coreboot flashrom cabinet"
printf "%-25s %s\n" "ite" "Create an ITE superio cabinet"
printf "\nmodel:\n"
printf "%-25s %s\n" "lite_apl" "StarLite Mk II"
printf "%-25s %s\n" "lite_glk" "StarLite Mk III"
printf "%-25s %s\n" "lite_glkr" "StarLite Mk IV"
printf "%-25s %s\n" "labtop_kbl" "StarLabTop Mk III"
printf "%-25s %s\n" "labtop_cml" "StarLabTop Mk IV"
printf "%-25s %s\n" "starbook_tgl" "StarBook Mk V"
printf "%-25s %s\n" "starbook_adl" "StarBook Mk VI - Intel"
printf "%-25s %s\n" "starbook_cezanne" "StarBook Mk VI - AMD"
printf "%-25s %s\n" "byte_cezane" "Byte Mk I"
printf "\nversion:\n"
printf "%-25s %s\n" "pair" "1.00"
printf "%-25s %s\n" "triplet" "1.0.0"
printf "\nExample usage:\n"
printf "make coreboot target=coreboot model=starbook_adl version=8.18\n\n"
.PHONY: help ite coreboot ami ami-flashrom release-notes