Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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