-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
74 lines (58 loc) · 2.02 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
# 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/mac-vz/macvz
VERSION=1.0.0
VERSION_TRIMMED := 1.0.0
GO_BUILD := $(GO) build -ldflags="-s -w -X $(PACKAGE)/pkg/version.Version=$(VERSION)"
.PHONY: all
all: binaries codesign
.PHONY: binaries
binaries: \
_output/bin/macvz \
_output/share/macvz/macvz-guestagent.Linux-x86_64 \
_output/share/macvz/macvz-guestagent.Linux-aarch64
.PHONY: _output/bin/macvz
_output/bin/macvz:
# 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/macvz
.PHONY: codesign
codesign:
codesign --entitlements vz.entitlements -s - ./_output/bin/macvz
.PHONY: install
install:
mkdir -p "$(DEST)"
cp -av _output/* "$(DEST)"
.PHONY: uninstall
uninstall:
@test -f "$(DEST)/bin/macvz" || (echo "macvz not found in $(DEST) prefix"; exit 1)
rm -rf \
"$(DEST)/bin/macvz" \
"$(DEST)/bin/vfcli"
.PHONY: lint
lint:
golangci-lint run ./...
yamllint .
find . -name '*.sh' | xargs shellcheck
find . -name '*.sh' | xargs shfmt -s -d
.PHONY: clean
clean:
rm -rf _output
.PHONY: artifacts-darwin
artifacts-darwin:
mkdir -p _artifacts
GOOS=darwin GOARCH=amd64 make clean binaries codesign
$(TAR) -C _output/ -czvf _artifacts/macvz-$(VERSION_TRIMMED)-Darwin-x86_64.tar.gz ./
GOOS=darwin GOARCH=arm64 make clean binaries codesign
$(TAR) -C _output -czvf _artifacts/macvz-$(VERSION_TRIMMED)-Darwin-arm64.tar.gz ./
.PHONY: _output/share/macvz/macvz-guestagent.Linux-x86_64
_output/share/macvz/macvz-guestagent.Linux-x86_64:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO_BUILD) -o $@ ./cmd/macvz-guestagent
chmod 644 $@
.PHONY: _output/share/macvz/macvz-guestagent.Linux-aarch64
_output/share/macvz/macvz-guestagent.Linux-aarch64:
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 $(GO_BUILD) -o $@ ./cmd/macvz-guestagent
chmod 644 $@