refactor: reorganize project in order to include automation #1

Merged
Emmanuel BENOîT merged 19 commits from :master into master 2024-07-19 22:01:35 +02:00
Showing only changes of commit d604d83c72 - Show all commits

View file

@ -4,13 +4,13 @@ DISTDIR = $(CURDIR)/dist
TARGETS = linux/amd64 linux/386 linux/arm linux/arm64
STATICFILES = README.md LICENSE
SRC := $(shell find . -type f -name '*.go' -print) go.mod go.sum
SRC := $(shell find . -type f -name '*.go' -not -path './dist/*' -print) go.mod go.sum
GOHOSTOS = $(shell go env GOHOSTOS)
GOHOSTARCH ?= $(shell go env GOHOSTARCH)
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
GIT_COMMIT = $(shell git rev-parse --short HEAD 2>/dev/null)
GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
GIT_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null)
GIT_STATUS ?= $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
ifneq ($(VERSION),)
BINARY_VERSION = $(VERSION)
@ -70,11 +70,32 @@ dist: GOARCH=$(GOHOSTARCH)
dist: dist-target
.PHONY: dist-all
dist-all:
dist-all: dist-source
@for target in $(TARGETS); do \
$(MAKE) dist-target GOOS=`echo $$target | cut -d / -f 1` GOARCH=`echo $$target | cut -d / -f 2`; \
done
.PHONY: dist-source
dist-source:
@set -e; \
if [ -z "$(BINARY_VERSION)" ]; then \
echo "No version set"; \
exit 1; \
fi; \
rm -rf $(DISTDIR)/$(BINNAME)-$(BINARY_VERSION); \
mkdir -p $(DISTDIR)/$(BINNAME)-$(BINARY_VERSION); \
for f in $(SRC) $(STATICFILES); do \
install -m 644 -D $$f $(DISTDIR)/$(BINNAME)-$(BINARY_VERSION)/$$f; \
done; \
( \
echo "VERSION = ${BINARY_VERSION}"; \
echo "GIT_COMMIT = ${GIT_COMMIT}"; \
echo "GIT_STATUS = ${GIT_STATUS}"; \
cat Makefile; \
) > $(DISTDIR)/$(BINNAME)-$(BINARY_VERSION)/Makefile; \
cd $(DISTDIR); \
tar cJf $(BINNAME)-$(BINARY_VERSION).tar.xz $(BINNAME)-$(BINARY_VERSION)
.PHONY: dist-target
dist-target: build-target
@set -e; \
@ -82,6 +103,7 @@ dist-target: build-target
echo "No version set"; \
exit 1; \
fi; \
rm -rf $(DISTDIR)/$(BINNAME)-$(BINARY_VERSION)-$(GOOS)-$(GOARCH); \
mkdir -p $(DISTDIR)/$(BINNAME)-$(BINARY_VERSION)-$(GOOS)-$(GOARCH); \
cp $(BINDIR)/$(GOOS)-$(GOARCH)/$(BINNAME) $(DISTDIR)/$(BINNAME)-$(BINARY_VERSION)-$(GOOS)-$(GOARCH); \
for f in $(STATICFILES); do \