sigs.k8s.io/cluster-api-provider-aws@v1.5.5/common.mk (about)

     1  # Copyright 2020 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  include $(ROOT_DIR_RELATIVE)/versions.mk
    16  
    17  # Ensure Make is run with bash shell as some syntax below is bash-specific
    18  SHELL:=bash
    19  .ONESHELL:
    20  .EXPORT_ALL_VARIABLES:
    21  .SHELLFLAGS := -eu -o pipefail -c
    22  .DELETE_ON_ERROR:
    23  MAKEFLAGS += --no-builtin-rules
    24  
    25  TOOLS_DIR := $(ROOT_DIR_RELATIVE)/hack/tools
    26  TOOLS_DIR_DEPS := $(TOOLS_DIR)/go.sum $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/Makefile
    27  TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
    28  UID := $(shell id -u)
    29  GID := $(shell id -g)
    30  
    31  rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
    32  
    33  # Hosts running SELinux need :z added to volume mounts
    34  SELINUX_ENABLED := $(shell cat /sys/fs/selinux/enforce 2> /dev/null || echo 0)
    35  
    36  ifeq ($(SELINUX_ENABLED),1)
    37    DOCKER_VOL_OPTS?=:z
    38  endif
    39  
    40  .DEFAULT_GOAL:=help
    41  
    42  # Use GOPROXY environment variable if set
    43  GOPROXY := $(shell go env GOPROXY)
    44  ifeq ($(GOPROXY),)
    45  GOPROXY := https://proxy.golang.org
    46  endif
    47  export GOPROXY
    48  
    49  $(TOOLS_BIN_DIR)/%: $(TOOLS_DIR_DEPS)
    50  	make -C $(TOOLS_DIR) $(subst $(TOOLS_DIR)/,,$@)
    51  
    52  ##@ help:
    53  
    54  help:  ## Display this help
    55  ifeq ($(OS),Windows_NT)
    56  	@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n  make <target>\n"} /^[a-zA-Z_-]+:.*?##/ { printf "  %-40s %s\n", $$1, $$2 } /^##@/ { printf "\n%s\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
    57  else
    58  	@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n  make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf "  \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
    59  endif