-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
103 lines (85 loc) · 3.42 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
##
# Plowshare4 Makefile
##
# Tools
INSTALL = install
LN_S = ln -sf
RM = rm -f
# Files
SRCS = src/download.sh src/upload.sh src/delete.sh src/list.sh \
src/probe.sh src/core.sh
SETUP_FILES = Makefile setup.sh
TEST_FILES = tests/modules.sh $(wildcard tests/*.t)
MODULE_FILES = $(wildcard src/modules/*.sh) src/modules/config
MANPAGES1 = plowdown.1 plowup.1 plowdel.1 plowlist.1 plowprobe.1
MANPAGES5 = plowshare.conf.5
MANPAGES = $(addprefix docs/,$(MANPAGES1)) $(addprefix docs/,$(MANPAGES5))
DOCS = AUTHORS COPYING INSTALL README
CONTRIB_FILES = $(addprefix contrib/,plowdown_add_remote_loop.sh plowdown_loop.sh \
plowdown_parallel.sh)
ETC_FILES = $(addprefix etc/,plowshare.completion)
# Target path
# DESTDIR is for package creation only
PREFIX ?= /usr/local
ETCDIR = /etc
BINDIR = $(PREFIX)/bin
DATADIR = ${PREFIX}/share/plowshare4
DOCDIR = ${PREFIX}/share/doc/plowshare4
MANDIR = ${PREFIX}/share/man/man
# Packaging
GIT_DATE:=$(shell LANG=C git log -n1 --pretty=%ci | cut -d' ' -f1)
GIT_HASH:=$(shell LANG=C git log -n1 --pretty=%h)
DISTDIR = plowshare4-snapshot-git$(subst -,,$(GIT_DATE).$(GIT_HASH))
install:
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -d $(DESTDIR)$(DATADIR)
$(INSTALL) -d $(DESTDIR)$(DATADIR)/modules
$(INSTALL) -d $(DESTDIR)$(DOCDIR)
$(INSTALL) -d $(DESTDIR)$(MANDIR)1
$(INSTALL) -d $(DESTDIR)$(MANDIR)5
$(INSTALL) -m 644 $(MODULE_FILES) $(DESTDIR)$(DATADIR)/modules
$(INSTALL) -m 755 $(SRCS) $(DESTDIR)$(DATADIR)
$(INSTALL) -m 644 $(addprefix docs/,$(MANPAGES1)) $(DESTDIR)$(MANDIR)1
$(INSTALL) -m 644 $(addprefix docs/,$(MANPAGES5)) $(DESTDIR)$(MANDIR)5
$(INSTALL) -m 644 README $(DESTDIR)$(DOCDIR)
$(LN_S) $(DATADIR)/download.sh $(DESTDIR)$(BINDIR)/plowdown
$(LN_S) $(DATADIR)/upload.sh $(DESTDIR)$(BINDIR)/plowup
$(LN_S) $(DATADIR)/delete.sh $(DESTDIR)$(BINDIR)/plowdel
$(LN_S) $(DATADIR)/list.sh $(DESTDIR)$(BINDIR)/plowlist
$(LN_S) $(DATADIR)/probe.sh $(DESTDIR)$(BINDIR)/plowprobe
uninstall:
@$(RM) $(DESTDIR)$(BINDIR)/plowdown
@$(RM) $(DESTDIR)$(BINDIR)/plowup
@$(RM) $(DESTDIR)$(BINDIR)/plowdel
@$(RM) $(DESTDIR)$(BINDIR)/plowlist
@rm -rf $(DESTDIR)$(DATADIR) $(DESTDIR)$(DOCDIR)
@$(RM) $(addprefix $(DESTDIR)$(MANDIR)1/, $(MANPAGES1))
@$(RM) $(addprefix $(DESTDIR)$(MANDIR)5/, $(MANPAGES5))
test:
@cd tests && ./modules.sh -l
install_bash_completion:
@$(INSTALL) -d $(DESTDIR)$(ETCDIR)/bash_completion.d
@sed -e "/cut/s,/usr/local/share/plowshare4,$(DATADIR)," etc/plowshare.completion > $(DESTDIR)$(ETCDIR)/bash_completion.d/plowshare4
dist: distdir
@tar -cf - $(DISTDIR)/* | gzip -9 >$(DISTDIR).tar.gz
@rm -rf $(DISTDIR)
distdir:
@test -d $(DISTDIR) || mkdir $(DISTDIR)
@mkdir -p $(DISTDIR)/etc $(DISTDIR)/tests $(DISTDIR)/docs $(DISTDIR)/contrib
@mkdir -p $(DISTDIR)/src/modules
@for file in $(SRCS) $(SETUP_FILES) $(MODULE_FILES) $(TEST_FILES) \
$(MANPAGES) $(DOCS) $(ETC_FILES) $(CONTRIB_FILES); do \
cp -pf $$file $(DISTDIR)/$$file; \
done
@for file in $(SRCS); do \
sed -i 's/^\(declare -r VERSION=\).*/\1'\''GIT-$(GIT_HASH) ($(GIT_DATE))'\''/' $(DISTDIR)/$$file; \
done
@for file in $(DOCS); do \
sed -i '/[Pp]lowshare/s/\(.*\)GIT-snapshot\(.*\)/\1GIT-$(GIT_HASH) ($(GIT_DATE))\2/' $(DISTDIR)/$$file; \
done
@for file in $(MANPAGES); do \
sed -i '/[Pp]lowshare/s/\(.*\)GIT-snapshot\(.*\)/\1GIT-$(GIT_HASH)\2/' $(DISTDIR)/$$file; \
done
distclean:
@rm -rf plowshare-snapshot-*
.PHONY: dist distclean install uninstall test