Makefile 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. DBG_MAKEFILE ?=
  15. ifeq ($(DBG_MAKEFILE),1)
  16. $(warning ***** starting Makefile for goal(s) "$(MAKECMDGOALS)")
  17. $(warning ***** $(shell date))
  18. else
  19. # If we're not debugging the Makefile, don't echo recipes.
  20. MAKEFLAGS += -s
  21. endif
  22. # Old-skool build tools.
  23. #
  24. # Commonly used targets (see each target for more information):
  25. # all: Build code.
  26. # test: Run tests.
  27. # clean: Clean up.
  28. # It's necessary to set this because some environments don't link sh -> bash.
  29. SHELL := /bin/bash
  30. # We don't need make's built-in rules.
  31. MAKEFLAGS += --no-builtin-rules
  32. .SUFFIXES:
  33. # Constants used throughout.
  34. .EXPORT_ALL_VARIABLES:
  35. OUT_DIR ?= _output
  36. BIN_DIR := $(OUT_DIR)/bin
  37. PRJ_SRC_PATH := k8s.io/kubernetes
  38. GENERATED_FILE_PREFIX := zz_generated.
  39. # Metadata for driving the build lives here.
  40. META_DIR := .make
  41. # Our build flags.
  42. # TODO(thockin): it would be nice to just use the native flags. Can we EOL
  43. # these "wrapper" flags?
  44. KUBE_GOFLAGS := $(GOFLAGS)
  45. KUBE_GOLDFLAGS := $(GOLDFLAGS)
  46. KUBE_GOGCFLAGS = $(GOGCFLAGS)
  47. # This controls the verbosity of the build. Higher numbers mean more output.
  48. KUBE_VERBOSE ?= 1
  49. # Build code.
  50. #
  51. # Args:
  52. # WHAT: Directory names to build. If any of these directories has a 'main'
  53. # package, the build will produce executable files under $(OUT_DIR)/go/bin.
  54. # If not specified, "everything" will be built.
  55. # GOFLAGS: Extra flags to pass to 'go' when building.
  56. # GOLDFLAGS: Extra linking flags passed to 'go' when building.
  57. # GOGCFLAGS: Additional go compile flags passed to 'go' when building.
  58. #
  59. # Example:
  60. # make
  61. # make all
  62. # make all WHAT=cmd/kubelet GOFLAGS=-v
  63. # make all GOGCFLAGS="-N -l"
  64. # Note: Use the -N -l options to disable compiler optimizations an inlining.
  65. # Using these build options allows you to subsequently use source
  66. # debugging tools like delve.
  67. .PHONY: all
  68. all: generated_files
  69. hack/make-rules/build.sh $(WHAT)
  70. # Build ginkgo
  71. #
  72. # Example:
  73. # make ginkgo
  74. .PHONY: ginkgo
  75. ginkgo:
  76. hack/make-rules/build.sh vendor/github.com/onsi/ginkgo/ginkgo
  77. # Runs all the presubmission verifications.
  78. #
  79. # Args:
  80. # BRANCH: Branch to be passed to verify-godeps.sh script.
  81. #
  82. # Example:
  83. # make verify
  84. # make verify BRANCH=branch_x
  85. .PHONY: verify
  86. verify:
  87. KUBE_VERIFY_GIT_BRANCH=$(BRANCH) hack/make-rules/verify.sh -v
  88. hack/make-rules/vet.sh
  89. # Build and run tests.
  90. #
  91. # Args:
  92. # WHAT: Directory names to test. All *_test.go files under these
  93. # directories will be run. If not specified, "everything" will be tested.
  94. # TESTS: Same as WHAT.
  95. # GOFLAGS: Extra flags to pass to 'go' when building.
  96. # GOLDFLAGS: Extra linking flags to pass to 'go' when building.
  97. # GOGCFLAGS: Additional go compile flags passed to 'go' when building.
  98. #
  99. # Example:
  100. # make check
  101. # make test
  102. # make check WHAT=pkg/kubelet GOFLAGS=-v
  103. .PHONY: check test
  104. check test: generated_files
  105. hack/make-rules/test.sh $(WHAT) $(TESTS)
  106. # Build and run integration tests.
  107. #
  108. # Example:
  109. # make test-integration
  110. .PHONY: test-integration
  111. test-integration: generated_files
  112. hack/make-rules/test-integration.sh
  113. # Build and run end-to-end tests.
  114. #
  115. # Example:
  116. # make test-e2e
  117. .PHONY: test-e2e
  118. test-e2e: ginkgo generated_files
  119. go run hack/e2e.go -v --build --up --test --down
  120. # Build and run node end-to-end tests.
  121. #
  122. # Args:
  123. # FOCUS: Regexp that matches the tests to be run. Defaults to "".
  124. # SKIP: Regexp that matches the tests that needs to be skipped. Defaults
  125. # to "".
  126. # RUN_UNTIL_FAILURE: If true, pass --untilItFails to ginkgo so tests are run
  127. # repeatedly until they fail. Defaults to false.
  128. # REMOTE: If true, run the tests on a remote host instance on GCE. Defaults
  129. # to false.
  130. # IMAGES: For REMOTE=true only. Comma delimited list of images for creating
  131. # remote hosts to run tests against. Defaults to a recent image.
  132. # LIST_IMAGES: If true, don't run tests. Just output the list of available
  133. # images for testing. Defaults to false.
  134. # HOSTS: For REMOTE=true only. Comma delimited list of running gce hosts to
  135. # run tests against. Defaults to "".
  136. # DELETE_INSTANCES: For REMOTE=true only. Delete any instances created as
  137. # part of this test run. Defaults to false.
  138. # ARTIFACTS: For REMOTE=true only. Local directory to scp test artifacts into
  139. # from the remote hosts. Defaults to ""/tmp/_artifacts".
  140. # REPORT: For REMOTE=false only. Local directory to write juntil xml results
  141. # to. Defaults to "/tmp/".
  142. # CLEANUP: For REMOTE=true only. If false, do not stop processes or delete
  143. # test files on remote hosts. Defaults to true.
  144. # IMAGE_PROJECT: For REMOTE=true only. Project containing images provided to
  145. # IMAGES. Defaults to "kubernetes-node-e2e-images".
  146. # INSTANCE_PREFIX: For REMOTE=true only. Instances created from images will
  147. # have the name "${INSTANCE_PREFIX}-${IMAGE_NAME}". Defaults to "test".
  148. # INSTANCE_METADATA: For REMOTE=true and running on GCE only.
  149. # GUBERNATOR: For REMOTE=true only. Produce link to Gubernator to view logs.
  150. # Defaults to false.
  151. #
  152. # Example:
  153. # make test-e2e-node FOCUS=Kubelet SKIP=container
  154. # make test-e2e-node REMOTE=true DELETE_INSTANCES=true
  155. # make test-e2e-node TEST_ARGS="--cgroups-per-qos=true"
  156. # Build and run tests.
  157. .PHONY: test-e2e-node
  158. test-e2e-node: ginkgo generated_files
  159. hack/make-rules/test-e2e-node.sh
  160. # Build and run cmdline tests.
  161. #
  162. # Example:
  163. # make test-cmd
  164. .PHONY: test-cmd
  165. test-cmd: generated_files
  166. hack/make-rules/test-cmd.sh
  167. # Remove all build artifacts.
  168. #
  169. # Example:
  170. # make clean
  171. #
  172. # TODO(thockin): call clean_generated when we stop committing generated code.
  173. .PHONY: clean
  174. clean: clean_meta
  175. build/make-clean.sh
  176. rm -rf $(OUT_DIR)
  177. rm -rf Godeps/_workspace # Just until we are sure it is gone
  178. # Remove make-related metadata files.
  179. #
  180. # Example:
  181. # make clean_meta
  182. .PHONY: clean_meta
  183. clean_meta:
  184. rm -rf $(META_DIR)
  185. # Remove all auto-generated artifacts.
  186. #
  187. # Example:
  188. # make clean_generated
  189. .PHONY: clean_generated
  190. clean_generated:
  191. find . -type f -name $(GENERATED_FILE_PREFIX)\* | xargs rm -f
  192. # Run 'go vet'.
  193. #
  194. # Args:
  195. # WHAT: Directory names to vet. All *.go files under these
  196. # directories will be vetted. If not specified, "everything" will be
  197. # vetted.
  198. #
  199. # Example:
  200. # make vet
  201. # make vet WHAT=pkg/kubelet
  202. .PHONY: vet
  203. vet:
  204. hack/make-rules/vet.sh $(WHAT)
  205. # Build a release
  206. #
  207. # Example:
  208. # make release
  209. .PHONY: release
  210. release:
  211. build/release.sh
  212. # Build a release, but skip tests
  213. #
  214. # Example:
  215. # make release-skip-tests
  216. .PHONY: release-skip-tests quick-release
  217. release-skip-tests quick-release:
  218. KUBE_RELEASE_RUN_TESTS=n KUBE_FASTBUILD=true build/release.sh
  219. # Cross-compile for all platforms
  220. #
  221. # Example:
  222. # make cross
  223. .PHONY: cross
  224. cross:
  225. hack/make-rules/cross.sh
  226. # Add rules for all directories in cmd/
  227. #
  228. # Example:
  229. # make kubectl kube-proxy
  230. .PHONY: $(notdir $(abspath $(wildcard cmd/*/)))
  231. $(notdir $(abspath $(wildcard cmd/*/))): generated_files
  232. hack/make-rules/build.sh cmd/$@
  233. # Add rules for all directories in plugin/cmd/
  234. #
  235. # Example:
  236. # make kube-scheduler
  237. .PHONY: $(notdir $(abspath $(wildcard plugin/cmd/*/)))
  238. $(notdir $(abspath $(wildcard plugin/cmd/*/))): generated_files
  239. hack/make-rules/build.sh plugin/cmd/$@
  240. # Add rules for all directories in federation/cmd/
  241. #
  242. # Example:
  243. # make federation-apiserver federation-controller-manager
  244. .PHONY: $(notdir $(abspath $(wildcard federation/cmd/*/)))
  245. $(notdir $(abspath $(wildcard federation/cmd/*/))): generated_files
  246. hack/make-rules/build.sh federation/cmd/$@
  247. # Produce auto-generated files needed for the build.
  248. #
  249. # Example:
  250. # make generated_files
  251. .PHONY: generated_files
  252. generated_files:
  253. $(MAKE) -f Makefile.$@ $@ CALLED_FROM_MAIN_MAKEFILE=1