forked from agra-uni-bremen/dependencies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sh
executable file
·83 lines (70 loc) · 1.42 KB
/
common.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
error() {
echo "ERROR: $@" >&2
echo "TERMINATING" >&2
exit 1
}
message() {
echo "$@"
}
run_scripts() {
cd $base_dir
package_dir=$base_dir/$p
source $p/setup.sh
for s in $@; do
echo "calling $s for $p"
$s || error "$s failed for $p"
done
}
with_deps() {
build="-"
local i
local dependencies
for i in $@; do
package_dir=$i
source $package_dir/setup.sh
with_deps $dependencies
echo $i
done
}
download_http() {
url="$2"
name="$1"
if which wget &>/dev/null; then
wget -c -O "$name" "$url"
elif which curl &>/dev/null; then
curl -C - -o "$name" "$url"
else
error "no tool for http download found"
fi
}
#
# install all CMakeLists.txt files from the package to the current folder.
# includes subfolders and keeps hierarchy
#
# currently all files are symlinked.
#
install_cmake_files() {
find $package_dir -name CMakeLists.txt -o -name "*.cmake"| while read f
do
ln -sf $f $(echo "$f" |sed "s@^$package_dir/*@@")
done
}
cmake_build_install() {
mkdir -p build &&
cd build &&
cmake ${1:-..} -DCMAKE_INSTALL_PREFIX=$target -DCMAKE_BUILD_TYPE=${BUILD_TYPE}&&
make install
}
setup_environment() {
ARCH=${ARCH:-$(uname -m)}
duplicate=${duplicate:-skip}
BUILD_TYPE=${BUILD_TYPE:-RELEASE}
case "$ARCH" in
i?86)
export CFLAGS="-m32 $CFLAGS"
export CXXFLAGS="-m32 $CXXFLAGS"
;;
esac
}
setup_environment
# vim: ts=2 sw=2 et