BIN := find-and-enflac
PREFIX := $(HOME)

.PHONY: default install build check test lint fmt fmt-check clean

default: install

install: build
	install -d $(PREFIX)/bin
	install -m 0755 $(BIN) $(PREFIX)/bin/$(BIN)

build:
	go build -o $(BIN) .

check: fmt-check lint test

test:
	go test ./...

lint:
	go vet ./...

fmt:
	gofmt -s -w .

fmt-check:
	@out="$$(gofmt -s -l .)"; \
	if [ -n "$$out" ]; then \
		echo "unformatted files:"; echo "$$out"; exit 1; \
	fi

clean:
	rm -f $(BIN)
