forked from ingydotnet/git-hub
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
107 lines (83 loc) · 2.45 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
CMD := git-hub
LOCAL_LIB := $(shell pwd)/lib/$(CMD)
LOCAL_EXT = $(LOCAL_LIB).d
LOCAL_EXTS = $(shell find $(LOCAL_EXT) -type f) \
$(shell find $(LOCAL_EXT) -type l)
# XXX Make these vars look like git.git/Makefile style
PREFIX ?= /usr/local
# XXX Using sed for now. Would like to use bash or make syntax.
# If GIT_EXEC_PATH is set, `git --exec-path` will contain that appended to the
# front. We just want the path where git is actually installed:
INSTALL_LIB ?= $(shell git --exec-path | sed 's/.*://')
INSTALL_CMD ?= $(INSTALL_LIB)/$(CMD)
INSTALL_EXT ?= $(INSTALL_LIB)/$(CMD).d
INSTALL_MAN ?= $(PREFIX)/share/man/man1
## XXX assert good bash
##
# Make sure we have 'git' and it works OK.
ifeq ($(shell which git),)
$(error 'git' is not installed on this system)
endif
GITVER ?= $(word 3,$(shell git --version))
##
# User targets:
.PHONY: default help test
default: help
help:
@echo 'Makefile rules:'
@echo ''
@echo 'test Run all tests'
@echo 'install Install $(CMD)'
@echo 'uninstall Uninstall $(CMD)'
test:
ifeq ($(shell which prove),)
@echo '`make test` requires the `prove` utility'
@exit 1
endif
prove $(PROVEOPT:%=% )test/
.PHONY: install install-lib install-doc
install: install-lib install-doc
install-lib: $(INSTALL_EXT)
install -C -m 0755 $(LOCAL_LIB) $(INSTALL_LIB)/
install -C -d -m 0755 $(INSTALL_EXT)/
install -C -m 0755 $(LOCAL_EXTS) $(INSTALL_EXT)/
install-doc:
install -C -d -m 0755 $(INSTALL_MAN)
install -C -m 0644 doc/$(CMD).1 $(INSTALL_MAN)
.PHONY: uninstall uninstall-lib uninstall-doc
uninstall: uninstall-lib uninstall-doc
uninstall-lib:
rm -f $(INSTALL_CMD)
rm -fr $(INSTALL_EXT)
uninstall-doc:
rm -f $(INSTALL_MAN)/$(CMD).1
$(INSTALL_EXT):
mkdir -p $@
##
# Build rules:
.PHONY: doc
doc: doc/$(CMD).1
$(CMD).txt: ReadMe.asc
cp $< $@
%.xml: %.txt
asciidoc -b docbook -d manpage -f doc/asciidoc.conf \
-agit_version=$(GITVER) $^
rm $<
%.1: %.xml
xmlto -m doc/manpage-normal.xsl man $^
doc/%.1: %.1
mv $< $@
##
# Undocumented dev rules
# Install using symlinks so repo changes can be tested live
.PHONY: dev-install dev-test dev-test-reset check-dev-install
dev-install:
ln -fs $(LOCAL_LIB) $(INSTALL_CMD)
ln -fs $(LOCAL_EXTS) $(INSTALL_EXT)
# Run a bunch of live tests. Make sure this thing really works. :)
dev-test:
bash test/dev-test/all_commands.t
bash test/dev-test/each.t
# Run this to reset if `make dev-test` fails.
dev-test-reset: check-dev-install
GIT_HUB_TEST_RESET=1 bash test/dev-test/all_commands.t