-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (45 loc) · 1.54 KB
/
Makefile
File metadata and controls
60 lines (45 loc) · 1.54 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
BINARY := mkprompt
REF_NAME ?= $(shell git describe --tags --always --dirty)
DESTDIR ?= /usr
EXTRA_LDFLAGS ?=
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
ARCHIVE := $(BINARY)-$(REF_NAME)-$(GOOS)-$(GOARCH).tar.gz
MANPAGE_SRC := man/mkprompt.1.adoc
MANPAGE := man/mkprompt.1
LDFLAGS := $(EXTRA_LDFLAGS)
LDFLAGS += -X 'github.com/Soft/mkprompt/internal/constants.Version=$(REF_NAME)'
LDFLAGS += -X 'github.com/Soft/mkprompt/internal/constants.DestDir=$(DESTDIR)'
.PHONY: all generate build test lint install archive clean download-assets man
all: build man
generate:
GOOS= GOARCH= go generate ./...
build: generate
go build \
-ldflags="$(LDFLAGS)" \
-o $(BINARY) \
./cmd/mkprompt
test: generate
go test -v ./...
lint: generate
go vet ./...
man: $(MANPAGE)
$(MANPAGE): $(MANPAGE_SRC)
asciidoctor -b manpage -o $@ $<
install: man
install -m 755 -D -t $(DESTDIR)/bin $(BINARY)
install -m 644 -D -t $(DESTDIR)/share/man/man1 $(MANPAGE)
install -m 644 -D -t $(DESTDIR)/share/$(BINARY)/shell shell/*
install -m 644 -D -t $(DESTDIR)/lib/$(BINARY)/std lib/std/*
install -m 644 -D -t $(DESTDIR)/share/doc/$(BINARY) README.md LICENSE
install -m 644 -D -t $(DESTDIR)/share/doc/$(BINARY)/examples examples/*
archive: build
$(eval STAGEDIR := $(shell mktemp -d))
$(MAKE) build
$(MAKE) install DESTDIR=$(STAGEDIR)
tar -czvf $(ARCHIVE) -C $(STAGEDIR) .
rm -rf $(STAGEDIR)
download-assets:
curl -o assets/glyphnames.json https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/glyphnames.json
clean:
rm -f $(BINARY) $(MANPAGE) *.tar.gz