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