-
Notifications
You must be signed in to change notification settings - Fork 2
/
setenv.sh
59 lines (50 loc) · 1.65 KB
/
setenv.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
#!/usr/bin/env bash
## Usage: $ . ./setenv.sh
##############################################################################
## Subroutines
getHome() {
local source="${BASH_SOURCE[0]}"
while [[ -h "$source" ]]; do
local linked="$(readlink "$source")"
local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )"
source="$dir/$(basename "$linked")"
done
( cd -P "$(dirname "$source")" && pwd )
}
getOS() {
local os
case "$(uname -s)" in
Linux*) os=linux;;
Darwin*) os=mac;;
CYGWIN*) os=cygwin;;
MINGW*) os=mingw;;
*) os=unknown
esac
echo $os
}
getPath() {
local path=""
for i in $(ls -d "$1"*/ 2>/dev/null); do path=$i; done
# ignore trailing slash introduced in for loop
[[ -z "$path" ]] && echo "" || echo "${path::-1}"
}
##############################################################################
## Environment setup
PROG_HOME="$(getHome)"
OS="$(getOS)"
[[ $OS == "unknown" ]] && { echo "Unsuppored OS"; exit 1; }
if [[ $OS == "cygwin" || $OS == "mingw" ]]; then
[[ $OS == "cygwin" ]] && prefix="/cygdrive" || prefix=""
export HOME=$prefix/c/Users/$USER
export CMAKE_HOME="$(getPath "$prefix/c/opt/cmake-3")"
export CPPCHECK_HOME="$(getPath "$ProgramFiles/CppCheck")"
export DOXYGEN_HOME="$(getPath "$prefix/c/opt/doxygen-1")"
export GIT_HOME="$(getPath "$prefix/c/opt/Git-2")"
export LLVM_HOME="$(getPath "$prefix/c/opt/LLVM-15")"
PATH1="$PATH"
[[ -x "$GIT_HOME/bin/git" ]] && PATH1="$PATH1:$GIT_HOME/bin"
export PATH="$PATH1"
else
export LLVM_HOME=/opt/llvm
fi
## echo "LLVM_HOME=$LLVM_HOME"