Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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