Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2016 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Use:
  15. #
  16. # `make kubectl` will build kubectl.
  17. # `make tag` will suggest a tag.
  18. # `make container` will build a container-- you must supply a tag.
  19. # `make push` will push the container-- you must supply a tag.
  20. GOARCH?=$(shell go env GOARCH)
  21. GOOS?=$(shell go env GOOS)
  22. kubectl:
  23. make -C ../../ WHAT=cmd/kubectl KUBE_STATIC_OVERRIDES="kubectl"; \
  24. cp ../../_output/local/bin/$(GOOS)/$(GOARCH)/kubectl .
  25. .tag: kubectl
  26. ./kubectl version --client | grep -o 'GitVersion:"[^"]*"' | sed 's/[^"]*"\([^"+]*\).*/\1/' > .tag
  27. tag: .tag
  28. @echo "Suggest using TAG=$(shell cat .tag)"
  29. @echo "$$ make container TAG=$(shell cat .tag)"
  30. @echo "or"
  31. @echo "$$ make push TAG=$(shell cat .tag)"
  32. container:
  33. $(if $(TAG),,$(error TAG is not defined. Use 'make tag' to see a suggestion))
  34. docker build -t gcr.io/google_containers/kubectl:$(TAG) .
  35. push: container
  36. $(if $(TAG),,$(error TAG is not defined. Use 'make tag' to see a suggestion))
  37. gcloud docker push gcr.io/google_containers/kubectl:$(TAG)
  38. clean:
  39. rm -f kubectl
  40. rm -f .tag