54 lines
1.6 KiB
Makefile
54 lines
1.6 KiB
Makefile
SHELL = /bin/bash
|
|
.PHONY: all version path deps run race build clean test format docs
|
|
.SILENT: clean
|
|
|
|
VERSION := $(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --dirty --always)
|
|
PROGRAM := $(notdir $(CURDIR))
|
|
|
|
all: docs
|
|
|
|
# show the current version
|
|
version:
|
|
@echo $(VERSION)
|
|
|
|
path:
|
|
./misc/make-path.sh
|
|
|
|
deps:
|
|
./misc/make-deps.sh
|
|
|
|
run:
|
|
find -maxdepth 1 -type f -name '*.go' -not -name '*_test.go' | xargs go run -ldflags "-X main.version=$(VERSION) -X main.program=$(PROGRAM)"
|
|
|
|
# include race flag
|
|
race:
|
|
find -maxdepth 1 -type f -name '*.go' -not -name '*_test.go' | xargs go run -race -ldflags "-X main.version=$(VERSION) -X main.program=$(PROGRAM)"
|
|
|
|
build: mgmt
|
|
|
|
mgmt: main.go
|
|
@echo "Building: $(PROGRAM), version: $(VERSION)."
|
|
go generate
|
|
# avoid equals sign in old golang versions eg in: -X foo=bar
|
|
if go version | grep -qE 'go1.3|go1.4'; then \
|
|
go build -ldflags "-X main.version $(VERSION) -X main.program $(PROGRAM)"; \
|
|
else \
|
|
go build -ldflags "-X main.version=$(VERSION) -X main.program=$(PROGRAM)"; \
|
|
fi
|
|
|
|
clean:
|
|
[ ! -e mgmt ] || rm mgmt
|
|
rm -f *_stringer.go # generated by `go generate`
|
|
|
|
test:
|
|
./test.sh
|
|
|
|
format:
|
|
find -type f -name '*.go' -not -path './old/*' -not -path './tmp/*' -exec gofmt -w {} \;
|
|
find -type f -name '*.yaml' -not -path './old/*' -not -path './tmp/*' -not -path './omv.yaml' -exec ruby -e "require 'yaml'; x=YAML.load_file('{}').to_yaml.each_line.map(&:rstrip).join(10.chr)+10.chr; File.open('{}', 'w').write x" \;
|
|
|
|
docs: mgmt-documentation.pdf
|
|
|
|
mgmt-documentation.pdf: DOCUMENTATION.md
|
|
pandoc DOCUMENTATION.md -o 'mgmt-documentation.pdf'
|