-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (73 loc) · 2.7 KB
/
Makefile
File metadata and controls
88 lines (73 loc) · 2.7 KB
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
SHELL := /usr/bin/env bash
.SHELLFLAGS := -euo pipefail -c
# get git root - if running as git submodule, return parent project root
ROOT_DIR := $(shell git rev-parse --show-toplevel --show-superproject-working-tree | tail -n1)
# Generate FLAVORS variable by running the flavor parser
FLAVORS := $(shell $(ROOT_DIR)/bin/gl-flavors-parse --exclude "bare-*" --build --test)
FLAVORS_BARE := $(shell $(ROOT_DIR)/bin/gl-flavors-parse --include-only "bare-*" --build --test)
# Base commands
CMD_BUILD := $(ROOT_DIR)/build
FLAG_KMS := --kms
CMD_BUILD_BARE := $(ROOT_DIR)/build_bare_flavors
# Default value for USE_KMS
USE_KMS ?= false
.PHONY: help all
.DEFAULT: help
# help: help List available tasks of the project
help:
@echo "Usage: make [target] [USE_KMS=true/false]"
@echo ""
@echo "general targets:"
@grep -E '^# help: ' $(MAKEFILE_LIST) | sed 's/^# help: //g' | awk 'BEGIN {FS = ": "}; {printf "%-80s %s\n", $$1, $$2}'
@echo ""
@echo "Available targets for Official Flavors:"
@echo ""
@echo "all targets:"
@printf "%-80s%s\n" " all" "Run build for all flavors"
@printf "%-80s%s\n" " all-build" "Run build for all flavors"
@echo ""
@echo "base build targets:"
@printf "%-80s%s\n" " base-amd64-build" "Run bootstrap/base build for amd64"
@printf "%-80s%s\n" " base-arm64-build" "Run bootstrap/base build for arm64"
@printf "%-80s%s\n" " container-amd64-build" "Run base container build for amd64"
@printf "%-80s%s\n" " container-arm64-build" "Run base container build for arm64"
@echo ""
@echo "bare container flavor build targets:"
@$(foreach flavor,$(FLAVORS_BARE), \
printf "%-80s%s\n" " $(flavor)-build" "Run build $(flavor)"; \
)
@echo ""
@echo "image flavor build targets:"
@$(foreach flavor,$(FLAVORS), \
printf "%-80s%s\n" " $(flavor)-build" "Run build $(flavor)"; \
)
# all: Run build for all flavors
all: all-build
# Run build for all flavors
all-build: $(addsuffix -build, $(FLAVORS)) $(addsuffix -build, $(FLAVORS_BARE))
define build
$(1)-build:
@echo "Running build for flavor $(1)"
$(CMD_BUILD) $(1)
endef
define build_kms
$(1)-build:
@echo "Running build for flavor $(1) with USE_KMS=$(USE_KMS)"
ifeq ($(USE_KMS), true)
$(CMD_BUILD) $(FLAG_KMS) $(1)
else
$(CMD_BUILD) $(1)
endif
endef
define build_bare
$(1)-build:
@echo "Running build_bare_flavors for flavor $(1)"
$(CMD_BUILD_BARE) $(subst bare-,,$(subst -amd64,,$(subst -arm64,,$(1))))
endef
# Generate rules dynamically for all bare flavors
$(foreach flavor, $(FLAVORS_BARE), $(eval $(call build_bare, $(flavor))))
# Generate rules for base targets only
$(eval $(call build, base-amd64))
$(eval $(call build, base-arm64))
# Generate rules dynamically for all flavors
$(foreach flavor, $(FLAVORS), $(eval $(call build_kms, $(flavor))))