Makefile 1.6 KB
Newer Older
S
stormgbs 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
# Root directory of the project (absolute path).
ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

# Base path used to install.
DESTDIR ?= /usr/local

ifneq "$(strip $(shell command -v go 2>/dev/null))" ""
	GOOS ?= $(shell go env GOOS)
	GOARCH ?= $(shell go env GOARCH)
else
	ifeq ($(GOOS),)
		# approximate GOOS for the platform if we don't have Go and GOOS isn't
		# set. We leave GOARCH unset, so that may need to be fixed.
		ifeq ($(OS),Windows_NT)
			GOOS = windows
		else
			UNAME_S := $(shell uname -s)
			ifeq ($(UNAME_S),Linux)
				GOOS = linux
			endif
			ifeq ($(UNAME_S),Darwin)
				GOOS = darwin
			endif
			ifeq ($(UNAME_S),FreeBSD)
				GOOS = freebsd
			endif
		endif
	else
		GOOS ?= $$GOOS
		GOARCH ?= $$GOARCH
	endif
endif

# Project binaries.
COMMANDS=containerd-shim-rune-v2

GO_BUILD_FLAGS=
SHIM_CGO_ENABLED ?= 0

BINARIES=$(addprefix bin/,$(COMMANDS))

J
jiazhiguang 已提交
42
.PHONY: clean all binaries help install uninstall rpm
S
stormgbs 已提交
43 44 45 46 47 48 49 50 51
.DEFAULT: default

all: binaries

# Build a binary from a cmd.
bin/containerd-shim-rune-v2:
	@echo "bin/containerd-shim-rune-v2"
	@CGO_ENABLED=${SHIM_CGO_ENABLED} GOOS=${GOOS} go build ${GO_BUILD_FLAGS} -o bin/containerd-shim-rune-v2 ./cmd/containerd-shim-rune-v2

J
jiazhiguang 已提交
52
binaries: clean $(BINARIES) ## build binaries
S
stormgbs 已提交
53 54 55 56

clean: ## clean up binaries
	@echo "$@"
	@rm -f $(BINARIES)
J
jiazhiguang 已提交
57 58

rpm:
H
hustliyilin 已提交
59
	$(MAKE) -C dist rpm
S
stormgbs 已提交
60 61 62 63 64 65 66 67 68 69 70 71

install: ## install binaries
	@echo "$@ $(BINARIES)"
	@mkdir -p $(DESTDIR)/bin
	@install $(BINARIES) $(DESTDIR)/bin

uninstall:
	@echo "$@"
	@rm -f $(addprefix $(DESTDIR)/bin/,$(notdir $(BINARIES)))

help: ## this help
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort