ecload/Makefile

47 lines
1.1 KiB
Makefile
Raw Normal View History

2019-05-29 16:35:50 +00:00
BINARIES=ecload ecload-tui
2019-05-29 16:35:50 +00:00
VERSION=0.1.0
BUILD:=`git rev-parse HEAD`
PLATFORMS=linux darwin windows
ARCHITECTURES=386 amd64
LDFLAGS=-ldflags "-s -X main.Version=${VERSION} -X main.Build=${BUILD}"
define BUILDER
bin/%/$(TARGET): cmd/$(TARGET)/*.go pkg/ecload/*.go
GOOS=$$(patsubst %/,%,$$(dir $$*)) GOARCH=$$(notdir $$*) go build $(LDFLAGS) -v -o $$@ cmd/$(TARGET)/main.go
endef
$(foreach TARGET,$(BINARIES),$(eval $(BUILDER)))
dist/%.tar.gz:
@mkdir -p ./dist
2019-05-27 15:11:33 +00:00
2019-05-29 16:35:50 +00:00
$(eval TMP := $(shell mktemp -d))
2019-05-27 15:11:33 +00:00
2019-05-29 16:35:50 +00:00
$(eval SANE=$(subst -,/,$*))
$(eval INPUT=bin/$(SANE)/)
$(eval PLATFORM=$(patsubst %/,%,$(dir $(SANE))))
2019-05-27 15:11:33 +00:00
2019-05-29 16:35:50 +00:00
@cp -r $(INPUT)* $(TMP)
2019-05-28 14:35:01 +00:00
2019-05-29 16:35:50 +00:00
@if [ "$(PLATFORM)" == "windows" ]; then \
for FILE in $(TMP)/*; do mv $$FILE $$FILE.exe; done \
fi
2019-05-28 14:35:01 +00:00
2019-05-29 16:35:50 +00:00
tar -zcf $@ -C $(TMP) .
@rm -rf $(TMP)
dist: binaries $(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), dist/$(GOOS)-$(GOARCH).tar.gz))
binaries: $(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), $(foreach BINARY, $(BINARIES), bin/$(GOOS)/$(GOARCH)/$(BINARY))))
all: dist
clean:
rm -rf bin/ dist/
go clean ./cmd/ecload ./cmd/ecload-tui ./pkg/ecload
2019-05-28 14:35:01 +00:00
2019-05-29 16:35:50 +00:00
.PHONY: all clean binaries dist