# Go Makefile tricks -rw-r--r-- 816 bytes View raw
                                                                                
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
GO?=go
GIT_VERSION := $(shell git describe --always --tags)
GOLDFLAGS := -X mpldr.codes/recter.Version='$(GIT_VERSION)'
EXTRA_GOFLAGS?=-buildmode=pie
GOTAGS?=netgo

PREFIX?=/usr/local
BINDIR?=$(PREFIX)/bin
TMPLDIR?=$(PREFIX)/recter
MANDIR?=$(PREFIX)/share/man

GOFILES := $(shell fd -t f -e go) go.mod go.sum

build/recter: $(GOFILES) Makefile
	@-mkdir build
	$(GO) build -v -ldflags="$(GOLDFLAGS)" --tags $(GOTAGS) $(EXTRA_GOFLAGS) -o build/

install: build/recter
	install -sDm755 build/recter $(DESTDIR)$(BINDIR)/recter

.PHONY: dev
dev:
	$(GO) run github.com/cosmtrek/air

clean:
	$(RM) -rf build/recter

TEMPLATEFILES := $(wildcard webinterface/*.qtpl)
TMPLS := $(patsubst webinterface/%.qtpl,webinterface/%.qtpl.go,$(TEMPLATEFILES))
templates: $(TMPLS)
webinterface/%.qtpl.go: webinterface/%.qtpl
	qtc -file $<