-
Notifications
You must be signed in to change notification settings - Fork 4
/
patchMATLAB.sh
52 lines (44 loc) · 1.53 KB
/
patchMATLAB.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
#!/bin/sh
#
# Based on https://github.com/jdreaver/NixOS-matlab/blob/master/builder.sh
#
PATCH_MATLAB_LOCK_FILE=patchMatlab.lock
if [ ! -f "$PATCH_MATLAB_LOCK_FILE" ]; then
PATCH_FILES=(
$MATLAB_PATH/bin/glnxa64/MATLAB
$MATLAB_PATH/bin/glnxa64/matlab_helper
$MATLAB_PATH/bin/glnxa64/mbuildHelp
$MATLAB_PATH/bin/glnxa64/mex
$MATLAB_PATH/bin/glnxa64/need_softwareopengl
$MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java
)
echo "Patching java... ($MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java)"
chmod u+rw "$MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java"
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "$libPath:$(patchelf --print-rpath $MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java)"\
--force-rpath "$MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java"
echo "Patching MATLAB executables..."
for f in ${PATCH_FILES[*]}; do
chmod u+rw $f
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "$libPath:$(patchelf --print-rpath $f)"\
--force-rpath $f
done
SO_FILES=$(ls -1 $MATLAB_PATH/bin/glnxa64/*.so)
for f in ${SO_FILES[*]}; do
chmod u+rw $f
patchelf --set-rpath "$libPath:$(patchelf --print-rpath $f)"\
--force-rpath $f
done
# Set the correct path to gcc
CC_FILES=(
$MATLAB_PATH/bin/mbuildopts.sh
$MATLAB_PATH/bin/mexopts.sh
)
for f in ${CC_FILES[*]}; do
chmod u+rw $f
substituteInPlace $f\
--replace "CC='gcc'" "CC='${matlabGcc}/bin/gcc'"
done
touch "$PATCH_MATLAB_LOCK_FILE"
fi