-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.sh
executable file
·74 lines (67 loc) · 1.77 KB
/
install.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
#!/bin/bash
# ./install.sh [directory [jobs]]
# Install GBWTGraph headers and library to the home directory or to the
# specified directory. The number of parallel make jobs is equal to the number
# of logical CPU cores unless specified otherwise.
GBWTGRAPH_DIR=$(pwd)
INCLUDE_DIR=include
INCLUDE=gbwtgraph
LIBRARY_DIR=lib
LIBRARY=libgbwtgraph.a
# Determine the directory where we will install GBWTGraph.
if [ $# -ge 1 ]; then
PREFIX=${1}
else
PREFIX=${HOME}
fi
mkdir -p "${PREFIX}" 2> /dev/null
cd "${PREFIX}" > /dev/null 2>&1
if [ $? != 0 ]; then
echo "Error: Directory '${PREFIX}' does not exist and cannot be created."
exit 1
else
PREFIX=$(pwd -P)
fi
echo "Installing GBWTGraph to '${PREFIX}'."
# Determine the number of jobs.
if [ $# -ge 2 ]; then
JOBS=${2}
else
JOBS=$(getconf _NPROCESSORS_ONLN)
fi
echo "Running ${JOBS} parallel make jobs."
# Create the include/library directories.
mkdir -p "${INCLUDE_DIR}" 2> /dev/null
if [ $? != 0 ]; then
echo "Error: Directory '${PREFIX}/${INCLUDE_DIR}' does not exist and cannot be created."
exit 1
fi
mkdir -p "${LIBRARY_DIR}" 2> /dev/null
if [ $? != 0 ]; then
echo "Error: Directory '${PREFIX}/${LIBRARY_DIR}' does not exist and cannot be created."
exit 1
fi
# Build GBWTGraph.
cd "${GBWTGRAPH_DIR}"
make clean > /dev/null
if [ $? != 0 ]; then
echo "Error: Cleanup failed."
exit 1
fi
make -j "${JOBS}"
if [ $? != 0 ]; then
echo "Error: Could not compile GBWTGraph."
exit 1
fi
# Install GBWTGraph.
cp -R "${INCLUDE_DIR}/${INCLUDE}" "${PREFIX}/${INCLUDE_DIR}" 2> /dev/null
if [ $? != 0 ]; then
echo "Error: Could not install the headers."
exit 1
fi
cp "${LIBRARY_DIR}/${LIBRARY}" "${PREFIX}/${LIBRARY_DIR}" 2> /dev/null
if [ $? != 0 ]; then
echo "Error: Could not install the library."
exit 1
fi
echo "GBWTGraph installed to '${PREFIX}'."