-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsource-megalib.sh
executable file
·73 lines (54 loc) · 1.46 KB
/
source-megalib.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
#!/bin/bash
# This bash script is part of the MEGAlib & COSItools setup procedure.
# As such it is dual licenced under Apache 2.0 for COSItools and LGPL 3.0 for MEGAlib
#
# Development lead: Andreas Zoglauer
#
# Description:
# Source all MEGAlib-related environment variables
# Make this script work with zsh
if [ -n "$ZSH_VERSION" ]; then emulate -L ksh; fi
# Print some help
confhelp() {
echo ""
echo "This script sources all MEGAlib-related environment variables"
echo " "
echo "Usage: ./source-megalib.sh --path=[full path to the MEGAlib installation]";
echo " "
}
# Parse the command line
CMD=( "$@" )
__TMP_PATH=""
__TMP_HERE=$(pwd)
for C in "${CMD[@]}"; do
if [[ ${C} == *-p*=* ]]; then
__TMP_PATH=`echo ${C} | awk -F"=" '{ print $2 }'`
elif [[ ${C} == *-h ]] || [[ ${C} == *-hel* ]]; then
echo ""
confhelp
exit 0
fi
done
# Perform sanity checks
# We require an absolute path
if [[ ${__TMP_PATH} != /* ]]; then
echo ""
echo "ERROR: The MEGAlib path must be an absolute path: ${__TMP_PATH}"
echo ""
return
fi
# The directory must exist
if [[ ! -d ${__TMP_PATH} ]]; then
echo ""
echo "ERROR: MEGAlib directory not found: ${__TMP_PATH}"
echo ""
return
fi
# Source the MEGAlib environment
export MEGALIB=${__TMP_PATH}
export PATH=${MEGALIB}/bin:${PATH}
export LD_LIBRARY_PATH=${MEGALIB}/lib:${LD_LIBRARY_PATH}
if [[ `uname -a` == *Darwin* ]]; then
export DYLD_LIBRARY_PATH=${MEGALIB}/lib:${LD_LIBRARY_PATH}
fi
return