2020-07-27 10:19:35 +00:00
|
|
|
#-include .env
|
|
|
|
|
|
|
|
VERSION := $(shell git describe --tags)
|
|
|
|
BUILD := $(shell git rev-parse --short HEAD)
|
|
|
|
PROJECTNAME := $(shell basename "$(PWD)")
|
|
|
|
|
|
|
|
# Use linker flags to provide version/build settings
|
2020-09-27 19:23:47 +00:00
|
|
|
LDFLAGS=-X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -linkmode external
|
2020-07-27 10:19:35 +00:00
|
|
|
|
|
|
|
# Make is verbose in Linux. Make it silent.
|
|
|
|
MAKEFLAGS += --silent
|
|
|
|
|
|
|
|
## run: run from code.
|
|
|
|
run:
|
|
|
|
go run cmd/distribyted/main.go examples/conf_example.yaml
|
|
|
|
|
|
|
|
## build: build binary.
|
|
|
|
build: go-generate go-build
|
|
|
|
|
|
|
|
## test: execute all tests.
|
|
|
|
test:
|
2020-09-27 19:23:47 +00:00
|
|
|
go test -v --race -coverprofile=coverage.out ./...
|
2020-07-27 10:19:35 +00:00
|
|
|
|
|
|
|
compile: go-generate go-compile
|
|
|
|
|
|
|
|
go-build:
|
|
|
|
@echo " > Building binary..."
|
2020-09-27 19:23:47 +00:00
|
|
|
go build -o bin/distribyted -tags "release" cmd/distribyted/main.go
|
2020-07-27 10:19:35 +00:00
|
|
|
|
|
|
|
go-generate:
|
|
|
|
@echo " > Generating code files..."
|
|
|
|
go generate ./...
|
|
|
|
|
|
|
|
go-compile:
|
2020-10-28 18:11:37 +00:00
|
|
|
GOPATH=~/go
|
|
|
|
ORGPATH=$(GOPATH)/src/github.com/distribyted
|
|
|
|
REPOPATH=$(ORGPATH)/distribyted
|
|
|
|
|
2020-07-27 10:19:35 +00:00
|
|
|
@echo " > Compiling for several platforms..."
|
2020-10-18 18:44:45 +00:00
|
|
|
go install src.techknowlogick.com/xgo
|
2020-10-18 18:14:32 +00:00
|
|
|
docker build ./build_tools/ -t distribyted/xgo-cgofuse
|
2020-09-27 19:23:47 +00:00
|
|
|
mkdir -p $(ORGPATH)
|
|
|
|
ln -sfrnT . $(REPOPATH)
|
|
|
|
|
|
|
|
@echo " > Compiling for windows..."
|
2020-10-18 18:14:32 +00:00
|
|
|
GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=distribyted/xgo-cgofuse -ldflags='-extldflags "-static" $(LDFLAGS)' -tags="release" -targets=windows/amd64 $(REPOPATH)/cmd/distribyted/
|
2020-09-27 19:23:47 +00:00
|
|
|
@echo " > Compiling for linux..."
|
2020-10-18 18:14:32 +00:00
|
|
|
GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=distribyted/xgo-cgofuse -ldflags='$(LDFLAGS)' -tags="release" -targets=linux/arm-7,linux/amd64 $(REPOPATH)/cmd/distribyted/
|
|
|
|
# @echo " > Compiling for darwin..."
|
|
|
|
# GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=distribyted/xgo-cgofuse -ldflags='$(LDFLAGS)' -tags="release" -targets=darwin/* $(REPOPATH)/cmd/distribyted/
|
2020-07-27 10:19:35 +00:00
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
all: help
|
|
|
|
help: Makefile
|
|
|
|
@echo
|
|
|
|
@echo " Choose a command run in "$(PROJECTNAME)":"
|
|
|
|
@echo
|
|
|
|
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
|
2020-10-28 18:11:37 +00:00
|
|
|
@echo
|