2018-02-18 16:46:54 +01:00
|
|
|
.PHONY: generate build test vet cover release docs docs-clean clean vendordeps
|
2017-11-12 21:41:34 +01:00
|
|
|
.DEFAULT_GOAL := build
|
2017-09-30 16:40:39 +02:00
|
|
|
|
|
|
|
ROOT := github.com/zrepl/zrepl
|
2018-09-05 02:02:16 +02:00
|
|
|
SUBPKGS += client
|
|
|
|
SUBPKGS += config
|
|
|
|
SUBPKGS += daemon
|
|
|
|
SUBPKGS += daemon/filters
|
|
|
|
SUBPKGS += daemon/job
|
|
|
|
SUBPKGS += daemon/logging
|
|
|
|
SUBPKGS += daemon/nethelpers
|
|
|
|
SUBPKGS += daemon/pruner
|
|
|
|
SUBPKGS += daemon/snapper
|
|
|
|
SUBPKGS += daemon/streamrpcconfig
|
2018-10-13 16:00:13 +02:00
|
|
|
SUBPKGS += daemon/transport
|
|
|
|
SUBPKGS += daemon/transport/connecter
|
|
|
|
SUBPKGS += daemon/transport/serve
|
2018-09-05 02:02:16 +02:00
|
|
|
SUBPKGS += endpoint
|
|
|
|
SUBPKGS += logger
|
|
|
|
SUBPKGS += pruning
|
2018-09-24 17:30:03 +02:00
|
|
|
SUBPKGS += pruning/retentiongrid
|
2018-08-26 14:35:18 +02:00
|
|
|
SUBPKGS += replication
|
|
|
|
SUBPKGS += replication/fsrep
|
|
|
|
SUBPKGS += replication/pdu
|
|
|
|
SUBPKGS += replication/internal/queue
|
|
|
|
SUBPKGS += replication/internal/diff
|
2018-09-05 02:02:16 +02:00
|
|
|
SUBPKGS += tlsconf
|
|
|
|
SUBPKGS += util
|
|
|
|
SUBPKGS += version
|
|
|
|
SUBPKGS += zfs
|
2017-09-30 16:40:39 +02:00
|
|
|
|
|
|
|
_TESTPKGS := $(ROOT) $(foreach p,$(SUBPKGS),$(ROOT)/$(p))
|
|
|
|
|
|
|
|
ARTIFACTDIR := artifacts
|
|
|
|
|
2017-11-18 20:34:28 +01:00
|
|
|
ifndef ZREPL_VERSION
|
|
|
|
ZREPL_VERSION := $(shell git describe --dirty 2>/dev/null || echo "ZREPL_BUILD_INVALID_VERSION" )
|
|
|
|
ifeq ($(ZREPL_VERSION),ZREPL_BUILD_INVALID_VERSION) # can't use .SHELLSTATUS because Debian Stretch is still on gmake 4.1
|
|
|
|
$(error cannot infer variable ZREPL_VERSION using git and variable is not overriden by make invocation)
|
|
|
|
endif
|
|
|
|
endif
|
2018-08-26 21:57:19 +02:00
|
|
|
GO_LDFLAGS := "-X github.com/zrepl/zrepl/version.zreplVersion=$(ZREPL_VERSION)"
|
2017-11-18 20:34:28 +01:00
|
|
|
|
|
|
|
GO_BUILD := go build -ldflags $(GO_LDFLAGS)
|
|
|
|
|
2018-02-18 16:46:54 +01:00
|
|
|
RELEASE_BINS := $(ARTIFACTDIR)/zrepl-freebsd-amd64 $(ARTIFACTDIR)/zrepl-linux-amd64
|
|
|
|
RELEASE_NOARCH := $(ARTIFACTDIR)/zrepl-noarch.tar
|
2017-12-27 13:48:28 +01:00
|
|
|
THIS_PLATFORM_RELEASE_BIN := $(shell bash -c 'source <(go env) && echo "zrepl-$${GOOS}-$${GOARCH}"' )
|
|
|
|
|
2017-11-19 12:32:25 +01:00
|
|
|
vendordeps:
|
|
|
|
dep ensure -v -vendor-only
|
|
|
|
|
2017-11-12 16:15:12 +01:00
|
|
|
generate: #not part of the build, must do that manually
|
2018-08-26 14:35:18 +02:00
|
|
|
protoc -I=replication/pdu --go_out=replication/pdu replication/pdu/pdu.proto
|
2017-09-30 16:40:39 +02:00
|
|
|
@for pkg in $(_TESTPKGS); do\
|
|
|
|
go generate "$$pkg" || exit 1; \
|
|
|
|
done;
|
|
|
|
|
2017-11-12 16:15:12 +01:00
|
|
|
build:
|
2017-11-19 12:32:25 +01:00
|
|
|
@echo "INFO: In case of missing dependencies, run 'make vendordeps'"
|
|
|
|
$(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl"
|
2017-11-12 16:15:12 +01:00
|
|
|
|
2017-09-30 16:40:39 +02:00
|
|
|
test:
|
|
|
|
@for pkg in $(_TESTPKGS); do \
|
|
|
|
echo "Testing $$pkg"; \
|
|
|
|
go test "$$pkg" || exit 1; \
|
|
|
|
done;
|
|
|
|
|
|
|
|
vet:
|
|
|
|
@for pkg in $(_TESTPKGS); do \
|
|
|
|
echo "Vetting $$pkg"; \
|
|
|
|
go vet "$$pkg" || exit 1; \
|
|
|
|
done;
|
|
|
|
|
|
|
|
cover: artifacts
|
|
|
|
@for pkg in $(_TESTPKGS); do \
|
|
|
|
profile="$(ARTIFACTDIR)/cover-$$(basename $$pkg).out"; \
|
|
|
|
go test -coverprofile "$$profile" $$pkg || exit 1; \
|
|
|
|
if [ -f "$$profile" ]; then \
|
|
|
|
go tool cover -html="$$profile" -o "$${profile}.html" || exit 2; \
|
|
|
|
fi; \
|
|
|
|
done;
|
|
|
|
|
2017-11-18 16:20:14 +01:00
|
|
|
$(ARTIFACTDIR):
|
|
|
|
mkdir -p "$@"
|
2017-09-30 16:40:39 +02:00
|
|
|
|
2017-11-18 16:21:53 +01:00
|
|
|
$(ARTIFACTDIR)/docs: $(ARTIFACTDIR)
|
|
|
|
mkdir -p "$@"
|
|
|
|
|
2018-02-18 16:46:54 +01:00
|
|
|
$(ARTIFACTDIR)/bash_completion: $(RELEASE_BINS)
|
2017-12-27 13:48:28 +01:00
|
|
|
artifacts/$(THIS_PLATFORM_RELEASE_BIN) bashcomp "$@"
|
|
|
|
|
2018-02-18 16:46:54 +01:00
|
|
|
$(ARTIFACTDIR)/go_version.txt:
|
|
|
|
go version > $@
|
|
|
|
|
2017-11-18 16:21:53 +01:00
|
|
|
docs: $(ARTIFACTDIR)/docs
|
|
|
|
make -C docs \
|
|
|
|
html \
|
|
|
|
BUILDDIR=../artifacts/docs \
|
|
|
|
|
|
|
|
docs-clean:
|
|
|
|
make -C docs \
|
|
|
|
clean \
|
|
|
|
BUILDDIR=../artifacts/docs
|
|
|
|
|
2017-09-30 16:40:39 +02:00
|
|
|
|
2018-02-18 16:46:54 +01:00
|
|
|
.PHONY: $(RELEASE_BINS)
|
|
|
|
# TODO: two wildcards possible
|
|
|
|
$(RELEASE_BINS): $(ARTIFACTDIR)/zrepl-%-amd64: generate $(ARTIFACTDIR) vet test
|
|
|
|
@echo "INFO: In case of missing dependencies, run 'make vendordeps'"
|
|
|
|
GOOS=$* GOARCH=amd64 $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-$*-amd64"
|
|
|
|
|
|
|
|
$(RELEASE_NOARCH): docs $(ARTIFACTDIR)/bash_completion $(ARTIFACTDIR)/go_version.txt
|
|
|
|
tar --mtime='1970-01-01' --sort=name \
|
|
|
|
--transform 's/$(ARTIFACTDIR)/zrepl-$(ZREPL_VERSION)-noarch/' \
|
|
|
|
-acf $@ \
|
|
|
|
$(ARTIFACTDIR)/docs/html \
|
|
|
|
$(ARTIFACTDIR)/bash_completion \
|
|
|
|
$(ARTIFACTDIR)/go_version.txt
|
|
|
|
|
|
|
|
release: $(RELEASE_BINS) $(RELEASE_NOARCH)
|
|
|
|
rm -rf "$(ARTIFACTDIR)/release"
|
|
|
|
mkdir -p "$(ARTIFACTDIR)/release"
|
|
|
|
cp $^ "$(ARTIFACTDIR)/release"
|
|
|
|
cd "$(ARTIFACTDIR)/release" && sha512sum $$(ls | sort) > sha512sum.txt
|
2017-12-29 22:32:21 +01:00
|
|
|
@if echo "$(ZREPL_VERSION)" | grep dirty > /dev/null; then\
|
|
|
|
echo '[WARN] Do not publish the artifacts, make variable ZREPL_VERSION=$(ZREPL_VERSION) indicates they are dirty!'; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2017-11-18 20:34:28 +01:00
|
|
|
|
2017-11-18 16:21:53 +01:00
|
|
|
clean: docs-clean
|
2017-09-30 16:40:39 +02:00
|
|
|
rm -rf "$(ARTIFACTDIR)"
|