-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfigure
executable file
·164 lines (141 loc) · 3.3 KB
/
configure
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env bash
# Configure script for R package generation
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${R_HOME}/exageostat/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$R_LIBS_USER/exageostat/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$R_LIBS/exageostat/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$R_PACKAGE_DIR/exageostat/lib/pkgconfig # if user uses -l option
export BASEDIR=$(pwd)
TMPDIR=$BASEDIR/_$$
BUILD_DEPENDENCIES='TRUE'
err=0
CUDA_VALUE="OFF"
MPI_VALUE="OFF"
mkdir -p "$TMPDIR"
SETUP_DIR=${R_PACKAGE_DIR:-''}
print_usage() {
echo "usage: $0 [--enable-mpi|--disable-mpi] [--enable-cuda|--disable-cuda] [--build-deps|--no-build-deps]
[--prefix /path/to/install]"
}
while [ -n "$1" ]
do
case "$1" in
--enable-cuda)
CUDA_VALUE="ON"
shift
;;
--disable-cuda)
CUDA_VALUE="OFF"
shift
;;
--enable-mpi)
MPI_VALUE="ON"
shift
;;
--disable-mpi)
MPI_VALUE="OFF"
shift
;;
--build-deps)
BUILD_DEPENDENCIES='true'
shift
;;
--no-build-deps)
BUILD_DEPENDENCIES='false'
shift
;;
--prefix)
shift
SETUP_DIR=$1
# Set this paths as rpath during compilation
r_paths="-Wl,-rpath=$SETUP_DIR/lib -L$SETUP_DIR/lib "
echo "LDFLAGS += $r_paths " >> "$BASEDIR"/src/Makefile
shift
;;
--help|-h)
print_usage
exit 0
;;
*)
print_usage
exit 1
;;
esac
done
if [ -z "$SETUP_DIR" ]; then
# Use R Library Paths for setup dir
mapfile -t arr < <(Rscript -e '.libPaths()')
for i in ${!arr[*]};
do
dir=$(echo "${arr[$i]}"| awk '{print $2}'| tr -d \")
if [ -d "$dir" ] && [ -w "$dir" ]
then
SETUP_DIR="$dir/exageostat"
break
fi
done
fi
if [ -z "$SETUP_DIR" ]
then
echo "Check your .libPaths() in R. Could not find a writable directory."
exit 1;
fi
PREFIX=$SETUP_DIR
echo "Installation Directory Set to $PREFIX"
############################## Check OS
echo "Finding the current os type"
echo
osType=$(uname)
case "$osType" in
"Darwin")
{
echo "Running on Mac OSX."
LIB_EXT="dylib"
export DYLD_LIBRARY_PATH=$PREFIX/lib:$DYLD_LIBRARY_PATH
} ;;
"Linux")
{
echo "Running on LINUX."
LIB_EXT="so"
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
} ;;
*)
{
echo "Unsupported OS, exiting"
exit
} ;;
esac
##### Check and build dependencies
# Prepare environment
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
if [ -n "$MKLROOT" ] && [ -d "$MKLROOT" ]; then
echo "mkl_dir directory exists!"
echo "Great... continue set-up"
source "$MKLROOT"/bin/mklvars.sh intel64
else
echo "MKL not found, trying to compile and use OpenBLAS"
fi
cd "$BASEDIR" || exit
rm -rf CMake*
CFLAGS="-fcommon" cmake \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DEXAGEOSTAT_SCHED_STARPU=ON \
-DEXAGEOSTAT_USE_MPI=OFF \
-DEXAGEOSTAT_PACKAGE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DEXAGEOSTAT_USE_STARSH=ON \
-DEXAGEOSTAT_USE_HICMA=ON \
-DEXAGEOSTAT_USE_NETCDF=ON \
-DEXAGEOSTAT_USE_CHAMELEON=ON \
-DEXAGEOSTAT_INSTALL_DEPS=ON \
-DBUILD_DEPENDENCIES=ON \
-DMPI_VALUE="$MPI_VALUE" \
-DCUDA_VALUE="$CUDA_VALUE" \
-DCMAKE_C_FLAGS_RELEASE="-O3 -Ofast -w" \
-DBUILD_SHARED_LIBS=ON ./src || exit 1;
echo "CMake Configuration of Exageostat Complete!"
cat > src/Makefile << EOF
.PHONY: all clean
all:
(cd .. && make VERBOSE=1 && cp ./lib*.${LIB_EXT} ./src/exageostat.so)
EOF
exit $err