forked from arlencox/QUICr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·89 lines (79 loc) · 2.49 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
# Usage: split "<word list>" <variable1> <variable2>...
# Split a string of $IFS seperated words into individual words, and
# assign them to a list of variables. If there are more words than
# variables then all the remaining words are put in the last variable;
# use a dummy last variable to collect any unwanted words.
# Any variables for which there are no words are cleared.
# eg. split 'hello Fred this is Bill' greeting who extra
# sets greeting=hello who=Fred extra="this is Bill"
# and split "$list" word list # "pops" the first word from a list
split()
{
# Prefix local names with the function name to try to avoid conflicts
# local split_wordlist
split_wordlist="$1"
shift
read "$@" <<EOF-split-end-of-arguments
${split_wordlist}
EOF-split-end-of-arguments
}
# Usage: version_ge v1 v2
# Where v1 and v2 are multi-part version numbers such as 12.5.67
# Missing .<number>s on the end of a version are treated as .0, & leading
# zeros are not significant, so 1.2 == 1.2.0 == 1.2.0.0 == 01.2 == 1.02
# Returns true if v1 >= v2, false if v1 < v2
version_ge()
{
# Prefix local names with the function name to try to avoid conflicts
# local version_ge_1 version_ge_2 version_ge_a version_ge_b
# local version_ge_save_ifs
version_ge_v1="$1"
version_ge_v2="$2"
version_ge_save_ifs="$IFS"
while test -n "${version_ge_v1}${version_ge_v2}"; do
IFS="."
split "$version_ge_v1" version_ge_a version_ge_v1
split "$version_ge_v2" version_ge_b version_ge_v2
IFS="$version_ge_save_ifs"
#echo " compare $version_ge_a $version_ge_b"
test "0$version_ge_a" -gt "0$version_ge_b" && return 0 # v1>v2: true
test "0$version_ge_a" -lt "0$version_ge_b" && return 1 # v1<v2:false
done
# version strings are both empty & no differences found - must be equal.
return 0 # v1==v2: true
}
options=""
check_pkg()
{
name=$1
version=$2
ocamlfind query $name > /dev/null 2>&1
if [ $? -eq 0 ]; then
# found package
installed=$(ocamlfind query -long-format $name | grep 'version:' | sed 's/version://' | xargs)
version_ge "$installed" "$version"
if [ $? -eq 0 ]; then
return 0
fi
fi
return 1
}
check_Z3()
{
check_pkg "Z3" "4.4.0.0"
if [ $? -eq 0 ]; then
options="-D PKG_Z3 $options"
fi
}
check_mlbdd()
{
check_pkg "mlbdd" "0.1"
if [ $? -eq 0 ]; then
options="-D PKG_MLBDD $options"
fi
}
check_Z3
check_mlbdd
cppo $options Main.ml.in -o Main.ml
cppo $options -n _tags.in -o _tags