forked from TheNewNormal/corectl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
137 lines (116 loc) · 3.53 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
PROG = corectl
DAEMON = corectld
TEAM = TheNewNormal
ORGANIZATION = github.com/$(TEAM)
REPOSITORY = $(ORGANIZATION)/$(PROG)
GOARCH ?= $(shell go env GOARCH)
GOOS ?= $(shell go env GOOS)
CGO_ENABLED = 1
GO15VENDOREXPERIMENT = 1
MACOS = $(shell sw_vers -productVersion | /usr/bin/awk -F '.' '{print $$1 "." $$2}')
BUILD_DIR ?= $(shell pwd)/bin
GOPATH := $(shell cd ../../../.. ; pwd)
GOCFG = GOPATH=$(GOPATH) GO15VENDOREXPERIMENT=$(GO15VENDOREXPERIMENT) \
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=$(CGO_ENABLED)
GOBUILD = $(GOCFG) go build
VERSION := $(shell git describe --abbrev=6 --dirty=+untagged --always --tags)
BUILDDATE = $(shell /bin/date "+%FT%T%Z")
OPAMROOT ?= ~/.opam
HYPERKIT_GIT = "https://github.com/moby/hyperkit.git"
HYPERKIT_COMMIT = 3e31617
MKDIR = /bin/mkdir -p
CP = /bin/cp
MV = /bin/mv
RM = /bin/rm -rf
DATE = /bin/date
LN = /bin/ln -sf
SED = /usr/bin/sed
GREP = /usr/bin/grep
TOUCH = /usr/bin/touch
GIT = /usr/bin/git
ifeq ($(DEBUG),true)
GO_GCFLAGS := $(GO_GCFLAGS) -N -l
GOBUILD = $(GOBUILD) -race
else
GO_LDFLAGS := $(GO_LDFLAGS) -w -s
endif
GO_LDFLAGS := $(GO_LDFLAGS) \
-X $(REPOSITORY)/release.Version=$(VERSION) \
-X $(REPOSITORY)/release.BuildDate=$(BUILDDATE)
default: documentation
documentation: documentation/man documentation/markdown
-$(GIT) status
all: clean hyperkit documentation
cmd: force
$(RM) $(BUILD_DIR)/$(PROG)
$(RM) $(BUILD_DIR)/$(DAEMON)
$(MKDIR) $(BUILD_DIR)
cd $@; $(GOBUILD) -o $(BUILD_DIR)/$(PROG) \
-gcflags "$(GO_GCFLAGS)" -ldflags "$(GO_LDFLAGS)"
cd $(BUILD_DIR); $(LN) $(PROG) $(DAEMON)
@$(TOUCH) $@
components/common/assets: force
cd $@; \
$(RM) assets_vfsdata.go ; \
$(GOCFG) go run assets_generator.go -tags=dev
clean: components/common/assets
$(RM) $(BUILD_DIR)/*
$(RM) hyperkit qcow-tool
$(RM) documentation/
$(RM) $(PROG)-$(VERSION).tar.gz
tarball: $(PROG)-$(VERSION).tar.gz
$(PROG)-$(VERSION).tar.gz: documentation hyperkit qcow-tool
cd bin; tar cvzf ../$@ *
release: force
github-release release -u $(TEAM) -r $(PROG) --tag $(VERSION) --draft
github-release upload -u $(TEAM) -r $(PROG) \
--label "macOS unsigned blobs (built in $(MACOS))" \
--tag $(VERSION) --name "corectl-$(VERSION)-macOS-$(GOARCH).tar.gz" \
--file $(PROG)-$(VERSION).tar.gz
hyperkit: force
# - ocaml stack
# - 1st run
# - brew install opam libev
# - opam init -y
# - opam install --yes uri qcow-format ocamlfind conf-libev
# - maintenance
# - opam update && opam upgrade -y
# - build
# - make clean
# - eval `opam config env` && make all
$(MKDIR) $(BUILD_DIR)
$(RM) $@
$(GIT) clone $(HYPERKIT_GIT)
cd $@; \
$(GIT) checkout $(HYPERKIT_COMMIT); \
$(MAKE) clean; \
$(shell opam config env) $(MAKE) all
$(CP) $@/build/hyperkit $(BUILD_DIR)/corectld.runner
$(RM) examples/dtrace
cd $@; \
$(SED) -i.bak -e "s,hyperkit,corectld.runner,g" dtrace/*.d; \
$(RM) dtrace/*.bak ; \
$(CP) -r dtrace ../examples
qcow-tool: force
$(RM) $(BUILD_DIR)/$@
$(CP) $(OPAMROOT)/system/bin/$@ $(BUILD_DIR)/$@
documentation/man: cmd force
$(RM) $@
$(MKDIR) $@
$(BUILD_DIR)/$(PROG) utils genManPages
$(BUILD_DIR)/$(DAEMON) utils genManPages
for p in $$(ls $@/*.1); do \
$(SED) -i.bak "s/$$($(DATE) '+%h %Y')//" "$$p" ;\
$(SED) -i.bak "/spf13\/cobra$$/d" "$$p" ;\
$(RM) "$$p.bak" ;\
done
documentation/markdown: cmd force
$(RM) $@
$(MKDIR) $@
$(BUILD_DIR)/$(PROG) utils genMarkdownDocs
$(BUILD_DIR)/$(DAEMON) utils genMarkdownDocs
for p in $$(ls $@/*.md); do \
$(SED) -i.bak "/spf13\/cobra/d" "$$p" ;\
$(RM) "$$p.bak" ;\
done
.PHONY: clean all docs force assets cmd