-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (31 loc) · 1.11 KB
/
Copy pathMakefile
File metadata and controls
41 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
.PHONY: build run test clean install
BINARY_NAME=cronplus
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_FLAGS=-ldflags "-s -w -X main.version=$(VERSION)"
GO_CACHE_DIR ?= $(CURDIR)/.cache/go-build
GO_MOD_CACHE_DIR ?= $(CURDIR)/.cache/go-mod
GO_ENV=GOCACHE="$(GO_CACHE_DIR)" GOMODCACHE="$(GO_MOD_CACHE_DIR)"
INSTALL_BINDIR ?= $(shell if [ -d /opt/homebrew/bin ]; then echo /opt/homebrew/bin; else echo /usr/local/bin; fi)
build:
$(GO_ENV) go build $(BUILD_FLAGS) -o $(BINARY_NAME) .
run: build
./$(BINARY_NAME)
test:
$(GO_ENV) go test ./... -v
clean:
rm -f $(BINARY_NAME)
$(GO_ENV) go clean
install: build
install -d "$(INSTALL_BINDIR)"
install -m 0755 "$(BINARY_NAME)" "$(INSTALL_BINDIR)/$(BINARY_NAME)"
@echo "Installed $(BINARY_NAME) to $(INSTALL_BINDIR)/"
uninstall:
rm -f "$(INSTALL_BINDIR)/$(BINARY_NAME)"
@echo "Removed $(BINARY_NAME) from $(INSTALL_BINDIR)/"
lint:
$(GO_ENV) go vet ./...
fmt:
gofmt -s -w .
# Development: build and run with live reload (requires entr)
dev:
find . -name '*.go' -o -name '*.html' -o -name '*.css' -o -name '*.js' | entr -r make run