-
Notifications
You must be signed in to change notification settings - Fork 1
/
env.sh
executable file
·104 lines (91 loc) · 3.02 KB
/
env.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
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
#!/bin/bash
# Copyright (C) 2008 Princeton University
# All rights reserved.
# Author: Christian Bienia
#
# Source this script to setup environment for more convenient work with PARSEC.
# This step is purely optional.
#
# You can use the script as follows:
#
# source env.sh
#
# This script only works if you are using the bash shell.
#
xxPWDxx=pwd
xxDIRNAMExx=dirname
# Function that tries to autodetect path to PARSEC distribution
# Side effect: `xxPARSECDIRxx' environment variable is set
function detect_path {
# Try to find path
local xxuniquefilexx=".parsec_uniquefile"
local xxparsecdirxx=""
if [ ! -z "${PARSECDIR}" ]; then
# User defined PARSECDIR, check it
xxparsecdirxx="${PARSECDIR}"
if [ ! -f "${xxparsecdirxx}/${xxuniquefilexx}" ]; then
echo "Error: Variable PARSECDIR points to '${PARSECDIR}', but this does not seem to be the PARSEC directory. Either unset PARSECDIR to make me try to autodetect the path or set it to the correct value."
exit 1
fi
else
# Try to autodetect path by looking at path used to invoke this script
# Try to extract absoute or relative path
if [ "${1:0:1}" == "/" ]; then
# Absolute path given
eval xxparsecdirxx=$(${xxDIRNAMExx} $(${xxDIRNAMExx} $1))
# Check
if [ -f "${xxparsecdirxx}/${xxuniquefilexx}" ]; then
xxPARSECDIRxx=${xxparsecdirxx}
fi
else
# No absolute path, maybe relative path?
eval xxparsecdirxx=$(${xxPWDxx})/$(${xxDIRNAMExx} $(${xxDIRNAMExx} $1))
# Check
if [ -f "${xxparsecdirxx}/${xxuniquefilexx}" ]; then
xxPARSECDIRxx=${xxparsecdirxx}
fi
fi
# If xxPARSECDIRxx is still undefined, we try to guess the path
if [ -z "${xxPARSECDIRxx}" ]; then
# Check current directory
if [ -f "./${xxuniquefilexx}" ]; then
xxparsecdirxx="$(${xxPWDxx})"
xxPARSECDIRxx=${xxparsecdirxx}
fi
fi
if [ -z "${xxPARSECDIRxx}" ]; then
# Check next-higher directory
if [ -f "../${xxuniquefilexx}" ]; then
xxparsecdirxx="$(${xxPWDxx})/.."
xxPARSECDIRxx=${xxparsecdirxx}
fi
fi
fi
# Make sure xxPARSECDIRxx is defined and exported
if [ -z "${xxPARSECDIRxx}" ]; then
echo "$Error: Unable to autodetect path to the PARSEC benchmark suite. Please define environment variable PARSECDIR."
exit 1
fi
export xxPARSECDIRxx
# Eliminate trailing `/.' from xxPARSECDIRxx
xxPARSECDIRxx=${xxPARSECDIRxx/%\/./}
}
detect_path "."
# Append `bin/' directory to PATH
if [ -z "${PATH}" ]; then
export PATH=${xxPARSECDIRxx}/bin
else
export PATH=${PATH}:${xxPARSECDIRxx}/bin
fi
# Append `man/' directory to MANPATH
if [ -z "${MANPATH}" ]; then
export MANPATH=${xxPARSECDIRxx}/man
else
export MANPATH=${MANPATH}:${xxPARSECDIRxx}/man
fi
# Add directory with hooks library to library search path
if [ -z "${LD_LIBRARY_PATH}" ]; then
export LD_LIBRARY_PATH="${PARSECDIR}/pkgs/libs/hooks/inst/${PARSECPLAT}/lib"
else
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${PARSECDIR}/pkgs/libs/hooks/inst/${PARSECPLAT}/lib"
fi