Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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