Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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