-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
151 lines (122 loc) · 4.4 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
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
# Paths Variables
SHELL = /bin/sh
PREFIX = /usr/local
BIN_PREFIX = $(PREFIX)/bin
INFO_DIR = $(shell git --info-path)
HTML_DIR = $(shell git --html-path)
MAN_DIR = $(shell git --man-path)
BASH_COMPL_DIR = /usr/local/etc/bash_completion/completions
FISH_COMPL_DIR = /usr/share/fish/completions
ZSH_COMPL_DIR = /usr/local/share/zsh/site-functions
LOCAL_BIN_DIR = bin
LOCAL_COMPL_DIR = completion
LOCAL_MAN_DIR = man
LOCAL_SRC_DIR = src
GITMOVE_VERSION = $(shell . src/version.sh && echo $${GITMOVE_VERSION})
# Commands Variables
RM = rm --force
RM_DIR = $(RM) --recursive
PANDOC = pandoc
INSTALL = install
INSTALL_BIN = $(INSTALL) --mode=0755
INSTALL_DIR = $(INSTALL) --directory --mode=0755
INSTALL_MAN = $(INSTALL) --mode=0644
ASCIIDOC = asciidoc
ASCIIDOC_HTML = xhtml11
ASCIIDOC_DOCBOOK = docbook
ASCIIDOC_MAN = manpage
ASCIIDOC_CONF = --conf-file=man/asciidoc.conf
ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_CONF) \
--attribute=manmanual='Git Move' \
--attribute=mansource='Yokozuna59' \
--attribute=manversion=$(GITMOVE_VERSION)
TO_HTML = $(ASCIIDOC_COMMON) --doctype=$(ASCIIDOC_MAN) --backend=$(ASCIIDOC_HTML)
TO_XML = $(ASCIIDOC_COMMON) --doctype=$(ASCIIDOC_MAN) --backend=$(ASCIIDOC_DOCBOOK)
XMLTO = xmlto
# Commands
.PHONY: all
all: build
.PHONY: build build-bin build-doc build-info build-html build-man
build: build-bin build-doc
build-bin:
cat src/version.sh > $(LOCAL_BIN_DIR)/git-move
find $(LOCAL_SRC_DIR) -maxdepth 1 -iname "*.sh" -not -name "version.sh" \
-exec sh -c "cat {} >> $(LOCAL_BIN_DIR)/git-move" \;
chmod +x $(LOCAL_BIN_DIR)/git-move
sed -i -e '1!{/^#!/d;}' -e '/^set -e/,+1d' -e '/main "$$@"/,+1d' $(LOCAL_BIN_DIR)/git-move
sed -i -e '/^#!/a set -euo pipefail' $(LOCAL_BIN_DIR)/git-move
echo 'main "$$@"' >> $(LOCAL_BIN_DIR)/git-move
sync
build-doc: build-info build-html build-man
build-info:
@echo git-move.info is not currently supported!
build-html:
$(TO_HTML) $(LOCAL_MAN_DIR)/git-mv.rst
build-man:
$(TO_XML) $(LOCAL_MAN_DIR)/git-mv.rst
$(XMLTO) man $(LOCAL_MAN_DIR)/git-mv.xml -o $(LOCAL_MAN_DIR)
.PHONY: clean clean-bin clean-doc clean-info clean-html clean-man
clean: clean-bin clean-doc
clean-bin:
$(RM) $(LOCAL_BIN_DIR)/git-move
clean-doc: clean-info clean-html clean-man
clean-info:
$(RM) $(wildcard $(LOCAL_MAN_DIR)/*.info)
clean-html:
$(RM) $(wildcard $(LOCAL_MAN_DIR)/*.html)
clean-man:
$(RM) $(wildcard $(LOCAL_MAN_DIR)/*.1 $(LOCAL_MAN_DIR)/*.xml)
.PHONY: install install-bin install-doc install-info install-html install-man \
install-completion install-bash install-fish install-zsh
install: install-bin install-doc install-completion
install-bin: build-bin
$(INSTALL_DIR) $(BIN_PREFIX)
$(INSTALL_BIN) $(LOCAL_BIN_DIR)/git-move $(BIN_PREFIX)
install-doc: build-doc install-info install-man install-html
install-info: build-info
$(INSTALL_DIR) $(INFO_DIR)
$(INSTALL_MAN) $(wildcard $(LOCAL_MAN_DIR)/*.info) $(INFO_DIR)
install-html: build-html
$(INSTALL_DIR) $(HTML_DIR)
$(INSTALL_MAN) $(wildcard $(LOCAL_MAN_DIR)/*.html) $(HTML_DIR)
install-man: build-man
$(INSTALL_DIR) $(MAN_DIR)
$(INSTALL_MAN) $(wildcard $(LOCAL_MAN_DIR)/*.1) $(MAN_DIR)
install-completion: install-bash install-fish install-zsh
install-bash:
$(INSTALL_DIR) $(ZSH_COMPL_DIR)
$(INSTALL_MAN) $(LOCAL_COMPL_DIR)/git-move.bash $(BASH_COMPL_DIR)
install-fish:
$(INSTALL_DIR) $(ZSH_COMPL_DIR)
$(INSTALL_MAN) $(LOCAL_COMPL_DIR)/git-move.fish $(FISH_COMPL_DIR)
install-zsh:
$(INSTALL_DIR) $(ZSH_COMPL_DIR)
$(INSTALL_MAN) $(LOCAL_COMPL_DIR)/git-move.zsh $(ZSH_COMPL_DIR)
.PHONY: uninstall uninstall-bin uninstall-doc uninstall-info uninstall-html \
uninstall-man uninstall-completion uninstall-bash uninstall-fish \
uninstall-zsh
uninstall: uninstall-bin uninstall-doc uninstall-completion
uninstall-bin:
$(RM) $(BIN_PREFIX)/git-move
uninstall-doc: uninstall-info uninstall-html uninstall-man
uninstall-info:
$(RM) $(addprefix $(INFO_DIR)/, \
$(notdir $(wildcard $(LOCAL_MAN_DIR)/*.info)))
uninstall-html:
$(RM) $(addprefix $(MAN_DIR)/, \
$(notdir $(wildcard $(LOCAL_MAN_DIR)/*.html)))
uninstall-man:
$(RM) $(addprefix $(HTML_DIR)/, \
$(notdir $(wildcard $(LOCAL_MAN_DIR)/*.1)))
uninstall-completion: uninstall-bash uninstall-fish uninstall-zsh
uninstall-bash:
$(RM) $(BASH_COMPL_DIR)/$(LOCAL_COMPL_DIR)/git-move.bash
uninstall-fish:
$(RM) $(FISH_COMPL_DIR)/$(LOCAL_COMPL_DIR)/git-move.fish
uninstall-zsh:
$(RM) $(ZSH_COMPL_DIR)/$(LOCAL_COMPL_DIR)/git-move.zsh
.PHONY: test
test: clean build
lint:
lint-doc:
lint-shell: