-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_pin.sh
executable file
·71 lines (57 loc) · 1.64 KB
/
setup_pin.sh
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
#!/usr/bin/env bash
set -u
PIN_DOWNLOAD_URL="https://software.intel.com/sites/landingpage/pintool/downloads"
# PIN_KIT_OSX="pin-2.13-61206-clang.3.0-mac"
PIN_KIT_OSX="pin-2.13-65163-clang.5.0-mac"
PIN_KIT_WINDOWS="pin-2.13-61206-msvc10-windows"
PIN_KIT_LINUX="pin-2.13-61206-gcc.4.4.7-linux"
if [ $EUID -eq 0 ]; then
echo "Please run this script as a regular user, not root."
exit 1
fi
INSTALL_DIR="$PWD"
if [ $? -ge 1 ]; then
INSTALL_DIR="$1"
if test ! -d "$INSTALL_DIR" -o test ! -w "$INSTALL_DIR"; then
echo "Error: install directory not writable: $INSTALL_DIR"
exit 1
fi
fi
SYSTEM=`uname -s`
case "$SYSTEM" in
Darwin) PIN_KIT="$PIN_KIT_OSX" ;;
CYGWIN*) PIN_KIT="$PIN_KIT_WINDOWS" ;;
*) PIN_KIT="$PIN_KIT_LINUX" ;;
esac
echo "Installing PIN kit $PIN_KIT into: $INSTALL_DIR"
PIN_TGZ="${PIN_KIT}.tar.gz"
PIN_URL="${PIN_DOWNLOAD_URL}/${PIN_TGZ}"
function curl_get() {
curl "$1" -o "$2"
}
function wget_get() {
wget --progress "$1" -O "$2"
}
if [ ! -d "${INSTALL_DIR}/${PIN_KIT}" ]; then
if type -p curl 2>/dev/null; then
DL=curl_get
elif type -p wget 2>/dev/null; then
DL=wget_get
else
echo "Sorry, couldn't find a download program :("
echo "Get curl or wget."
exit 1
fi
rm -f "${INSTALL_DIR}/${PIN_TGZ}"
$DL "$PIN_URL" "${INSTALL_DIR}/${PIN_TGZ}"
tar x -C "${INSTALL_DIR}" -zf "${PIN_TGZ}"
fi
rm -f pin
ln -s "${INSTALL_DIR}/${PIN_KIT}" pin
PIN_ROOT="$PWD/pin"
cat >pin_env.sh <<END
export PIN_ROOT="$PIN_ROOT"
export PIN_HOME="\$PIN_ROOT"
export PATH="\$PATH:\$PIN_HOME"
END
echo "Created pin_env.sh with PIN_ROOT=$PIN_ROOT"