-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.bash
executable file
·110 lines (97 loc) · 3.1 KB
/
build.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
#!/bin/bash
if [ $# -lt 1 ]; then
echo $"Usage: $(basename $0) PKG
Available SuiteSparse PKG:
* ALL (build all packages)
$(ls -1d addons/* | xargs -n1 basename | grep -v '^\(config\|m4\)' | awk '{print " * "$1}')"
exit
fi
build_suitesparse_pkg() {
local lib=$1 i
shift
# remove old
if [[ -d SuiteSparse ]]; then
chmod -R 755 SuiteSparse
rm -rf SuiteSparse
fi
rm -rf ${lib}_build
tar xf SuiteSparse.tar.gz
# backup all Makefile's
for i in $(find SuiteSparse/${lib} -name Makefile); do
[ -e ${i}.orig ] || mv ${i} ${i}.orig
done
# copy common files
cp -r addons/{config,m4} SuiteSparse/${lib}
# copy specific files
for i in $(find addons/${lib} -type f); do
cp ${i} SuiteSparse/$(dirname ${i/addons\/})
done
pushd SuiteSparse/${lib} > /dev/null
# apply hook
[[ -x post-copy-hook.bash ]] && ./post-copy-hook.bash
# try to guess version
if [ -e Doc/ChangeLog ]; then
version=$(awk '{print $5;exit};1' Doc/ChangeLog | sed 's/,/./g')
else
version=$(grep VERSION ../README.txt | awk '{print $6}')
fi
sed -i -e "/AC_INIT/s/[[:digit:]]\.[[:digit:]]\.[[:digit:]]/${version}/" configure.ac
# configure, build, test, and package
autoreconf -vi && \
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH" \
./configure && make distcheck PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH"
# cleanup
if [[ $? -eq 0 ]]; then
make maintainer-clean
[[ -x post-install-hook.bash ]] && ./post-install-hook.bash
rm -rf config m4 configure.ac *.pc.in post-*.bash
find . -name Makefile.am -delete
for i in $(find . -name Makefile.orig); do
mv ${i} ${i/.orig/}
done
else
popd > /dev/null
echo "!! FAILED - See above"
return
fi
popd > /dev/null
# now install and save generated tar ball
local tb=$(find SuiteSparse/${lib} -name \*-${version}.tar.bz2)
local src=$(basename ${tb} .tar.bz2)
tar xf ${tb} && \
mkdir ${lib}_build && \
pushd ${lib}_build && \
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH" \
../${src}/configure --prefix=${PREFIX} --disable-static $@ && \
make install && \
popd && \
rm -rf ${lib}_build ${src} && \
mkdir -p distfiles && mv ${tb} distfiles/ && \
echo "Successfully built ${tb} now in distfiles"
}
PREFIX=${PWD}/usr
[[ -e SuiteSparse.tar.gz ]] || ./sync.bash
if test $(find SuiteSparse.tar.gz -ctime 30); then
echo "Current version more than one month old, re-fetching"
rm -rf SuiteSparse SuiteSparse.tar.gz
./sync.bash
fi
[[ -d SuiteSparse ]] || tar xf SuiteSparse.tar.gz
if [[ $1 == ALL ]]; then
# need to keep an order for dependencies
build_suitesparse_pkg SuiteSparse_config
build_suitesparse_pkg AMD
build_suitesparse_pkg COLAMD
build_suitesparse_pkg CAMD
build_suitesparse_pkg CCOLAMD
build_suitesparse_pkg CXSparse
build_suitesparse_pkg RBio
build_suitesparse_pkg LDL
build_suitesparse_pkg BTF
build_suitesparse_pkg CHOLMOD --with-partition
build_suitesparse_pkg KLU
build_suitesparse_pkg SPQR --with-partition
build_suitesparse_pkg UMFPACK
else
build_suitesparse_pkg $1
fi