opam_config.sh 1.34 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh

VERBOSE="false"
WITHOCAML="false"
OCAMLFOLDER="ocaml"

usage ()
{
    echo "$0 [--verbose|-v] [--mliface=DIR] ocamlversion"
    echo "Example: $0 --verbose --mliface=ocaml 4.01.0"
}

if test $# -lt 1; then usage; exit 1; fi

Julien Lopez's avatar
Julien Lopez committed
15
while true; do
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    if test $1 = "-v" || test $1 = "--verbose"; then VERBOSE="true";
    elif echo $1 | grep -qs "\-\-mliface=*"; then
	WITHOCAML="true"; OCAMLFOLDER=`echo $1 | cut -d '=' -f 2`;
    else break; fi;
    shift;
done

echo -n "Switching to version $1 of OCaml..."

if test $VERBOSE = "false"; then
    opam switch $1 > /dev/null 2>&1
else
    opam switch $1
fi

if test $? -ne 0; then
    echo "failed. This version doesn't seem to exist."; exit 2;
fi

echo "done."

if test $VERBOSE = "false"; then
    eval `opam config env` > /dev/null 2>&1
else
    eval `opam config env`
fi

#if test $? -ne 0; then
echo "Warning: Could not complete the configuration of opam, type:"
echo "eval \`opam config env\`";
#fi

echo "Installing mandatory packages to compile CDuce."
opam install pcre-ocaml
opam install ocamlnet
opam install pxp
opam install ocurl
opam install ocaml-expat

if $WITHOCAML = "true"; then
    if test -d $OCAMLFOLDER; then
Julien Lopez's avatar
Julien Lopez committed
57
58
	cd $OCAMLFOLDER; git checkout $1 > /dev/null 2>&1
	echo "OCaml sources updated to version $1."
59
60
61
62
    else
	echo "Couldn't find $OCAMLFOLDER. The interface will not be built."
    fi
fi