-
Notifications
You must be signed in to change notification settings - Fork 1
/
R.bash
121 lines (91 loc) · 4.13 KB
/
R.bash
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
rV=4.0
IrV=$rV.2
add_package -alias R -package R \
https://cran.r-project.org/src/base/R-${rV:0:1}/R-$IrV.tar.gz
pack_set -s $BUILD_DIR -s $MAKE_PARALLEL -s $IS_MODULE
pack_set $(list -prefix '-mod-req ' readline curl)
pack_set -install-query $(pack_get -prefix)/bin/R
# for openssl
pack_set -mod-req openssl
# for git2r
pack_set -mod-req libgit2
# for xml dependency
pack_set -mod-req libxml2
pack_set -mod-req pcre2
tmp=
if $(is_c intel) ; then
tmp="$tmp BLAS_LIBS='$MKL_LIB -mkl=parallel $FLAG_OMP'"
tmp="$tmp LAPACK_LIBS='$MKL_LIB -mkl=parallel $FLAG_OMP'"
else
la=$(pack_choice -i linalg)
pack_set -module-requirement $la
tmp="$tmp BLAS_LIBS='-L$(pack_get -LD $la) -Wl,-rpath=$(pack_get -LD $la) $(pack_get -lib[omp] $la)'"
tmp="$tmp LAPACK_LIBS='-L$(pack_get -LD $la) -Wl,-rpath=$(pack_get -LD $la) $(pack_get -lib[omp] $la)'"
fi
pack_cmd "../configure CFLAGS='$CFLAGS $FLAG_OMP' $tmp" \
"--enable-R-shlib --enable-R-static-lib" \
"--with-blas --with-lapack" \
"--enable-lto" \
"--with-readline" \
"--prefix=$(pack_get -prefix)"
# Make commands
pack_cmd "make $(get_make_parallel)"
pack_cmd "make check-all > R.test 2>&1 || echo forced"
pack_cmd "make install"
pack_cmd "make install-tests"
pack_store R.test
# Install directory for intrinsic packages
pack_cmd "mkdir -p $(pack_get -prefix)/library"
# Ensure the library path is added
pack_cmd "[ -d $(pack_get -prefix)/lib64 ] && echo '# Custom R profile' > $(pack_get -prefix)/lib64/R/etc/Rprofile.site || echo '# Custom R profile' > $(pack_get -prefix)/lib/R/etc/Rprofile.site"
pack_cmd "[ -d $(pack_get -prefix)/lib64 ] && echo '#' >> $(pack_get -prefix)/lib64/R/etc/Rprofile.site || echo '#' >> $(pack_get -prefix)/lib/R/etc/Rprofile.site"
pack_cmd "[ -d $(pack_get -prefix)/lib64 ] && echo '# Custom location of libraries (without using env-vars)' >> $(pack_get -prefix)/lib64/R/etc/Rprofile.site || echo '# Custom location of libraries (without using env-vars)' >> $(pack_get -prefix)/lib/R/etc/Rprofile.site"
pack_cmd "[ -d $(pack_get -prefix)/lib64 ] && echo 'invisible(.libPaths( c(\"$(pack_get -prefix)/library\", .libPaths()) ))' >> $(pack_get -prefix)/lib64/R/etc/Rprofile.site || echo 'invisible(.libPaths( c(\"$(pack_get -prefix)/library\", .libPaths()) ))' >> $(pack_get -prefix)/lib/R/etc/Rprofile.site"
# Create a new build with this module
new_build -name _internal-R$IrV \
-module-path $(build_get -module-path)-R/$IrV \
-source $(build_get -source) \
$(list -prefix "-default-module " $(pack_get -mod-req-module) R[$IrV]) \
-installation-path $(dirname $(pack_get -prefix $(get_parent)))/packages \
-build-module-path "-package -version" \
-build-installation-path "$IrV -package -version" \
-build-path $(build_get -build-path)/r-$rV
mkdir -p $(build_get -module-path[_internal-R$IrV])-apps
build_set -default-setting[_internal-R$IrV] $(build_get -default-setting)
# Now add options to ensure that loading this module will enable the path for the *new build*
pack_set -module-opt "-use-path $(build_get -module-path[_internal-R$IrV])"
case $_mod_format in
$_mod_format_ENVMOD)
;;
*)
pack_set -module-opt "-use-path $(build_get -module-path[_internal-R$IrV])-apps"
;;
esac
# Needed as it is not source_pack
pack_install
create_module \
-module-path $(build_get -module-path)-apps \
-n $(pack_get -alias).$(pack_get -version) \
-W "Loading $(pack_get -package): $(get_c)" \
-v $(pack_get -version) \
-M $(pack_get -alias).$(pack_get -version) \
-P "/directory/should/not/exist" \
$(list -prefix '-L ' $(pack_get -module-requirement)) \
-L $(pack_get -alias)
# The lookup name in the list for version number etc...
set_parent $(pack_get -alias)[$IrV]
set_parent_exec $(pack_get -prefix)/bin/R
# Save the default build index
def_idx=$(build_get -default-build)
# Change to the new build default
build_set --default-build _internal-R$IrV
# Install all R packages
source R-install.bash
clear_parent
# Initialize the module read path
old_path=$(build_get -module-path)
build_set -module-path $old_path-apps
source R/R-mods.bash
build_set -module-path $old_path
# Reset default build
build_set --default-build $def_idx