Skip to content
This repository
Newer
Older
100755 685 lines (607 sloc) 18.718 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
19 -help shows this message
20 EOF
21 # --no-<lib> if available
22 }
23
24 cd "$OPA_SOURCE_DIR"
25
26 while [ $# -gt 0 ]; do
27 case "$1" in
28 -prefix)
29 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument" >&2; exit 1; fi
30 shift
31 PREFIX=$1
32 ;;
66ff782b » Aqua-Ye
2012-06-22 [fix] install, package: renamed install_dir into libdir + related fix
33 -libdir)
6ba0a554 » Aqua-Ye
2012-06-19 [enhance] config: added an install_dir variable
34 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument" >&2; exit 1; fi
35 shift
66ff782b » Aqua-Ye
2012-06-22 [fix] install, package: renamed install_dir into libdir + related fix
36 LIBDIR=$1
6ba0a554 » Aqua-Ye
2012-06-19 [enhance] config: added an install_dir variable
37 ;;
fccc6851 » MLstate
2011-06-21 Initial open-source release
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 ;;
62 -h|-help|--help)
63 help
64 exit 0;;
65 *)
66 echo "Error: unknown option $1" >&2
67 echo
68 help
69 exit 2
70 esac
71 shift
72 done
73
74 : ${PREFIX:=${MLSTATELIBS:-}}
75 : ${PREFIX:=/usr/local}
76 : ${IS_RELEASE:=}
66ff782b » Aqua-Ye
2012-06-22 [fix] install, package: renamed install_dir into libdir + related fix
77 : ${LIBDIR:=$PREFIX}
fccc6851 » MLstate
2011-06-21 Initial open-source release
78
030430ad » Aqua-Ye
2012-07-10 [fix] build: fix compilation because of config path change
79 CONFIG_PATH=$PWD/tools/build
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
80 CONFIG_LOG=$CONFIG_PATH/config.log
fccc6851 » MLstate
2011-06-21 Initial open-source release
81
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
82 echo -n > $CONFIG_LOG
fccc6851 » MLstate
2011-06-21 Initial open-source release
83
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
84 echo-check() { echo -n "Checking $*... " >&2 ; echo "# CHECK-START: $*" >> $CONFIG_LOG; }
fccc6851 » MLstate
2011-06-21 Initial open-source release
85 echo-ok() {
86 local opts=; if [ "X$1" = "X-n" ]; then shift; opts="-n"; fi
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
87 echo $opts "$*" >&2 ; echo $opts -e "# CHECK-OK: $*\n" >> $CONFIG_LOG;
fccc6851 » MLstate
2011-06-21 Initial open-source release
88 }
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
89 echo-ok-tag() { echo "OK" >&2 ; echo -e "# CHECK-OK\n" >> $CONFIG_LOG; }
90 echo-err() { echo "$*" >&2 ; echo -e "# CHECK-FAIL: $*\n" >> $CONFIG_LOG; }
91 echo-skip() { echo "$*" >&2 ; echo -e "# CHECK-SKIP: $*\n" >> $CONFIG_LOG; }
fccc6851 » MLstate
2011-06-21 Initial open-source release
92
93 # check OS
94 echo-check your OS
95 EXT_LIB="a"
96 EXT_OBJ="o"
97 EXT_SHARED="so"
7daa64c0 » Rudy Sicard
2012-10-31 [fix] windows,myocamlbuild: exe extension
98 EXT_EXE=".exe"
fccc6851 » MLstate
2011-06-21 Initial open-source release
99 case $(uname) in
100 CYGWIN*)
101 echo-ok Windows/cygwin
102 EXT_LIB="lib"
103 EXT_SHARED="dll"
7daa64c0 » Rudy Sicard
2012-10-31 [fix] windows,myocamlbuild: exe extension
104 EXT_EXE=".exe"
fccc6851 » MLstate
2011-06-21 Initial open-source release
105 IS_WINDOWS=1;;
106 Darwin*)
107 echo-ok MacOS
108 IS_MAC=1;;
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
109 Linux*|GNU/kFreeBSD)
fccc6851 » MLstate
2011-06-21 Initial open-source release
110 echo-ok Linux
111 IS_LINUX=1;;
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
112 FreeBSD)
113 echo-ok FreeBSD
114 IS_FREEBSD=1;;
fccc6851 » MLstate
2011-06-21 Initial open-source release
115 *)
116 echo-err "Not sure, probably Unix / Linux"
117 IS_LINUX=1
118 esac
119
120 echo-check your architecture
121 case $(uname -m) in
87791cef » Frédéric Perrin
2011-09-03 amd64 is a synonym for x86_64
122 x86_64|amd64)
fccc6851 » MLstate
2011-06-21 Initial open-source release
123 echo-ok x86_64;;
124 i?86)
125 echo-ok ix86;;
126 *)
127 echo-err "$(uname -m)"
128 echo "Sorry, this architecture is unsupported at the moment." >&2
129 exit 1
130 esac
131
132 lastresort_hint() {
133 cat <<EOF
134
135 If you have trouble meeting the required dependencies with your distribution,
136 you may want to have a look at the script installation_helper.sh in the
b8072706 » Aqua-Ye
2012-07-16 [fix] various: fix dependencies path in various files
137 tools/dependencies/ directory to build them from source.
fccc6851 » MLstate
2011-06-21 Initial open-source release
138
139 EOF
140 }
141 trap lastresort_hint ERR
142
143 # specific platform checks
144 if [ -n "${IS_MAC:-}" ]; then
29f30388 » Hugo Venturini
2011-07-01 [fix] gsed: not in GNU coreutils on Mac
145 echo-check for gsed
146 if which gsed > /dev/null 2>&1; then echo-ok ok
147 else
148 echo-err Not found
fb3a4096 » Aqua-Ye
2012-06-18 [fix] configure: typo on word Opa
149 echo "gsed is needed to build Opa."
29f30388 » Hugo Venturini
2011-07-01 [fix] gsed: not in GNU coreutils on Mac
150 if which port >/dev/null 2>&1; then
151 echo -e " You should run:\n\tsudo port install gsed"
152 # else #todo# [add useful suggestion here]
153 fi
154 exit 1
155 fi >&2
fccc6851 » MLstate
2011-06-21 Initial open-source release
156 echo-check for GNU coreutils
29f30388 » Hugo Venturini
2011-07-01 [fix] gsed: not in GNU coreutils on Mac
157 if which gtail gmktemp gsort greadlink >/dev/null 2>&1; then echo-ok ok
fccc6851 » MLstate
2011-06-21 Initial open-source release
158 else
159 echo-err Not found
fb3a4096 » Aqua-Ye
2012-06-18 [fix] configure: typo on word Opa
160 echo "GNU coreutils are needed to build Opa."
fccc6851 » MLstate
2011-06-21 Initial open-source release
161 if which port >/dev/null 2>&1; then
162 echo -e " You should run:\n\tsudo port install coreutils"
163 # else #todo# [add useful suggestion here]
164 fi
165 exit 1
166 fi >&2
1c372aae » Aqua-Ye
2012-11-21 [enhance] build: cleanup, improve
167 . ${OPALANG_DIR:-"."}/tools/platform_helper.sh
fccc6851 » MLstate
2011-06-21 Initial open-source release
168 fi
169
1321ba91 » Frédéric Perrin
2011-09-21 On FreeBSD check and use gmake, use make elsewhere
170 if [ -n "${IS_FREEBSD:-}" ]; then
171 echo-check gmake
172 if which gmake >/dev/null 2>&1; then echo-ok ok
173 else
174 echo-err Not found
175 echo "Please install port devel/gmake."
176 exit 1
177 fi >&2
178 fi
179
fccc6851 » MLstate
2011-06-21 Initial open-source release
180 # check ocaml version and location
181 echo-check ocamlopt
182 if OCAMLOPT=${OCAMLOPT:-$(which ocamlopt.opt)} || OCAMLOPT=${OCAMLOPT:-$(which ocamlopt)}
183 then echo-ok $OCAMLOPT
184 else
185 echo-err Not found
7caa3f5a » Aqua-Ye
2012-11-21 [enhance] configure: require OCaml 4 at least
186 echo "Ocaml 4.00 or newer is required. It's usually found in package 'ocaml'."
fccc6851 » MLstate
2011-06-21 Initial open-source release
187 false
188 fi
f3b8472b » Aqua-Ye
2012-07-30 [fix] configure: wrong OCAMLOPT_DIR
189 OCAMLOPT_DIR=$(dirname $OCAMLOPT)
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
190
fccc6851 » MLstate
2011-06-21 Initial open-source release
191
192 echo-check ocamlbuild
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
193 : ${OCAMLBUILD:=$OCAMLOPT_DIR/ocamlbuild}
fccc6851 » MLstate
2011-06-21 Initial open-source release
194 if [ -n "$IS_RELEASE" ]; then
195 OCAMLBUILD_FLAGS="${OCAMLBUILD_FLAGS:-} -tag release -tag noassert"
196 else
197 OCAMLBUILD_FLAGS="${OCAMLBUILD_FLAGS:-} -tag debug"
198 fi
199 if [ -x "$OCAMLBUILD" ]
200 then echo-ok $OCAMLBUILD
201 else
202 echo-err Not found
203 echo "Ocamlbuild is required. It should come with your ocaml distribution."
204 false
205 fi
206
207 echo-check ocamldir
208 : ${OCAMLLIB:=$($OCAMLOPT -where)}
562e3636 » Rudy Sicard
2012-10-31 [fix] windows,configure: remove bslash from OCAMLLIB
209 OCAMLLIB=$(echo "$OCAMLLIB" | sed -e "s/\\\\/\//g")
fccc6851 » MLstate
2011-06-21 Initial open-source release
210 echo-ok $OCAMLLIB
211
212 export OCAMLLIB
213
214 echo-check ocaml version
215 OCAML_VERSION=$($OCAMLOPT -version)
216 OCAML_VERSION_MAJOR=${OCAML_VERSION%%.*}
217 OCAML_VERSION_MIDDLE=${OCAML_VERSION%.*}
218 OCAML_VERSION_MIDDLE=${OCAML_VERSION_MIDDLE#*.}
7caa3f5a » Aqua-Ye
2012-11-21 [enhance] configure: require OCaml 4 at least
219 if [ $OCAML_VERSION_MAJOR -ge 4 ]; then
fccc6851 » MLstate
2011-06-21 Initial open-source release
220 echo-ok $OCAML_VERSION
221 else
222 echo-err $OCAML_VERSION
7caa3f5a » Aqua-Ye
2012-11-21 [enhance] configure: require OCaml 4 at least
223 echo "Ocaml 4.00 or newer is required"
fccc6851 » MLstate
2011-06-21 Initial open-source release
224 false
225 fi
226
227 echo-check your ocaml setup
228 check-ocaml () {
229 local DIR=$(mktemp -d /tmp/opa-configure.XXXXX)
230 trap "rm -rf /tmp/${DIR#/tmp/}" EXIT
231 cd $DIR
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
232 cat > test.ml <<EOF
fccc6851 » MLstate
2011-06-21 Initial open-source release
233 let p = Unix.getpid()
234 let _ = Printf.printf "%s, %s %dbit" Sys.ocaml_version Sys.os_type Sys.word_size
235 let _ =
c24f5678 » mbarbin
2011-07-18 [enhance] build: detect and accept 32bits version
236 exit Sys.word_size
fccc6851 » MLstate
2011-06-21 Initial open-source release
237 EOF
238
6e6731fd » OpaOnWindowsNow
2011-09-15 [fix] configure: typo, missing space
239 echo "# $OCAMLBUILD $OCAMLBUILD_FLAGS -tag use_unix test.native" >> $CONFIG_LOG
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
240 R=0; $OCAMLBUILD $OCAMLBUILD_FLAGS -tag use_unix test.native > test.log 2>&1 || R=$?
fccc6851 » MLstate
2011-06-21 Initial open-source release
241
242 cat test.log >> $CONFIG_LOG
243
244 if [ $R -ne 0 ]; then
245 echo-err "could not compile"
246 echo "----------"
247 tail -n 5 test.log | sed 's/^/ /'
248 echo "----------"
249 echo "Your ocaml installation seems broken, please fix it"
250 false
251 fi >&2
c24f5678 » mbarbin
2011-07-18 [enhance] build: detect and accept 32bits version
252 set +e
253 RET=$(_build/test.native);
254 R=$?
255 set -e
256 case $R in
257 32)
258 OCAML_WORD_SIZE=32
259 echo-ok $RET
260 ;;
261 64)
262 OCAML_WORD_SIZE=64
263 echo-ok $RET
264 ;;
265 *)
266 echo-err $RET
267 echo "Your ocaml seems to be neither a 64bit or a 32bit version. Please install a native 64 bit package."
268 false
269 esac >&2
fccc6851 » MLstate
2011-06-21 Initial open-source release
270 rm -rf /tmp/${DIR#/tmp/}
271 trap - EXIT
272 cd "$OPA_SOURCE_DIR"
273 }
274 check-ocaml
275
276 echo-check for camlp4
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
277 : ${CAMLP4O:=$OCAMLOPT_DIR/camlp4o}
278 : ${CAMLP4ORF:=$OCAMLOPT_DIR/camlp4orf}
fccc6851 » MLstate
2011-06-21 Initial open-source release
279 if [ -x "$CAMLP4O" ] && [ -x "$CAMLP4ORF" ]
280 then echo-ok $CAMLP4O
281 else
282 echo-err Not found
283 echo "You need camlp4 to build this package. It is usually found in packages camlp4, camlp4-extra"
284 false
285 fi
286
3dd7ffc4 » Aqua-Ye
2012-11-20 [fix] configure: cygpath only on windows
287 if [ -n "${IS_WINDOWS:-}" ]; then
288 CAMLP4O=$(cygpath -m $CAMLP4O || echo $CAMLP4O)
289 CAMLP4ORF=$(cygpath -m $CAMLP4ORF || echo $CAMLP4ORF)
290 fi
fbbb97df » Rudy Sicard
2012-11-14 [fix] win,configure: camlp4 invocation thru ocamlopt must be in win f…
291
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
a6982e9a » Frédéric Perrin
2011-08-29 Check for java
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
1bf8db9a » Aqua-Ye
2012-06-18 [feature] configure,make_package,README: added dependency to node.js,…
314 # - checking for nodejs
315 echo-check for nodejs
316 if which node &>/dev/null; then
317 echo-ok found
318 else
319 echo-err Not found
320 exit 1
321 fi
322
323 # - checking for nodejs version
1c372aae » Aqua-Ye
2012-11-21 [enhance] build: cleanup, improve
324 echo-check for nodejs version
1bf8db9a » Aqua-Ye
2012-06-18 [feature] configure,make_package,README: added dependency to node.js,…
325 NODE_VERSION=$(node --version)
326 NODE_MIN_VERSION="v0.6"
327 if [[ $NODE_VERSION > $NODE_MIN_VERSION ]]; then
328 echo-ok $NODE_VERSION
329 else
330 echo-err $NODE_VERSION
331 echo "Node $NODE_MIN_VERSION or newer is required"
7c7f1bbc » Aqua-Ye
2012-06-18 [enhance] configure: exit on nodejs version check if error
332 exit 1
1bf8db9a » Aqua-Ye
2012-06-18 [feature] configure,make_package,README: added dependency to node.js,…
333 fi
334
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
5f95972b » Aqua-Ye
2012-04-26 [feature] iconv: binded iconv in Opa
349 if [ -e $d/lib$LIBNAME.a ] || [ -e $d/lib$LIBNAME.dylib ] ; then
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
5f95972b » Aqua-Ye
2012-04-26 [feature] iconv: binded iconv in Opa
364 echo-ok -n "$LD_DIR/lib$LIBNAME..., "
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
5f95972b » Aqua-Ye
2012-04-26 [feature] iconv: binded iconv in Opa
397
fccc6851 » MLstate
2011-06-21 Initial open-source release
398 # check ocaml libs:
399 # probably, first try with ocamlfind then fallback to
400 # custom check ; ensure consistency with function
401 # "get_ocamlfind_directory" in build/myocamlbuild_prefix.ml
402 echo-check for ocamlfind
403 if [ -n "${NO_OCAMLFIND:-}" ]; then
404 OCAMLFIND=
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
405 echo-skip Disabled
fccc6851 » MLstate
2011-06-21 Initial open-source release
406 elif [ -z "${OCAMLFIND:-}" ]; then
62e3dc8b » OpaOnWindowsNow
2012-01-13 [fix] fedora,configure: work with non fresh install
407 OCAMLFIND=$OCAMLOPT_DIR/ocamlfind
fccc6851 » MLstate
2011-06-21 Initial open-source release
408 if [ ! -x "$OCAMLFIND" ]; then
409 OCAMLFIND=$OCAMLLIB/../../bin/ocamlfind
410 fi
411 if [ ! -x "$OCAMLFIND" ]; then
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
412 echo-skip "Not found (but optional)"
fccc6851 » MLstate
2011-06-21 Initial open-source release
413 OCAMLFIND=
414 else
415 echo-ok $OCAMLFIND
416 fi
417 elif [ -x "$OCAMLFIND" ]; then
418 echo-ok $OCAMLFIND
419 else
420 echo-err "Not found"
421 echo "You specified $OCAMLFIND on the command-line, but it doesn't exist or isn't executable" >&2
422 OCAMLFIND=
423 fi
424
425 EXTRA_TAGS="-tag use_unix"
426 check-ocaml-lib () {
427 local MODULE=$1; shift
428 local LIB=$1; shift
429 local LIBDIR=$1; shift
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
430 MORE=""
431 if [ $# -gt 0 ]; then
432 MORE=$1; shift
433 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
434
435 local DIR=$(mktemp -d /tmp/opa-configure.XXXXX)
436 trap "rm -rf /tmp/${DIR#/tmp/}" EXIT
437 cd $DIR
438
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
439 echo "module M = $MODULE $MORE" >check_${LIB}.ml
fccc6851 » MLstate
2011-06-21 Initial open-source release
440
441 local libdir_ins=""
442 if [ "$LIBDIR" != "$OCAMLLIB" ]; then libdir_ins=' ~dir:"'$LIBDIR'"'; fi
443 cat >myocamlbuild.ml <<EOF
444 let _ = Ocamlbuild_plugin.dispatch (function
445 | Ocamlbuild_plugin.After_rules ->
446 Ocamlbuild_plugin.ocaml_lib ~extern:true$libdir_ins ~tag_name:"use_my_lib" "$LIB"
447 | _ -> ()
448 )
449 EOF
450
6e6731fd » OpaOnWindowsNow
2011-09-15 [fix] configure: typo, missing space
451 echo "# $OCAMLBUILD $OCAMLBUILD_FLAGS $EXTRA_TAGS -tag use_my_lib check_${LIB}.native" >> $CONFIG_LOG
fccc6851 » MLstate
2011-06-21 Initial open-source release
452
6e6731fd » OpaOnWindowsNow
2011-09-15 [fix] configure: typo, missing space
453 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
454 cat check_${LIB}.log >> $CONFIG_LOG
455
456 if [ $R -ne 0 ]; then
457 echo-err "could not compile"
458 echo "----------"
459 tail -n 5 check_${LIB}.log | sed 's/^/ /'
460 echo "----------"
461 echo "The installation of $LIB seems broken, please fix it (did it come with a different ocaml compiler ?)"
462 return 1
463 else
464 echo-ok-tag
465 fi >&2
466 rm -rf /tmp/${DIR#/tmp/}
467 trap - EXIT
468 cd "$OPA_SOURCE_DIR"
469 }
470
471 check-cmxa () {
472 local DIR=$1; shift
473 [ $# -gt 0 ]
474 local canonical_name=$1
475 while [ $# -gt 0 ] && [ ! -e "$DIR/$(basename $1).cmxa" ]; do shift; done
476 if [ $# -eq 0 ]; then
477 echo-err "Not found"
478 echo "Please fix your installation of $canonical_name in $LIBDIR: no proper cmxa file was found there." >&2
479 return 1
480 fi
481 echo $1
482 }
483
484 locate-ocaml-lib () {
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
485 local OPTIONAL=""
486 if [ "$1" = "-opt" ]; then OPTIONAL=1; shift; fi
cc3b881d » Aqua-Ye
2012-11-21 [enhance] build: remove cryptokit dependency
487 if [ "$1" = "-custom-check" ]; then
488 CHECK=$2; shift; shift;
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
489 else
cc3b881d » Aqua-Ye
2012-11-21 [enhance] build: remove cryptokit dependency
490 CHECK=check-ocaml-lib
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
491 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
492 local MODULE=$1; shift # one module that the lib contains, to check
493 [ $# -gt 0 ] # remaining args: possible lib names (may be usual_dir/libname)
494
495 echo-check for $(basename $1)
496
497 local LIBDIR=""
498 local LIB
499 local LIB_NAMES=("$@")
500 while [ $# -gt 0 ] && [ -z "$LIBDIR" ]; do
501 LIB=$(basename $1)
502 USUAL_DIR=$(dirname $1)
503 [ "$USUAL_DIR" = "." ] && USUAL_DIR=$LIB
504 if [ -n "$OCAMLFIND" ] &&
505 LIBDIR=$("$OCAMLFIND" query "$LIB" 2>/dev/null)
506 then
8e18f402 » Rudy Sicard
2012-10-31 [fix] windows,configure: remove \r from a path during caml lib detection
507 LIBDIR=$(echo $LIBDIR | sed s/\\r//g)
fccc6851 » MLstate
2011-06-21 Initial open-source release
508 LIB=$(check-cmxa $LIBDIR $LIB "${LIB_NAMES[@]}") || return 1
509 echo-ok -n "ocamlfind:$LIBDIR, "
510 elif [ -d "$OCAMLLIB"/"$USUAL_DIR" ]
511 then
512 LIB=$(check-cmxa "$OCAMLLIB"/"$USUAL_DIR" $LIB "${LIB_NAMES[@]}") \
513 || return 1
514 echo-ok -n "+$USUAL_DIR, "
515 LIBDIR=+"$USUAL_DIR"
516 elif [ -e "$OCAMLLIB"/"$LIB".cmxa ]
517 then
518 echo-ok -n "$LIB.cmxa, "
519 LIBDIR="$OCAMLLIB"
520 fi
521 shift
522 done
523 if [ -z "$LIBDIR" ]; then
ebb9f529 » Louis Gesbert
2011-08-10 [feature] Database: making dblight compilation optional, depending on…
524 if [ -n "$OPTIONAL" ]; then
525 echo-skip "Not found (but optional)"
526 else
527 echo-err "Not found"
528 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
529 return 1
530 fi
531
519b211f » Aqua-Ye
2012-02-08 [enhance] configure: cryptokit version check does not require findlib…
532 $CHECK "$MODULE" "$LIB" "$LIBDIR" || return 1
fccc6851 » MLstate
2011-06-21 Initial open-source release
533 echo "$LIBDIR/$LIB"
534 }
535 # for libs which are needed (fatal warning)
536 LIBS_NOT_FOUND=()
537 lib-not-found () {
538 local lib=$1; shift
539 local package=$1; shift
540 LIBS_NOT_FOUND[${#LIBS_NOT_FOUND[@]}]="$lib (might be found in package $package)"
541 }
542
9dcdcf40 » Aqua-Ye
2012-11-20 [enhance] build: removed useless caml dependencies
543 # - checking ulex
544 if ! CONFIG_LIB_ULEX=$(locate-ocaml-lib "Ulexing" "ulex" "ulexing")
545 then lib-not-found "ulex" "ocaml-ulex"
fccc6851 » MLstate
2011-06-21 Initial open-source release
546 fi
547
548 # - checking camlzip
549 if ! CONFIG_LIB_CAMLZIP=$(locate-ocaml-lib "Zip" "camlzip" "zip")
550 then lib-not-found "camlzip" "libzip-ocaml-dev"
551 fi
552
553 # - checking ocamlgraph
8e3d78ca » Rudy Sicard
2012-10-31 [fix] windows,configure: ocamlgraph detection call
554 if ! CONFIG_LIB_OCAMLGRAPH=$(locate-ocaml-lib "Graph" "ocamlgraph" "graph")
fccc6851 » MLstate
2011-06-21 Initial open-source release
555 then lib-not-found "ocamlgraph" "libocamlgraph-ocaml-dev"
556 fi
557
558 if [ ${#LIBS_NOT_FOUND[@]} -ne 0 ]; then
559 echo
560 echo "Not configured. You need the following libraries installed:" >&2
561 for lib in "${LIBS_NOT_FOUND[@]}"; do
562 echo " - $lib" >&2
563 done
564 false
565 fi
566
567 # Output the configuration
568
569 dir_opt() {
570 local DIR=$(dirname "$1"); shift; [ $# -eq 0 ]
571 if [ "$DIR" = "$OCAMLLIB" ]; then echo 'None'
572 else echo 'Some "'$DIR'"'
573 fi
574 }
575
576 camlbool() { [ $# -eq 1 ]; if [ -n "$1" ]; then echo true; else echo false; fi; }
577
578 camlstrtuple() {
579 echo -n '"'$1'"'; shift
580 while [ $# -gt 0 ]; do
581 echo -n ', "'$1'"'; shift
582 done
583 }
584
585 camlopt() {
586 local cond=$1; shift
587 local val=$1; shift
588 [ $# -eq 0 ]
589 if [ -n "$cond" ]; then echo 'Some ('$val')'
590 else echo 'None'
591 fi
592 }
593
594 # See config.mli for the documentation and spec of these variables
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
595 cat > $CONFIG_PATH/config.ml <<EOF
fccc6851 » MLstate
2011-06-21 Initial open-source release
596 let prefix = "$PREFIX"
66ff782b » Aqua-Ye
2012-06-22 [fix] install, package: renamed install_dir into libdir + related fix
597 let lib_dir = "$LIBDIR"
fccc6851 » MLstate
2011-06-21 Initial open-source release
598 let ocamllib = "$OCAMLLIB"
599 let ocamlopt = "$OCAMLOPT"
600 let ocamlbuild = "$OCAMLBUILD"
601 let ocamlbuild_flags = "$OCAMLBUILD_FLAGS"
602 let camlp4o = "$CAMLP4O"
603 let camlp4orf = "$CAMLP4ORF"
604
605 let is_release = $(camlbool "$IS_RELEASE")
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
606 type os = Linux | Mac | Win32 | Cygwin | FreeBSD
fccc6851 » MLstate
2011-06-21 Initial open-source release
607 let os =
608 $(if [ -n "${IS_LINUX:-}" ]; then echo Linux
609 elif [ -n "${IS_MAC:-}" ]; then echo Mac
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
610 elif [ -n "${IS_FREEBSD:-}" ]; then echo FreeBSD
fccc6851 » MLstate
2011-06-21 Initial open-source release
611 else echo 'match Sys.os_type with "Win32" -> Win32 | "Cygwin" -> Cygwin | _ -> assert false'
612 fi)
613
1321ba91 » Frédéric Perrin
2011-09-21 On FreeBSD check and use gmake, use make elsewhere
614 let makebinary =
615 $(if [ -n "${IS_FREEBSD:-}" ];
616 then echo '"gmake"'
617 else echo '"make"'
618 fi)
619
fccc6851 » MLstate
2011-06-21 Initial open-source release
620 module Libdir = struct
621 let camlzip_name = "$(basename "$CONFIG_LIB_CAMLZIP")"
622 let camlzip = $(dir_opt "$CONFIG_LIB_CAMLZIP")
623 let graph = $(dir_opt "$CONFIG_LIB_OCAMLGRAPH")
624 let ulex = $(dir_opt "$CONFIG_LIB_ULEX")
625 end
626
627 let ext_lib = "$EXT_LIB"
628 let ext_obj = "$EXT_OBJ"
629 let ext_shared = "$EXT_SHARED"
7daa64c0 » Rudy Sicard
2012-10-31 [fix] windows,myocamlbuild: exe extension
630 let ext_exe = "$EXT_EXE"
fccc6851 » MLstate
2011-06-21 Initial open-source release
631
9dcdcf40 » Aqua-Ye
2012-11-20 [enhance] build: removed useless caml dependencies
632 let more_server_include_dir = []
633
fccc6851 » MLstate
2011-06-21 Initial open-source release
634 EOF
635
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
636 cat > $CONFIG_PATH/config.sh <<EOF
fccc6851 » MLstate
2011-06-21 Initial open-source release
637 PREFIX="$PREFIX"
66ff782b » Aqua-Ye
2012-06-22 [fix] install, package: renamed install_dir into libdir + related fix
638 LIBDIR="$LIBDIR"
fccc6851 » MLstate
2011-06-21 Initial open-source release
639 OCAMLLIB="$OCAMLLIB"
640 OCAMLOPT="$OCAMLOPT"
641 OCAMLBUILD="$OCAMLBUILD"
642 OCAMLBUILD_FLAGS="$OCAMLBUILD_FLAGS"
643 CAMLP4O="$CAMLP4O"
644 CAMLP4ORF="$CAMLP4ORF"
c24f5678 » mbarbin
2011-07-18 [enhance] build: detect and accept 32bits version
645 OCAML_WORD_SIZE="$OCAML_WORD_SIZE"
616a53ef » Rudy Sicard
2012-11-02 [enhance] OCaml4: Hastbl.create API change
646 OCAML_VERSION_MAJOR="$OCAML_VERSION_MAJOR"
fccc6851 » MLstate
2011-06-21 Initial open-source release
647
648 IS_RELEASE="$IS_RELEASE"
649 IS_LINUX="${IS_LINUX:-}"
650 IS_WINDOWS="${IS_WINDOWS:-}"
651 IS_MAC="${IS_MAC:-}"
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
652 IS_FREEBSD="${IS_FREEBSD:-}"
fccc6851 » MLstate
2011-06-21 Initial open-source release
653 OS=$(if [ -n "${IS_LINUX:-}" ]; then echo '"Linux"'
654 elif [ -n "${IS_MAC:-}" ]; then echo '"Mac"'
655 elif [ -n "${IS_WINDOWS:-}" ]; then echo '"Win32"'
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
656 elif [ -n "${IS_FREEBSD:-}" ]; then echo '"FreeBSD"'
fccc6851 » MLstate
2011-06-21 Initial open-source release
657 else echo "Error: OS inconsistency" >&2; exit 2
658 fi)
659
660 LIB_CAMLZIP_NAME="$(basename "$CONFIG_LIB_CAMLZIP")"
661 LIB_CAMLZIP_DIR="$(dirname "$CONFIG_LIB_CAMLZIP")"
662 LIB_OCAMLGRAPH_DIR="$(dirname "$CONFIG_LIB_OCAMLGRAPH")"
663 LIB_ULEX_DIR="$(dirname "$CONFIG_LIB_ULEX")"
664
665 EXT_LIB="$EXT_LIB"
666 EXT_OBJ="$EXT_OBJ"
667 EXT_SHARED="$EXT_SHARED"
7daa64c0 » Rudy Sicard
2012-10-31 [fix] windows,myocamlbuild: exe extension
668 EXT_EXE="$EXT_EXE"
fccc6851 » MLstate
2011-06-21 Initial open-source release
669 EOF
670
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
671 sed 's/=["(]\(.*\)[)"]$/ := \1/' $CONFIG_PATH/config.sh > $CONFIG_PATH/config.make
fccc6851 » MLstate
2011-06-21 Initial open-source release
672 if [ -n "${IS_MAC:-}" ]; then
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
673 echo "INSTALL := gcp -u -L" >> $CONFIG_PATH/config.make
d863cc77 » Aqua-Ye
2012-07-02 [enhance] all: wip compilation
674 elif [ -n "${IS_FREEBSD:-}" ]; then
94ed07bc » Aqua-Ye
2012-07-10 [enhance] build: moved config files in tools/build
675 echo "INSTALL := cp" >> $CONFIG_PATH/config.make
e215f99d » arthuraa
2012-07-19 [fix] build: set INSTALL correctly for Linux.
676 elif [ -n "${IS_LINUX:-}" ]; then
677 echo "INSTALL := cp -u -L" >> $CONFIG_PATH/config.make
7de4ee06 » Frédéric Perrin
2011-09-12 New platform: `FreeBSD'
678 fi
fccc6851 » MLstate
2011-06-21 Initial open-source release
679
680 {
681 echo
682 echo "Congrats, you're all set. Installation will be done in:"
683 echo " $PREFIX"
684 echo
685 } >&2
Something went wrong with that request. Please try again.