forked from alisw/alidist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boost.sh
140 lines (132 loc) · 5.08 KB
/
boost.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
package: boost
version: "%(tag_basename)s"
tag: v1.72.0-alice1
source: https://github.com/alisw/boost.git
requires:
- "GCC-Toolchain:(?!osx)"
- "Python-modules:(?!osx)"
- libpng
- zlib
build_requires:
- lzma
- bz2
prepend_path:
ROOT_INCLUDE_PATH: "$BOOST_ROOT/include"
---
#!/bin/bash -e
BOOST_PYTHON=
BOOST_CXXFLAGS=
if [[ $ARCHITECTURE != osx* && $PYTHON_MODULES_VERSION ]]; then
# Enable boost_python on platforms other than macOS
BOOST_PYTHON=1
if [[ $PYTHON_VERSION ]]; then
# Our Python. We need to pass the appropriate flags to boost for the includes
BOOST_CXXFLAGS="$(python3-config --includes)"
else
# Using system's Python. We want to make sure `python-config` is available in $PATH and points
# to the Python 3 version. Note that a symlink will not work due to the automatic prefix
# calculation of the python-config script. Our own Python does not require tricks
if ! type python3-config &> /dev/null; then
echo "FATAL: cannot find python3-config in your \$PATH. Cannot enable boost_python"
exit 1
fi
mkdir fake_bin
cat > fake_bin/python-config <<\EOF
#!/bin/bash
exec python3-config "$@"
EOF
chmod +x fake_bin/python-config
ln -nfs "$(which python3)" fake_bin/python
ln -nfs "$(which pip3)" fake_bin/pip
export PATH="$PWD/fake_bin:$PATH"
fi
fi
BOOST_NO_PYTHON=
if [[ ! $BOOST_PYTHON ]]; then
BOOST_NO_PYTHON=1
fi
if [[ $CXXSTD && $CXXSTD -ge 17 ]]; then
# Use C++17: https://github.com/boostorg/system/issues/26#issuecomment-413631998
CXXSTD=17
fi
TMPB2=$BUILDDIR/tmp-boost-build
case $ARCHITECTURE in
osx*) TOOLSET=clang-darwin ;;
*) TOOLSET=gcc ;;
esac
rsync -a $SOURCEDIR/ $BUILDDIR/
cd $BUILDDIR/tools/build
# This is to work around an issue in boost < 1.70 where the include path misses
# the ABI suffix. E.g. ../include/python3 rather than ../include/python3m.
# This is causing havok on different combinations of Ubuntu / Anaconda
# installations.
bash bootstrap.sh $TOOLSET
case $ARCHITECTURE in
osx*) ;;
*) export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$(python3 -c 'import sysconfig; print(sysconfig.get_path("include"))')" ;;
esac
mkdir -p $TMPB2
./b2 install --prefix=$TMPB2
export PATH=$TMPB2/bin:$PATH
cd $BUILDDIR
b2 -q \
-d2 \
${JOBS+-j $JOBS} \
--prefix=$INSTALLROOT \
--build-dir=build-boost \
--disable-icu \
--without-context \
--without-coroutine \
--without-graph \
--without-graph_parallel \
--without-locale \
--without-math \
--without-mpi \
${BOOST_NO_PYTHON:+--without-python} \
--without-wave \
--debug-configuration \
-sNO_ZSTD=1 \
${BZ2_ROOT:+-sBZIP2_INCLUDE="$BZ2_ROOT/include"} \
${BZ2_ROOT:+-sBZIP2_LIBPATH="$BZ2_ROOT/lib"} \
${ZLIB_ROOT:+-sZLIB_INCLUDE="$ZLIB_ROOT/include"} \
${ZLIB_ROOT:+-sZLIB_LIBPATH="$ZLIB_ROOT/lib"} \
${LZMA_ROOT:+-sLZMA_INCLUDE="$LZMA_ROOT/include"} \
${LZMA_ROOT:+-sLZMA_LIBPATH="$LZMA_ROOT/lib"} \
toolset=$TOOLSET \
link=shared \
threading=multi \
variant=release \
${BOOST_CXXFLAGS:+cxxflags="$BOOST_CXXFLAGS"} \
${CXXSTD:+cxxstd=$CXXSTD} \
install
# If boost_python is enabled, check if it was really compiled
[[ $BOOST_PYTHON ]] && ls -1 "$INSTALLROOT"/lib/*boost_python* > /dev/null
# We need to tell boost libraries linking other boost libraries to look for them
# inside the same directory as the main ones, on macOS (@loader_path).
if [[ $ARCHITECTURE == osx* ]]; then
for LIB in $INSTALLROOT/lib/libboost*.dylib; do
otool -L $LIB | grep -v $(basename $LIB) | { grep -oE 'libboost_[^ ]+' || true; } | \
xargs -I{} install_name_tool -change {} @loader_path/{} "$LIB"
done
fi
# Modulefile
MODULEDIR="$INSTALLROOT/etc/modulefiles"
MODULEFILE="$MODULEDIR/$PKGNAME"
mkdir -p "$MODULEDIR"
cat > "$MODULEFILE" <<EoF
#%Module1.0
proc ModulesHelp { } {
global version
puts stderr "ALICE Modulefile for $PKGNAME $PKGVERSION-@@PKGREVISION@$PKGHASH@@"
}
set version $PKGVERSION-@@PKGREVISION@$PKGHASH@@
module-whatis "ALICE Modulefile for $PKGNAME $PKGVERSION-@@PKGREVISION@$PKGHASH@@"
# Dependencies
module load BASE/1.0 ${GCC_TOOLCHAIN_REVISION:+GCC-Toolchain/$GCC_TOOLCHAIN_VERSION-$GCC_TOOLCHAIN_REVISION} \\
${PYTHON_REVISION:+Python/$PYTHON_VERSION-$PYTHON_REVISION} \\
${ZLIB_REVISION:+zlib/$ZLIB_VERSION-$ZLIB_REVISION}
# Our environment
set BOOST_ROOT \$::env(BASEDIR)/$PKGNAME/\$version
prepend-path LD_LIBRARY_PATH \$BOOST_ROOT/lib
prepend-path ROOT_INCLUDE_PATH \$BOOST_ROOT/include
EoF