Skip to content
This repository
Newer
Older
100755 757 lines (670 sloc) 20.594 kb
22b433a3 » Frédéric Perrin
2011-08-29 Don't assume that bash is in /bin
1 #!/usr/bin/env bash
2
3 set -u
4 set -e
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
c6585927 » François-Régis Sinot
2011-09-01 [fix] configure: disable camlidl and dbm by default
19 -camlidl enable features based on camlidl
836e2185 » Mathieu Baudet
2011-12-13 [fix] build: fixed misleading inline help for ./configure
20 -dbm enable features based on dbm
fccc6851 » MLstate
2011-06-21 Initial open-source release
21 -help shows this message
22 EOF
23 # --no-<lib> if available
24 }
25
26 cd "$OPA_SOURCE_DIR"
27
c6585927 » François-Régis Sinot
2011-09-01 [fix] configure: disable camlidl and dbm by default
28 NO_CAMLIDL=1
29 NO_DBM=1
30
fccc6851 » MLstate
2011-06-21 Initial open-source release
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 ;;
c6585927 » François-Régis Sinot
2011-09-01 [fix] configure: disable camlidl and dbm by default
62 -camlidl)
63 NO_CAMLIDL=0
64 ;;
65 -dbm)
66 NO_DBM=0
67 ;;
fccc6851 » MLstate
2011-06-21 Initial open-source release
68 -no-camlidl)
69 NO_CAMLIDL=1
70 ;;
292ad427 » nrs135
2011-08-26 [feature] configure: Added --no-dbm to ensure no Dbm dependencies.
71 -no-dbm)
72 NO_DBM=1
73 ;;
fccc6851 » MLstate
2011-06-21 Initial open-source release
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; }
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
101 echo-skip() { echo "$*" >&2 ; echo -e "# CHECK-SKIP: $*\n" >>$CONFIG_LOG; }
fccc6851 » MLstate
2011-06-21 Initial open-source release
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;;
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
117 Linux*|GNU/kFreeBSD)
fccc6851 » MLstate
2011-06-21 Initial open-source release
118 echo-ok Linux
119 IS_LINUX=1;;
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
120 FreeBSD)
121 echo-ok FreeBSD
122 IS_FREEBSD=1;;
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
87791cef » Frédéric Perrin
2011-09-03 amd64 is a synonym for x86_64
130 x86_64|amd64)
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
29f30388 » Hugo Venturini
2011-07-01 [fix] gsed: not in GNU coreutils on Mac
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
fccc6851 » MLstate
2011-06-21 Initial open-source release
164 echo-check for GNU coreutils
29f30388 » Hugo Venturini
2011-07-01 [fix] gsed: not in GNU coreutils on Mac
165 if which gtail gmktemp gsort greadlink >/dev/null 2>&1; then echo-ok ok
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
1321ba91 » Frédéric Perrin
2011-09-21 On FreeBSD check and use gmake, use make elsewhere
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
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
197 OCAMLOPT_DIR=$(dirname $(which $OCAMLOPT))
198
fccc6851 » MLstate
2011-06-21 Initial open-source release
199
200 echo-check ocamlbuild
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
201 : ${OCAMLBUILD:=$OCAMLOPT_DIR/ocamlbuild}
fccc6851 » MLstate
2011-06-21 Initial open-source release
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 _ =
c24f5678 » mbarbin
2011-07-18 [enhance] build: detect and accept 32bits version
243 exit Sys.word_size
fccc6851 » MLstate
2011-06-21 Initial open-source release
244 EOF
245
6e6731fd » OpaOnWindowsNow
2011-09-15 [fix] configure: typo, missing space
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=$?
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
c24f5678 » mbarbin
2011-07-18 [enhance] build: detect and accept 32bits version
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
fccc6851 » MLstate
2011-06-21 Initial open-source release
277 rm -rf /tmp/${DIR#/tmp/}
278 trap - EXIT
279 cd "$OPA_SOURCE_DIR"
280 }
281 check-ocaml
282
283 echo-check for camlp4
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
284 : ${CAMLP4O:=$OCAMLOPT_DIR/camlp4o}
285 : ${CAMLP4ORF:=$OCAMLOPT_DIR/camlp4orf}
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
a6982e9a » Frédéric Perrin
2011-08-29 Check for java
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
fccc6851 » MLstate
2011-06-21 Initial open-source release
316 # - checking camlidl *
317 echo-check for camlidl
fb7ab0a1 » aszlig
2011-09-13 [fix] configure: Correctly check for $NO_CAMLIDL.
318 if [ "X$NO_CAMLIDL" = "X1" ]; then
fccc6851 » MLstate
2011-06-21 Initial open-source release
319 HAS_CAMLIDL=
320 CAMLIDL=
321 echo-ok Disabled
322 elif
323 [ -e $OCAMLLIB/libcamlidl.a ] &&
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
324 CAMLIDL=${CAMLIDL:-$OCAMLOPT_DIR)/camlidl} && [ -x "$CAMLIDL" ] ||
fccc6851 » MLstate
2011-06-21 Initial open-source release
325 CAMLIDL=$(which camlidl)
326 then
327 HAS_CAMLIDL=1
328 echo-ok $CAMLIDL
329 else
330 HAS_CAMLIDL=
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
331 echo-skip "Not found (but optional)"
fccc6851 » MLstate
2011-06-21 Initial open-source release
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 () (
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
339 local OPTIONAL=""
340 if [ $1 = "-opt" ]; then OPTIONAL=1; shift; fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
358 if [ -n "$OPTIONAL" ]; then echo-skip "Not found (but optional)"
359 else echo-err Not found
360 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
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=
6bb04182 » Louis Gesbert
2011-06-28 [fix] configure: handling the absence of camlidl correctly
398 LIBNATPMP=("")
fccc6851 » MLstate
2011-06-21 Initial open-source release
399 HAS_MINIUPNPC=
6bb04182 » Louis Gesbert
2011-06-28 [fix] configure: handling the absence of camlidl correctly
400 MINIUPNPC=("")
fccc6851 » MLstate
2011-06-21 Initial open-source release
401 if [ -n "$HAS_CAMLIDL" ]; then
402 # - checking libnatpmp *
403 echo-check libnatpmp
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
404 if LIBNATPMP=($(check-c-lib -opt libnatpmp/natpmp netinet/in.h arpa/inet.h libnatpmp/getgateway.h libnatpmp/natpmp.h)); then
fccc6851 » MLstate
2011-06-21 Initial open-source release
405 HAS_LIBNATPMP=1
17a5e593 » Louis Gesbert
2011-06-24 [fix] configure: fix for the 'XXX[@] : undefined variable' under some…
406 else
407 LIBNATPMP=("")
fccc6851 » MLstate
2011-06-21 Initial open-source release
408 fi
409
410 # - checking miniupnpc *
411 echo-check miniupnpc
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
412 if MINIUPNPC=($(check-c-lib -opt miniupnpc/miniupnpc miniupnpc/miniwget.h miniupnpc/miniupnpc.h miniupnpc/upnpcommands.h)); then
fccc6851 » MLstate
2011-06-21 Initial open-source release
413 HAS_MINIUPNPC=1
17a5e593 » Louis Gesbert
2011-06-24 [fix] configure: fix for the 'XXX[@] : undefined variable' under some…
414 else
415 MINIUPNPC=("")
fccc6851 » MLstate
2011-06-21 Initial open-source release
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=
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
426 echo-skip Disabled
fccc6851 » MLstate
2011-06-21 Initial open-source release
427 elif [ -z "${OCAMLFIND:-}" ]; then
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
428 OCAMLFIND=$OCAMLOPT_DIR/ocamlfind
fccc6851 » MLstate
2011-06-21 Initial open-source release
429 if [ ! -x "$OCAMLFIND" ]; then
430 OCAMLFIND=$OCAMLLIB/../../bin/ocamlfind
431 fi
432 if [ ! -x "$OCAMLFIND" ]; then
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
433 echo-skip "Not found (but optional)"
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
451 MORE=""
452 if [ $# -gt 0 ]; then
453 MORE=$1; shift
454 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
455
456 local DIR=$(mktemp -d /tmp/opa-configure.XXXXX)
457 trap "rm -rf /tmp/${DIR#/tmp/}" EXIT
458 cd $DIR
459
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
460 echo "module M = $MODULE $MORE" >check_${LIB}.ml
fccc6851 » MLstate
2011-06-21 Initial open-source release
461
462 local libdir_ins=""
463 if [ "$LIBDIR" != "$OCAMLLIB" ]; then libdir_ins=' ~dir:"'$LIBDIR'"'; fi
464 cat >myocamlbuild.ml <<EOF
465 let _ = Ocamlbuild_plugin.dispatch (function
466 | Ocamlbuild_plugin.After_rules ->
467 Ocamlbuild_plugin.ocaml_lib ~extern:true$libdir_ins ~tag_name:"use_my_lib" "$LIB"
468 | _ -> ()
469 )
470 EOF
471
6e6731fd » OpaOnWindowsNow
2011-09-15 [fix] configure: typo, missing space
472 echo "# $OCAMLBUILD $OCAMLBUILD_FLAGS $EXTRA_TAGS -tag use_my_lib check_${LIB}.native" >> $CONFIG_LOG
fccc6851 » MLstate
2011-06-21 Initial open-source release
473
6e6731fd » OpaOnWindowsNow
2011-09-15 [fix] configure: typo, missing space
474 R=0; $OCAMLBUILD $OCAMLBUILD_FLAGS $EXTRA_TAGS -tag use_my_lib check_${LIB}.native >check_${LIB}.log 2>&1 || R=$?
fccc6851 » MLstate
2011-06-21 Initial open-source release
475 cat check_${LIB}.log >> $CONFIG_LOG
476
477 if [ $R -ne 0 ]; then
478 echo-err "could not compile"
479 echo "----------"
480 tail -n 5 check_${LIB}.log | sed 's/^/ /'
481 echo "----------"
482 echo "The installation of $LIB seems broken, please fix it (did it come with a different ocaml compiler ?)"
483 return 1
484 else
485 echo-ok-tag
486 fi >&2
487 rm -rf /tmp/${DIR#/tmp/}
488 trap - EXIT
489 cd "$OPA_SOURCE_DIR"
490 }
491
492 check-cmxa () {
493 local DIR=$1; shift
494 [ $# -gt 0 ]
495 local canonical_name=$1
496 while [ $# -gt 0 ] && [ ! -e "$DIR/$(basename $1).cmxa" ]; do shift; done
497 if [ $# -eq 0 ]; then
498 echo-err "Not found"
499 echo "Please fix your installation of $canonical_name in $LIBDIR: no proper cmxa file was found there." >&2
500 return 1
501 fi
502 echo $1
503 }
504
505 locate-ocaml-lib () {
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
506 local OPTIONAL=""
507 if [ "$1" = "-opt" ]; then OPTIONAL=1; shift; fi
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
508 if [ "$1" = "-crypto" ]; then
509 CHECK=check-cryptokit; shift
510 else
511 CHECK=check-ocaml-lib
512 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
513 local MODULE=$1; shift # one module that the lib contains, to check
514 [ $# -gt 0 ] # remaining args: possible lib names (may be usual_dir/libname)
515
516 echo-check for $(basename $1)
517
518 local LIBDIR=""
519 local LIB
520 local LIB_NAMES=("$@")
521 while [ $# -gt 0 ] && [ -z "$LIBDIR" ]; do
522 LIB=$(basename $1)
523 USUAL_DIR=$(dirname $1)
524 [ "$USUAL_DIR" = "." ] && USUAL_DIR=$LIB
525 if [ -n "$OCAMLFIND" ] &&
526 LIBDIR=$("$OCAMLFIND" query "$LIB" 2>/dev/null)
527 then
528 LIB=$(check-cmxa $LIBDIR $LIB "${LIB_NAMES[@]}") || return 1
529 echo-ok -n "ocamlfind:$LIBDIR, "
530 elif [ -d "$OCAMLLIB"/"$USUAL_DIR" ]
531 then
532 LIB=$(check-cmxa "$OCAMLLIB"/"$USUAL_DIR" $LIB "${LIB_NAMES[@]}") \
533 || return 1
534 echo-ok -n "+$USUAL_DIR, "
535 LIBDIR=+"$USUAL_DIR"
536 elif [ -e "$OCAMLLIB"/"$LIB".cmxa ]
537 then
538 echo-ok -n "$LIB.cmxa, "
539 LIBDIR="$OCAMLLIB"
540 fi
541 shift
542 done
543 if [ -z "$LIBDIR" ]; then
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
544 if [ -n "$OPTIONAL" ]; then
545 echo-skip "Not found (but optional)"
546 else
547 echo-err "Not found"
548 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
549 return 1
550 fi
551
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
552 $CHECK "$MODULE" "$LIB" "$LIBDIR" || return 1
fccc6851 » MLstate
2011-06-21 Initial open-source release
553 echo "$LIBDIR/$LIB"
554 }
555 # for libs which are needed (fatal warning)
556 LIBS_NOT_FOUND=()
557 lib-not-found () {
558 local lib=$1; shift
559 local package=$1; shift
560 LIBS_NOT_FOUND[${#LIBS_NOT_FOUND[@]}]="$lib (might be found in package $package)"
561 }
562
2f70b7f1 » Aqua-Ye
2012-02-06 [enhance] configure: added a specific check for cryptokit, need >= 1.…
563 check-cryptokit () {
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
564 if !(check-ocaml-lib $1 $2 $3 "let _ = Cryptokit.MAC.hmac_sha256 \"OPA\""); then
565 echo-err "You need cryptokit >= 1.4"
2f70b7f1 » Aqua-Ye
2012-02-06 [enhance] configure: added a specific check for cryptokit, need >= 1.…
566 fi
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
567 }
2f70b7f1 » Aqua-Ye
2012-02-06 [enhance] configure: added a specific check for cryptokit, need >= 1.…
568
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
569 locate-and-check-cryptokit () {
570 locate-ocaml-lib -crypto "Cryptokit" "cryptokit"
2f70b7f1 » Aqua-Ye
2012-02-06 [enhance] configure: added a specific check for cryptokit, need >= 1.…
571 }
572
fccc6851 » MLstate
2011-06-21 Initial open-source release
573 # - checking ocaml-ssl
574 if ! CONFIG_LIB_OCAMLSSL=$(locate-ocaml-lib "Ssl" "ssl")
575 then lib-not-found "ocaml_ssl" "libssl-ocaml-dev"
576 fi
577
578 # - checking cryptokit
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
579 if ! CONFIG_LIB_CRYPTOKIT=$(EXTRA_TAGS="$EXTRA_TAGS -tag use_nums" locate-and-check-cryptokit)
fccc6851 » MLstate
2011-06-21 Initial open-source release
580 then lib-not-found "cryptokit" "libcryptokit-ocaml-dev"
581 fi
582
583 # - checking camlzip
584 if ! CONFIG_LIB_CAMLZIP=$(locate-ocaml-lib "Zip" "camlzip" "zip")
585 then lib-not-found "camlzip" "libzip-ocaml-dev"
586 fi
587
588 # - checking ocamlgraph
589 if ! CONFIG_LIB_OCAMLGRAPH=$(locate-ocaml-lib "Graph" "ocamlgraph/graph")
590 then lib-not-found "ocamlgraph" "libocamlgraph-ocaml-dev"
591 fi
592
593 # - checking ulex
594 if ! CONFIG_LIB_ULEX=$(locate-ocaml-lib "Ulexing" "ulex" "ulexing")
595 then lib-not-found "ulex" "ocaml-ulex"
596 fi
597
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
598 # - checking dbm
7a6af1e4 » Raja
2011-08-29 [fix] configure: unbound variable
599 : ${NO_DBM:=""}
292ad427 » nrs135
2011-08-26 [feature] configure: Added --no-dbm to ensure no Dbm dependencies.
600 if [ "X$NO_DBM" = "X1" ]; then
601 HAS_DBM=
602 else
603 HAS_DBM="1"
604 if ! CONFIG_LIB_DBM=$(locate-ocaml-lib -opt "Dbm" "dbm")
605 then HAS_DBM=
606 fi
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
607 fi
608
fccc6851 » MLstate
2011-06-21 Initial open-source release
609 # # - checking camlimages *
610 # CONFIG_LIB_CAMLIMAGES=$(EXTRA_TAGS="$EXTRA_TAGS -tag use_graphics" locate-ocaml-lib "Jpeg" "camlimages") || true
611
612 if [ ${#LIBS_NOT_FOUND[@]} -ne 0 ]; then
613 echo
614 echo "Not configured. You need the following libraries installed:" >&2
615 for lib in "${LIBS_NOT_FOUND[@]}"; do
616 echo " - $lib" >&2
617 done
618 false
619 fi
620
621 # Output the configuration
622
623 dir_opt() {
624 local DIR=$(dirname "$1"); shift; [ $# -eq 0 ]
625 if [ "$DIR" = "$OCAMLLIB" ]; then echo 'None'
626 else echo 'Some "'$DIR'"'
627 fi
628 }
629
630 camlbool() { [ $# -eq 1 ]; if [ -n "$1" ]; then echo true; else echo false; fi; }
631
632 camlstrtuple() {
633 echo -n '"'$1'"'; shift
634 while [ $# -gt 0 ]; do
635 echo -n ', "'$1'"'; shift
636 done
637 }
638
639 camlopt() {
640 local cond=$1; shift
641 local val=$1; shift
642 [ $# -eq 0 ]
643 if [ -n "$cond" ]; then echo 'Some ('$val')'
644 else echo 'None'
645 fi
646 }
647
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
648 ALL_TAGS_LIST="camlidl libnatpmp miniupnpc dbm"
7b118edd » Louis Gesbert
2011-06-24 [feature] configure: generating a list of available optional tags, fo…
649 TAGS_LIST=""
fdba0491 » Louis Gesbert
2011-06-24 [fix] configure: fixed for old bash versions, now providing a list of…
650 for tag in $ALL_TAGS_LIST; do
651 hasvar=HAS_$(tr '[:lower:]' '[:upper:]' <<<"$tag")
7b118edd » Louis Gesbert
2011-06-24 [feature] configure: generating a list of available optional tags, fo…
652 if [ -n "${!hasvar}" ]; then TAGS_LIST="$TAGS_LIST\"$tag\"; "; fi
653 done
654
fccc6851 » MLstate
2011-06-21 Initial open-source release
655 # See config.mli for the documentation and spec of these variables
656 cat >config.ml <<EOF
657 let prefix = "$PREFIX"
658 let ocamllib = "$OCAMLLIB"
659 let ocamlopt = "$OCAMLOPT"
660 let ocamlbuild = "$OCAMLBUILD"
661 let ocamlbuild_flags = "$OCAMLBUILD_FLAGS"
662 let camlp4o = "$CAMLP4O"
663 let camlp4orf = "$CAMLP4ORF"
664
665 let camlidl = $(camlopt "$HAS_CAMLIDL" '"'"$CAMLIDL"'"')
666 let libnatpmp = $(camlopt "$HAS_LIBNATPMP" "$(camlstrtuple "${LIBNATPMP[@]}")")
667 let miniupnpc = $(camlopt "$HAS_MINIUPNPC" "$(camlstrtuple "${MINIUPNPC[@]}")")
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
668 let has_dbm = $(camlbool "$HAS_DBM")
fccc6851 » MLstate
2011-06-21 Initial open-source release
669
7b118edd » Louis Gesbert
2011-06-24 [feature] configure: generating a list of available optional tags, fo…
670 let available = [ $TAGS_LIST]
fdba0491 » Louis Gesbert
2011-06-24 [fix] configure: fixed for old bash versions, now providing a list of…
671 let all_tags = [ $(for t in $ALL_TAGS_LIST; do echo -n "\"$t\"; "; done)]
7b118edd » Louis Gesbert
2011-06-24 [feature] configure: generating a list of available optional tags, fo…
672
fccc6851 » MLstate
2011-06-21 Initial open-source release
673 let is_release = $(camlbool "$IS_RELEASE")
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
674 type os = Linux | Mac | Win32 | Cygwin | FreeBSD
fccc6851 » MLstate
2011-06-21 Initial open-source release
675 let os =
676 $(if [ -n "${IS_LINUX:-}" ]; then echo Linux
677 elif [ -n "${IS_MAC:-}" ]; then echo Mac
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
678 elif [ -n "${IS_FREEBSD:-}" ]; then echo FreeBSD
fccc6851 » MLstate
2011-06-21 Initial open-source release
679 else echo 'match Sys.os_type with "Win32" -> Win32 | "Cygwin" -> Cygwin | _ -> assert false'
680 fi)
681
1321ba91 » Frédéric Perrin
2011-09-21 On FreeBSD check and use gmake, use make elsewhere
682 let makebinary =
683 $(if [ -n "${IS_FREEBSD:-}" ];
684 then echo '"gmake"'
685 else echo '"make"'
686 fi)
687
fccc6851 » MLstate
2011-06-21 Initial open-source release
688 module Libdir = struct
689 let ssl = $(dir_opt "$CONFIG_LIB_OCAMLSSL")
690 let cryptokit = $(dir_opt "$CONFIG_LIB_CRYPTOKIT")
691 let camlzip_name = "$(basename "$CONFIG_LIB_CAMLZIP")"
692 let camlzip = $(dir_opt "$CONFIG_LIB_CAMLZIP")
693 let graph = $(dir_opt "$CONFIG_LIB_OCAMLGRAPH")
694 let ulex = $(dir_opt "$CONFIG_LIB_ULEX")
695 end
696
697 let ext_lib = "$EXT_LIB"
698 let ext_obj = "$EXT_OBJ"
699 let ext_shared = "$EXT_SHARED"
700
701 EOF
702
703 cat >config.sh <<EOF
704 PREFIX="$PREFIX"
705 OCAMLLIB="$OCAMLLIB"
706 OCAMLOPT="$OCAMLOPT"
707 OCAMLBUILD="$OCAMLBUILD"
708 OCAMLBUILD_FLAGS="$OCAMLBUILD_FLAGS"
709 CAMLP4O="$CAMLP4O"
710 CAMLP4ORF="$CAMLP4ORF"
c24f5678 » mbarbin
2011-07-18 [enhance] build: detect and accept 32bits version
711 OCAML_WORD_SIZE="$OCAML_WORD_SIZE"
fccc6851 » MLstate
2011-06-21 Initial open-source release
712
713 HAS_CAMLIDL="$HAS_CAMLIDL"
714 CAMLIDL="$CAMLIDL"
715 HAS_LIBNATPMP="$HAS_LIBNATPMP"
716 LIBNATPMP=(${LIBNATPMP[@]})
717 HAS_MINIUPNPC="$HAS_MINIUPNPC"
718 MINIUPNPC=(${MINIUPNPC[@]})
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
719 HAS_DBM="$HAS_DBM"
fccc6851 » MLstate
2011-06-21 Initial open-source release
720 IS_RELEASE="$IS_RELEASE"
721 IS_LINUX="${IS_LINUX:-}"
722 IS_WINDOWS="${IS_WINDOWS:-}"
723 IS_MAC="${IS_MAC:-}"
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
724 IS_FREEBSD="${IS_FREEBSD:-}"
fccc6851 » MLstate
2011-06-21 Initial open-source release
725 OS=$(if [ -n "${IS_LINUX:-}" ]; then echo '"Linux"'
726 elif [ -n "${IS_MAC:-}" ]; then echo '"Mac"'
727 elif [ -n "${IS_WINDOWS:-}" ]; then echo '"Win32"'
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
728 elif [ -n "${IS_FREEBSD:-}" ]; then echo '"FreeBSD"'
fccc6851 » MLstate
2011-06-21 Initial open-source release
729 else echo "Error: OS inconsistency" >&2; exit 2
730 fi)
731
732 LIB_OCAMLSSL_DIR="$(dirname "$CONFIG_LIB_OCAMLSSL")"
733 LIB_CRYPTOKIT_DIR="$(dirname "$CONFIG_LIB_CRYPTOKIT")"
734 LIB_CAMLZIP_NAME="$(basename "$CONFIG_LIB_CAMLZIP")"
735 LIB_CAMLZIP_DIR="$(dirname "$CONFIG_LIB_CAMLZIP")"
736 LIB_OCAMLGRAPH_DIR="$(dirname "$CONFIG_LIB_OCAMLGRAPH")"
737 LIB_ULEX_DIR="$(dirname "$CONFIG_LIB_ULEX")"
738
739 EXT_LIB="$EXT_LIB"
740 EXT_OBJ="$EXT_OBJ"
741 EXT_SHARED="$EXT_SHARED"
742 EOF
743
744 sed 's/=["(]\(.*\)[)"]$/ := \1/' config.sh > config.make
745 if [ -n "${IS_MAC:-}" ]; then
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
746 echo "INSTALL := gcp -u -L" >>config.make
747 fi
748 if [ -n "${IS_FREEBSD:-}" ]; then
749 echo "INSTALL := cp" >>config.make
750 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
751
752 {
753 echo
754 echo "Congrats, you're all set. Installation will be done in:"
755 echo " $PREFIX"
756 echo
757 } >&2
Something went wrong with that request. Please try again.