Skip to content

Commit 806a886

Browse files
committed
Makefile: make it a bit more readable.
- add separator comment to divide sections. - add spaces around the `=` sign. - replaced `=` with `:=`. Signed-off-by: Norio Nomura <[email protected]>
1 parent 6b36bfa commit 806a886

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

Makefile

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif
2323

2424
GO_BUILDTAGS ?=
2525
ifeq ($(GOOS),darwin)
26-
MACOS_SDK_VERSION=$(shell xcrun --show-sdk-version | cut -d . -f 1)
26+
MACOS_SDK_VERSION = $(shell xcrun --show-sdk-version | cut -d . -f 1)
2727
ifeq ($(shell test $(MACOS_SDK_VERSION) -lt 13; echo $$?),0)
2828
# The "vz" mode needs macOS 13 SDK or later
2929
GO_BUILDTAGS += no_vz
@@ -43,7 +43,7 @@ endif
4343

4444
PACKAGE := github.com/lima-vm/lima
4545

46-
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
46+
VERSION := $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
4747
VERSION_TRIMMED := $(VERSION:v%=%)
4848

4949
GO_BUILD_LDFLAGS := -ldflags="-s -w -X $(PACKAGE)/pkg/version.Version=$(VERSION)"
@@ -52,12 +52,17 @@ GO_BUILD_LDFLAGS := -ldflags="-s -w -X $(PACKAGE)/pkg/version.Version=$(VERSION)
5252
GO_BUILD_FLAG_TAGS := $(addprefix -tags=,$(shell echo "$(GO_BUILDTAGS)"|tr " " "\n"|paste -sd "," -))
5353
GO_BUILD := $(GO) build $(GO_BUILD_LDFLAGS) $(GO_BUILD_FLAG_TAGS)
5454

55+
################################################################################
56+
# Features
5557
.NOTPARALLEL:
5658
.SECONDEXPANSION:
5759

60+
################################################################################
5861
.PHONY: all
5962
all: binaries manpages
6063

64+
################################################################################
65+
# Help
6166
.PHONY: help
6267
help:
6368
@echo ' binaries - Build all binaries'
@@ -114,12 +119,16 @@ help-artifact:
114119
@echo 'Targets for miscellaneous artifacts:'
115120
@echo '- artifacts-misc : Build artifacts for go.mod, go.sum, and vendor'
116121

122+
################################################################################
123+
# convenience targets
117124
exe: _output/bin/limactl$(exe)
118125

119126
.PHONY: minimal native
120127
minimal: clean limactl native-guestagent default_template
121128
native: clean limactl helpers native-guestagent templates
122129

130+
################################################################################
131+
# Kconfig
123132
config: Kconfig
124133
$(KCONFIG_CONF) $<
125134

@@ -134,11 +143,13 @@ menuconfig: Kconfig
134143

135144
-include .config
136145

146+
################################################################################
137147
.PHONY: binaries
138148
binaries: limactl helpers guestagents \
139149
templates template_experimentals create-examples-link \
140150
documentation create-links-in-doc-dir
141151

152+
################################################################################
142153
# _output/bin
143154
.PHONY: limactl lima helpers
144155
limactl: _output/bin/limactl$(exe) lima
@@ -192,6 +203,9 @@ force_build = $(if $(call compare_build_vars,$(1),$(call extract_build_vars,$(1)
192203

193204
force: # placeholder for force build
194205

206+
################################################################################
207+
# _output/bin/limactl$(exe)
208+
195209
# dependencies for limactl
196210
LIMACTL_DEPS = $(call dependencis_for_cmd,limactl)
197211
ifeq ($(GOOS),darwin)
@@ -228,6 +242,7 @@ _output/bin/%: ./cmd/% | _output/bin
228242

229243
MKDIR_TARGETS += _output/bin
230244

245+
################################################################################
231246
# _output/share/lima/lima-guestagent
232247
LINUX_GUESTAGENT_PATH_COMMON = _output/share/lima/lima-guestagent.Linux-
233248

@@ -275,9 +290,10 @@ endif
275290

276291
MKDIR_TARGETS += _output/share/lima
277292

293+
################################################################################
278294
# _output/share/lima/templates
279-
TEMPLATES=$(addprefix _output/share/lima/templates/,$(filter-out experimental,$(notdir $(wildcard examples/*))))
280-
TEMPLATE_EXPERIMENTALS=$(addprefix _output/share/lima/templates/experimental/,$(notdir $(wildcard examples/experimental/*)))
295+
TEMPLATES = $(addprefix _output/share/lima/templates/,$(filter-out experimental,$(notdir $(wildcard examples/*))))
296+
TEMPLATE_EXPERIMENTALS = $(addprefix _output/share/lima/templates/experimental/,$(notdir $(wildcard examples/experimental/*)))
281297

282298
.PHONY: default_template templates template_experimentals
283299
default_template: _output/share/lima/templates/default.yaml
@@ -296,6 +312,7 @@ _output/share/lima/templates/%: examples/%
296312
# On Windows, always copy to ensure the target has the same file as the source.
297313
force_link = $(if $(filter windows,$(GOOS)),force,$(shell test ! -L $(1) && echo force))
298314

315+
################################################################################
299316
# _output/share/lima/examples
300317
.PHONY: create-examples-link
301318
create-examples-link: _output/share/lima/examples
@@ -309,8 +326,9 @@ else
309326
cp -aL $< $@
310327
endif
311328

329+
################################################################################
312330
# _output/share/doc/lima
313-
DOCUMENTATION=$(addprefix _output/share/doc/lima/,$(wildcard *.md) LICENSE SECURITY.md VERSION)
331+
DOCUMENTATION = $(addprefix _output/share/doc/lima/,$(wildcard *.md) LICENSE SECURITY.md VERSION)
314332

315333
.PHONY: documentation
316334
documentation: $(DOCUMENTATION)
@@ -388,6 +406,7 @@ diagrams: docs/lima-sequence-diagram.png
388406
docs/lima-sequence-diagram.png: docs/images/lima-sequence-diagram.puml
389407
$(PLANTUML) ./docs/images/lima-sequence-diagram.puml
390408

409+
################################################################################
391410
.PHONY: install
392411
install: uninstall
393412
mkdir -p "$(DEST)"

0 commit comments

Comments
 (0)