Makefile 3.9 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
19
VERSION ?= v0.6.0
20

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

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

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

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

42
MKGOPATH := mkdir -p $(shell dirname $(GOPATH)/src/$(REPOPATH)) && ln -s -f $(shell pwd) $(GOPATH)/src/$(REPOPATH)
43

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

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

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

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

62 63 64 65 66 67
localkube-image: out/localkube
	make -C deploy/docker VERSION=$(VERSION)

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

D
dlorenc 已提交
68
.PHONY: integration
69
integration: out/minikube
D
dlorenc 已提交
70
	go test -v $(REPOPATH)/test/integration --tags=integration
71 72

.PHONY: test
73
test: pkg/minikube/cluster/assets.go
74
	$(MKGOPATH)
D
dlorenc 已提交
75
	./test.sh
76

77 78
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 已提交
79

80 81
$(GOPATH)/bin/go-bindata:
	$(MKGOPATH)
82
	GOBIN=$(GOPATH)/bin go get github.com/jteeuwen/go-bindata/...
83

84 85 86 87 88 89 90
.PHONY: cross
cross: out/localkube
	GOOS=linux GOARCH=amd64 make out/minikube-linux-amd64
	GOOS=darwin GOARCH=amd64 make out/minikube-darwin-amd64
	GOOS=windows GOARCH=amd64 make out/minikube-windows-amd64
	mv out/minikube-windows-amd64 out/minikube-windows-amd64.exe

M
Morgan Bauer 已提交
91
.PHONY: clean
92 93 94
clean:
	rm -rf $(GOPATH)
	rm -rf $(BUILD_DIR)
95
	rm -f pkg/minikube/cluster/assets.go
J
Jimmi Dyson 已提交
96 97 98 99 100 101 102

.PHONY: gendocs
gendocs: docs/minikube.md

docs/minikube.md: $(shell find cmd) pkg/minikube/cluster/assets.go
	$(MKGOPATH)
	cd $(GOPATH)/src/$(REPOPATH) && go run gen_help_text.go