-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
142 lines (98 loc) · 3.5 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
# Should be changed to /usr/local
prefix="$(HOME)"
bindir=$(prefix)/bin
libdir=$(prefix)/lib/cogito
sharedir=$(prefix)/share/cogito
INSTALL?=install
export prefix bindir libdir sharedir INSTALL
### --- END CONFIGURATION SECTION ---
SCRIPT= cg-object-id cg-add cg-admin-uncommit \
cg-branch-add cg-branch-ls cg-reset cg-clone cg-commit cg-diff \
cg-export cg-help cg-init cg-log cg-merge cg-mkpatch cg-patch \
cg-fetch cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \
cg cg-admin-ls cg-push cg-branch-chg cg-admin-cat cg-clean \
cg-admin-setuprepo cg-switch cg-mv cg-admin-rewritehist cg-tag-show
LIB_SCRIPT=cg-Xlib cg-Xmergefile cg-Xfetchprogress cg-Xfollowrenames
GEN_SCRIPT= cg-version
VERSION= VERSION
SHARE_FILES= default-exclude
-include config.mak
### Build rules
.PHONY: all cogito
all: cogito
cogito: $(GEN_SCRIPT)
ifneq (,$(wildcard .git))
GIT_HEAD=.git/$(shell git-symbolic-ref HEAD)
GIT_HEAD_ID=$(shell cg-object-id -d)
endif
cg-version: cg-version.in $(VERSION) $(GIT_HEAD)
@echo Generating cg-version...
@rm -f $@
@sed -e 's/@@VERSION@@/$(shell cat $(VERSION))/' \
-e 's/@@GIT_HEAD_ID@@/$(GIT_HEAD_ID)/' \
< $< > $@
@chmod +x $@
doc:
$(MAKE) -C Documentation all
### Testing rules
test: all
$(MAKE) -C t/ all
$(MAKE) -C Documentation/ test
### Installation rules
sedlibdir=$(shell echo $(libdir) | sed 's/\//\\\//g')
sedsharedir=$(shell echo $(sharedir) | sed 's/\//\\\//g')
.PHONY: install install-cogito install-doc
install: install-cogito
install-cogito: $(SCRIPT) $(LIB_SCRIPT) $(GEN_SCRIPT)
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(SCRIPT) $(GEN_SCRIPT) $(DESTDIR)$(bindir)
$(INSTALL) -m755 -d $(DESTDIR)$(libdir)
$(INSTALL) $(LIB_SCRIPT) $(DESTDIR)$(libdir)
cd $(DESTDIR)$(bindir); \
for file in $(SCRIPT) $(GEN_SCRIPT); do \
sed -e 's/\$${COGITO_LIB}/\$${COGITO_LIB:-$(sedlibdir)\/}/g' \
-e 's/\$${COGITO_SHARE}/\$${COGITO_SHARE:-$(sedsharedir)\/}/g' \
$$file > $$file.new; \
cat $$file.new > $$file; rm $$file.new; \
done
cd $(DESTDIR)$(libdir); \
for file in $(LIB_SCRIPT); do \
sed -e 's/\$${COGITO_LIB}/\$${COGITO_LIB:-$(sedlibdir)\/}/g' \
-e 's/\$${COGITO_SHARE}/\$${COGITO_SHARE:-$(sedsharedir)\/}/g' \
$$file > $$file.new; \
cat $$file.new > $$file; rm $$file.new; \
done
$(INSTALL) -m755 -d $(DESTDIR)$(sharedir)
$(INSTALL) -m644 $(SHARE_FILES) $(DESTDIR)$(sharedir)
install-doc:
$(MAKE) -C Documentation install
uninstall:
cd $(DESTDIR)$(bindir) && rm -f $(SCRIPT) $(GEN_SCRIPT)
cd $(DESTDIR)$(libdir) && rm -f $(LIB_SCRIPT)
cd $(DESTDIR)$(sharedir) && rm -f $(SHARE_FILES)
### Maintainer's dist rules
cogito.spec: cogito.spec.in $(VERSION)
sed -e 's/@@VERSION@@/$(shell cat $(VERSION) | cut -d"-" -f2)/g' < $< > $@
GIT_TARNAME=$(shell cat $(VERSION))
dist: cogito.spec
cg-export $(GIT_TARNAME).tar
@mkdir -p $(GIT_TARNAME)
@cp cogito.spec $(GIT_TARNAME)
tar rf $(GIT_TARNAME).tar $(GIT_TARNAME)/cogito.spec
@rm -rf $(GIT_TARNAME)
gzip -f -9 $(GIT_TARNAME).tar
rpm: dist
rpmbuild -ta $(GIT_TARNAME).tar.gz
deb: dist
tar zxf $(GIT_TARNAME).tar.gz
dpkg-source -b $(GIT_TARNAME)
cd $(GIT_TARNAME) && fakeroot debian/rules binary \
&& cd .. && rm -rf $(GIT_TARNAME)
Portfile: Portfile.in $(VERSION) dist
sed -e 's/@@VERSION@@/$(shell cat $(VERSION) | cut -d"-" -f2)/g' < Portfile.in > Portfile
echo "checksums md5 " `md5sum $(GIT_TARNAME).tar.gz | cut -d ' ' -f 1` >> Portfile
### Cleaning rules
clean:
rm -f $(GEN_SCRIPT)
rm -f cogito-*.tar.gz cogito.spec
$(MAKE) -C Documentation/ clean