-
Notifications
You must be signed in to change notification settings - Fork 161
/
boost.sh
126 lines (118 loc) · 4.48 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
package: boost
version: v1.83.0-alice2
tag: v1.83.0-alice2
source: https://github.com/alisw/boost.git
requires:
- "GCC-Toolchain:(?!osx)"
- "Python-modules:(?!osx)"
- libpng
- zlib
build_requires:
- lzma
- bz2
- alibuild-recipe-tools
prepend_path:
ROOT_INCLUDE_PATH: "$BOOST_ROOT/include"
---
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 ;;
*) 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-mpi \
${BOOST_NO_PYTHON:+--without-python} \
--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 etc/modulefiles
alibuild-generate-module --lib --cmake > etc/modulefiles/$PKGNAME
cat << EOF >> etc/modulefiles/$PKGNAME
prepend-path ROOT_INCLUDE_PATH \$PKG_ROOT/include
EOF
mkdir -p $INSTALLROOT/etc/modulefiles && rsync -a --delete etc/modulefiles/ $INSTALLROOT/etc/modulefiles