Update makefile and install instructions
[bloat] / Makefile
1 GO=go
2 GOFLAGS=-mod=vendor
3 PREFIX=/usr/local
4 BINPATH=$(PREFIX)/bin
5 SHAREPATH=$(PREFIX)/share/bloat
6
7 TMPL=templates/*.tmpl
8 SRC=main.go             \
9         config/*.go     \
10         kv/*.go         \
11         mastodon/*.go   \
12         model/*.go      \
13         renderer/*.go   \
14         repo/*.go       \
15         service/*.go    \
16         util/*.go       \
17
18 all: bloat bloat.def.conf
19
20 bloat: $(SRC) $(TMPL)
21         $(GO) build $(GOFLAGS) -o bloat main.go
22
23 bloat.def.conf:
24         sed -e "s%=database%=/var/bloat%g" \
25                 -e "s%=templates%=$(SHAREPATH)/templates%g" \
26                 -e "s%=static%=$(SHAREPATH)/static%g" \
27                 < bloat.conf > bloat.def.conf
28
29 install: bloat
30         mkdir -p $(BINPATH) $(SHAREPATH)/templates $(SHAREPATH)/static
31         cp bloat $(BINPATH)/bloat
32         chmod 0755 $(BINPATH)/bloat
33         cp -r templates/* $(SHAREPATH)/templates
34         chmod 0644 $(SHAREPATH)/templates/*
35         cp -r static/* $(SHAREPATH)/static
36         chmod 0644 $(SHAREPATH)/static/*
37
38 tags: $(SRC)
39         gotags $(SRC) > tags
40
41 uninstall:
42         rm -f $(BINPATH)/bloat
43         rm -fr $(SHAREPATH)/templates
44         rm -fr $(SHAREPATH)/static
45
46 clean: 
47         rm -f bloat
48         rm -f bloat.def.conf