-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconfigure
executable file
·52 lines (44 loc) · 1.4 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
#!/usr/bin/env bash
# Erik Martin-Dorel, 2021 (configure script for SsrMultinomials)
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )
le_version() {
[ "$(printf '%s\n' "$1" "$2" | sort -V -u | tail -n1)" = "$2" ]
}
# BEGIN TESTS
fail_test() {
echo "error: test $* failed" >&2; exit 2
}
unit_tests() {
le_version "8.12.1" "8.12.1" || fail_test 0
le_version "8.9.0" "8.12.1" || fail_test 1
le_version "8.12.1" "8.12.2" || fail_test 2
le_version "8.12.2" "8.13.0" || fail_test 3
}
# unit_tests
# END TESTS
coq_version() {
coqc --version | grep version | \
sed -e 's/^.*version \([-0-9a-z.+~]\+\)\( .*\)\?$/\1/'
}
coq_native_compiler_default() {
coqc -config | grep -q 'COQ_NATIVE_COMPILER_DEFAULT=yes'
}
coq_native_compiler() {
cv=$(coq_version)
{ le_version "8.12.1" "$cv" && ! le_version "8.13.0" "$cv"; } \
|| coq_native_compiler_default
}
main() {
# Note: Replace with "if coq_native_compiler"
# to also test with Coq 8.12.1+
if coq_native_compiler_default; then
echo 'coq-native support enabled!' >&2
sed -e 's/;coq-native-disabled; \?//' "$dir/src/dune.in" > "$dir/src/dune"
else
cat "$dir/src/dune.in" > "$dir/src/dune"
fi
}
# Credits: https://stackoverflow.com/a/28776166/9164010
( return 0 2>/dev/null ) || main
# ./configure => Run main
# . configure => Don't run main (useful in .github/workflows/ci.yml)