|
1 |
| -BINDIR ?= $(CURDIR)/bin |
2 |
| -ARCH ?= amd64 |
| 1 | +# Copyright 2023 The cert-manager 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. |
3 | 14 |
|
4 |
| -help: ## display this help |
5 |
| - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) |
| 15 | +# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. |
| 16 | +# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/Makefile instead. |
6 | 17 |
|
7 |
| -.PHONY: help build image all clean |
| 18 | +# NOTE FOR DEVELOPERS: "How do the Makefiles work and how can I extend them?" |
| 19 | +# |
| 20 | +# Shared Makefile logic lives in the make/_shared/ directory. The source of truth for these files |
| 21 | +# lies outside of this repository, eg. in the cert-manager/makefile-modules repository. |
| 22 | +# |
| 23 | +# Logic specific to this repository must be defined in the make/00_mod.mk and make/02_mod.mk files: |
| 24 | +# - The make/00_mod.mk file is included first and contains variable definitions needed by |
| 25 | +# the shared Makefile logic. |
| 26 | +# - The make/02_mod.mk file is included later, it can make use of most of the shared targets |
| 27 | +# defined in the make/_shared/ directory (all targets defined in 00_mod.mk and 01_mod.mk). |
| 28 | +# This file should be used to define targets specific to this repository. |
8 | 29 |
|
9 |
| -deps: ## Download all Dependencies |
10 |
| - go mod download |
| 30 | +################################## |
11 | 31 |
|
12 |
| -test: deps ## test version-checker |
13 |
| - go test ./... -coverprofile=coverage.out |
| 32 | +# Some modules build their dependencies from variables, we want these to be |
| 33 | +# evalutated at the last possible moment. For this we use second expansion to |
| 34 | +# re-evaluate the generate and verify targets a second time. |
| 35 | +# |
| 36 | +# See https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html |
| 37 | +.SECONDEXPANSION: |
14 | 38 |
|
15 |
| -$(BINDIR): |
16 |
| - mkdir -p $(BINDIR) |
| 39 | +# For details on some of these "prelude" settings, see: |
| 40 | +# https://clarkgrubb.com/makefile-style-guide |
| 41 | +MAKEFLAGS += --warn-undefined-variables --no-builtin-rules |
| 42 | +SHELL := /usr/bin/env bash |
| 43 | +.SHELLFLAGS := -uo pipefail -c |
| 44 | +.DEFAULT_GOAL := help |
| 45 | +.DELETE_ON_ERROR: |
| 46 | +.SUFFIXES: |
| 47 | +FORCE: |
17 | 48 |
|
18 |
| -build: deps $(BINDIR) ## build version-checker |
19 |
| - CGO_ENABLED=0 go build -o ./bin/version-checker ./cmd/. |
| 49 | +noop: # do nothing |
20 | 50 |
|
21 |
| -verify: test build ## tests and builds version-checker |
| 51 | +# Set empty value for MAKECMDGOALS to prevent the "warning: undefined variable 'MAKECMDGOALS'" |
| 52 | +# warning from happening when running make without arguments |
| 53 | +MAKECMDGOALS ?= |
22 | 54 |
|
23 | 55 | image: ## build docker image
|
24 | 56 | GOARCH=$(ARCH) GOOS=linux CGO_ENABLED=0 go build -o ./bin/version-checker-linux ./cmd/.
|
25 | 57 | docker build -t quay.io/jetstack/version-checker:v0.9.0 .
|
26 | 58 |
|
27 |
| -clean: ## clean up created files |
28 |
| - rm -rf \ |
29 |
| - $(BINDIR) |
| 59 | +################################## |
| 60 | +# Host OS and architecture setup # |
| 61 | +################################## |
30 | 62 |
|
31 |
| -all: test build image ## runs test, build and image |
| 63 | +# The reason we don't use "go env GOOS" or "go env GOARCH" is that the "go" |
| 64 | +# binary may not be available in the PATH yet when the Makefiles are |
| 65 | +# evaluated. HOST_OS and HOST_ARCH only support Linux, *BSD and macOS (M1 |
| 66 | +# and Intel). |
| 67 | +host_os := $(shell uname -s | tr A-Z a-z) |
| 68 | +host_arch := $(shell uname -m) |
| 69 | +HOST_OS ?= $(host_os) |
| 70 | +HOST_ARCH ?= $(host_arch) |
| 71 | + |
| 72 | +ifeq (x86_64, $(HOST_ARCH)) |
| 73 | + HOST_ARCH = amd64 |
| 74 | +else ifeq (aarch64, $(HOST_ARCH)) |
| 75 | + # linux reports the arm64 arch as aarch64 |
| 76 | + HOST_ARCH = arm64 |
| 77 | +endif |
| 78 | + |
| 79 | +################################## |
| 80 | +# Git and versioning information # |
| 81 | +################################## |
| 82 | + |
| 83 | +git_version := $(shell git describe --tags --always --match='v*' --abbrev=14 --dirty) |
| 84 | +VERSION ?= $(git_version) |
| 85 | +IS_PRERELEASE := $(shell git describe --tags --always --match='v*' --abbrev=0 | grep -q '-' && echo true || echo false) |
| 86 | +GITCOMMIT := $(shell git rev-parse HEAD) |
| 87 | +GITEPOCH := $(shell git show -s --format=%ct HEAD) |
| 88 | + |
| 89 | +################################## |
| 90 | +# Global variables and dirs # |
| 91 | +################################## |
| 92 | + |
| 93 | +bin_dir := _bin |
| 94 | + |
| 95 | +# The ARTIFACTS environment variable is set by the CI system to a directory |
| 96 | +# where artifacts should be placed. These artifacts are then uploaded to a |
| 97 | +# storage bucket by the CI system (https://docs.prow.k8s.io/docs/components/pod-utilities/). |
| 98 | +# An example of such an artifact is a jUnit XML file containing test results. |
| 99 | +# If the ARTIFACTS environment variable is not set, we default to a local |
| 100 | +# directory in the _bin directory. |
| 101 | +ARTIFACTS ?= $(bin_dir)/artifacts |
| 102 | + |
| 103 | +$(bin_dir) $(ARTIFACTS) $(bin_dir)/scratch: |
| 104 | + mkdir -p $@ |
| 105 | + |
| 106 | +.PHONY: clean |
| 107 | +## Clean all temporary files |
| 108 | +## @category [shared] Tools |
| 109 | +clean: |
| 110 | + rm -rf $(bin_dir) |
| 111 | + |
| 112 | +################################## |
| 113 | +# Include all the Makefiles # |
| 114 | +################################## |
| 115 | + |
| 116 | +-include make/00_mod.mk |
| 117 | +-include make/_shared/*/00_mod.mk |
| 118 | +-include make/_shared/*/01_mod.mk |
| 119 | +-include make/02_mod.mk |
| 120 | +-include make/_shared/*/02_mod.mk |
0 commit comments