-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
176 lines (137 loc) · 5.06 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#
# Copyright 2012-2013 Diomidis Spinellis
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-include .config
export PREFIX?=/usr/local
ifdef DEBUG
CPPFLAGS=-DDEBUG
CXXFLAGS=-g -Wall -O0
else
CXXFLAGS=-O -Wall
endif
ifdef TIME
CFLAGS+=-DTIME
endif
DOTFLAGS=-Nfontname=Arial -Ngradientangle=90 -Nstyle=filled -Nshape=ellipse -Nfillcolor=yellow:white
# Manual pages
MAN1SRC=$(wildcard core-tools/src/*.1)
MANPDF=$(patsubst %.1,%.pdf,$(MAN1SRC)) core-tools/src/dgsh_negotiate.pdf
MANHTML=$(patsubst %.1,%.html,$(MAN1SRC)) core-tools/src/dgsh_negotiate.html
# Web files
EXAMPLES=$(patsubst example/%,%,$(wildcard example/*.sh))
EGPNG=$(patsubst %.sh,png/%-pretty.png,$(EXAMPLES))
EGDOT=$(patsubst %.sh,graphdot/%.dot,$(EXAMPLES))
WEBPNG=$(EGPNG)
WEBDIST=../../../pubs/web/home/sw/dgsh/
png/%-pretty.png: graphdot/%.dot
gvpr 'BEG_G { graph_t L = cloneG($$G,"last")} END {write(L)}' $< | \
dot $(DOTFLAGS) -Tpng >$@
%.pdf: %.1
groff -man -Tps $< | ps2pdf - $@
%.pdf: %.3
groff -man -Tps $< | ps2pdf - $@
%.html: %.1
groff -man -Thtml $< >$@
%.html: %.3
groff -man -Thtml $< >$@
graphdot/%.dot: example/%.sh
mkdir -p graphdot
rm -f graphdot/$*.dot
DGSH_DRAW_EXIT=1 DGSH_DOT_DRAW=graphdot/$* ./unix-tools/bash/bash --dgsh $<
.PHONY: all tools core-tools unix-tools export-prefix \
config config-core-tools \
test test-dgsh test-merge-sum test-tee test-negotiate \
test-unix-tools test-wrap test-kvstore \
clean install webfiles dist pull commit uninstall dotfiles
all: tools
tools: core-tools unix-tools
core-tools:
$(MAKE) -C core-tools CFLAGS="$(CFLAGS)"
cd core-tools/src && $(MAKE) build-install
unix-tools: core-tools
$(MAKE) -C unix-tools make MAKEFLAGS=
$(MAKE) -C unix-tools build-install
export-prefix:
echo "export PREFIX?=$(PREFIX)" >.config
config: export-prefix config-core-tools
$(MAKE) -C unix-tools configure
config-core-tools: core-tools/configure.ac core-tools/Makefile.am core-tools/src/Makefile.am core-tools/tests/Makefile.am
-mkdir core-tools/m4
cd core-tools && \
autoreconf --install && \
./configure --prefix=$(PREFIX) \
--bindir=$(PREFIX)/bin && \
cd tests && \
patch Makefile <Makefile.patch
test: test-negotiate test-tee test-kvstore test-unix-tools test-merge-sum test-wrap test-dgsh
test-dgsh: tools
cd core-tools/tests-regression && ./test-dgsh.sh
test-wrap: tools
cd core-tools/tests-regression && ./test-wrap.sh
test-merge-sum:
cd core-tools/tests-regression && ./test-merge-sum.sh
test-tee: tools
cd core-tools/tests-regression && ./test-tee.sh
test-negotiate: tools
cd core-tools/tests && \
$(MAKE) && \
$(MAKE) check
test-unix-tools: tools
$(MAKE) -C unix-tools -s test
test-kvstore: core-tools
cd core-tools/tests-regression && ./test-kvstore.sh
clean:
rm -rf build $(MANPDF) $(MANHTML) $(EGPNG)
$(MAKE) -C core-tools clean
$(MAKE) -C unix-tools clean
install:
-rm -r build
$(MAKE) -C core-tools install
$(MAKE) -C unix-tools install
webfiles: $(MANPDF) $(MANHTML) $(WEBPNG)
# Create web page
dist: $(MANPDF) $(MANHTML) $(WEBPNG)
perl -n -e 'if (/^<!-- #!(.*) -->/) { system("$$1"); } else { print; }' web/index.html >$(WEBDIST)/index.html
cp $(MANHTML) $(MANPDF) $(WEBDIST)
cp $(WEBPNG) $(WEBDIST)
# Obtain dot files from Unix host
rsync-graphdot:
ssh stereo 'cd src/dgsh && git pull && make webfiles'
rsync -a stereo:src/dgsh/graphdot/ graphdot/
rsync -a stereo:src/dgsh/example/ example/
dotfiles: $(EGDOT)
pull:
git pull
# Pull master on all sub-repositories.
# Note that the gnulib ones get detached by by builds specifying
# a specific gnulib version. Through this pull repos on master
# stay on master; detached repos (gnulib) stay in the version they
# were detached.
git submodule status --recursive | awk '{print $$2}' | sort -r | while read d ; do ( echo "Pulling $$d" && cd $$d && old=$$(if [ $$(git rev-parse master) = $$(git rev-parse HEAD) ] ; then echo master ; else git rev-parse HEAD ; fi) && git checkout master && git pull && git checkout -q $$old ) ; done
push:
git push --recurse-submodules=on-demand
commit:
# Commit -a including submodules
printf '\n\n# Please enter the commit message for your changes.\n#\n' >.git/COMMIT_EDITMSG
git status --ignore-submodules=untracked | sed '/./s/^/# /;s/^$$/#/' >>.git/COMMIT_EDITMSG
$${VISUAL-vi} .git/COMMIT_EDITMSG
for i in $$(echo unix-tools/*/.git | sed 's/\.git//g') . ; do grep -v '^#' .git/COMMIT_EDITMSG | (cd $$i && git commit -a -F -) ; done
rm -f .git/COMMIT_EDITMSG
zip:
cd .. && zip -r dgsh.zip dgsh -x *.git*
# Rough uninstall rule to verify that tests pick up correct files
uninstall:
rm -rf $(PREFIX)/bin/dgsh-* $(PREFIX)/libexec/dgsh \
$(PREFIX)/lib/libdgsh.a