2016-05-05 13:38:23 +00:00
# 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.
2016-05-25 20:23:12 +00:00
# Use the native vendor/ dependency system
export GO15VENDOREXPERIMENT = 1
2016-05-28 14:50:36 +00:00
# Bump this on release
2016-07-13 18:25:07 +00:00
VERSION ?= v0.6.0
2016-05-28 19:41:45 +00:00
2016-05-04 21:29:13 +00:00
GOOS ?= $( shell go env GOOS)
GOARCH ?= $( shell go env GOARCH)
BUILD_DIR ?= ./out
2016-07-14 18:36:05 +00:00
ORG := k8s.io
REPOPATH ?= $( ORG) /minikube
2016-05-25 20:23:12 +00:00
BUILD_IMAGE ?= gcr.io/google_containers/kube-cross:v1.6.2-1
2016-05-14 17:27:58 +00:00
i f e q ( $( IN_DOCKER ) , 1 )
GOPATH := /go
e l s e
2016-05-24 17:25:09 +00:00
GOPATH := $( shell pwd ) /_gopath
2016-05-14 17:27:58 +00:00
e n d i f
2016-05-27 04:58:12 +00:00
# Use system python if it exists, otherwise use Docker.
2016-06-23 17:50:09 +00:00
PYTHON := $( shell command -v python || echo " docker run --rm -it -v $( shell pwd ) :/minikube -w /minikube python python " )
2016-05-30 17:50:06 +00:00
BUILD_OS := $( shell uname -s)
2016-05-28 19:41:45 +00:00
2016-05-25 20:23:12 +00:00
# Set the version information for the Kubernetes servers, and build localkube statically
2016-05-28 14:50:36 +00:00
K8S_VERSION_LDFLAGS := $( shell $( PYTHON) hack/get_k8s_version.py 2>& 1)
2016-07-14 16:22:19 +00:00
MINIKUBE_LDFLAGS := -X k8s.io/minikube/pkg/version.version= $( VERSION)
2016-05-28 14:50:36 +00:00
LOCALKUBE_LDFLAGS := " $( K8S_VERSION_LDFLAGS) $( MINIKUBE_LDFLAGS) -s -w -extldflags '-static' "
2016-05-15 16:17:42 +00:00
2016-07-14 18:36:05 +00:00
MKGOPATH := mkdir -p $( GOPATH) /src/$( ORG) && ln -s -f $( shell pwd ) $( GOPATH) /src/$( ORG)
2016-06-01 20:30:49 +00:00
2016-06-06 18:51:52 +00:00
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}}' )
2016-05-04 21:29:13 +00:00
2016-05-12 18:44:32 +00:00
out/minikube : out /minikube -$( GOOS ) -$( GOARCH )
2016-05-04 21:29:13 +00:00
cp $( BUILD_DIR) /minikube-$( GOOS) -$( GOARCH) $( BUILD_DIR) /minikube
2016-05-18 02:02:32 +00:00
out/localkube : $( LOCALKUBEFILES )
$( MKGOPATH)
2016-05-30 17:50:06 +00:00
i f e q ( $( BUILD_OS ) , L i n u x )
2016-05-28 14:50:36 +00:00
CGO_ENABLED = 1 go build -ldflags= $( LOCALKUBE_LDFLAGS) -o $( BUILD_DIR) /localkube ./cmd/localkube
2016-05-12 18:44:32 +00:00
e l s e
2016-05-25 20:23:12 +00:00
docker run -w /go/src/$( REPOPATH) -e IN_DOCKER = 1 -v $( shell pwd ) :/go/src/$( REPOPATH) $( BUILD_IMAGE) make out/localkube
2016-05-12 18:44:32 +00:00
e n d i f
2016-05-04 21:29:13 +00:00
2016-06-09 18:38:33 +00:00
out/minikube-$(GOOS)-$(GOARCH) : $( MINIKUBEFILES ) pkg /minikube /cluster /assets .go
2016-05-18 02:02:32 +00:00
$( MKGOPATH)
2016-07-14 16:22:19 +00:00
CGO_ENABLED = 0 GOARCH = $( GOARCH) GOOS = $( GOOS) go build --installsuffix cgo -ldflags= " $( K8S_VERSION_LDFLAGS) $( MINIKUBE_LDFLAGS) " -a -o $( BUILD_DIR) /minikube-$( GOOS) -$( GOARCH) ./cmd/minikube
2016-05-04 21:29:13 +00:00
2016-05-27 21:42:42 +00:00
localkube-image : out /localkube
make -C deploy/docker VERSION = $( VERSION)
iso :
cd deploy/iso && ./build.sh
2016-05-04 22:29:50 +00:00
.PHONY : integration
2016-05-12 18:44:32 +00:00
integration : out /minikube
2016-06-01 18:28:23 +00:00
go test -v $( REPOPATH) /test/integration --tags= integration
2016-05-04 21:29:13 +00:00
.PHONY : test
2016-06-09 18:38:33 +00:00
test : pkg /minikube /cluster /assets .go
2016-05-18 02:02:32 +00:00
$( MKGOPATH)
2016-05-04 22:29:50 +00:00
./test.sh
2016-05-12 17:09:58 +00:00
2016-06-09 18:38:33 +00:00
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
2016-05-13 15:35:30 +00:00
2016-05-18 02:02:32 +00:00
$(GOPATH)/bin/go-bindata :
$( MKGOPATH)
2016-07-07 20:07:00 +00:00
GOBIN = $( GOPATH) /bin go get github.com/jteeuwen/go-bindata/...
2016-07-04 10:10:44 +00:00
2016-07-08 16:23:03 +00:00
.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
2016-07-07 18:29:31 +00:00
.PHONY : clean
2016-07-04 10:10:44 +00:00
clean :
rm -rf $( GOPATH)
rm -rf $( BUILD_DIR)
2016-07-07 02:41:12 +00:00
rm -f pkg/minikube/cluster/assets.go
2016-07-08 16:38:23 +00:00
.PHONY : gendocs
gendocs : docs /minikube .md
docs/minikube.md : $( shell find cmd ) pkg /minikube /cluster /assets .go
$( MKGOPATH)
2016-07-14 16:22:19 +00:00
cd $( GOPATH) /src/$( REPOPATH) && go run -ldflags= " $( K8S_VERSION_LDFLAGS) $( MINIKUBE_LDFLAGS) " gen_help_text.go