Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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