aboutsummaryrefslogtreecommitdiff
path: root/academic/suitesparse/suitesparse.SlackBuild
blob: 9750a951efcfe1d4d3c8cfd4eb937d240549f681 (plain)
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/bin/sh

# Slackware build script for suitesparse

# Written by Pablo Santamaria (pablosantamaria@gmail.com)

PRGNAM=suitesparse
VERSION=${VERSION:-3.4.0}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

amd_version=2.2.0
amd_version_major=2
btf_version=1.1.0
btf_version_major=1
camd_version=2.2.0
camd_version_major=2
ccolamd_version=2.7.1
ccolamd_version_major=2
cholmod_version=1.7.1
cholmod_version_major=1
colamd_version=2.7.1
colamd_version_major=2
csparse_version=2.2.3
csparse_version_major=2
cxsparse_version=2.2.3
cxsparse_version_major=2
klu_version=1.1.0
klu_version_major=1
ldl_version=2.0.1
ldl_version_major=2
umfpack_version=5.4.0
umfpack_version_major=5
spqr_version=1.1.2
spqr_version_major=1

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf SuiteSparse
tar xvf $CWD/SuiteSparse-$VERSION.tar.gz

cd SuiteSparse
chown -R root:root .
find . \
 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;

# Set common configuration for the SuiteSparse
cp $CWD/UFconfig.mk UFconfig

mkdir -p Doc/{AMD,BTF,CAMD,CCOLAMD,CHOLMOD,COLAMD,KLU,LDL,UMFPACK,SPQR} Lib Include

pushd AMD
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libamd.so.${amd_version_major} -o \
        libamd.so.${amd_version} ../AMD/Lib/*.o -lm
    ln -sf libamd.so.${amd_version} libamd.so.${amd_version_major}
    ln -sf libamd.so.${amd_version} libamd.so
    cp -p ../AMD/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/License Doc/ChangeLog Doc/*.pdf ../Doc/AMD
popd

pushd BTF
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libbtf.so.${btf_version_major} -o \
        libbtf.so.${btf_version} ../BTF/Lib/*.o
    ln -sf libbtf.so.${btf_version} libbtf.so.${btf_version_major}
    ln -sf libbtf.so.${btf_version} libbtf.so
    cp -p ../BTF/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/* ../Doc/BTF
popd

pushd CAMD
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libcamd.so.${camd_version_major} -o \
        libcamd.so.${camd_version} ../CAMD/Lib/*.o -lm
    ln -sf libcamd.so.${camd_version} libcamd.so.${camd_version_major}
    ln -sf libcamd.so.${camd_version} libcamd.so
    cp -p ../CAMD/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/ChangeLog Doc/License Doc/*.pdf ../Doc/CAMD
popd

pushd CCOLAMD
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libccolamd.so.${ccolamd_version_major} -o \
        libccolamd.so.${ccolamd_version} ../CCOLAMD/Lib/*.o -lm
    ln -sf libccolamd.so.${ccolamd_version} libccolamd.so.${ccolamd_version_major}
    ln -sf libccolamd.so.${ccolamd_version} libccolamd.so
    cp -p ../CCOLAMD/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/* ../Doc/CCOLAMD
popd

pushd COLAMD
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libcolamd.so.${colamd_version_major} -o \
        libcolamd.so.${colamd_version} ../COLAMD/Lib/*.o -lm
    ln -sf libcolamd.so.${colamd_version} libcolamd.so.${colamd_version_major}
    ln -sf libcolamd.so.${colamd_version} libcolamd.so
    cp -p ../COLAMD/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/* ../Doc/COLAMD
popd

# CHOLMOD can also be compiled to use the METIS library, but it is not
# used here because its licensing terms exclude it from Octave.
pushd CHOLMOD
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libcholmod.so.${cholmod_version_major} -o \
        libcholmod.so.${cholmod_version} ../CHOLMOD/Lib/*.o \
        -lblas -lgfortran -lgfortranbegin -llapack \
        libamd.so.${amd_version_major} \
        libcamd.so.${camd_version_major} libcolamd.so.${colamd_version_major} \
        libccolamd.so.${ccolamd_version_major} -lm
    ln -sf libcholmod.so.${cholmod_version} libcholmod.so.${cholmod_version_major}
    ln -sf libcholmod.so.${cholmod_version} libcholmod.so
    cp -p ../CHOLMOD/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/*.pdf ../Doc/CHOLMOD
  cp -p Cholesky/License.txt ../Doc/CHOLMOD/Cholesky_License.txt
  cp -p Core/License.txt ../Doc/CHOLMOD/Core_License.txt
  cp -p MatrixOps/License.txt ../Doc/CHOLMOD/MatrixOps_License.txt
  cp -p Partition/License.txt ../Doc/CHOLMOD/Partition_License.txt
  cp -p Supernodal/License.txt ../Doc/CHOLMOD/Supernodal_License.txt
popd

# CXSparse is a superset of CSparse, and the two share common header
# names, so it does not make sense to build both.
pushd CXSparse
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libcxsparse.so.${cxsparse_version_major} -o \
        libcxsparse.so.${cxsparse_version} ../CXSparse/Lib/*.o -lm
    ln -sf libcxsparse.so.${cxsparse_version} libcxsparse.so.${cxsparse_version_major}
    ln -sf libcxsparse.so.${cxsparse_version} libcxsparse.so
    cp -p ../CXSparse/Lib/*.a ./
  popd
  cp -p Include/cs.h ../Include
  mkdir ../Doc/CXSparse/
  cp -p Doc/* ../Doc/CXSparse
popd

pushd KLU
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libklu.so.${klu_version_major} -o \
        libklu.so.${klu_version} ../KLU/Lib/*.o \
        libamd.so.${amd_version_major} libcolamd.so.${colamd_version_major} \
        libbtf.so.${btf_version_major} libcholmod.so.${cholmod_version_major}
    ln -sf libklu.so.${klu_version} libklu.so.${klu_version_major}
    ln -sf libklu.so.${klu_version} libklu.so
    cp -p ../KLU/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/lesser.txt ../Doc/KLU
popd

pushd LDL
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libldl.so.${ldl_version_major} -o \
        libldl.so.${ldl_version} ../LDL/Lib/*.o
    ln -sf libldl.so.${ldl_version} libldl.so.${ldl_version_major}
    ln -sf libldl.so.${ldl_version} libldl.so
    cp -p ../LDL/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/ChangeLog Doc/lesser.txt Doc/*.pdf ../Doc/LDL
popd

pushd UMFPACK
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    gcc -shared -Wl,-soname,libumfpack.so.${umfpack_version_major} -o \
        libumfpack.so.${umfpack_version} ../UMFPACK/Lib/*.o \
        -lblas -lgfortran -lgfortranbegin -llapack \
        libamd.so.${amd_version_major} -lm
    ln -sf libumfpack.so.${umfpack_version} libumfpack.so.${umfpack_version_major}
    ln -sf libumfpack.so.${umfpack_version} libumfpack.so
    cp -p ../UMFPACK/Lib/*.a ./
  popd
  cp -p Include/*.h ../Include
  cp -p README.txt Doc/License Doc/ChangeLog Doc/gpl.txt Doc/*.pdf ../Doc/UMFPACK
popd

pushd SPQR
  pushd Lib
    make CFLAGS="$SLKCFLAGS -fPIC"
  popd
  pushd ../Lib
    g++ -shared -Wl,-soname,libspqr.so.${spqr_version_major} -o \
        libspqr.so.${spqr_version} ../SPQR/Lib/*.o \
         -lblas -lgfortran -lgfortranbegin -llapack \
        libcholmod.so.${cholmod_version_major} -lm
    ln -sf libspqr.so.${spqr_version} libspqr.so.${spqr_version_major}
    ln -sf libspqr.so.${spqr_version} libspqr.so
    cp -p ../SPQR/Lib/*.a ./
  popd
  cp -p Include/*.h* ../Include
  cp -p README{,_SPQR}.txt
  cp -p README_SPQR.txt Doc/* ../Doc/SPQR
popd

cp -p UFconfig/UFconfig.h Include

mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
cp -a Lib/*  $PKG/usr/lib${LIBDIRSUFFIX}
mkdir -p $PKG/usr/include/suitesparse
cp -a Include/* $PKG/usr/include/suitesparse 

find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a README.txt Doc/* $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}