-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·335 lines (290 loc) · 8.07 KB
/
configure
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#! /bin/sh
# ReactiveML
# Louis Mandel
# adapted from Objective Caml
configure_options="$*"
prefix=/usr/local
bindir=''
libdir=''
mandir=''
manext=1
emacsdir=''
target=''
debug=''
ocamlversion_min=3.06
# Parse command-line arguments
while : ; do
case "$1" in
"") break;;
-prefix|--prefix)
prefix=$2; shift;;
-bindir|--bindir)
bindir=$2; shift;;
-libdir|--libdir)
libdir=$2; shift;;
-mandir|--mandir)
case "$2" in
*/man[1-9ln])
mandir=`echo $2 | sed -e 's|^\(.*\)/man.$|\1|'`
manext=`echo $2 | sed -e 's/^.*\(.\)$/\1/'`;;
*)
mandir=$2
manext=1;;
esac
shift;;
-debug|--debug)
debug='-g -dtypes';
shift;
continue;;
-target|--target)
target=$2; shift;;
-with-emacs-dir|--with-emacs-dir)
emacsdir=$2; shift;;
-help|--help)
cat <<EOF
Usage: configure [options]
Options: [defaults in brackets after descriptions]
--prefix PREFIX install files in PREFIX [$/usr/local]
--bindir DIR user executables in DIR [PREFIX/bin]
--libdir DIR object code libraries in DIR [PREFIX/lib]
--mandir DIR man documentation in DIR [PREFIX/man]
--target TARGET must be byte or opt [byte]
--debug add "-g -dtypes" to ocaml flags
--with-emacs-dir DIR set emacs dir to DIR
-with-emacs-dir DIR (same as above)
--help print this message
EOF
exit 0;;
*) echo "Unknown option \"$1\"." 1>&2; exit 2;;
esac
shift
done
# Sanity checks
case "$prefix" in
/*) ;;
*) echo "The -prefix directory must be absolute." 1>&2; exit 2;;
esac
case "$bindir" in
/*) ;;
"") ;;
*) echo "The -bindir directory must be absolute." 1>&2; exit 2;;
esac
case "$libdir" in
/*) ;;
"") ;;
*) echo "The -libdir directory must be absolute." 1>&2; exit 2;;
esac
case "$mandir" in
/*) ;;
"") ;;
*) echo "The -mandir directory must be absolute." 1>&2; exit 2;;
esac
# Generate the config file
rootdir=`dirname $0`
cd $rootdir/configure-tools
rm -f config
touch config
# Write options
echo "# -*- makefile -*-" >> config
echo "# generated by ./configure $configure_options" >> config
echo "" >> config
cat version >> config
echo "" >> config
# Generate a dummy rzi.ml file
if [ ! -f ../compiler/global/rzi.ml ]; then
echo "creating compiler/global/rzi.ml"
echo "let known_modules = [" > rzi.ml
echo "]" >> rzi.ml
mv rzi.ml ../compiler/global
fi
# Where to install
echo "# Where to install" >> config
echo "PREFIX=$prefix" >> config
case "$bindir" in
"") echo 'BINDIR="$(PREFIX)/bin"' >> config
bindir="$prefix/bin";;
*) echo 'BINDIR="$bindir"' >> config;;
esac
case "$libdir" in
"") echo 'LIBDIR="$(PREFIX)/lib/rml"' >> config
libdir="$prefix/lib/rml";;
*) echo 'LIBDIR="$libdir"' >> config;;
esac
case "$mandir" in
"") echo 'MANDIR="$(PREFIX)/man"' >> config
mandir="$prefix/man";;
*) echo 'MANDIR="$mandir"' >> config;;
esac
echo "MANEXT=$manext" >> config
echo 'EMACSDIR="$emacsdir"' >> config
echo "" >> config
# Check for install script
set dummy install; cmd_name=$2
echo -n "checking for $cmd_name... "
if sh ./searchpath $cmd_name; then
echo "$cmd_name"
else
echo "not found"
{ echo "configure: error: Cannot find $cmd_name." 1>&2; exit 1; }
fi
install=$cmd_name
# Check for Ocaml compilers
echo "# Program used" >> config
echo >> config
# checking for ocaml
set dummy ocaml; compiler_name=$2
echo -n "checking for $compiler_name... "
if sh ./searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: Cannot find $compiler_name." 1>&2; exit 1; }
fi
ocaml=$compiler
# checking for ocamlc
set dummy ocamlc; compiler_name=$2
echo -n "checking for $compiler_name... "
if sh ./searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: Cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamlc=$compiler
# we extract Ocaml version number and library path
# (borrowed from JC Filliatre)
ocamlversion=`$ocamlc -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
echo "ocaml version is $ocamlversion"
bad_version=`expr "$ocamlversion" \< "$ocamlversion_min"`
if test "$bad_version" = "1"; then
{ echo "configure: error: Ocaml >= $ocamlversion_min needed." 1>&2; exit 1; }
fi
ocamllib=`$ocamlc -where`
echo "ocaml library path is $ocamllib"
# checking for ocamlopt
set dummy ocamlopt; compiler_name=$2
echo -n "checking for $compiler_name... "
if sh ./searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
fi
ocamlopt=$compiler
ocamlbest=byte
if [ -n "$ocamlopt" ]; then
ocamlbest=opt
fi
if [ -z "$target" ]; then
target=$ocamlbest
fi
echo "TARGET=$target" >> config
echo "" >> config
# we extract Ocaml version number and library path
# (borrowed from JC Filliatre)
ocamlversion=`$ocamlopt -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
echo "ocaml version is $ocamlversion"
bad_version=`expr "$ocamlversion" \< "$ocamlversion_min"`
if test "$bad_version" = "1"; then
{ echo "configure: error: Ocaml >= $ocamlversion_min needed." 1>&2; exit 1; }
fi
ocamllib=`$ocamlopt -where`
echo "ocaml library path is $ocamllib"
# checking for ocamldep
set dummy ocamldep; compiler_name=$2
echo -n "checking for $compiler_name... "
if sh ./searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: Cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamldep=$compiler
# checking for ocamllex
set dummy ocamllex; compiler_name=$2
echo -n "checking for $compiler_name... "
if sh ./searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: Cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamllex=$compiler
# checking for ocamlyacc
set dummy ocamlyacc; compiler_name=$2
echo -n "checking for $compiler_name... "
if sh ./searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: Cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamlyacc=$compiler
# checking for ocamlcp
set dummy ocamlcp; compiler_name=$2
echo -n "checking for $compiler_name... "
if sh ./searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: Cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamlcp=$compiler
# checking for ocamlbuild
# set dummy ocamlbuild; compiler_name=$2
# echo -n "checking for $compiler_name... "
# if sh ./searchpath $compiler_name; then
# echo "$compiler_name"
# compiler=$compiler_name
# else
# echo "not found"
# { echo "configure: error: Cannot find $compiler_name." 1>&2; exit 1; }
# fi
# ocamlbuild=$compiler
# Finish generated files
echo "INSTALL=$install" >> config
echo "OCAML=$ocaml" >> config
echo "OCAMLCP=$ocamlcp" >> config
echo "OCAMLC=$ocamlc" >> config
echo "OCAMLOPT=$ocamlopt" >> config
echo "OCAMLDEP=$ocamldep" >> config
echo "OCAMLLEX=$ocamllex" >> config
echo "OCAMLYACC=$ocamlyacc" >> config
# echo "OCAMLBUILD=$ocamlbuild" >> config
echo "OCAMLFLAGS=$debug" >> config
echo "OCAMLOPTFLAGS=$debug" >> config
echo "OCAMLDEPFLAGS=-slash" >> config
echo "OCAMLBEST=$ocamlbest" >> config
echo
mv config ..
touch ../config-stamp
# Patch Caml files
cd ../patch
if sh ./patch_all.sh; then
echo "Patch OK"
else
{ echo "configure: error: Install \"patch\" or send an email to [email protected]" 1>&2; exit 1; }
fi
cd ../configure-tools
# Print a summary
echo
echo "** Configuration summary **"
echo
echo "Directories where ReactiveML will be installed:"
echo " binaries.................. $bindir"
echo " standard library.......... $libdir"
echo " manual pages.............. $mandir (with extension .$manext)"
if test "$EMACSDIR" != ""; then
echo " emacs files............... $emacsdir"
fi
echo
echo "creating config"
echo
echo "** ReactiveML configuration completed successfully **"
echo