-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfigure
executable file
·75 lines (65 loc) · 2.17 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
#!/usr/bin/env bash
readonly CONFIG=.config.in
readonly TOP_PID=$$
readonly MISSING_LIB="Error: missing library dependency"
readonly MISSING_JANSSON="$MISSING_LIB libjansson (see www.digip.org/jansson)"
readonly MISSING_PCAP="$MISSING_LIB pcap (see www.tcpdump.org)"
trap "exit 1" TERM
error() {
declare msg="$1"
echo "$0: ${msg}."
kill -s TERM $TOP_PID
}
supports_i386() {
# Get gcc base settings
declare cc_text="$(echo | (gcc -E -Wp,-v - > /dev/null) 2>&1)"
# Extract include path
declare prog="BEGIN { f=0 };
/include <\.\.\.> search starts here:/ { f=1; next };
/^End/ { f=0; next };
f { print}"
declare include_path="$(echo "$cc_text" | awk "$prog")"
echo "supports_i386=false" > "$CONFIG"
while read -r line; do
# Check if 32bits compatibility bits are there
if [ -e "$line/gnu/stubs-32.h" ]; then
sed -i -E "s/(supports_i386=).*/\1true/" "$CONFIG"
exit 0
fi
done <<< "$include_path"
exit 1
}
missing_lib_version() {
declare lib="$1"
declare version="$2"
error "Error: missing library version (${version} version of ${lib})"
}
assert_lib_present() {
declare lib="$1"
declare error_msg="$2"
if ! /sbin/ldconfig -p | grep "$lib" >/dev/null 2>&1; then
error "$error_msg"
fi
}
assert_lib_version_present() {
declare lib="$1"
declare version="$2"
if ! file $(readlink -f $(/sbin/ldconfig -p | grep "$lib" | awk '{print $NF}')) | grep "$version" >/dev/null; then
missing_lib_version $lib $version
fi
}
echo "[-] Checking presence of library dependencies..."
assert_lib_present "libjansson" "$MISSING_JANSSON"
assert_lib_present "libpcap" "$MISSING_PCAP"
echo "[-] Checking presence of 64-bit versions..."
assert_lib_version_present "libjansson" 64-bit
assert_lib_version_present "libpcap" 64-bit
if $(supports_i386); then
echo "[-] Checking presence of 32-bit versions..."
assert_lib_version_present "libjansson" 32-bit
assert_lib_version_present "libpcap" 32-bit
else
echo "[-] 32-bit support is disabled."
fi
echo "[-] Ok! Dependencies present."
echo "[-] Issue \"make && make install\" to compile & install tcpsnitch."