This repository was archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (78 loc) · 2.12 KB
/
Makefile
File metadata and controls
106 lines (78 loc) · 2.12 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
VERSION := ${shell cat ./VERSION}
DESTDIR :=
PREFIX := /usr
BINDIR=$(PREFIX)/bin
LIBEXECDIR := $(PREFIX)/libexec
LOCALSTATEDIR := /var
SOURCES := $(shell find . 2>&1 | grep -E '.*\.(c|h|go)$$')
PROXY_SOCKET := $(LOCALSTATEDIR)/run/clear-containers/proxy.sock
COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
VERSION_COMMIT := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION))
#
# systemd files
#
HAVE_SYSTEMD := $(shell pkg-config --exists systemd 2>/dev/null && echo 'yes')
ifeq ($(HAVE_SYSTEMD),yes)
UNIT_DIR := $(shell pkg-config --variable=systemdsystemunitdir systemd)
UNIT_FILES = cc-proxy.service cc-proxy.socket
GENERATED_FILES += $(UNIT_FILES)
endif
#
# Pretty printing
#
V = @
Q = $(V:1=)
QUIET_GOBUILD = $(Q:@=@echo ' GOBUILD '$@;)
QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
# Entry point
all: cc-proxy $(UNIT_FILES)
#
# proxy
#
cc-proxy: $(SOURCES) Makefile VERSION
$(QUIET_GOBUILD)go build -i -o $@ -ldflags \
"-X main.DefaultSocketPath=$(PROXY_SOCKET) -X main.Version=$(VERSION_COMMIT)"
#
# Tests
#
.PHONY: check check-go-static check-go-test
check: check-go-static check-go-test
check-go-static:
.ci/go-lint.sh
check-go-test:
.ci/go-test.sh
coverage:
.ci/go-test.sh html-coverage
#
# Documentation
#
doc:
$(Q).ci/go-doc.sh || true
#
# install
#
define INSTALL_EXEC
$(QUIET_INST)install -D $1 $(DESTDIR)$2/$1 || exit 1;
endef
define INSTALL_FILE
$(QUIET_INST)install -D -m 644 $1 $(DESTDIR)$2/$1 || exit 1;
endef
all-installable: cc-proxy $(UNIT_FILES)
install: all-installable
$(call INSTALL_EXEC,cc-proxy,$(LIBEXECDIR)/clear-containers)
$(foreach f,$(UNIT_FILES),$(call INSTALL_FILE,$f,$(UNIT_DIR)))
clean:
rm -f cc-proxy $(GENERATED_FILES)
$(GENERATED_FILES): %: %.in Makefile
@mkdir -p `dirname $@`
$(QUIET_GEN)sed \
-e 's|[@]bindir[@]|$(BINDIR)|g' \
-e 's|[@]libexecdir[@]|$(LIBEXECDIR)|' \
-e "s|[@]localstatedir[@]|$(LOCALSTATEDIR)|" \
"$<" > "$@"
#
# dist
#
dist:
git archive --format=tar --prefix=cc-proxy-$(VERSION)/ HEAD | xz -c > cc-proxy-$(VERSION).tar.xz