-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
191 lines (152 loc) · 4.9 KB
/
Copy pathMakefile
File metadata and controls
191 lines (152 loc) · 4.9 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# Makefile for git-teleport
#
# SPDX-License-Identifier: MIT
.PHONY: all \
precheck \
check check-main check-aux \
dist distdocs \
doc try-doc \
install \
test
## Required programs ##
MDBOOK := mdbook
SHELLCHECK := shellcheck
GIT := git
## Git information ##
export SOURCE_DATE_EPOCH := $(shell $(GIT) log -1 --pretty=%ct 2>/dev/null || echo 0)
GITINFO := $(shell $(GIT) describe --exact-match 2>/dev/null || $(GIT) log -1 --pretty=%h --abbrev=15 2>/dev/null || echo nogit)
## Configurable options ##
# Where to write documentation in `make doc`
DOC_OUTDIR ?= share/git-teleport/html
# Tarball name (main)
PKG_NAME_MAIN ?= git-teleport
# Tarball name (docs only)
PKG_NAME_DOC ?= git-teleport-doc
# Version identifier
PKG_VERSION ?= $(GITINFO)
# tar file extension (also sets compression)
PKG_TAR_EXT ?= tar.xz
# true if check includes precheck
PRECHECK := 1
# umask for installed files
UMASK := 022
## Installation Options ##
# where to install
DESTDIR :=
PREFIX := $(HOME)/.git-teleport
# directory names
BINDIR := bin
LIBDIR := lib
LIBEXECDIR := libexec
SHAREDIR := share
# files which are part of git-teleport proper
BINS = \
git-teleport
LIBS = \
gteleport-prelude.bash \
gteleport.bash
LIBEXECS = \
git-teleport-bundle \
git-teleport-setup \
git-teleport-skeleton \
git-teleport-help \
git-teleport-version \
git-teleport-bootstrap \
git-teleport-fetch \
git-teleport-pack \
git-teleport-bundle-all \
git-teleport-unpack
# auxiliary script files (shellchecked but not installed)
AUX_SCRIPTS = \
ci/bin/mktar.sh \
ci/bin/package_url.sh \
ci/bin/precheck.sh \
share/git-teleport/template/receive/hooks/post-receive.mirror.sample \
share/git-teleport/template/receive/hooks/pre-receive
all:
@echo "This Makefile exists to support development and packaging."
@echo
@echo "You can use git-teleport from this directory without installing it."
@echo "Try running \`bin/git-teleport setup --path\` to add git-teleport to"
@echo "your PATH."
@echo
@echo "Run $(MAKE) TARGET to do the following:"
@echo
@echo "Installation"
@echo " install - Install git-teleport to PREFIX"
@echo " doc - Build mdbook documentation"
@echo
@echo "Tests & QA"
@echo " precheck - Check a feature branch in Git"
@echo " check - Run \`precheck\` and shellcheck all scripts"
@echo " test - Run unit tests"
@echo
@echo "Packaging"
@echo " dist - Make distribution tarball"
@echo " distdocs - Make distribution tarball of only docs"
@echo
@echo "The default install PREFIX is \"$(PREFIX)\"."
@echo
## QA and Checks ##
# merge requests checks
precheck:
ci/bin/precheck.sh
# shellcheck
check: $(if $(PRECHECK),precheck,) check-main check-aux
check-main: \
$(addprefix bin/,$(BINS)) \
$(addprefix lib/git-teleport/,$(LIBS)) \
$(addprefix libexec/git-teleport/,$(LIBEXECS))
$(SHELLCHECK) -x -- $^
check-aux: $(AUX_SCRIPTS)
$(SHELLCHECK) -- $^
# unit tests
test:
test/run.sh
## documentation build ##
HAVE_MDBOOK := $(shell command -v "$(MDBOOK)")
ifneq ($(HAVE_MDBOOK),)
try-doc: | doc
else
try-doc:
@echo >&2 'WARNING: mdbook not found on your $$PATH.'; \
echo >&2 "Documentation will not be built.";
endif
doc:
umask $(UMASK) && $(MDBOOK) build --dest-dir $(DOC_OUTDIR)
## create tarballs: main package ##
TAR_ROOT_MAIN := $(PKG_NAME_MAIN)-$(PKG_VERSION)
dist: $(TAR_ROOT_MAIN)
ci/bin/mktar.sh $< $<.$(PKG_TAR_EXT)
$(TAR_ROOT_MAIN): \
$(addprefix $(TAR_ROOT_MAIN)/$(BINDIR)/,$(BINS)) \
$(addprefix $(TAR_ROOT_MAIN)/$(LIBDIR)/git-teleport/,$(LIBS)) \
$(addprefix $(TAR_ROOT_MAIN)/$(LIBEXECDIR)/git-teleport/,$(LIBEXECS)) \
$(TAR_ROOT_MAIN)/$(SHAREDIR)/git-teleport/LICENSE \
$(TAR_ROOT_MAIN)/$(SHAREDIR)/git-teleport/VERSION \
FORCE \
| try-doc
umask $(UMASK) && \
cp -R --no-preserve=all --preserve=timestamps -- \
share/git-teleport/. $@/$(SHAREDIR)/git-teleport/.
## create tarballs: documentation ##
TAR_ROOT_DOCS := $(PKG_NAME_DOC)-$(PKG_VERSION)
distdocs: | doc
umask $(UMASK) && cp -R --preserve=all -- $(DOC_OUTDIR)/. $(TAR_ROOT_DOCS)
ci/bin/mktar.sh $(TAR_ROOT_DOCS) $(TAR_ROOT_DOCS).$(PKG_TAR_EXT)
## installation rules ##
install: $(TAR_ROOT_MAIN).$(PKG_TAR_EXT)
umask $(UMASK) && mkdir -p -m 0755 -- $(DESTDIR)$(PREFIX)
tar -C $(DESTDIR)$(PREFIX) --strip-components=1 --extract --file $<
## file packaging rules ##
$(TAR_ROOT_MAIN)/$(BINDIR)/%: bin/%
umask $(UMASK) && install --preserve-timestamps --no-target-directory --mode 0755 -D -- $< $@
$(TAR_ROOT_MAIN)/$(LIBDIR)/%: lib/%
umask $(UMASK) && install --preserve-timestamps --no-target-directory --mode 0644 -D -- $< $@
$(TAR_ROOT_MAIN)/$(LIBEXECDIR)/%: libexec/%
umask $(UMASK) && install --preserve-timestamps --no-target-directory --mode 0755 -D -- $< $@
$(TAR_ROOT_MAIN)/$(SHAREDIR)/git-teleport/LICENSE: LICENSE
umask $(UMASK) && install --preserve-timestamps --no-target-directory --mode 0644 -D -- $< $@
$(TAR_ROOT_MAIN)/$(SHAREDIR)/git-teleport/VERSION: FORCE
echo $(PKG_VERSION) >$@
FORCE: