Files
my-rook-config/Makefile
T

214 lines
6.3 KiB
Makefile
Raw Normal View History

2016-11-05 17:09:05 -07:00
# Copyright 2016 The Rook 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.
include build/makelib/common.mk
include build/makelib/helm.mk
.PHONY: all
all: build
2021-10-27 13:38:54 +00:00
.DEFAULT_GOAL := all
# ====================================================================================
# Build Options
2021-01-29 18:21:58 +01:00
# Controller-gen version
2021-04-14 17:28:34 -06:00
# f284e2e8... is master ahead of v0.5.0 which has ability to generate embedded objectmeta in CRDs
CONTROLLER_GEN_VERSION=f284e2e8098cb0193c2b0c7c1c651ae75496539b
2021-01-29 18:21:58 +01:00
# Set GOBIN
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# set the shell to bash in case some environments use sh
SHELL := /bin/bash
2017-06-15 12:09:09 -07:00
# Can be used or additional go build flags
BUILDFLAGS ?=
LDFLAGS ?=
2021-10-27 16:35:36 +02:00
# use the "ceph_preview" tag to consume go-ceph preview APIs, remove this once go-ceph 0.13 is out
TAGS ?= ceph_preview
# turn on more verbose build
V ?= 0
ifeq ($(V),1)
LDFLAGS += -v -n
BUILDFLAGS += -x
2017-02-02 17:58:41 -08:00
MAKEFLAGS += VERBOSE=1
2016-08-08 16:39:26 -07:00
else
2016-09-14 21:10:37 -07:00
MAKEFLAGS += --no-print-directory
endif
2017-06-15 12:09:09 -07:00
# whether to generate debug information in binaries. this includes DWARF
# and symbol tables.
DEBUG ?= 0
ifeq ($(DEBUG),0)
LDFLAGS += -s -w
endif
# platforms
PLATFORMS ?= $(ALL_PLATFORMS)
2021-11-02 18:54:58 +01:00
# PLATFORMS_TO_BUILD_FOR controls for which platforms to build the rook binary for
PLATFORMS_TO_BUILD_FOR ?= linux_amd64 linux_arm64
SERVER_PLATFORMS := $(filter linux_%,$(PLATFORMS))
CLIENT_PLATFORMS := $(filter-out linux_%,$(PLATFORMS))
2017-06-15 12:09:09 -07:00
# server projects that we build on server platforms
2021-09-22 16:39:09 -06:00
SERVER_PACKAGES = $(GO_PROJECT)/cmd/rook
2017-06-15 12:09:09 -07:00
2017-07-21 12:20:37 -07:00
# tests packages that will be compiled into binaries
2017-09-19 01:10:50 -07:00
TEST_PACKAGES = $(GO_PROJECT)/tests/integration
2017-07-21 12:20:37 -07:00
# the root go project
2016-10-26 00:38:39 +02:00
GO_PROJECT=github.com/rook/rook
2016-10-17 09:27:55 -07:00
# inject the version number into the golang version package using the -X linker flag
2016-11-14 14:54:51 -08:00
LDFLAGS += -X $(GO_PROJECT)/pkg/version.Version=$(VERSION)
2021-11-03 15:00:09 +01:00
# CGO_ENABLED value
CGO_ENABLED_VALUE=0
# ====================================================================================
# Setup projects
# setup go projects
2017-06-15 12:09:09 -07:00
GO_STATIC_PACKAGES=
ifneq ($(filter $(PLATFORM),$(CLIENT_PLATFORMS) $(SERVER_PLATFORMS)),)
2017-06-15 12:09:09 -07:00
GO_STATIC_PACKAGES += $(CLIENT_PACKAGES)
endif
ifneq ($(filter $(PLATFORM),$(SERVER_PLATFORMS)),)
2017-06-15 12:09:09 -07:00
GO_STATIC_PACKAGES += $(SERVER_PACKAGES)
endif
GO_BUILDFLAGS=$(BUILDFLAGS)
GO_LDFLAGS=$(LDFLAGS)
GO_TAGS=$(TAGS)
2017-07-21 12:20:37 -07:00
GO_TEST_PACKAGES=$(TEST_PACKAGES)
2017-06-26 21:52:06 -07:00
GO_TEST_FLAGS=$(TESTFLAGS)
GO_TEST_SUITE=$(SUITE)
2017-09-19 01:10:50 -07:00
GO_TEST_FILTER=$(TESTFILTER)
include build/makelib/golang.mk
2016-10-10 22:36:15 -07:00
# ====================================================================================
# Targets
build.version:
@mkdir -p $(OUTPUT_DIR)
@echo "$(VERSION)" > $(OUTPUT_DIR)/version
build.common: build.version helm.build mod.check crds
2017-03-30 15:42:03 +02:00
@$(MAKE) go.init
@$(MAKE) go.validate
@$(MAKE) -C images/ceph list-image
2017-03-30 15:42:03 +02:00
2017-06-15 12:09:09 -07:00
do.build.platform.%:
@$(MAKE) PLATFORM=$* go.build
2017-06-13 14:25:27 -07:00
2021-11-02 18:54:58 +01:00
do.build.parallel: $(foreach p,$(PLATFORMS_TO_BUILD_FOR), do.build.platform.$(p))
2017-06-15 12:09:09 -07:00
2021-04-21 14:57:31 -06:00
build: csv-clean build.common ## Only build for linux platform
2018-04-19 15:24:06 +08:00
@$(MAKE) go.build PLATFORM=linux_$(GOHOSTARCH)
@$(MAKE) -C images PLATFORM=linux_$(GOHOSTARCH)
2017-06-13 14:25:27 -07:00
2020-02-17 11:06:01 +01:00
build.all: build.common ## Build source code for all platforms. Best done in the cross build container due to cross compiler dependencies.
2018-04-26 15:28:39 +08:00
ifneq ($(GOHOSTARCH),amd64)
$(error cross platform image build only supported on amd64 host currently)
endif
2017-06-15 12:09:09 -07:00
@$(MAKE) do.build.parallel
@$(MAKE) -C images build.all
2017-03-30 15:42:03 +02:00
install: build.common
2017-03-02 13:50:39 -08:00
@$(MAKE) go.install
2020-02-17 11:06:01 +01:00
check test: ## Runs unit tests.
2017-06-26 21:52:06 -07:00
@$(MAKE) go.test.unit
2020-02-17 11:06:01 +01:00
test-integration: ## Runs integration tests.
2017-06-26 21:52:06 -07:00
@$(MAKE) go.test.integration
2020-02-17 11:06:01 +01:00
lint: ## Check syntax and styling of go sources.
2017-03-30 15:42:03 +02:00
@$(MAKE) go.init
@$(MAKE) go.lint
2017-03-02 11:30:33 -08:00
2020-02-17 11:06:01 +01:00
vet: ## Runs lint checks on go sources.
2017-03-30 15:42:03 +02:00
@$(MAKE) go.init
@$(MAKE) go.vet
2020-02-17 11:06:01 +01:00
fmt: ## Check formatting of go sources.
2017-03-30 15:42:03 +02:00
@$(MAKE) go.init
@$(MAKE) go.fmt
2021-04-20 02:53:36 +00:00
codegen: ${CODE_GENERATOR} ## Run code generators.
@build/codegen/codegen.sh
2020-02-17 11:06:01 +01:00
mod.check: go.mod.check ## Check if any go modules changed.
mod.update: go.mod.update ## Update all go modules.
clean: csv-clean ## Remove all files that are created by building.
2020-03-10 14:42:15 +09:00
@$(MAKE) go.mod.clean
2017-06-09 13:34:41 -07:00
@$(MAKE) -C images clean
@rm -fr $(OUTPUT_DIR) $(WORK_DIR)
2020-02-17 11:06:01 +01:00
distclean: clean ## Remove all files that are created by building or configuring.
@rm -fr $(CACHE_DIR)
2017-04-01 20:20:18 -07:00
2020-02-17 11:06:01 +01:00
prune: ## Prune cached artifacts.
@$(MAKE) -C images prune
2017-03-30 17:10:42 +02:00
2021-04-08 13:19:14 -06:00
# Change how CRDs are generated for CSVs
csv-ceph: export MAX_DESC_LEN=0 # sets the description length to 0 since CSV cannot be bigger than 1MB
csv-ceph: export NO_OB_OBC_VOL_GEN=true
csv-ceph: csv-clean crds ## Generate a CSV file for OLM.
2021-04-08 13:19:14 -06:00
$(MAKE) -C images/ceph csv
2019-03-13 17:48:41 +01:00
csv-clean: ## Remove existing OLM files.
@$(MAKE) -C images/ceph csv-clean
2021-04-08 13:19:14 -06:00
crds: $(CONTROLLER_GEN) $(YQ)
2021-01-29 18:21:58 +01:00
@echo Updating CRD manifests
2021-03-26 09:21:33 +01:00
@build/crds/build-crds.sh $(CONTROLLER_GEN) $(YQ)
2021-01-29 18:21:58 +01:00
2021-11-22 17:31:19 -07:00
gen-rbac: $(HELM) $(YQ) ## generate RBAC from Helm charts
2021-11-17 15:53:30 -07:00
@# output only stdout to the file; stderr for debugging should keep going to stderr
HELM=$(HELM) ./build/rbac/get-helm-rbac.sh > build/rbac/rbac.yaml
.PHONY: all build.common cross.build.parallel
2020-03-10 14:42:15 +09:00
.PHONY: build build.all install test check vet fmt codegen mod.check clean distclean prune
# ====================================================================================
# Help
2018-07-19 12:36:30 -06:00
define HELPTEXT
Options:
DEBUG Whether to generate debug symbols. Default is 0.
IMAGES Backend images to make. All by default. See: /rook/images/ dir
PLATFORM The platform to build.
SUITE The test suite to run.
TESTFILTER Tests to run in a suite.
VERSION The version information compiled into binaries.
The default is obtained from git.
V Set to 1 enable verbose build. Default is 0.
endef
export HELPTEXT
.PHONY: help
2020-02-17 11:06:01 +01:00
help: ## Show this help menu.
@echo "Usage: make [TARGET ...]"
@echo ""
2020-05-18 15:05:38 +05:30
@grep --no-filename -E '^[a-zA-Z_%-. ]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2020-02-17 11:06:01 +01:00
@echo ""
2018-07-19 12:36:30 -06:00
@echo "$$HELPTEXT"