| 1 |
# Copyright The containerd 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 |
|
| 16 |
# Base path used to install. |
| 17 |
DESTDIR ?= /usr/local |
| 18 |
|
| 19 |
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always) |
| 20 |
|
| 21 |
CTR_LDFLAGS=-ldflags '-X github.com/containerd/containerd/version.Version=$(VERSION)' |
| 22 |
COMMANDS=ctd-decoder ctr-enc |
| 23 |
RELEASE_COMMANDS=ctd-decoder |
| 24 |
|
| 25 |
BINARIES=$(addprefix bin/,$(COMMANDS)) |
| 26 |
RELEASE_BINARIES=$(addprefix bin/,$(RELEASE_COMMANDS)) |
| 27 |
|
| 28 |
.PHONY: check build ctd-decoder |
| 29 |
|
| 30 |
all: build |
| 31 |
|
| 32 |
build: $(BINARIES) |
| 33 |
|
| 34 |
FORCE: |
| 35 |
|
| 36 |
bin/ctd-decoder: cmd/ctd-decoder FORCE |
| 37 |
cd cmd && go build -o ../$@ -v ./ctd-decoder/ |
| 38 |
|
| 39 |
bin/ctr-enc: cmd/ctr FORCE |
| 40 |
cd cmd && go build -o ../$@ ${CTR_LDFLAGS} -v ./ctr/ |
| 41 |
|
| 42 |
check: |
| 43 |
@echo "$@" |
| 44 |
@golangci-lint run |
| 45 |
@script/check_format.sh |
| 46 |
|
| 47 |
install: |
| 48 |
@echo "$@" |
| 49 |
@mkdir -p $(DESTDIR)/bin |
| 50 |
@install $(BINARIES) $(DESTDIR)/bin |
| 51 |
|
| 52 |
containerd-release: |
| 53 |
@echo "$@" |
| 54 |
@mkdir -p $(DESTDIR)/bin |
| 55 |
@install $(RELEASE_BINARIES) $(DESTDIR)/bin |
| 56 |
|
| 57 |
uninstall: |
| 58 |
@echo "$@" |
| 59 |
@rm -f $(addprefix $(DESTDIR)/bin/,$(notdir $(BINARIES))) |
| 60 |
|
| 61 |
clean: |
| 62 |
@echo "$@" |
| 63 |
@rm -f $(BINARIES) |
| 64 |
|
| 65 |
test: |
| 66 |
@echo "$@" |
| 67 |
@go test ./... |