Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 693 lines (613 sloc) 19.333 kB
fccc685 Initial open-source release
MLstate authored
1 #!/bin/bash -ue
2
3 : ${OPA_SOURCE_DIR:=$(dirname $0)}
4 if [ "${OPA_SOURCE_DIR#/}" = "$OPA_SOURCE_DIR" ]; then OPA_SOURCE_DIR=$PWD/$OPA_SOURCE_DIR; fi
5
6 help() {
7 cat >&2 <<EOF
8 opalang configure script. Options:
9 -prefix <dir> the final installation prefix
10 -release configure for building in release mode
11 -noassert configure for building in noassert mode
12 -ocamldir <dir> where to find the ocaml libraries
13 -ocamlopt <path> the ocaml compiler to use
14 -ocamlfind <path> use the given ocamlfind to locate libraries
15 -no-ocamlfind don't use ocamlfind
16 -no-camlidl disable features based on camlidl
7a6af1e [fix] configure: unbound variable
Raja authored
17 -no-dbm disable features based on dbm
fccc685 Initial open-source release
MLstate authored
18 -help shows this message
19 EOF
20 # --no-<lib> if available
21 }
22
23 cd "$OPA_SOURCE_DIR"
24
25 while [ $# -gt 0 ]; do
26 case "$1" in
27 -prefix)
28 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument" >&2; exit 1; fi
29 shift
30 PREFIX=$1
31 ;;
32 -release)
33 IS_RELEASE=1
34 ;;
35 -noassert)
36 OCAMLBUILD_FLAGS="${OCAMLBUILD_FLAGS:-} -tag noassert"
37 ;;
38 -ocamldir)
39 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument" >&2; exit 1; fi
40 shift
41 OCAMLLIB=$1
42 ;;
43 -ocamlopt)
44 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument" >&2; exit 1; fi
45 shift
46 OCAMLOPT=$1
47 ;;
48 -ocamlfind)
49 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument" >&2; exit 1; fi
50 shift
51 OCAMLFIND=$1
52 ;;
53 -no-ocamlfind)
54 NO_OCAMLFIND=1
55 ;;
56 -no-camlidl)
57 NO_CAMLIDL=1
58 ;;
292ad42 @nrs135 [feature] configure: Added --no-dbm to ensure no Dbm dependencies.
nrs135 authored
59 -no-dbm)
60 NO_DBM=1
61 ;;
fccc685 Initial open-source release
MLstate authored
62 -h|-help|--help)
63 help
64 exit 0;;
65 *)
66 echo "Error: unknown option $1" >&2
67 echo
68 help
69 exit 2
70 esac
71 shift
72 done
73
74 : ${PREFIX:=${MLSTATELIBS:-}}
75 : ${PREFIX:=/usr/local}
76 : ${IS_RELEASE:=}
77
78 CONFIG_LOG=$PWD/config.log
79
80 echo -n >$CONFIG_LOG
81
82 echo-check() { echo -n "Checking $*... " >&2 ; echo "# CHECK-START: $*" >>$CONFIG_LOG; }
83 echo-ok() {
84 local opts=; if [ "X$1" = "X-n" ]; then shift; opts="-n"; fi
85 echo $opts "$*" >&2 ; echo $opts -e "# CHECK-OK: $*\n" >>$CONFIG_LOG;
86 }
87 echo-ok-tag() { echo "OK" >&2 ; echo -e "# CHECK-OK\n" >>$CONFIG_LOG; }
88 echo-err() { echo "$*" >&2 ; echo -e "# CHECK-FAIL: $*\n" >>$CONFIG_LOG; }
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
89 echo-skip() { echo "$*" >&2 ; echo -e "# CHECK-SKIP: $*\n" >>$CONFIG_LOG; }
fccc685 Initial open-source release
MLstate authored
90
91 # check OS
92 echo-check your OS
93 EXT_LIB="a"
94 EXT_OBJ="o"
95 EXT_SHARED="so"
96 case $(uname) in
97 CYGWIN*)
98 echo-ok Windows/cygwin
99 EXT_LIB="lib"
100 EXT_OBJ="obj"
101 EXT_SHARED="dll"
102 IS_WINDOWS=1;;
103 Darwin*)
104 echo-ok MacOS
105 IS_MAC=1;;
106 Linux*)
107 echo-ok Linux
108 IS_LINUX=1;;
109 *)
110 echo-err "Not sure, probably Unix / Linux"
111 IS_LINUX=1
112 esac
113
114 echo-check your architecture
115 case $(uname -m) in
116 x86_64)
117 echo-ok x86_64;;
118 i?86)
119 echo-ok ix86;;
120 *)
121 echo-err "$(uname -m)"
122 echo "Sorry, this architecture is unsupported at the moment." >&2
123 exit 1
124 esac
125
126 lastresort_hint() {
127 cat <<EOF
128
129 If you have trouble meeting the required dependencies with your distribution,
130 you may want to have a look at the script installation_helper.sh in the
131 dependencies/ directory to build them from source.
132
133 EOF
134 }
135 trap lastresort_hint ERR
136
137 # specific platform checks
138 if [ -n "${IS_MAC:-}" ]; then
29f3038 [fix] gsed: not in GNU coreutils on Mac
Hugo Venturini authored
139 echo-check for gsed
140 if which gsed > /dev/null 2>&1; then echo-ok ok
141 else
142 echo-err Not found
143 echo "gsed is needed to build OPA."
144 if which port >/dev/null 2>&1; then
145 echo -e " You should run:\n\tsudo port install gsed"
146 # else #todo# [add useful suggestion here]
147 fi
148 exit 1
149 fi >&2
fccc685 Initial open-source release
MLstate authored
150 echo-check for GNU coreutils
29f3038 [fix] gsed: not in GNU coreutils on Mac
Hugo Venturini authored
151 if which gtail gmktemp gsort greadlink >/dev/null 2>&1; then echo-ok ok
fccc685 Initial open-source release
MLstate authored
152 else
153 echo-err Not found
154 echo "GNU coreutils are needed to build OPA."
155 if which port >/dev/null 2>&1; then
156 echo -e " You should run:\n\tsudo port install coreutils"
157 # else #todo# [add useful suggestion here]
158 fi
159 exit 1
160 fi >&2
161 . ./platform_helper.sh
162 fi
163
164 # check ocaml version and location
165 echo-check ocamlopt
166 if OCAMLOPT=${OCAMLOPT:-$(which ocamlopt.opt)} || OCAMLOPT=${OCAMLOPT:-$(which ocamlopt)}
167 then echo-ok $OCAMLOPT
168 else
169 echo-err Not found
170 echo "Ocaml 3.12 or newer is required. It's usually found in package 'ocaml'."
171 false
172 fi
173
174 echo-check ocamlbuild
175 : ${OCAMLBUILD:=$(dirname $OCAMLOPT)/ocamlbuild}
176 if [ -n "$IS_RELEASE" ]; then
177 OCAMLBUILD_FLAGS="${OCAMLBUILD_FLAGS:-} -tag release -tag noassert"
178 else
179 OCAMLBUILD_FLAGS="${OCAMLBUILD_FLAGS:-} -tag debug"
180 fi
181 if [ -x "$OCAMLBUILD" ]
182 then echo-ok $OCAMLBUILD
183 else
184 echo-err Not found
185 echo "Ocamlbuild is required. It should come with your ocaml distribution."
186 false
187 fi
188
189 echo-check ocamldir
190 : ${OCAMLLIB:=$($OCAMLOPT -where)}
191 echo-ok $OCAMLLIB
192
193 export OCAMLLIB
194
195 echo-check ocaml version
196 OCAML_VERSION=$($OCAMLOPT -version)
197 OCAML_VERSION_MAJOR=${OCAML_VERSION%%.*}
198 OCAML_VERSION_MIDDLE=${OCAML_VERSION%.*}
199 OCAML_VERSION_MIDDLE=${OCAML_VERSION_MIDDLE#*.}
200 if [ $OCAML_VERSION_MAJOR -eq 3 ] && [ $OCAML_VERSION_MIDDLE -ge 12 ]; then
201 echo-ok $OCAML_VERSION
202 else
203 echo-err $OCAML_VERSION
204 echo "Ocaml 3.12 or newer is required"
205 false
206 fi
207
208 echo-check your ocaml setup
209 check-ocaml () {
210 local DIR=$(mktemp -d /tmp/opa-configure.XXXXX)
211 trap "rm -rf /tmp/${DIR#/tmp/}" EXIT
212 cd $DIR
213 cat >test.ml <<EOF
214 let p = Unix.getpid()
215 let _ = Printf.printf "%s, %s %dbit" Sys.ocaml_version Sys.os_type Sys.word_size
216 let _ =
c24f567 [enhance] build: detect and accept 32bits version
Mathieu Barbin authored
217 exit Sys.word_size
fccc685 Initial open-source release
MLstate authored
218 EOF
219
220 echo "# $OCAMLBUILD$OCAMLBUILD_FLAGS -tag use_unix test.native" >> $CONFIG_LOG
221 R=0; $OCAMLBUILD$OCAMLBUILD_FLAGS -tag use_unix test.native >test.log 2>&1 || R=$?
222
223 cat test.log >> $CONFIG_LOG
224
225 if [ $R -ne 0 ]; then
226 echo-err "could not compile"
227 echo "----------"
228 tail -n 5 test.log | sed 's/^/ /'
229 echo "----------"
230 echo "Your ocaml installation seems broken, please fix it"
231 false
232 fi >&2
c24f567 [enhance] build: detect and accept 32bits version
Mathieu Barbin authored
233 set +e
234 RET=$(_build/test.native);
235 R=$?
236 set -e
237 case $R in
238 32)
239 OCAML_WORD_SIZE=32
240 echo-ok $RET
241 ;;
242 64)
243 OCAML_WORD_SIZE=64
244 echo-ok $RET
245 ;;
246 *)
247 echo-err $RET
248 echo "Your ocaml seems to be neither a 64bit or a 32bit version. Please install a native 64 bit package."
249 false
250 esac >&2
fccc685 Initial open-source release
MLstate authored
251 rm -rf /tmp/${DIR#/tmp/}
252 trap - EXIT
253 cd "$OPA_SOURCE_DIR"
254 }
255 check-ocaml
256
257 echo-check for camlp4
258 : ${CAMLP4O:=$(dirname $OCAMLOPT)/camlp4o}
259 : ${CAMLP4ORF:=$(dirname $OCAMLOPT)/camlp4orf}
260 if [ -x "$CAMLP4O" ] && [ -x "$CAMLP4ORF" ]
261 then echo-ok $CAMLP4O
262 else
263 echo-err Not found
264 echo "You need camlp4 to build this package. It is usually found in packages camlp4, camlp4-extra"
265 false
266 fi
267
268 # check tools:
269 # (*) stuff marked with * could maybe be optional and restrict the build correspondingly
270
271 # - checking for perl
272 echo-check for perl 5
273 if perl -v 2>/dev/null | grep -q 'v5\.'; then
274 echo-ok found
275 else
276 echo-err Not found
277 echo "You need Perl v5 to build this package ; it's usually found in package perl-base"
278 exit 1
279 fi >&2
280
281 # - checking camlidl *
282 echo-check for camlidl
283 if [ -n "${NO_CAMLIDL:-}" ]; then
284 HAS_CAMLIDL=
285 CAMLIDL=
286 echo-ok Disabled
287 elif
288 [ -e $OCAMLLIB/libcamlidl.a ] &&
289 CAMLIDL=${CAMLIDL:-$(dirname "$OCAMLOPT")/camlidl} && [ -x "$CAMLIDL" ] ||
290 CAMLIDL=$(which camlidl)
291 then
292 HAS_CAMLIDL=1
293 echo-ok $CAMLIDL
294 else
295 HAS_CAMLIDL=
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
296 echo-skip "Not found (but optional)"
fccc685 Initial open-source release
MLstate authored
297 fi
298
299
300 # check C libs:
301 # we depend on libssl, libzip and others, but through
302 # ocaml libs, so no need to check them directly
303 check-c-lib () (
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
304 local OPTIONAL=""
305 if [ $1 = "-opt" ]; then OPTIONAL=1; shift; fi
fccc685 Initial open-source release
MLstate authored
306 local LIB=$1; shift
307 [ $# -gt 0 ]
308 local INCLUDES=("$@")
309
310 local LIBNAME=$(basename "$LIB")
311 local LIBDIR=$(dirname "$LIB")
312 local INCLUDE_DIR
313 for d in {"$OCAMLLIB/..","$OCAMLLIB",/usr/lib,/usr/local/lib}{/$LIBDIR,}; do
314 if [ -e $d/lib$LIBNAME.a ]; then
315 LD_DIR=$(readlink -f $d)
316 INCLUDE_DIR=$LD_DIR/
317 INCLUDE_DIR=${INCLUDE_DIR%/lib/*}/include
318 break
319 fi
320 done
321 if [ -z "${LD_DIR:-}" ]; then
322 echo "could not find lib$LIBNAME.a" >>$CONFIG_LOG
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
323 if [ -n "$OPTIONAL" ]; then echo-skip "Not found (but optional)"
324 else echo-err Not found
325 fi
fccc685 Initial open-source release
MLstate authored
326 return 1
327 fi >&2
328
329 echo-ok -n "$LD_DIR/lib$LIBNAME.a, "
330
331 # Now checking compile, link & run
332 local DIR=$(mktemp -d /tmp/opa-configure.XXXXX)
333 trap "rm -rf /tmp/${DIR#/tmp/}" EXIT
334 cd $DIR
335
336 {
337 for i in "${INCLUDES[@]}"; do echo '#include <'$i'>'; done
338 echo 'int main () { return 0; }'
339 } >test_$LIBNAME.c
340
341 echo "# gcc -L$LD_DIR -I$INCLUDE_DIR -l$LIBNAME test_$LIBNAME.c -o test_$LIBNAME" >> $CONFIG_LOG
342 R=0; gcc -L$LD_DIR -I$INCLUDE_DIR -l$LIBNAME test_$LIBNAME.c -o test_$LIBNAME >check_$LIBNAME.log 2>&1 || R=$?
343
344 cat check_$LIBNAME.log >> $CONFIG_LOG
345
346 if [ $R -ne 0 ]; then
347 echo-err "could not compile"
348 echo "----------"
349 tail -n 5 check_${LIBNAME}.log | sed 's/^/ /'
350 echo "----------"
351 return 1
352 fi >&2
353 if ! ./test_$LIBNAME >> $CONFIG_LOG 2>&1; then
354 echo-err "compiled program doesn't work"
355 return 1
356 fi
357
358 echo-ok-tag
359 echo "$LIBNAME $LD_DIR $INCLUDE_DIR"
360 )
361
362 HAS_LIBNATPMP=
6bb0418 [fix] configure: handling the absence of camlidl correctly
Louis Gesbert authored
363 LIBNATPMP=("")
fccc685 Initial open-source release
MLstate authored
364 HAS_MINIUPNPC=
6bb0418 [fix] configure: handling the absence of camlidl correctly
Louis Gesbert authored
365 MINIUPNPC=("")
fccc685 Initial open-source release
MLstate authored
366 if [ -n "$HAS_CAMLIDL" ]; then
367 # - checking libnatpmp *
368 echo-check libnatpmp
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
369 if LIBNATPMP=($(check-c-lib -opt libnatpmp/natpmp netinet/in.h arpa/inet.h libnatpmp/getgateway.h libnatpmp/natpmp.h)); then
fccc685 Initial open-source release
MLstate authored
370 HAS_LIBNATPMP=1
17a5e59 [fix] configure: fix for the 'XXX[@] : undefined variable' under some…
Louis Gesbert authored
371 else
372 LIBNATPMP=("")
fccc685 Initial open-source release
MLstate authored
373 fi
374
375 # - checking miniupnpc *
376 echo-check miniupnpc
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
377 if MINIUPNPC=($(check-c-lib -opt miniupnpc/miniupnpc miniupnpc/miniwget.h miniupnpc/miniupnpc.h miniupnpc/upnpcommands.h)); then
fccc685 Initial open-source release
MLstate authored
378 HAS_MINIUPNPC=1
17a5e59 [fix] configure: fix for the 'XXX[@] : undefined variable' under some…
Louis Gesbert authored
379 else
380 MINIUPNPC=("")
fccc685 Initial open-source release
MLstate authored
381 fi
382 fi
383
384 # check ocaml libs:
385 # probably, first try with ocamlfind then fallback to
386 # custom check ; ensure consistency with function
387 # "get_ocamlfind_directory" in build/myocamlbuild_prefix.ml
388 echo-check for ocamlfind
389 if [ -n "${NO_OCAMLFIND:-}" ]; then
390 OCAMLFIND=
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
391 echo-skip Disabled
fccc685 Initial open-source release
MLstate authored
392 elif [ -z "${OCAMLFIND:-}" ]; then
393 OCAMLFIND=$(dirname $OCAMLOPT)/ocamlfind
394 if [ ! -x "$OCAMLFIND" ]; then
395 OCAMLFIND=$OCAMLLIB/../../bin/ocamlfind
396 fi
397 if [ ! -x "$OCAMLFIND" ]; then
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
398 echo-skip "Not found (but optional)"
fccc685 Initial open-source release
MLstate authored
399 OCAMLFIND=
400 else
401 echo-ok $OCAMLFIND
402 fi
403 elif [ -x "$OCAMLFIND" ]; then
404 echo-ok $OCAMLFIND
405 else
406 echo-err "Not found"
407 echo "You specified $OCAMLFIND on the command-line, but it doesn't exist or isn't executable" >&2
408 OCAMLFIND=
409 fi
410
411 EXTRA_TAGS="-tag use_unix"
412 check-ocaml-lib () {
413 local MODULE=$1; shift
414 local LIB=$1; shift
415 local LIBDIR=$1; shift
416 [ $# -eq 0 ]
417
418 local DIR=$(mktemp -d /tmp/opa-configure.XXXXX)
419 trap "rm -rf /tmp/${DIR#/tmp/}" EXIT
420 cd $DIR
421
422 echo "module M = $MODULE" >check_${LIB}.ml
423
424 local libdir_ins=""
425 if [ "$LIBDIR" != "$OCAMLLIB" ]; then libdir_ins=' ~dir:"'$LIBDIR'"'; fi
426 cat >myocamlbuild.ml <<EOF
427 let _ = Ocamlbuild_plugin.dispatch (function
428 | Ocamlbuild_plugin.After_rules ->
429 Ocamlbuild_plugin.ocaml_lib ~extern:true$libdir_ins ~tag_name:"use_my_lib" "$LIB"
430 | _ -> ()
431 )
432 EOF
433
434 echo "# $OCAMLBUILD$OCAMLBUILD_FLAGS $EXTRA_TAGS -tag use_my_lib check_${LIB}.native" >> $CONFIG_LOG
435
436 R=0; $OCAMLBUILD$OCAMLBUILD_FLAGS $EXTRA_TAGS -tag use_my_lib check_${LIB}.native >check_${LIB}.log 2>&1 || R=$?
437 cat check_${LIB}.log >> $CONFIG_LOG
438
439 if [ $R -ne 0 ]; then
440 echo-err "could not compile"
441 echo "----------"
442 tail -n 5 check_${LIB}.log | sed 's/^/ /'
443 echo "----------"
444 echo "The installation of $LIB seems broken, please fix it (did it come with a different ocaml compiler ?)"
445 return 1
446 else
447 echo-ok-tag
448 fi >&2
449 rm -rf /tmp/${DIR#/tmp/}
450 trap - EXIT
451 cd "$OPA_SOURCE_DIR"
452 }
453
454 check-cmxa () {
455 local DIR=$1; shift
456 [ $# -gt 0 ]
457 local canonical_name=$1
458 while [ $# -gt 0 ] && [ ! -e "$DIR/$(basename $1).cmxa" ]; do shift; done
459 if [ $# -eq 0 ]; then
460 echo-err "Not found"
461 echo "Please fix your installation of $canonical_name in $LIBDIR: no proper cmxa file was found there." >&2
462 return 1
463 fi
464 echo $1
465 }
466
467 locate-ocaml-lib () {
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
468 local OPTIONAL=""
469 if [ "$1" = "-opt" ]; then OPTIONAL=1; shift; fi
fccc685 Initial open-source release
MLstate authored
470 local MODULE=$1; shift # one module that the lib contains, to check
471 [ $# -gt 0 ] # remaining args: possible lib names (may be usual_dir/libname)
472
473 echo-check for $(basename $1)
474
475 local LIBDIR=""
476 local LIB
477 local LIB_NAMES=("$@")
478 while [ $# -gt 0 ] && [ -z "$LIBDIR" ]; do
479 LIB=$(basename $1)
480 USUAL_DIR=$(dirname $1)
481 [ "$USUAL_DIR" = "." ] && USUAL_DIR=$LIB
482 if [ -n "$OCAMLFIND" ] &&
483 LIBDIR=$("$OCAMLFIND" query "$LIB" 2>/dev/null)
484 then
485 LIB=$(check-cmxa $LIBDIR $LIB "${LIB_NAMES[@]}") || return 1
486 echo-ok -n "ocamlfind:$LIBDIR, "
487 elif [ -d "$OCAMLLIB"/"$USUAL_DIR" ]
488 then
489 LIB=$(check-cmxa "$OCAMLLIB"/"$USUAL_DIR" $LIB "${LIB_NAMES[@]}") \
490 || return 1
491 echo-ok -n "+$USUAL_DIR, "
492 LIBDIR=+"$USUAL_DIR"
493 elif [ -e "$OCAMLLIB"/"$LIB".cmxa ]
494 then
495 echo-ok -n "$LIB.cmxa, "
496 LIBDIR="$OCAMLLIB"
497 fi
498 shift
499 done
500 if [ -z "$LIBDIR" ]; then
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
501 if [ -n "$OPTIONAL" ]; then
502 echo-skip "Not found (but optional)"
503 else
504 echo-err "Not found"
505 fi
fccc685 Initial open-source release
MLstate authored
506 return 1
507 fi
508
509 check-ocaml-lib "$MODULE" "$LIB" "$LIBDIR" || return 1
510 echo "$LIBDIR/$LIB"
511 }
512 # for libs which are needed (fatal warning)
513 LIBS_NOT_FOUND=()
514 lib-not-found () {
515 local lib=$1; shift
516 local package=$1; shift
517 LIBS_NOT_FOUND[${#LIBS_NOT_FOUND[@]}]="$lib (might be found in package $package)"
518 }
519
520 # - checking ocaml-ssl
521 if ! CONFIG_LIB_OCAMLSSL=$(locate-ocaml-lib "Ssl" "ssl")
522 then lib-not-found "ocaml_ssl" "libssl-ocaml-dev"
523 fi
524
525 # - checking cryptokit
526 if ! CONFIG_LIB_CRYPTOKIT=$(EXTRA_TAGS="$EXTRA_TAGS -tag use_nums" locate-ocaml-lib "Cryptokit" "cryptokit")
527 then lib-not-found "cryptokit" "libcryptokit-ocaml-dev"
528 fi
529
530 # - checking camlzip
531 if ! CONFIG_LIB_CAMLZIP=$(locate-ocaml-lib "Zip" "camlzip" "zip")
532 then lib-not-found "camlzip" "libzip-ocaml-dev"
533 fi
534
535 # - checking ocamlgraph
536 if ! CONFIG_LIB_OCAMLGRAPH=$(locate-ocaml-lib "Graph" "ocamlgraph/graph")
537 then lib-not-found "ocamlgraph" "libocamlgraph-ocaml-dev"
538 fi
539
540 # - checking ulex
541 if ! CONFIG_LIB_ULEX=$(locate-ocaml-lib "Ulexing" "ulex" "ulexing")
542 then lib-not-found "ulex" "ocaml-ulex"
543 fi
544
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
545 # - checking dbm
7a6af1e [fix] configure: unbound variable
Raja authored
546 : ${NO_DBM:=""}
292ad42 @nrs135 [feature] configure: Added --no-dbm to ensure no Dbm dependencies.
nrs135 authored
547 if [ "X$NO_DBM" = "X1" ]; then
548 HAS_DBM=
549 else
550 HAS_DBM="1"
551 if ! CONFIG_LIB_DBM=$(locate-ocaml-lib -opt "Dbm" "dbm")
552 then HAS_DBM=
553 fi
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
554 fi
555
fccc685 Initial open-source release
MLstate authored
556 # # - checking camlimages *
557 # CONFIG_LIB_CAMLIMAGES=$(EXTRA_TAGS="$EXTRA_TAGS -tag use_graphics" locate-ocaml-lib "Jpeg" "camlimages") || true
558
559 if [ ${#LIBS_NOT_FOUND[@]} -ne 0 ]; then
560 echo
561 echo "Not configured. You need the following libraries installed:" >&2
562 for lib in "${LIBS_NOT_FOUND[@]}"; do
563 echo " - $lib" >&2
564 done
565 false
566 fi
567
568 # Output the configuration
569
570 dir_opt() {
571 local DIR=$(dirname "$1"); shift; [ $# -eq 0 ]
572 if [ "$DIR" = "$OCAMLLIB" ]; then echo 'None'
573 else echo 'Some "'$DIR'"'
574 fi
575 }
576
577 camlbool() { [ $# -eq 1 ]; if [ -n "$1" ]; then echo true; else echo false; fi; }
578
579 camlstrtuple() {
580 echo -n '"'$1'"'; shift
581 while [ $# -gt 0 ]; do
582 echo -n ', "'$1'"'; shift
583 done
584 }
585
586 camlopt() {
587 local cond=$1; shift
588 local val=$1; shift
589 [ $# -eq 0 ]
590 if [ -n "$cond" ]; then echo 'Some ('$val')'
591 else echo 'None'
592 fi
593 }
594
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
595 ALL_TAGS_LIST="camlidl libnatpmp miniupnpc dbm"
7b118ed [feature] configure: generating a list of available optional tags, fo…
Louis Gesbert authored
596 TAGS_LIST=""
fdba049 [fix] configure: fixed for old bash versions, now providing a list of…
Louis Gesbert authored
597 for tag in $ALL_TAGS_LIST; do
598 hasvar=HAS_$(tr '[:lower:]' '[:upper:]' <<<"$tag")
7b118ed [feature] configure: generating a list of available optional tags, fo…
Louis Gesbert authored
599 if [ -n "${!hasvar}" ]; then TAGS_LIST="$TAGS_LIST\"$tag\"; "; fi
600 done
601
fccc685 Initial open-source release
MLstate authored
602 # See config.mli for the documentation and spec of these variables
603 cat >config.ml <<EOF
604 let prefix = "$PREFIX"
605 let ocamllib = "$OCAMLLIB"
606 let ocamlopt = "$OCAMLOPT"
607 let ocamlbuild = "$OCAMLBUILD"
608 let ocamlbuild_flags = "$OCAMLBUILD_FLAGS"
609 let camlp4o = "$CAMLP4O"
610 let camlp4orf = "$CAMLP4ORF"
611
612 let camlidl = $(camlopt "$HAS_CAMLIDL" '"'"$CAMLIDL"'"')
613 let libnatpmp = $(camlopt "$HAS_LIBNATPMP" "$(camlstrtuple "${LIBNATPMP[@]}")")
614 let miniupnpc = $(camlopt "$HAS_MINIUPNPC" "$(camlstrtuple "${MINIUPNPC[@]}")")
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
615 let has_dbm = $(camlbool "$HAS_DBM")
fccc685 Initial open-source release
MLstate authored
616
7b118ed [feature] configure: generating a list of available optional tags, fo…
Louis Gesbert authored
617 let available = [ $TAGS_LIST]
fdba049 [fix] configure: fixed for old bash versions, now providing a list of…
Louis Gesbert authored
618 let all_tags = [ $(for t in $ALL_TAGS_LIST; do echo -n "\"$t\"; "; done)]
7b118ed [feature] configure: generating a list of available optional tags, fo…
Louis Gesbert authored
619
fccc685 Initial open-source release
MLstate authored
620 let is_release = $(camlbool "$IS_RELEASE")
621 type os = Linux | Mac | Win32 | Cygwin
622 let os =
623 $(if [ -n "${IS_LINUX:-}" ]; then echo Linux
624 elif [ -n "${IS_MAC:-}" ]; then echo Mac
625 else echo 'match Sys.os_type with "Win32" -> Win32 | "Cygwin" -> Cygwin | _ -> assert false'
626 fi)
627
628 module Libdir = struct
629 let ssl = $(dir_opt "$CONFIG_LIB_OCAMLSSL")
630 let cryptokit = $(dir_opt "$CONFIG_LIB_CRYPTOKIT")
631 let camlzip_name = "$(basename "$CONFIG_LIB_CAMLZIP")"
632 let camlzip = $(dir_opt "$CONFIG_LIB_CAMLZIP")
633 let graph = $(dir_opt "$CONFIG_LIB_OCAMLGRAPH")
634 let ulex = $(dir_opt "$CONFIG_LIB_ULEX")
635 end
636
637 let ext_lib = "$EXT_LIB"
638 let ext_obj = "$EXT_OBJ"
639 let ext_shared = "$EXT_SHARED"
640
641 EOF
642
643 cat >config.sh <<EOF
644 PREFIX="$PREFIX"
645 OCAMLLIB="$OCAMLLIB"
646 OCAMLOPT="$OCAMLOPT"
647 OCAMLBUILD="$OCAMLBUILD"
648 OCAMLBUILD_FLAGS="$OCAMLBUILD_FLAGS"
649 CAMLP4O="$CAMLP4O"
650 CAMLP4ORF="$CAMLP4ORF"
c24f567 [enhance] build: detect and accept 32bits version
Mathieu Barbin authored
651 OCAML_WORD_SIZE="$OCAML_WORD_SIZE"
fccc685 Initial open-source release
MLstate authored
652
653 HAS_CAMLIDL="$HAS_CAMLIDL"
654 CAMLIDL="$CAMLIDL"
655 HAS_LIBNATPMP="$HAS_LIBNATPMP"
656 LIBNATPMP=(${LIBNATPMP[@]})
657 HAS_MINIUPNPC="$HAS_MINIUPNPC"
658 MINIUPNPC=(${MINIUPNPC[@]})
ebb9f52 [feature] Database: making dblight compilation optional, depending on…
Louis Gesbert authored
659 HAS_DBM="$HAS_DBM"
fccc685 Initial open-source release
MLstate authored
660 IS_RELEASE="$IS_RELEASE"
661 IS_LINUX="${IS_LINUX:-}"
662 IS_WINDOWS="${IS_WINDOWS:-}"
663 IS_MAC="${IS_MAC:-}"
664 OS=$(if [ -n "${IS_LINUX:-}" ]; then echo '"Linux"'
665 elif [ -n "${IS_MAC:-}" ]; then echo '"Mac"'
666 elif [ -n "${IS_WINDOWS:-}" ]; then echo '"Win32"'
667 else echo "Error: OS inconsistency" >&2; exit 2
668 fi)
669
670 LIB_OCAMLSSL_DIR="$(dirname "$CONFIG_LIB_OCAMLSSL")"
671 LIB_CRYPTOKIT_DIR="$(dirname "$CONFIG_LIB_CRYPTOKIT")"
672 LIB_CAMLZIP_NAME="$(basename "$CONFIG_LIB_CAMLZIP")"
673 LIB_CAMLZIP_DIR="$(dirname "$CONFIG_LIB_CAMLZIP")"
674 LIB_OCAMLGRAPH_DIR="$(dirname "$CONFIG_LIB_OCAMLGRAPH")"
675 LIB_ULEX_DIR="$(dirname "$CONFIG_LIB_ULEX")"
676
677 EXT_LIB="$EXT_LIB"
678 EXT_OBJ="$EXT_OBJ"
679 EXT_SHARED="$EXT_SHARED"
680 EOF
681
682 sed 's/=["(]\(.*\)[)"]$/ := \1/' config.sh > config.make
683 if [ -n "${IS_MAC:-}" ]; then
684 echo "INSTALL := gcp -u -L"
685 fi >>config.make
686
687 {
688 echo
689 echo "Congrats, you're all set. Installation will be done in:"
690 echo " $PREFIX"
691 echo
692 } >&2
Something went wrong with that request. Please try again.