-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
56 lines (45 loc) · 1.63 KB
/
Makefile
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
DOMAIN=$(shell cat DOMAIN)
HTTP_PORT=$(shell cat HTTP_PORT)
HTTPS_PORT=$(shell cat HTTPS_PORT)
DEBUG=$(shell cat DEBUG)
COMMIT=$(shell git log -n1 --pretty=format:%H)
dir_guard=@mkdir -p $(@D) # create the folder of the target if it doesn't exist
BUILD=build
GOOUT=$(BUILD)/vandal
GOFILES=eventtype.go location.go main.go user.go messageslog.go utils.go currently_used_sites.go
JSOUT=$(BUILD)/static/script.js
JSFILES=js/header.js js/polyfill.js js/colorpicker.js js/msgpack.codec.js js/user.js js/ui.js js/client.js js/script.js js/footer.js
HTMLOUT=$(BUILD)/templates/index.html
HTMLFILES=templates/index.html
ifeq ($(DEBUG),true)
GOFLAGS=-race
else
GOFLAGS=
endif
all: $(GOOUT) $(JSOUT) $(HTMLOUT) staticfiles version
$(GOOUT): $(GOFILES) DEBUG
$(dir_guard)
go build $(GOFLAGS) -o $(GOOUT) $(GOFILES)
$(HTMLOUT): $(HTMLFILES) DOMAIN HTTPS_PORT
$(dir_guard)
sed 's/DOMAIN_PLACEHOLDER/'$(DOMAIN)'/g' $(HTMLFILES) > $(HTMLOUT)
sed -i 's/HTTPS_PORT_PLACEHOLDER/'$(HTTPS_PORT)'/g' $(HTMLOUT)
$(JSOUT): $(JSFILES) DOMAIN DEBUG HTTPS_PORT HTTP_PORT
$(dir_guard)
cat $(JSFILES) > $(JSOUT)
ifeq ($(DEBUG),true)
@echo "I will only concatenate script files (no minifying)."
else
google-closure-compiler --js $(JSOUT) --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file $(JSOUT).min
mv $(JSOUT).min $(JSOUT)
endif
sed -i 's/DOMAIN_PLACEHOLDER/'$(DOMAIN)'/g' $(JSOUT)
sed -i 's/HTTP_PORT_PLACEHOLDER/'$(HTTP_PORT)'/g' $(JSOUT)
sed -i 's/HTTPS_PORT_PLACEHOLDER/'$(HTTPS_PORT)'/g' $(JSOUT)
.PHONY: version staticfiles
staticfiles:
rsync -r static $(BUILD)/
version:
sed -i 's/COMMIT_PLACEHOLDER/'$(COMMIT)'/g' $(HTMLOUT)
mrproper:
rm -rf $(BUILD)