2016-11-05 16:43:00 +00:00
|
|
|
|
2016-11-07 14:53:24 +00:00
|
|
|
BUILD := gomtree
|
2017-01-20 15:28:19 +00:00
|
|
|
BUILDPATH := github.com/vbatts/go-mtree/cmd/gomtree
|
2016-11-07 14:53:24 +00:00
|
|
|
CWD := $(shell pwd)
|
2016-11-05 16:43:00 +00:00
|
|
|
SOURCE_FILES := $(shell find . -type f -name "*.go")
|
2016-08-25 18:17:08 +00:00
|
|
|
CLEAN_FILES := *~
|
2017-02-15 16:10:30 +00:00
|
|
|
TAGS :=
|
2016-12-08 01:39:47 +00:00
|
|
|
ARCHES := linux,386 linux,amd64 linux,arm linux,arm64 openbsd,amd64 windows,amd64 darwin,amd64
|
2020-04-02 15:49:21 +00:00
|
|
|
GO_VER := go1.14
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2017-02-15 16:10:30 +00:00
|
|
|
default: build validation
|
2016-11-05 16:43:00 +00:00
|
|
|
|
|
|
|
.PHONY: validation
|
2016-12-08 01:03:41 +00:00
|
|
|
validation: .test .lint .vet .cli.test
|
|
|
|
|
|
|
|
.PHONY: validation.tags
|
|
|
|
validation.tags: .test.tags .vet.tags .cli.test
|
2016-11-05 16:43:00 +00:00
|
|
|
|
|
|
|
.PHONY: test
|
2016-12-08 01:03:41 +00:00
|
|
|
test: .test
|
2016-08-25 18:17:08 +00:00
|
|
|
|
|
|
|
CLEAN_FILES += .test .test.tags
|
2019-01-21 17:06:24 +00:00
|
|
|
NO_VENDOR_DIR := $(shell find . -type f -name '*.go' ! -path './vendor*' ! -path './.git*' ! -path './.vscode*' -exec dirname "{}" \; | sort -u)
|
2016-11-05 16:43:00 +00:00
|
|
|
|
|
|
|
.test: $(SOURCE_FILES)
|
2019-01-21 17:06:24 +00:00
|
|
|
go test -v $(NO_VENDOR_DIR) && touch $@
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-08-25 18:17:08 +00:00
|
|
|
.test.tags: $(SOURCE_FILES)
|
2019-01-21 17:06:24 +00:00
|
|
|
set -e ; for tag in $(TAGS) ; do go test -tags $$tag -v $(NO_VENDOR_DIR) ; done && touch $@
|
2016-08-25 18:17:08 +00:00
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.PHONY: lint
|
2016-12-08 01:03:41 +00:00
|
|
|
lint: .lint
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-12-08 01:03:41 +00:00
|
|
|
CLEAN_FILES += .lint
|
2016-08-25 18:17:08 +00:00
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.lint: $(SOURCE_FILES)
|
2021-01-25 18:46:31 +00:00
|
|
|
@if [ "$(findstring $(GO_VER),$(shell go version))" != "" ] ; then \
|
2020-04-02 15:49:21 +00:00
|
|
|
set -e ; for dir in $(NO_VENDOR_DIR) ; do golint -set_exit_status $$dir ; done && touch $@ \
|
2018-11-08 16:50:04 +00:00
|
|
|
else \
|
2020-04-02 15:49:21 +00:00
|
|
|
touch $@ ; \
|
2018-11-08 16:50:04 +00:00
|
|
|
fi
|
2016-11-05 16:43:00 +00:00
|
|
|
|
|
|
|
.PHONY: vet
|
2016-12-07 21:26:04 +00:00
|
|
|
vet: .vet .vet.tags
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-12-07 21:26:04 +00:00
|
|
|
CLEAN_FILES += .vet .vet.tags
|
2016-08-25 18:17:08 +00:00
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.vet: $(SOURCE_FILES)
|
2019-01-21 17:06:24 +00:00
|
|
|
go vet $(NO_VENDOR_DIR) && touch $@
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-12-07 21:26:04 +00:00
|
|
|
.vet.tags: $(SOURCE_FILES)
|
2019-01-21 17:06:24 +00:00
|
|
|
set -e ; for tag in $(TAGS) ; do go vet -tags $$tag -v $(NO_VENDOR_DIR) ; done && touch $@
|
2016-12-07 21:26:04 +00:00
|
|
|
|
2016-11-07 14:53:24 +00:00
|
|
|
.PHONY: cli.test
|
|
|
|
cli.test: .cli.test
|
|
|
|
|
2016-12-08 01:03:41 +00:00
|
|
|
CLEAN_FILES += .cli.test .cli.test.tags
|
2016-08-25 18:17:08 +00:00
|
|
|
|
2016-11-07 14:53:24 +00:00
|
|
|
.cli.test: $(BUILD) $(wildcard ./test/cli/*.sh)
|
2016-11-22 15:57:47 +00:00
|
|
|
@go run ./test/cli.go ./test/cli/*.sh && touch $@
|
2016-11-07 14:53:24 +00:00
|
|
|
|
2016-12-08 01:03:41 +00:00
|
|
|
.cli.test.tags: $(BUILD) $(wildcard ./test/cli/*.sh)
|
|
|
|
@set -e ; for tag in $(TAGS) ; do go run -tags $$tag ./test/cli.go ./test/cli/*.sh ; done && touch $@
|
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
.PHONY: build
|
2016-11-07 14:53:24 +00:00
|
|
|
build: $(BUILD)
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2016-11-07 14:53:24 +00:00
|
|
|
$(BUILD): $(SOURCE_FILES)
|
2017-01-20 15:28:19 +00:00
|
|
|
go build -o $(BUILD) $(BUILDPATH)
|
2016-11-05 16:43:00 +00:00
|
|
|
|
2018-08-14 03:03:28 +00:00
|
|
|
install.tools:
|
2020-04-02 15:49:21 +00:00
|
|
|
@go get -u github.com/fatih/color ; \
|
2021-01-25 18:46:31 +00:00
|
|
|
if [ "$(findstring $(GO_VER),$(shell go version))" != "" ] ; then \
|
2020-04-02 15:49:21 +00:00
|
|
|
go get -u golang.org/x/lint/golint ;\
|
|
|
|
fi
|
2018-08-14 03:03:28 +00:00
|
|
|
|
2016-12-08 01:39:47 +00:00
|
|
|
./bin:
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
CLEAN_FILES += bin
|
|
|
|
|
|
|
|
build.arches: ./bin
|
|
|
|
@set -e ;\
|
|
|
|
for pair in $(ARCHES); do \
|
|
|
|
p=$$(echo $$pair | cut -d , -f 1);\
|
|
|
|
a=$$(echo $$pair | cut -d , -f 2);\
|
|
|
|
echo "Building $$p/$$a ...";\
|
2017-01-20 15:28:19 +00:00
|
|
|
GOOS=$$p GOARCH=$$a go build -o ./bin/gomtree.$$p.$$a $(BUILDPATH) ;\
|
2016-12-08 01:39:47 +00:00
|
|
|
done
|
|
|
|
|
2016-11-05 16:43:00 +00:00
|
|
|
clean:
|
2016-08-25 18:17:08 +00:00
|
|
|
rm -rf $(BUILD) $(CLEAN_FILES)
|
2016-11-05 16:43:00 +00:00
|
|
|
|