Makefile 4.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15 16 17
# Use the native vendor/ dependency system
export GO15VENDOREXPERIMENT=1

18
# Bump this on release
A
Aaron Prindle 已提交
19
VERSION ?= v0.8.0
20

21 22 23
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
BUILD_DIR ?= ./out
24 25
ORG := k8s.io
REPOPATH ?= $(ORG)/minikube
26
BUILD_IMAGE ?= gcr.io/google_containers/kube-cross:v1.6.2-1
D
Dan Lorenc 已提交
27 28 29 30

ifeq ($(IN_DOCKER),1)
	GOPATH := /go
else
31
	GOPATH := $(shell pwd)/_gopath
D
Dan Lorenc 已提交
32 33
endif

34
# Use system python if it exists, otherwise use Docker.
35
PYTHON := $(shell command -v python || echo "docker run --rm -it -v $(shell pwd):/minikube -w /minikube python python")
D
Dan Lorenc 已提交
36
BUILD_OS := $(shell uname -s)
37

38
# Set the version information for the Kubernetes servers, and build localkube statically
39
K8S_VERSION_LDFLAGS := $(shell $(PYTHON) hack/get_k8s_version.py 2>&1)
40
MINIKUBE_LDFLAGS := -X k8s.io/minikube/pkg/version.version=$(VERSION)
41
LOCALKUBE_LDFLAGS := "$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS) -s -w -extldflags '-static'"
42

D
Dan Lorenc 已提交
43
MKGOPATH := if [ ! -e $(GOPATH)/src/$(ORG) ]; then mkdir -p $(GOPATH)/src/$(ORG) && ln -s -f $(shell pwd) $(GOPATH)/src/$(ORG); fi
44

D
Dan Lorenc 已提交
45 46
LOCALKUBEFILES := go list  -f '{{join .Deps "\n"}}' ./cmd/localkube/ | grep k8s.io | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
MINIKUBEFILES := go list  -f '{{join .Deps "\n"}}' ./cmd/minikube/ | grep k8s.io | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
47

48
out/minikube: out/minikube-$(GOOS)-$(GOARCH)
49 50
	cp $(BUILD_DIR)/minikube-$(GOOS)-$(GOARCH) $(BUILD_DIR)/minikube

D
Dan Lorenc 已提交
51
out/localkube: $(shell $(LOCALKUBEFILES))
52
	$(MKGOPATH)
D
Dan Lorenc 已提交
53
ifeq ($(BUILD_OS),Linux)
54
	CGO_ENABLED=1 go build -ldflags=$(LOCALKUBE_LDFLAGS) -o $(BUILD_DIR)/localkube ./cmd/localkube
55
else
56
	docker run -w /go/src/$(REPOPATH) -e IN_DOCKER=1 -v $(shell pwd):/go/src/$(REPOPATH) $(BUILD_IMAGE) make out/localkube
57
endif
58

D
Dan Lorenc 已提交
59
out/minikube-darwin-amd64: pkg/minikube/cluster/assets.go $(shell $(MINIKUBEFILES))
60
	$(MKGOPATH)
D
Dan Lorenc 已提交
61 62 63 64 65 66
	CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS)" -a -o $(BUILD_DIR)/minikube-darwin-amd64 ./cmd/minikube

out/minikube-linux-amd64: pkg/minikube/cluster/assets.go $(shell $(MINIKUBEFILES))
	$(MKGOPATH)
	CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS)" -a -o $(BUILD_DIR)/minikube-linux-amd64 ./cmd/minikube

J
Jimmi Dyson 已提交
67
out/minikube-windows-amd64.exe: pkg/minikube/cluster/assets.go $(shell $(MINIKUBEFILES))
D
Dan Lorenc 已提交
68 69
	$(MKGOPATH)
	CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS)" -a -o $(BUILD_DIR)/minikube-windows-amd64.exe ./cmd/minikube
70

71 72 73 74 75 76
localkube-image: out/localkube
	make -C deploy/docker VERSION=$(VERSION)

iso:
	cd deploy/iso && ./build.sh

D
dlorenc 已提交
77
.PHONY: integration
78
integration: out/minikube
D
dlorenc 已提交
79
	go test -v $(REPOPATH)/test/integration --tags=integration
80 81

.PHONY: test
82
test: pkg/minikube/cluster/assets.go
83
	$(MKGOPATH)
D
dlorenc 已提交
84
	./test.sh
85

86 87
pkg/minikube/cluster/assets.go: out/localkube $(GOPATH)/bin/go-bindata deploy/iso/addon-manager.yaml deploy/addons/dashboard-rc.yaml deploy/addons/dashboard-svc.yaml
	$(GOPATH)/bin/go-bindata -nomemcopy -o pkg/minikube/cluster/assets.go -pkg cluster ./out/localkube deploy/iso/addon-manager.yaml deploy/addons/dashboard-rc.yaml deploy/addons/dashboard-svc.yaml
D
Dan Lorenc 已提交
88

89 90
$(GOPATH)/bin/go-bindata:
	$(MKGOPATH)
91
	GOBIN=$(GOPATH)/bin go get github.com/jteeuwen/go-bindata/...
92

93
.PHONY: cross
J
Jimmi Dyson 已提交
94
cross: out/localkube out/minikube-linux-amd64 out/minikube-darwin-amd64 out/minikube-windows-amd64.exe
95

J
Jimmi Dyson 已提交
96 97 98 99 100 101 102 103
.PHONE: checksum
checksum:
	for f in out/localkube out/minikube-linux-amd64 out/minikube-darwin-amd64 out/minikube-windows-amd64.exe ; do \
		if [ -f "$${f}" ]; then \
			openssl sha256 "$${f}" | awk '{print $$2}' > "$${f}.sha256" ; \
		fi ; \
	done

M
Morgan Bauer 已提交
104
.PHONY: clean
105 106 107
clean:
	rm -rf $(GOPATH)
	rm -rf $(BUILD_DIR)
108
	rm -f pkg/minikube/cluster/assets.go
J
Jimmi Dyson 已提交
109 110 111 112

.PHONY: gendocs
gendocs: docs/minikube.md

113
docs/minikube.md: $(shell find cmd) $(shell find pkg/minikube/constants) pkg/minikube/cluster/assets.go
J
Jimmi Dyson 已提交
114
	$(MKGOPATH)
115
	cd $(GOPATH)/src/$(REPOPATH) && go run -ldflags="$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS)" -tags gendocs gen_help_text.go