forked from ingydotnet/git-subrepo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
87 lines (60 loc) · 1.62 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
# Make sure we have 'git' and it works OK:
ifeq ($(shell which git),)
$(error 'git' is not installed on this system)
endif
# Set variables:
CMD := git-subrepo
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)
PREFIX ?= /usr/local
INSTALL_LIB ?= $(shell git --exec-path)
INSTALL_CMD ?= $(INSTALL_LIB)/$(CMD)
INSTALL_EXT ?= $(INSTALL_LIB)/$(CMD).d
INSTALL_MAN ?= $(PREFIX)/share/man/man1
# Basic 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/
# Install support:
.PHONY: install install-lib install-doc
install: install-lib install-doc
install-lib:
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)
# Uninstall support:
.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
# Build manpage from markdown:
.PHONY: doc
doc: doc/$(CMD).1
%.1: %.md
ronn --roff < $< > $@
# Development installation:
.PHONY: dev-install
dev-install:
ln -fs $(LOCAL_LIB) $(INSTALL_CMD)
ln -fs $(LOCAL_EXTS) $(INSTALL_EXT)
clean purge:
rm -fr tmp