forked from ocsigen/eliom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·494 lines (404 loc) · 10.7 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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
#! /bin/sh
# Adapted from the ocamlnet configure script.
#######################################################################
# Helpers:
test_binary () {
# $1: the name of the binary
echo -n "Checking for $1 ... "
if which "$1" >/dev/null 2>/dev/null; then
echo "found"
return 0
else
echo "not found"
return 1
fi
}
fail_binary () {
echo
echo "Required command '$1' not found!"
[ -z "$2" ] || echo "===> $2"
exit 1
}
check_binary () {
# $1: the name of the binary
# $2: an URL
if test_binary "$1"; then
return
else
fail_binary "$1" "$2"
fi
}
test_library () {
# $1: the name of the library (findlib)
echo -n "Checking for $1 ... "
if ocamlfind query $1 >/dev/null 2>/dev/null; then
echo "found"
return 0
else
echo "not found"
return 1
fi
}
fail_library () {
echo
echo "Required library $1 not found!"
[ -z "$2" ] || echo "===> Opam package(s): $2"
[ -z "$3" ] || echo "===> $3"
exit 1
}
check_library () {
# $1: the name of the library (findlib)
# $2: an URL
if test_library "$1"; then
return
else
fail_library "$1" "$2" "$3"
fi
}
#######################################################################
# Defaults
#--- Options ---
# value 0: off
# value 1: on
# defaults:
set_defaults () {
name="eliom"
enable_natdynlink=1
enable_debug=0
enable_annot=0
with_preempt=1
root=""
temproot=""
prefix="/usr/local"
bindir=""
mandir=""
libdir=""
docdir=""
datadir=""
}
set_defaults
my_pwd=$(dirname $0)
version=$(head -n 1 $my_pwd/VERSION)
full_pwd=$(pwd)
########################################################################
## Option parsing
#
#
ehelp_debug="Enable/disable debug output"
ehelp_annot="Enable/disable .annot files"
ehelp_natdynlink="Enable/disable nativecode dynamic linking"
## Which options exist? eoptions for enable/disable, woptions for with/without:
eoptions="debug annot natdynlink"
woptions="preempt"
print_options () {
for opt in $eoptions; do
e="o=\$enable_$opt"
eval "$e"
uopt=$(echo $opt | sed -e 's/_/-/g')
if [ $o -gt 0 ]; then
echo " --enable-$uopt"
else
echo " --disable-$uopt"
fi
done
for opt in $woptions; do
e="o=\$with_$opt"
eval "$e"
uopt=$(echo $opt | sed -e 's/_/-/g')
if [ $o -gt 0 ]; then
echo " --with-$uopt"
else
echo " --without-$uopt"
fi
done
case "$bindir" in
"") bindir2="<prefix>/bin";;
*) bindir2=$bindir;;
esac
case "$mandir" in
"") mandir2="<prefix>/man";;
*) mandir2=$mandir;;
esac
case "$libdir" in
"") libdir2="\$(shell \${OCAMLFIND} printconf destdir)";;
*) libdir2=$libdir;;
esac
case "$docdir" in
"") docdir2="<prefix>/share/doc/\$(PROJECTNAME)";;
*) docdir2=$docdir;;
esac
case "$datadir" in
"") datadir2="<prefix>/share/\$(PROJECTNAME)";;
*) datadir2=$datadir;;
esac
echo " --name $name"
echo " --root $root"
echo " --temproot $temproot"
echo " --prefix $prefix"
echo " --bindir $bindir2"
echo " --mandir $mandir2"
echo " --libdir $libdir2"
echo " --docdir $docdir2"
echo " --datadir $datadir2"
}
usage () {
set_defaults
cat <<_EOF_ >&2
usage: ./configure [ options ]
--enable-debug, --disable-debug Enable/disable debug output
--enable-annot, --disable-annot Enable/disable .annot files generation
--enable-natdynlink, --disable-natdynlink Enable/disable nativecode dynamic linking
--with-preempt, --without-preempt compile with preemptive threads support.
--name=NAME The name of the library and ocamlfind package.
--root=DIR Root directory to install the package, every other options are relatives to this path. (usually /)
--temproot=DIR Temporary root directory to install the package (usually always "" but for package makers)
--prefix=DIR Subdirectory where to install binaries and libs (usually /usr or /usr/local)
--bindir=DIR Install binaries into this directory
--mandir=DIR Install manpages into this directory
--libdir=DIR Common directory for Ocsigen server's libraries
--docdir=DIR Install documentation in this directory
--datadir=DIR Install additional data files in this directory
Defaults are:
_EOF_
print_options >&2
exit 1
}
check_eopt () {
for x in $eoptions; do
if [ "$x" = "$1" ]; then
return 0
fi
done
echo "Unknown option: $1" >&2
exit 1
}
check_wopt () {
for x in $woptions; do
if [ "$x" = "$1" ]; then
return 0
fi
done
echo "Unknown option: $1" >&2
exit 1
}
echo "Welcome to Eliom version $version" >&2
while [ "$#" -gt 0 ]; do
case "$1" in
--enable-*)
opt=$(echo "$1" | sed -e 's/--enable-//' -e 's/-/_/g')
check_eopt "$opt"
eval "enable_$opt=2"
shift
;;
--disable-*)
opt=$(echo "$1" | sed -e 's/--disable-//' -e 's/-/_/g')
check_eopt "$opt"
eval "enable_$opt=-1"
shift
;;
--with-*)
opt=$(echo "$1" | sed -e 's/--with-//' -e 's/-/_/g')
check_wopt "$opt"
eval "with_$opt=2"
shift
;;
--without-*)
opt=$(echo "$1" | sed -e 's/--without-//' -e 's/-/_/g')
check_wopt "$opt"
eval "with_$opt=-1"
shift
;;
--root)
root="$2"
shift
shift
;;
--temproot)
temproot="$2"
shift
shift
;;
--prefix)
prefix="$2"
shift
shift
;;
--name)
name="$2"
shift
shift
;;
--bindir)
bindir="$2"
shift
shift
;;
--mandir)
mandir="$2"
shift
shift
;;
--libdir)
libdir="$2"
shift
shift
;;
--docdir)
docdir="$2"
shift
shift
;;
--datadir)
datadir="$2"
shift
shift
;;
*)
echo "Unknown option: $1" >&2
usage
esac
done
case "$bindir" in
"") bindir="$prefix/bin";;
esac
case "$mandir" in
"") mandir="$prefix/man";;
esac
case "$libdir" in
"") libdir="\$(shell \${OCAMLFIND} printconf destdir)";;
*) libdir=$root$libdir
esac
case "$docdir" in
"") docdir="$prefix/share/doc/\$(PROJECTNAME)";;
esac
case "$datadir" in
"") datadir="$prefix/share/\$(PROJECTNAME)";;
esac
check_binary ocamlc "See: http://www.ocaml.org/"
check_ocamlversion () {
echo -n "Checking for OCaml version... "
version=$(ocamlc -version)
echo $version
n1=$(echo $version | sed 's/^\([0-9][0-9]*\)\..*$/\1/')
n2=$(echo $version | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/')
# n3=`echo $version | sed 's/^[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/'`
if [ $n1 -eq 3 ] && [ $n2 -lt 12 ]; then
echo;
echo "OCaml >= 3.12 is required. Aborting.";
exit 1;
fi
}
check_ocsigenserverversion () {
echo -n "Checking for ocsigenserver version... "
version=$(ocamlfind query ocsigenserver -l | grep version: | awk '{ print $2 }')
echo $version
n1=$(echo $version | sed 's/^\([0-9][0-9]*\)\..*$/\1/')
n2=$(echo $version | sed 's/^[0-9][0-9]*\.\([0-9][0-9]*\).*$/\1/')
# n3=`echo $version | sed 's/^[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)\..*$/\1/'`
if [ $n1 -eq 1 ] && [ $n2 -lt 91 ]; then
echo;
echo "Ocsigenserver >= 1.91 is required. Aborting.";
exit 1;
fi
}
check_ocamlversion
check_binary ocamlfind "See: http://projects.camlcity.org/projects/findlib.html"
check_library ocsigenserver ocsigenserver "See also: http://ocsigen.org/ocsigenserver/"
check_ocsigenserverversion
check_library deriving deriving "See also: https://github.com/ocsigen/deriving"
check_binary js_of_ocaml js_of_ocaml "See also: http://ocsigen.org/js_of_ocaml"
check_library js_of_ocaml.deriving "deriving js_of_ocaml" "Missing support for deriving in js_of_ocaml"
check_library react react "See also: http://erratique.ch/software/react"
check_library lwt lwt "See also: http://ocsigen.org/lwt"
check_library lwt.unix lwt "Missing support for 'unix' in lwt."
check_library lwt.react "react lwt" "Missing support for 'react' in lwt."
check_library calendar calendar "See also: http://calendar.forge.ocamlcore.org/"
check_library cryptokit cryptokit "See also: http://pauillac.inria.fr/~xleroy/software.html#cryptokit"
######################################################################
# Summary
echo
echo "Effective options:"
print_options
echo
#Convert 0/1 values to YES/NO
if [ $enable_debug -gt 0 ] ; then
enable_debug="YES"
else
enable_debug="NO"
fi
if [ $enable_annot -gt 0 ] ; then
enable_annot="YES"
else
enable_annot="NO"
fi
if [ $enable_natdynlink -gt 0 ] ; then
enable_natdynlink="YES"
else
enable_natdynlink="NO"
fi
if [ $with_preempt -gt 0 ] ; then
with_preempt="YES"
else
with_preempt="NO"
fi
######################################################################
# Write Makefile.conf
echo "Writing Makefile.config"
cat <<_EOF_ > $my_pwd/Makefile.config
# The name of the library, ocamlfind package, etc.
PROJECTNAME := $name
#### External binaries ####
OCAMLFIND := ocamlfind
OCAMLMKLIB := ocamlmklib
JS_OF_OCAML := js_of_ocaml
CC := gcc
INSTALL := install
### Options ###
# Do you want preemptive threads ? YES/NO
PREEMPTIVE:=$with_preempt
# Do you want to use dynamic linking for native code? YES/NO
NATDYNLINK:=$enable_natdynlink
# Do you want debugging information (-g) ? YES/NO
DEBUG:=$enable_debug
# Do you want annot files (-dtypes) ? YES/NO
ANNOT:=$enable_annot
# Profiling (always put NO here - but if you want to debug eliom):
PROFILING:=NO
### Paths ###
# Temporary root directory to install the package (usually always "" but for package makers)
TEMPROOT = $temproot
# The directory for eliom compiler (binary):
BINDIR := $root$bindir
# Where to install Eliom tools manpages:
MANDIR := $root$mandir
# Where to install Eliom libraries:
LIBDIR := $libdir
# Where to put Eliom documentation:
DOCDIR := $root$docdir
# Where to install additional data:
DATADIR := $root$datadir
# The source directory (needed for local testing)
SRC := $full_pwd
include \$(SRC)/Makefile.options
_EOF_
######################################################################
# Finish
echo
echo
echo "Please check Makefile.config."
echo
echo "You can now compile Eliom by invoking:"
echo
echo " make"
echo " make doc"
echo
echo "You may want to test the extension before installation:"
echo
echo " make run.local"
echo " make run.opt.local"
echo
echo "Finally, if you want system-wide install, (become root if needed and) do"
echo
echo " make install"
echo " make install.doc"
echo