-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure
executable file
·116 lines (96 loc) · 2.15 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
readonly PIPE="/tmp/configure"
version() {
echo -n "Looking for $1..."
local version
echo -n " broken installation" >"$PIPE.err"
version="`"$1" --version 2>>"$PIPE.err" | grep -o '[[:digit:].]\+[[:digit:]]'`"
rm "$PIPE.err"
echo " found `echo "$version" | head -n1`"
}
helper() {
local file="$1"
local color="$2"
printf %s "[${color}m" >&2
tr -d '\n' <"$file" | sed 's/.*://;a\' >&2
printf %s "[0m" >&2
rm "$file"
}
handler() {
[ -e "$PIPE.err" ] && helper "$PIPE.err" 31
[ -e "$PIPE.warn" ] && helper "$PIPE.warn" 93
}
set -e
trap handler EXIT
version cargo
version rustc
echo -n "Checking Rust 2018 support..."
echo " not present" >"$PIPE.err"
rustc --help -v | grep -- --edition >/dev/null
echo " present"
version make
echo -n "Checking GNU Make language support..."
echo " not present" >"$PIPE.err"
make --version | grep GNU >/dev/null
echo " present"
version cc
version bindgen
version rustfmt
version ld
version nm
version objcopy
version git
dir="`dirname "$0"`"
git() {
"`which git`" -C "$dir" "$@"
}
cargo() {
local owd="$PWD"
cd "$dir"
"`which cargo`" "$@"
cd "$owd"
}
echo -n "Checking submodules..."
if git submodule status | grep '^-' >/dev/null
then
echo " initializing"
git submodule update --init --recursive
elif git submodule status | grep '^+' >/dev/null
then
echo " inconsistent" >"$PIPE.warn"
handler
else
echo " consistent"
fi
echo -n "Configuring toolchain..."
if [ -e "$dir/.cargo/config" ]
then
echo " skipping"
else
cat >"$dir/.cargo/config" <<-tac
`cat "$dir/.cargo/config.toml"`
rustc = ".cargo/rustc"
tac
echo " generated"
fi
echo -n "Cleaning libinger build..."
cargo clean
echo " done"
echo -n "Cleaning libgotcha build..."
make -C"$dir/external/libgotcha" clean >/dev/null
echo " done"
echo -n "Removing lockfile..."
rm -f "$dir/Cargo.lock"
echo " done"
echo -n "Detecting interpreter..."
if [ -n "$LIBINGER_LINKER" ]
then
file -L "$LIBINGER_LINKER" 2>&1 | tee "$PIPE.err" | grep '\<ELF\>' >/dev/null
echo " using $LIBINGER_LINKER"
elif [ -e "$dir/ld.so" ]
then
echo " using `readlink "$dir/ld.so"`"
else
echo " define LIBINGER_LINKER to a dynamic linker or place one at ./ld.so" >"$PIPE.err"
false
fi