-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-lapack.sh
executable file
·149 lines (119 loc) · 2.64 KB
/
build-lapack.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
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
#!/bin/bash
#
# lapack build
#
### FUNCTIONS ###
#
# custom basename
_basename()
{
typeset root="$1"
awk -vroot=$root '
{
rootlen = length(root)
base = substr($0, rootlen + 2, length($0) - rootlen)
if (length(base) != 0) { print base; }
}
'
}
_bulk_ln()
{
typeset root="$1"
typeset target="$2"
awk -vroot=$root -vtarget=$target '
BEGIN { cnt = 0; }
{
rootlen = length(root)
base = substr($0, rootlen + 2, length($0) - rootlen)
if (length(base) != 0)
{
print "ln -sf " $0 " "target "/" base " &&";
cnt = cnt + 1;
# if (cnt % 100 == 0) { print "echo success for " cnt; }
}
}
END { print " echo Created: for " cnt " links" ; }
'
}
#
# debug / more informational echo
#
decho()
{
echo "lapack: $*"
}
### ENV ###
id="lapack"
buildid="${id}.${RANDOM}"
projectdir="${GPAW}"
src="${projectdir}/source/${id}"
target="${projectdir}/build/${id}"
install="${projectdir}/software"
### MAIN ###
# Sanity checks
[ ! -d "${projectdir}" ] && { echo "Project directory invalid: ${projectdir}"; exit 1; }
[ ! -d "${src}" ] && { echo "Source directory invalid: ${src}"; exit 1; }
[ ! -d "${target}" ] && { mkdir -p "${target}" || exit 1; }
# Actual main
# make links for files and re-create directories in build directory
allDirs=$(find $src -type d | _basename ${src} )
cd ${target} || { echo "Failed changing directory to target: ${target}"; return 1; }
pwd
mkdir -p ${allDirs}
# Create symlinks for all files
find $src -type f | awk '
!/\.git/&&!/\.out$/&&!/\.o$/&&!/\.a$/
' | _bulk_ln $src $target | sh
rc=$?
[ $rc -ne 0 ] && { echo "failed creating links"; exit 1; }
echo "Creating make.inc"
pwd
ln -sf make.inc.example make.inc
[ -f "makefile.orig" ] && ls -lt makefile.orig
ls -lt makefile
echo "Starting at :"$(date)
log="/tmp/blaslib.${buildid}.log"
make blaslib > ${log} 2>&1
rc_blaslib=$?
[ "$rc_blaslib" -ne 0 ] &&
{
cat "${log}"
rm "${log}"
echo
echo "make blas lib failed with return code: $make_rc"
exit $make_rc
}
log="/tmp/lib.${buildid}.log"
make lib > ${log} 2>&1
rc_lib=$?
[ "$rc_lib" -ne 0 ] &&
{
cat "${log}"
rm "${log}"
echo
echo "make lib failed with return code: $make_rc"
exit $make_rc
}
log="/tmp/lapackinstall.${buildid}.log"
make lapack_install > ${log} 2>&1
rc_lapackinstall=$?
[ "$rc_lapackinstall" -ne 0 ] &&
{
cat "${log}"
rm "${log}"
echo
echo "make lapack_install failed with return code: $make_rc"
exit $make_rc
}
libs="./liblapack.a
./librefblas.a
./libtmglib.a
"
# There is no "make install" in lapack (.......!)
for lib in $libs
do
echo "Installing $lib"
cp "$lib" "$install/lib" || { rc=$?; echo "Failed copying $lib: return code = $rc"; exit $rc; }
ls -lt "${install}/lib/${lib}"
done
### EOF ###