forked from lima-vm/lima
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (77 loc) · 2.88 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
# Files are installed under $(DESTDIR)/$(PREFIX)
PREFIX ?= /usr/local
DEST := $(shell echo "$(DESTDIR)/$(PREFIX)" | sed 's:///*:/:g; s://*$$::')
GO ?= go
TAR ?= tar
PACKAGE := github.com/lima-vm/lima
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
VERSION_TRIMMED := $(VERSION:v%=%)
GO_BUILD := $(GO) build -ldflags="-s -w -X $(PACKAGE)/pkg/version.Version=$(VERSION)"
.PHONY: all
all: binaries
.PHONY: binaries
binaries: \
_output/bin/lima \
_output/bin/limactl \
_output/bin/nerdctl.lima \
_output/share/lima/lima-guestagent.Linux-x86_64 \
_output/share/lima/lima-guestagent.Linux-aarch64
mkdir -p _output/share/doc/lima
cp -aL README.md LICENSE docs examples _output/share/doc/lima
echo $(VERSION) > _output/share/doc/lima/VERSION
.PHONY: _output/bin/lima
_output/bin/lima:
mkdir -p _output/bin
cp -a ./cmd/lima $@
.PHONY: _output/bin/nerdctl.lima
_output/bin/nerdctl.lima:
mkdir -p _output/bin
cp -a ./cmd/nerdctl.lima $@
.PHONY: _output/bin/limactl
_output/bin/limactl:
# The hostagent must be compiled with CGO_ENABLED=1 so that net.LookupIP() in the DNS server
# calls the native resolver library and not the simplistic version in the Go library.
CGO_ENABLED=1 $(GO_BUILD) -o $@ ./cmd/limactl
.PHONY: _output/share/lima/lima-guestagent.Linux-x86_64
_output/share/lima/lima-guestagent.Linux-x86_64:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO_BUILD) -o $@ ./cmd/lima-guestagent
chmod 644 $@
.PHONY: _output/share/lima/lima-guestagent.Linux-aarch64
_output/share/lima/lima-guestagent.Linux-aarch64:
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 $(GO_BUILD) -o $@ ./cmd/lima-guestagent
chmod 644 $@
.PHONY: install
install:
mkdir -p "$(DEST)"
cp -av _output/* "$(DEST)"
if [ "$(shell uname -s )" != "Linux" -a ! -e "$(DEST)/bin/nerdctl" ]; then ln -sf nerdctl.lima "$(DEST)/bin/nerdctl"; fi
.PHONY: uninstall
uninstall:
@test -f "$(DEST)/bin/lima" || (echo "lima not found in $(DEST) prefix"; exit 1)
rm -rf \
"$(DEST)/bin/lima" \
"$(DEST)/bin/limactl" \
"$(DEST)/bin/nerdctl.lima" \
"$(DEST)/share/lima" "$(DEST)/share/doc/lima"
# TODO: remove $(DEST)/bin/nerdctl only when it is a symlink to nerdctl.lima
.PHONY: lint
lint:
golangci-lint run ./...
yamllint .
.PHONY: clean
clean:
rm -rf _output
.PHONY: artifacts-darwin
artifacts-darwin:
mkdir -p _artifacts
GOOS=darwin GOARCH=amd64 make clean binaries
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Darwin-x86_64.tar.gz ./
GOOS=darwin GOARCH=arm64 make clean binaries
$(TAR) -C _output -czvf _artifacts/lima-$(VERSION_TRIMMED)-Darwin-arm64.tar.gz ./
.PHONY: artifacts-linux
artifacts-linux:
mkdir -p _artifacts
GOOS=linux GOARCH=amd64 make clean binaries
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Linux-x86_64.tar.gz ./
GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc make clean binaries
$(TAR) -C _output/ -czvf _artifacts/lima-$(VERSION_TRIMMED)-Linux-aarch64.tar.gz ./