2019-09-30 10:53:51 -04:00
|
|
|
# Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved.
|
2020-01-21 17:00:00 +08:00
|
|
|
# syscontainer-tools is licensed under the Mulan PSL v1.
|
2019-09-30 10:53:51 -04:00
|
|
|
# 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.
|
2020-01-21 17:00:00 +08:00
|
|
|
# Description: makefile for syscontainer-tools
|
2019-09-30 10:53:51 -04:00
|
|
|
# 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)
|
|
|
|
|
|
2020-01-21 17:00:00 +08:00
|
|
|
BEP_DIR=/tmp/syscontainer-tools-build-bep
|
|
|
|
|
BEP_FLAGS=-tmpdir=/tmp/syscontainer-tools-build-bep
|
2019-09-30 10:53:51 -04:00
|
|
|
|
2020-03-12 20:11:37 +08:00
|
|
|
GO_LDFLAGS="-w -buildid=IdByiSula -extldflags -static $(BEP_FLAGS) -X main.gitCommit=${COMMIT} -X main.version=${VERSION}"
|
2019-09-30 10:53:51 -04:00
|
|
|
ENV = GOPATH=${GOPATH} CGO_ENABLED=1
|
|
|
|
|
|
|
|
|
|
## PLEASE be noticed that the vendor dir can only work with golang > 1.6 !!
|
|
|
|
|
|
2020-01-21 17:00:00 +08:00
|
|
|
all: dep syscontainer-tools syscontainer-hooks
|
2019-09-30 10:53:51 -04:00
|
|
|
dep:
|
|
|
|
|
mkdir -p $(BEP_DIR)
|
|
|
|
|
|
|
|
|
|
init:
|
|
|
|
|
sh -x apply-patch
|
|
|
|
|
|
2020-01-21 17:00:00 +08:00
|
|
|
syscontainer-tools: $(SOURCES) | $(DEPS_LINK)
|
|
|
|
|
@echo "Making syscontainer-tools..."
|
|
|
|
|
${ENV} go build -mod=vendor -tags ${TAGS} -ldflags ${GO_LDFLAGS} -o build/syscontainer-tools .
|
2019-09-30 10:53:51 -04:00
|
|
|
@echo "Done!"
|
|
|
|
|
|
2020-01-21 17:00:00 +08:00
|
|
|
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
|
2019-09-30 10:53:51 -04:00
|
|
|
@echo "Done!"
|
|
|
|
|
|
|
|
|
|
localtest:
|
|
|
|
|
go test -tags ${TAGS} -ldflags ${GO_LDFLAGS} -v ./...
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
rm -rf build
|
|
|
|
|
|
|
|
|
|
install:
|
|
|
|
|
cd hack && ./install.sh
|
|
|
|
|
|
|
|
|
|
.PHONY: test
|