Makefile 1.8 KB
Newer Older
O
overweight 已提交
1
# Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved.
2
# syscontainer-tools is licensed under the Mulan PSL v1.
O
overweight 已提交
3 4 5 6 7 8 9
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You may obtain a copy of Mulan PSL v1 at:
#    http://license.coscl.org.cn/MulanPSL
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v1 for more details.
10
# Description: makefile for syscontainer-tools
O
overweight 已提交
11 12 13 14 15 16 17 18 19
# Author: zhangwei
# Create: 2018-01-18

COMMIT=$(shell git rev-parse HEAD 2> /dev/null || true)
SOURCES := $(shell find . 2>&1 | grep -E '.*\.(c|h|go)$$')
DEPS_LINK := $(CURDIR)/vendor/
TAGS="cgo static_build"
VERSION := $(shell cat ./VERSION)

20 21
BEP_DIR=/tmp/syscontainer-tools-build-bep
BEP_FLAGS=-tmpdir=/tmp/syscontainer-tools-build-bep
O
overweight 已提交
22

23
GO_LDFLAGS="-w -buildid=IdByiSula -extldflags -static $(BEP_FLAGS) -X main.gitCommit=${COMMIT} -X main.version=${VERSION}"
O
overweight 已提交
24 25 26 27
ENV = GOPATH=${GOPATH} CGO_ENABLED=1

## PLEASE be noticed that the vendor dir can only work with golang > 1.6 !!

28
all: dep syscontainer-tools syscontainer-hooks
O
overweight 已提交
29 30 31 32 33 34
dep:
	mkdir -p $(BEP_DIR)

init:
	sh -x apply-patch

35 36 37
syscontainer-tools: $(SOURCES) | $(DEPS_LINK)
	@echo "Making syscontainer-tools..."
	${ENV} go build -mod=vendor -tags ${TAGS} -ldflags ${GO_LDFLAGS} -o build/syscontainer-tools .
O
overweight 已提交
38 39
	@echo "Done!"

40 41 42
syscontainer-hooks: $(SOURCES) | $(DEPS_LINK)
	@echo "Making syscontainer-hooks..."
	${ENV} go build -mod=vendor -tags ${TAGS} -ldflags ${GO_LDFLAGS} -o build/syscontainer-hooks ./hooks/syscontainer-hooks
O
overweight 已提交
43 44 45 46 47 48 49 50 51 52 53 54
	@echo "Done!"

localtest:
	go test -tags ${TAGS} -ldflags ${GO_LDFLAGS} -v ./...

clean:
	rm -rf build

install:
	cd hack && ./install.sh

.PHONY: test