Skip to content

HTTPS clone URL

Subversion checkout URL

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