mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-04-10 22:12:35 +00:00
We set the VERSION variable consistently across Makefiles to 'unknown' if the file is empty or not present. We also use git commands consistently for calculating the COMMIT, COMMIT_NO variables, not erroring out when building outside of a git repository. In create_summary_file we also account for a missing/empty VERSION file. This makes e.g. the UVM build process in an environment where we build outside of git with a minimal/reduced set of files smoother. Signed-off-by: Manuel Huber <mahuber@microsoft.com>
40 lines
946 B
Makefile
40 lines
946 B
Makefile
#
|
|
# Copyright (c) 2017-2018 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
TARGET = kata-log-parser
|
|
SOURCES = $(shell find . 2>&1 | grep -E '.*\.go$$')
|
|
|
|
VERSION_FILE := ./VERSION
|
|
VERSION := $(shell grep -v ^\# $(VERSION_FILE) 2>/dev/null || echo "unknown")
|
|
COMMIT_NO := $(shell git rev-parse HEAD 2>/dev/null || true)
|
|
COMMIT := $(if $(shell git status --porcelain --untracked-files=no 2>/dev/null || true),"${COMMIT_NO}-dirty","${COMMIT_NO}")
|
|
|
|
BINDIR := $(GOPATH)/bin
|
|
DESTTARGET := $(abspath $(BINDIR)/$(TARGET))
|
|
|
|
default: install
|
|
|
|
check:
|
|
go test .
|
|
|
|
test:
|
|
go test -v .
|
|
|
|
$(TARGET): $(SOURCES) check
|
|
go build -o "$(TARGET)" -ldflags "-X main.name=${TARGET} -X main.commit=${COMMIT} -X main.version=${VERSION}" .
|
|
|
|
install: $(TARGET)
|
|
install -d $(shell dirname $(DESTTARGET))
|
|
install $(TARGET) $(DESTTARGET)
|
|
|
|
static-checks-build:
|
|
@echo "INFO: static-checks-build do nothing.."
|
|
|
|
clean:
|
|
rm -f $(TARGET)
|
|
|
|
.PHONY: test install clean
|