-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
89 lines (67 loc) · 1.71 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
REPO := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
LOGOS = $(REPO)/contrib/logos
WEBUI_DIR = contrib/webui
WEBUI = ./$(WEBUI_DIR)
GO_ASSETS = $(REPO)/build-assets
DOCROOT = $(WEBUI)/docroot
WEBUI_LOGO = $(DOCROOT)/favicon.png
WEB_FILES = $(DOCROOT)/index.html
WEB_FILES += $(DOCROOT)/xd.min.js
WEB_FILES += $(DOCROOT)/xd.css
WEB_FILES += $(WEBUI_LOGO)
WEBUI_CORE = $(DOCROOT)/xd.min.js
WEBUI_CORE += $(DOCROOT)/xd.css
WEBUI_PREFIX = /contrib/webui/docroot
ASSETS = $(REPO)/lib/rpc/assets/assets.go
TAGS ?= webui
LOKINET ?= 0
ifeq ($(LOKINET),1)
TAGS += lokinet
endif
ifeq ($(GOOS),windows)
BINEXT = .exe
endif
MKDIR = mkdir -p
RM = rm -f
CP = cp
CPLINK = cp -P
INSTALL = install
LINK = ln -s
CHMOD = chmod
GIT_VERSION ?= $(shell test -e .git && git rev-parse --short HEAD || true)
GO = go
XD ?= XD$(BINEXT)
CLI ?= XD-CLI$(BINEXT)
build: $(CLI)
$(XD): $(WEBUI_CORE)
$(GO) build -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION)" -tags='$(TAGS)' -o $(XD)
dev: $(WEBUI_CORE)
$(GO) build -race -v -a -ldflags "-X xd/lib/version.Git=$(GIT_VERSION)" -tags='$(TAGS)' -o $(XD)
$(CLI): $(XD)
$(RM) $(CLI)
$(LINK) $(XD) $(CLI)
$(CHMOD) 755 $(CLI)
test:
$(GO) test ./...
clean: webui-clean go-clean
$(RM) $(CLI)
distclean: clean clean-assets
clean-assets:
$(RM) $(ASSETS)
webui-clean:
$(RM) $(WEBUI_LOGO)
$(MAKE) -C $(WEBUI) clean
go-clean:
$(GO) clean
$(WEBUI_LOGO):
$(CP) $(LOGOS)/xd_logo.png $(WEBUI_LOGO)
$(WEBUI_CORE): $(WEBUI_LOGO)
$(MAKE) -C $(WEBUI)
$(CP) $(WEB_FILES) $(REPO)/lib/rpc/assets/
webui: $(WEBUI_CORE)
no-webui:
$(GO) build -ldflags "-X xd/lib/version.Git=$(GIT_VERSION)" -o $(XD)
install: $(XD) $(CLI)
$(MKDIR) $(PREFIX)/bin
$(INSTALL) XD $(PREFIX)/bin
$(CPLINK) $(CLI) $(PREFIX)/bin