|
| 1 | +# Copyright 2021 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 | + |
| 15 | +ROOT_DIR_RELATIVE := ../.. |
| 16 | +include $(ROOT_DIR_RELATIVE)/common.mk |
| 17 | + |
| 18 | +# Directories. |
| 19 | +MDBOOK := $(TOOLS_BIN_DIR)/mdbook |
| 20 | +MDBOOK_EMBED := $(TOOLS_BIN_DIR)/mdbook-embed |
| 21 | +MDBOOK_RELEASELINK := $(TOOLS_BIN_DIR)/mdbook-releaselink |
| 22 | +MDBOOK_TABULATE := $(TOOLS_BIN_DIR)/mdbook-tabulate |
| 23 | +GENCRDAPIREFERENCEDOCS := $(TOOLS_BIN_DIR)/gen-crd-api-reference-docs |
| 24 | +GENCRDAPIREFERENCEDOCS_SRCS := $(call rwildcard,.,gen-crd-api-reference-docs/*.*) |
| 25 | +CRD_DOCS := src/crd/cluster-api-aws.md src/crd/experimental.md src/crd/eks-control-plane.md |
| 26 | +BOOK_SRCS := $(filter-out $(CRD_DOCS), $(call rwildcard,.,*.*)) |
| 27 | + |
| 28 | +API_DIRS := cmd/clusterawsadm/api/bootstrap/v1beta1 api/v1beta1 exp/api/v1beta1 controlplane/eks/api/v1beta1 bootstrap/eks/api/v1beta1 iam/api/v1beta1 |
| 29 | +API_SRCS := $(foreach dir, $(API_DIRS), $(call rwildcard,../../$(dir),*.go)) |
| 30 | +GENERATED_SRCS := $(foreach dir, $(API_DIRS),../../$(dir)/zz_generated.deepcopy.go ../../$(dir)/zz_generated.conversion.go ../../$(dir)/zz_generated.defaults.go) |
| 31 | +API_FILTERED_SRCS := $(filter-out $(GENERATED_SRCS), $(API_SRCS)) |
| 32 | + |
| 33 | +OS := $(shell go env GOOS) |
| 34 | +ARCH := $(shell go env GOARCH) |
| 35 | +PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH) |
| 36 | +export PATH |
| 37 | + |
| 38 | +src/crd: |
| 39 | + mkdir -p src/crd |
| 40 | + |
| 41 | +src/crd/index.md: $(API_FILTERED_SRCS) src/crd |
| 42 | + $(MAKE) gen_crd_docs API_DIR="../.." OUT_FILE=$@ |
| 43 | + |
| 44 | +.PHONY: gen_crd_docs |
| 45 | +gen_crd_docs: $(GENCRDAPIREFERENCEDOCS) src/crd $(GENCRDAPIREFERENCEDOCS_SRCS) |
| 46 | + $(GENCRDAPIREFERENCEDOCS) -template-dir gen-crd-api-reference-docs/template -config "gen-crd-api-reference-docs/config.json" \ |
| 47 | + -api-dir $(API_DIR) \ |
| 48 | + -out-file $(OUT_FILE) |
| 49 | + |
| 50 | +src/clusterawsadm: |
| 51 | + mkdir -p src/clusterawsadm |
| 52 | + |
| 53 | +terraform/out: |
| 54 | + mkdir -p terraform/out |
| 55 | + |
| 56 | +terraform/out/amilist: terraform/out |
| 57 | + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ ./cmd/amilist && chmod 755 $@ |
| 58 | + |
| 59 | +.PHONY: generate |
| 60 | +generate: ## Generate any dependent files outside of a build |
| 61 | + $(MAKE) -C ../ diagrams |
| 62 | + |
| 63 | +#src/SUMMARY_CLUSTERAWSADM.md: src/clusterawsadm $(CLUSTERAWSADMCMDREF_SRCS) |
| 64 | +# go run ./cmd/clusterawsadmdocs > src/SUMMARY_CLUSTERAWSADM.md |
| 65 | +# |
| 66 | +## SUMMARY.md doesn't support processor statements, so construct it using cat |
| 67 | +#src/SUMMARY.md: src/SUMMARY_PREFIX.md src/SUMMARY_SUFFIX.md |
| 68 | +# cat src/SUMMARY_PREFIX.md > src/SUMMARY.md |
| 69 | +# cat src/SUMMARY_CLUSTERAWSADM.md >> src/SUMMARY.md |
| 70 | +# cat src/SUMMARY_SUFFIX.md >> src/SUMMARY.md |
| 71 | + |
| 72 | +verify: generate ## Verify that dependent artifacts are up to date |
| 73 | + @if !(git diff --quiet HEAD); then \ |
| 74 | + git diff; \ |
| 75 | + echo "generated files are out of date, run make generate"; exit 1; \ |
| 76 | + fi |
| 77 | + |
| 78 | +BOOK_DEPS := $(BOOK_SRCS) $(MDBOOK) $(MDBOOK_EMBED) $(MDBOOK_RELEASELINK) $(MDBOOK_TABULATE) #src/SUMMARY.md src/crd/index.md |
| 79 | + |
| 80 | +.PHONY: build |
| 81 | +build: $(BOOK_DEPS) ## Build the book |
| 82 | + $(MDBOOK) build |
| 83 | + |
| 84 | +.PHONY: serve |
| 85 | +serve: $(BOOK_DEPS) ## Run a local webserver with the compiled book |
| 86 | + $(MDBOOK) serve |
| 87 | + |
| 88 | +.PHONY: clean |
| 89 | +clean: |
| 90 | + rm -rf book |
0 commit comments