diff --git a/Makefile b/Makefile index 67bea110..7569479c 100644 --- a/Makefile +++ b/Makefile @@ -12,18 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -ROOT_DIR_RELATIVE := . +export REPO_ROOT := $(shell git rev-parse --show-toplevel) -include $(ROOT_DIR_RELATIVE)/common.mk +include $(REPO_ROOT)/common.mk # Directories -TOOLS_DIR := hack/tools +TOOLS_DIR := $(REPO_ROOT)/hack/tools TOOLS_DIR_DEPS := $(TOOLS_DIR)/go.sum $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/Makefile TOOLS_BIN_DIR := $(TOOLS_DIR)/bin BIN_DIR ?= bin RELEASE_DIR ?= out -export REPO_ROOT := $(shell git rev-parse --show-toplevel) GH_REPO ?= kubernetes-sigs/cluster-api-provider-cloudstack # Binaries @@ -86,7 +85,7 @@ all: build ## -------------------------------------- .PHONY: binaries -binaries: $(CONTROLLER_GEN KUSTOMIZE) $(GOLANGCI_LINT) $(STATIC_CHECK) $(GINKGO_V1) $(GINKGO_V2) $(MOCKGEN) $(KUSTOMIZE) managers # Builds and installs all binaries +binaries: $(CONTROLLER_GEN) $(GOLANGCI_LINT) $(STATIC_CHECK) $(GINKGO_V1) $(GINKGO_V2) $(MOCKGEN) $(KUSTOMIZE) managers # Builds and installs all binaries .PHONY: managers managers: @@ -247,7 +246,8 @@ cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api ## -------------------------------------- ## Tests ## -------------------------------------- -export KUBEBUILDER_ASSETS=$(REPO_ROOT)/$(TOOLS_BIN_DIR) + +export KUBEBUILDER_ASSETS=$(TOOLS_BIN_DIR) DEEPCOPY_GEN_TARGETS_TEST=$(shell find test/fakes -type d -name "fakes" -exec echo {}\/zz_generated.deepcopy.go \;) DEEPCOPY_GEN_INPUTS_TEST=$(shell find test/fakes/* -name "*zz_generated*" -prune -o -type f -print) .PHONY: generate-deepcopy-test diff --git a/common.mk b/common.mk index 5c1675ef..c3a081b9 100644 --- a/common.mk +++ b/common.mk @@ -12,16 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -include $(ROOT_DIR_RELATIVE)/versions.mk +include $(REPO_ROOT)/versions.mk # Ensure Make is run with bash shell as some syntax below is bash-specific SHELL:=bash .ONESHELL: -.SHELLFLAGS := -eu -o pipefail -c +.SHELLFLAGS := -euc # No spaces allowed in linux SHELLFLAGS, so omitting -o pipefail .DELETE_ON_ERROR: MAKEFLAGS += --no-builtin-rules -TOOLS_DIR := $(ROOT_DIR_RELATIVE)/hack/tools +TOOLS_DIR := $(REPO_ROOT)/hack/tools TOOLS_DIR_DEPS := $(TOOLS_DIR)/go.sum $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/Makefile TOOLS_BIN_DIR := $(TOOLS_DIR)/bin UID := $(shell id -u) diff --git a/docs/book/Makefile b/docs/book/Makefile index 99b00565..d9e9b970 100644 --- a/docs/book/Makefile +++ b/docs/book/Makefile @@ -12,8 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -ROOT_DIR_RELATIVE := ../.. -include $(ROOT_DIR_RELATIVE)/common.mk +export REPO_ROOT := $(shell git rev-parse --show-toplevel) + +include $(REPO_ROOT)/common.mk # Directories. MDBOOK := $(TOOLS_BIN_DIR)/mdbook diff --git a/hack/tools/Makefile b/hack/tools/Makefile index 300aebbb..00a47722 100644 --- a/hack/tools/Makefile +++ b/hack/tools/Makefile @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -ROOT_DIR_RELATIVE := ../.. -include $(ROOT_DIR_RELATIVE)/common.mk +export REPO_ROOT := $(shell git rev-parse --show-toplevel) +include $(REPO_ROOT)/common.mk UNAME := $(shell uname -s)