feta/Makefile

42 lines
944 B
Makefile

VERSION := $(shell git rev-parse --short HEAD)
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ')
BUILDUSER := $(shell whoami)
BUILDHOST := $(shell hostname -s)
BUILDARCH := $(shell uname -m)
FN := fediverse-archive
IMAGENAME := sneak/$(FN)
GOLDFLAGS += -X main.Version=$(VERSION)
GOLDFLAGS += -X main.Buildtime=$(BUILDTIME)
GOLDFLAGS += -X main.Builduser=$(BUILDUSER)@$(BUILDHOST)
GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
GOFLAGS = -ldflags "$(GOLDFLAGS)"
default: rundebug
rundebug: build
./$(FN) -debug
run: build
./$(FN)
build: ./$(FN)
./$(FN): *.go
go build -o $@ $(GOFLAGS) .
fmt:
go fmt *.go
test: build-docker-image
build-docker-image:
docker build -t $(IMAGENAME) .
dist: build-docker-image
-mkdir -p ./output
docker run --rm --entrypoint cat $(IMAGENAME) /bin/$(FN) > output/$(FN)
docker save $(IMAGENAME) | bzip2 > output/$(BUILDTIMEFILENAME).$(FN).tbz2