kpaste

git clone git://git.lin.moe/go/kpaste.git

 1APP_BIN = kpaste
 2
 3PREFIX ?= /usr/local
 4BINDIR ?= $(PREFIX)/bin
 5
 6AIR_PACKAGE ?= github.com/air-verse/air@v1
 7GOFLAGS := -buildmode=pie -modcacherw -trimpath -buildvcs=false
 8GO_TAGS := fts5
 9
10ifeq "$(shell pkg-config sqlite3; echo $$?)" "0"
11	GO_TAGS += libsqlite3
12endif
13
14space := $(subst ,, )
15comma=,
16GOFLAGS += -tags=$(subst $(space),$(comma),$(strip $(GO_TAGS)))
17GOTESTFLAGS += -tags=$(subst $(space),$(comma),$(strip $(GO_TAGS)))
18
19all: build
20build:
21	go build $(GOFLAGS) -o $(APP_BIN)
22
23install: build
24	install -Dm755 $(APP_BIN) "$(DESTDIR)$(BINDIR)/$(APP_BIN)"
25
26clean:
27	go clean
28	rm -f $(APP_BIN) mlisting.db
29	rm -rf ./tmp/
30
31watch:
32	go run $(AIR_PACKAGE) \
33            -build.include_ext="go,tpl,tmpl,html,css" \
34            -build.cmd 'make build' \
35            -build.args_bin 'serve --db /tmp/kpaste.db' \
36            -build.bin "./$(APP_BIN)"
37
38
39.PHONY: all build clean watch