This repository has been archived by the owner on Sep 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
mkfile
293 lines (248 loc) · 8.21 KB
/
mkfile
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# ------------------------------------------------------------------
# $Id: mkfile,v 1.84 2006-04-10 21:28:53 nr Exp $
# ------------------------------------------------------------------
NAME = qc--
VERSION = `date +%Y%m%d`
#
# For configuration, see the files config/*.mk, in particular check that
# config/lua.mk has the right seting to find the Lua 4.0 header and
# library files.
#
< config/config.mk
# ------------------------------------------------------------------
# SUBDIRS are made from left to right - order matters
# ------------------------------------------------------------------
SUBDIRS = cllib asdl gen lua rtl camlburg tools doc src runtime interp
# ------------------------------------------------------------------
# profiling
# ------------------------------------------------------------------
#
# Profiling requires a "mk clobber" in advance.
#
# for ocamlprof(1): mk P=count
# for gprof(1): mk P=gprof all.opt
# test coverage: mk coverage (this uses ocamlprof)
#
# Maybe we should introduce virtual targets for these and call mk(1)
# recursively? --CL
#
# ------------------------------------------------------------------
# high level targets
# ------------------------------------------------------------------
# all: build the compiler, interpreter, documentation
# qc--: build compiler
# interp: build interpreter
# lib: build just the lib/ directory, but not the compiler
# clean: remove non-source files (recursive) but leave all
# binaries in bin/
# clobber: remove all non-source file
#
# test: run test suite
# install: simple-minded install to $prefix; need to call 'all' first
# coverage: show how much code is covered by the test suite
all:V: config qc-- $config_build_interp doc
all.opt:V: config qc--.opt $config_build_interp doc
config:QV:
if [ -f config/config.mk ]; then
if $config_test configure -nt config/config.mk
then
echo "============================================"
echo "config.mk is out of date."
echo "you must run ./configure before continuing"
echo "============================================"
exit 1
fi
else
echo "============================================"
echo "Run the ./configure script first!"
echo "Alternatively, create config/config.mk"
echo "from config/config.mk.template."
echo "============================================"
exit 1
fi
QCSRC=src runtime
qc--:VQ: tools lib dirs
./mkdirs $QCSRC
qc--.opt:VQ: tools.opt lib.opt dirs
./mkdirs -opt $QCSRC
LIBSRC=cllib asdl gen lua rtl
lib:VQ: dirs
./mkdirs $LIBSRC
lib.opt:QV: dirs
./mkdirs -opt $LIBSRC
TOOLSSRC=tools camlburg
tools:V: lib dirs
./mkdirs $TOOLSSRC
tools.opt:V: lib dirs
./mkdirs -opt $TOOLSSRC
interp:V: dirs qc--
./mkdirs interp
doc:V: dirs
./mkdirs doc
test:V: all
cd test2 && NPROC=1 mk $MKFLAGS all
test.opt:V: all.opt
cd test2 && NPROC=1 mk QC=../bin/qc--.opt $MKFLAGS all
coverage: test2/ocamlprof.dump
rm -f $target
for f in src/*.ml lua/*.ml cclib/*.ml rtl/*.ml gen/*.ml; do
ocamlprof -f test2/ocamlprof.dump -F @@@ $f | ./tools/coverage $f
done | sort -k 2 -n -r > $target
test2/ocamlprof.dump:Q:
echo "==========================================================="
echo "== No profile information found. Run first:"
echo "== mk P=count test"
echo "==========================================================="
exit 1
# ------------------------------------------------------------------
# line counting
#
# ------------------------------------------------------------------
count:V:
nocount cllib/*.nw rtl/*.nw src/*.nw
# ------------------------------------------------------------------
# installation
#
# delegate to subdirs
# ------------------------------------------------------------------
INST_DIRS=camlburg tools doc src runtime $config_build_interp
# SHOULDN'T THESE TARGETS ALSO MK DEPEND??? ---NR
install:QV: all
for d in $INST_DIRS
do
(echo "# cd $d" && cd $d && mk $MKFLAGS install) ||
exit 1
done
install.opt:QV: install all.opt
for d in $INST_DIRS
do
(echo "# cd $d" && cd $d && mk $MKFLAGS install.opt) ||
exit 1
done
# ------------------------------------------------------------------
# print dependency graph
# ------------------------------------------------------------------
dot:V: graph.dot
print-dot:V: graph.ps
lpr $prereq
%.ps:D: %.dot
dot -Tps $prereq > $target
DEPENDFILES = cllib/DEPEND.evaluating \
gen/DEPEND \
lua/DEPEND.std \
rtl/DEPEND.evaluating \
src/DEPEND.evaluating \
graph.dot:D: $DEPENDFILES
cat $prereq | ocamldot -landscape > $target
# ------------------------------------------------------------------
# Devleoper's Documentation
# ------------------------------------------------------------------
html \
dvi:V: dirs
for i in $SUBDIRS;
do
(echo "# cd $i" && cd $i && mk $MKFLAGS $target) ||
exit 1
done
# ------------------------------------------------------------------
# Cleaning
# ------------------------------------------------------------------
clean:V: dirs
for i in $SUBDIRS test2
do
(echo "#cd $i" && cd $i && mk $MKFLAGS $target)
done
find lib \
\( -name 'CVS' \
-o -name '.cvsignore' \
\) -prune \
-o -type f -exec rm '{}' \;
rm -f *.tar.gz
rm -f config/auxdir/tst
clean.opt:V: dirs
for i in $SUBDIRS test2
do
(echo "#cd $i" && cd $i && mk $MKFLAGS $target)
done
find lib \
\( -name 'CVS' \
-o -name '.cvsignore' \
\) -prune \
-o \
\( -name '*.cmx' \
-o -name '*.o' \
-o -name '*.a' \
-o -name '*.cmxa' \
\) -exec rm '{}' \;
rm -f *.tar.gz
rm -f config/auxdir/tst
clobber:V: dirs clean
for i in $SUBDIRS test2
do
(echo "# cd $i" && cd $i && mk $MKFLAGS $target)
done
find bin lib man \
\( -name 'CVS' \
-o -name '.cvsignore' \
\) -prune -o -type f -exec rm '{}' \;
rm -f FILES
rm -f config/config.mk
rm -f coverage */ocamlprof.dump
# make sure appropriate empty directories exist
dirs:VQ:
for i in bin include lib man man/man1 lua/std; do
[ -d $i ] || mkdir $i
done
# ------------------------------------------------------------------
# build distribution
#
# It is a good idea to call tar on a freshly checked out CVS repository
# to avoid junk being included into the tar file.
#
# tar - build a *.tar.gz file
# tar-test - unpack *.tar.gz file and call mk
# timestamps - make sure that machine generated sources are younger
# than their specs to not trigger call to tools
# that are unavailable. Usually necessary after
# checkout from CVS.
#
# ------------------------------------------------------------------
# name of directory a distribution unpacks into.
DIR = $NAME$VERSION
# find(1)'s job is it to exclude unwanted files and directories.
FILES:D: clobber
find . \
\( -path "*/CVS/*" \
-o -path "*/.*" \
-o -path "./lib/*" \
-o -path "./man/*" \
-o -path "./bin/*" \
-o -path "./test/*" \
-o -path "./aug99/*" \
-o -path "./ccl-suite/*" \
-o -path "./mwb/*" \
-o -path "./specialized/*" \
-o -path "./tdpe/*" \
-o -path "./bin/*" \
-o -path "./man/*" \
-o -path "./lib/*" \
-o -path "./lua-bench/*" \
-o -path "./lua-uniq/*" \
-o -path "./config/aux/*" \
-o -name "*.tar*" \
-o -type l \
\) -prune \
-o -type f -print | sort > $target
timestamps:V:
(cd interp; mk -t -a disasm-dec.c interp-dec.c encode.[ch])
touch */*.1
tar:V: $DIR.tar.gz
$DIR.tar.gz: FILES timestamps
ln -s . $DIR
tar czvhf $DIR.tar.gz `sed "s+^\./+$DIR/+" FILES`
rm -f $DIR
rm -f FILES
tar-test:V: $DIR.tar.gz
tar zxvf $DIR.tar.gz
( cd $DIR && ./configure && mk )
rm -rf $DIR