Files
my-rook-config/Makefile
T

209 lines
5.6 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
.PHONY: all
all: build
# ====================================================================================
# Build Options
# 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 ?=
TAGS ?=
# 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)
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
2017-10-09 12:13:25 -07:00
SERVER_PACKAGES = $(GO_PROJECT)/cmd/rook $(GO_PROJECT)/cmd/rookflex
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)
# ====================================================================================
# 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
2017-08-10 13:26:45 -07:00
# setup helm charts
include build/makelib/helm.mk
2016-10-10 22:36:15 -07:00
# ====================================================================================
# Targets
build.version:
@mkdir -p $(OUTPUT_DIR)
@echo "$(VERSION)" > $(OUTPUT_DIR)/version
2017-08-10 13:26:45 -07:00
build.common: build.version helm.build
2017-03-30 15:42:03 +02:00
@$(MAKE) go.init
@$(MAKE) go.validate
2017-06-15 12:09:09 -07:00
do.build.platform.%:
@$(MAKE) PLATFORM=$* go.build
2017-06-13 14:25:27 -07:00
2017-06-15 12:09:09 -07:00
do.build.parallel: $(foreach p,$(PLATFORMS), do.build.platform.$(p))
build: build.common
2017-06-16 10:18:00 -07:00
@$(MAKE) go.build
# if building on non-linux platforms, also build the linux container
2017-06-16 10:18:00 -07:00
ifneq ($(GOOS),linux)
2018-04-19 15:24:06 +08:00
@$(MAKE) go.build PLATFORM=linux_$(GOHOSTARCH)
2017-06-16 10:18:00 -07:00
endif
2018-04-19 15:24:06 +08:00
@$(MAKE) -C images PLATFORM=linux_$(GOHOSTARCH)
2017-06-13 14:25:27 -07:00
build.all: build.common
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
2017-06-26 21:52:06 -07:00
check test:
@$(MAKE) go.test.unit
test-integration:
@$(MAKE) go.test.integration
2017-03-30 15:42:03 +02:00
lint:
@$(MAKE) go.init
@$(MAKE) go.lint
2017-03-02 11:30:33 -08:00
2017-03-30 15:42:03 +02:00
vet:
@$(MAKE) go.init
@$(MAKE) go.vet
2017-03-30 15:42:03 +02:00
fmt:
@$(MAKE) go.init
@$(MAKE) go.fmt
codegen:
@build/codegen/codegen.sh
vendor: go.vendor
2018-09-30 08:05:03 -07:00
vendor.check: go.vendor.check
vendor.update: go.vendor.update
clean:
2017-06-09 13:34:41 -07:00
@$(MAKE) -C images clean
@rm -fr $(OUTPUT_DIR) $(WORK_DIR)
distclean: go.distclean clean
@rm -fr $(CACHE_DIR)
2017-04-01 20:20:18 -07:00
prune:
@$(MAKE) -C images prune
2017-03-30 17:10:42 +02:00
2019-03-13 17:48:41 +01:00
csv-ceph:
@cluster/olm/ceph/generate-rook-csv.sh $(CSV_VERSION) $(CSV_PLATFORM) $(ROOK_OP_VERSION)
.PHONY: all build.common cross.build.parallel
.PHONY: build build.all install test check vet fmt codegen vendor clean distclean prune
# ====================================================================================
# Help
2018-07-19 12:36:30 -06:00
define HELPTEXT
Usage: make <OPTIONS> ... <TARGETS>
Targets:
build Build source code for host platform.
build.all Build source code for all platforms.
Best done in the cross build container
due to cross compiler dependencies.
check Runs unit tests.
clean Remove all files that are created by building.
codegen Run code generators.
2019-05-31 11:08:21 +02:00
csv-ceph Generate a CSV file for OLM.
2018-07-19 12:36:30 -06:00
distclean Remove all files that are created
by building or configuring.
fmt Check formatting of go sources.
lint Check syntax and styling of go sources.
help Show this help info.
prune Prune cached artifacts.
test Runs unit tests.
test-integration Runs integration tests.
vendor Update vendor dependencies.
2018-09-30 08:05:03 -07:00
vendor.check Checks if vendor dependencies changed.
vendor.update Update all vendor dependencies.
2018-07-19 12:36:30 -06:00
vet Runs lint checks on go sources.
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
help:
2018-07-19 12:36:30 -06:00
@echo "$$HELPTEXT"