-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (50 loc) · 1.79 KB
/
Copy pathMakefile
File metadata and controls
64 lines (50 loc) · 1.79 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
SHELL := /bin/sh
BINARY ?= cortex
CMD ?= ./cmd/cortex
DIST ?= dist
PREFIX ?= $(HOME)/.local
BINDIR ?= $(PREFIX)/bin
DESTDIR ?=
GO ?= go
CGO_ENABLED ?= 1
GOFLAGS ?=
.PHONY: all build test vet check install uninstall env run clean help bench
all: build
# Cortex uses Tree-sitter's cgo bindings. Build natively on macOS/Linux.
build:
@case "$$(uname -s)" in Darwin|Linux) ;; *) echo "Cortex currently supports native macOS and Linux builds only (Windows support is planned)." >&2; exit 1 ;; esac
@mkdir -p "$(DIST)"
CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(GOFLAGS) -trimpath -o "$(DIST)/$(BINARY)" $(CMD)
test:
$(GO) test ./...
vet:
$(GO) vet ./...
check: test vet build
install: build
install -d "$(DESTDIR)$(BINDIR)"
install -m 0755 "$(DIST)/$(BINARY)" "$(DESTDIR)$(BINDIR)/$(BINARY)"
@echo "Installed $(BINARY) to $(DESTDIR)$(BINDIR)/$(BINARY)"
uninstall:
rm -f "$(DESTDIR)$(BINDIR)/$(BINARY)"
# Print a command that updates PATH in the calling shell:
# eval "$(make env)"
env:
@printf 'export PATH="%s:$$PATH"\n' "$(BINDIR)"
run: build
"$(DIST)/$(BINARY)" $(ARGS)
clean:
rm -rf "$(DIST)"
help:
@printf '%s\n' \
'make build Build dist/cortex' \
'make test Run Go tests' \
'make vet Run go vet' \
'make check Run tests, vet, and build' \
'make install Install to $$(HOME)/.local/bin' \
'make install PREFIX=/usr/local Override install prefix' \
'make env Print a sourceable PATH export' \
'make run ARGS="version" Build and run Cortex' \
'make clean Remove build output' \
'make bench ITERATIONS=3 Run the local benchmark suite'
bench: build
$(DIST)/$(BINARY) benchmark --iterations $${ITERATIONS:-3}