Skip to content

Commit 9905cc0

Browse files
committed
rules.mk: Avoid using Constructed Macro Names
This was nice to let make be aware of all the dependencies but it was making use of some uncommon makeisms. Seeing as `dist` is a leaf target anyway its not super critical to avoid running unnecessarily. Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
1 parent 1b42f6c commit 9905cc0

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

rules.mk

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@ ARCH = arm64
2323
endif
2424

2525
arches := amd64 arm64
26-
DOCKER_2_HW_amd64 := x86_64
27-
DOCKER_2_HW_arm64 := aarch64
26+
modes := rel dbg
2827

29-
dist-files :=
3028
hook-bootkit-deps := $(wildcard hook-bootkit/*)
3129
hook-docker-deps := $(wildcard hook-docker/*)
32-
modes := rel dbg
3330

3431
define foreach_mode_arch_rules =
3532
# mode := $(1)
@@ -52,11 +49,6 @@ out/$T/$(1)/$(2)/hook.yaml: $$(LINUXKIT_CONFIG)
5249
if [[ $(1) == dbg ]]; then
5350
sed -i '/^\s*#dbg/ s|#dbg||' $$@
5451
fi
55-
56-
out/$T/$(1)/hook_$(DOCKER_2_HW_$(2)).tar.gz: out/$T/$(1)/initramfs-$(DOCKER_2_HW_$(2)) out/$T/$(1)/vmlinuz-$(DOCKER_2_HW_$(2))
57-
out/$T/$(1)/initramfs-$(DOCKER_2_HW_$(2)): out/$T/$(1)/$(2)/initrd.img
58-
out/$T/$(1)/vmlinuz-$(DOCKER_2_HW_$(2)): out/$T/$(1)/$(2)/kernel
59-
dist-files += out/$T/$(1)/initramfs-$(DOCKER_2_HW_$(2)) out/$T/$(1)/vmlinuz-$(DOCKER_2_HW_$(2))
6052
endef
6153
$(foreach m,$(modes),$(foreach a,$(arches),$(eval $(call foreach_mode_arch_rules,$m,$a))))
6254

@@ -65,7 +57,6 @@ define foreach_arch_rules =
6557

6658
debug: dbg-image-$(1)
6759
dbg-image-$(1): out/$T/dbg/$(1)/hook.tar
68-
dist: out/$T/rel/hook_$(DOCKER_2_HW_$(1)).tar.gz
6960
images: out/$T/rel/$(1)/hook.tar
7061

7162
hook-bootkit: out/$T/hook-bootkit-$(1)
@@ -85,15 +76,6 @@ run-$(1):
8576
endef
8677
$(foreach a,$(arches),$(eval $(call foreach_arch_rules,$a)))
8778

88-
define foreach_mode_rules =
89-
# mode := $(1)
90-
91-
out/$T/$(1)/hook_%.tar.gz:
92-
tar -C $$(@D) -cvf- $$(^F) | pigz > $$@
93-
94-
endef
95-
$(foreach m,$(modes),$(eval $(call foreach_mode_rules,$m)))
96-
9779
push-hook-bootkit: $(hook-bootkit-deps)
9880
push-hook-docker: $(hook-docker-deps)
9981
push-hook-bootkit push-hook-docker: platforms=$(addprefix linux/,$(arches))
@@ -104,12 +86,19 @@ push-hook-bootkit push-hook-docker:
10486
docker buildx build --platform $$platforms --push -t $(ORG)/$(container):$T $(container)
10587

10688
.PHONY: dist
107-
dist: ## Build tarballs for distribution
108-
$(dist-files):
109-
cp $< $@
110-
111-
.PHONY: dbg-dist
112-
dbg-dist: out/$T/dbg/hook_$(DOCKER_2_HW_$(ARCH)).tar.gz ## Build debug enabled tarball
89+
dist: out/$T/rel/amd64/hook.tar out/$T/rel/arm64/hook.tar ## Build tarballs for distribution
90+
dbg-dist: out/$T/dbg/$(ARCH)/hook.tar ## Build debug enabled tarball
91+
dist dbg-dist:
92+
for f in $^; do
93+
case $$f in
94+
*amd64*) arch=x86_64 ;;
95+
*arm64*) arch=aarch64 ;;
96+
*) echo unknown arch && exit 1;;
97+
esac
98+
d=$$(dirname $$(dirname $$f))
99+
tar -xf $$f -C $$d/ kernel && mv $$d/kernel $$d/vmlinuz-$$arch
100+
tar -xf $$f -C $$d/ initrd.img && mv $$d/initrd.img $$d/initramfs-$$arch
101+
done
113102

114103
.PHONY: deploy
115104
deploy: dist ## Push tarball to S3

0 commit comments

Comments
 (0)