GO ?= go
RM ?= rm
GOFLAGS ?= -v -mod=vendor
PREFIX ?= /usr/local
BINDIR ?= bin
MANDIR ?= share/man
MKDIR ?= mkdir
CP ?= cp
SYSCONFDIR ?= /etc

VERSION = `git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION"`
COMMIT = `git rev-parse --short HEAD || echo "$COMMIT"`
BRANCH = `git rev-parse --abbrev-ref HEAD`
BUILD = `git show -s --pretty=format:%cI`

GOARCH ?= amd64
GOOS ?= linux

all: yukari

yukari:
	$(GO) build $(GOFLAGS) -o $@
clean:
	$(RM) -f yukari
install:
	$(MKDIR) -p $(DESTDIR)$(PREFIX)/$(BINDIR)
	$(MKDIR) -p $(DESTDIR)$(PREFIX)/$(MANDIR)/man1
	$(CP) -f yukari $(DESTDIR)$(PREFIX)/$(BINDIR)
	$(CP) -f yukari.1 $(DESTDIR)$(PREFIX)/$(MANDIR)/man1
test:
	go test
bench:
	go test -benchmem -bench .

.PHONY: yukari clean install
