-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (51 loc) · 1.51 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
.SUFFIXES:
.PHONY: all check clean dist distclean doc install release uninstall
PREFIX ?= $(HOME)/.local
dest = $(DESTDIR)$(PREFIX)
bindir = $(dest)/bin
mandir = $(dest)/share/man/man1
bin = git-mr-to
manpage = doc/$(bin).1
ASCIIDOC ?= asciidoctor
all: doc
doc: $(manpage)
%.1: %.1.adoc
$(ASCIIDOC) --backend manpage --doctype manpage $<
test -f $@
install: $(manpage)
install -d $(bindir) $(mandir)
install -m 0775 $(bin) $(bindir)
install -m 0644 $(manpage) $(mandir)
uninstall:
$(RM) $(bindir)/$(bin)
$(RM) $(mandir)/$(manpage)
check:
shellcheck $(bin)
shellcheck --shell sh completion.sh
clean:
$(RM) $(manpage)
DIST_VERSION ?= $(shell git describe --always)
dist_name = git-mr-to-$(DIST_VERSION)
dist_tar_name = $(dist_name).tar
dist: $(dist_tar_name).gz
$(dist_tar_name).gz: $(manpage)
git archive --format=tar \
--prefix=$(dist_name)/ $(DIST_VERSION)^{tree} \
> $(dist_tar_name)
@mkdir -p $(dist_name)/doc
@cp $(manpage) $(dist_name)/doc
@# git-archive does not include .git directory and some targets don't
@# work without it. Those targets fortunately don't matter for package
@# distribution so strip them.
sed '/^check:/,$$ d' Makefile > $(dist_name)/Makefile
tar rf $(dist_tar_name) $(dist_name)
@$(RM) -r $(dist_name)
gzip -f -9 $(dist_tar_name)
distclean:
$(RM) $(dist_tar_name)*
release:
test -n "$(v)"
sed -i "s/^\(:man source: git mr-to\).\+$$/\1 $(v)/" doc/git-mr-to.1.adoc
git add -p doc/git-mr-to.1.adoc
git commit -m "git-mr-to $(v)"
git tag -a -m "git-mr-to $(v)" "v$(v)"