Files
BMLFS/build-scripts/boost.build
2025-07-05 16:57:41 -05:00

126 lines
4.5 KiB
Bash

#! /bin/bash
# Boost
# Source: https://github.com/boostorg/boost/releases/download/boost-1.88.0/boost-1.88.0-b2-nodocs.tar.xz
#
# $BUILD = Directory to temporarily install
# $PKGS = Directory to store built packages
#
# DEPS
# Required: NONE
# Recommended: Which
# Optional: ICU, NumPy, Open MPI
# LTO: Tested with LLVM
# Per LFS, fix a build issue which occurs in the stacktrace library.
# This issue is specific to i686 systems.
case $(uname -m) in
i?86)
sed -e "s/defined(__MINGW32__)/& || defined(__i386__)/" \
-i ./libs/stacktrace/src/exception_headers.h ;;
esac
export PVER="1.88"
# Setup build environment
export CXXFLAGS="-std=c++14"
case $(uname -m) in
x86_64*) export BARCH=x86 && export BABI=sysv
;;
i686*) export BARCH=x86 && export BABI=sysv
;;
aarch64*) export BARCH=arm && export BABI=aapcs
;;
arm*) export BARCH=arm && export BABI=aapcs
;;
esac
# Apply patches
#patch -Np1 -i ../patches/boost-alpine/0001-revert-cease-dependence-on-range.patch
patch -Np1 -i ../patches/boost-alpine/boost-1.57.0-python-abi_letters.patch
patch -Np1 -i ../patches/boost-alpine/boost-1.57.0-python-libpython_dep.patch
patch -Np1 -i ../patches/boost-alpine/boost-phoenix-uarg.patch
# Apply patches if clang is used instead of gcc
patch -Np1 -i ../patches/boost-chimera/0001-revert-cease-dependence-on-range.patch
patch -Np1 -i ../patches/boost-chimera/boost-1.57.0-python-abi_letters.patch
patch -Np1 -i ../patches/boost-chimera/boost-1.57.0-python-libpython_dep.patch
patch -Np1 -i ../patches/boost-chimera/fix-x86-build.patch
patch -Np1 -i ../patches/boost-chimera/install-strip-destdir.patch
patch -Np1 -i ../patches/boost-chimera/toolset-default-clang.patch
# If not using pkgtools or any package manager, set $BUILD=""
# Bootstap source
./bootstrap.sh --prefix=${BUILD}/usr --with-python=/usr/bin/python3 --with-python-root=/usr &&
# Rebuild bjam for target
cd tools/build/src/engine &&
./build.sh gcc &&
cd ../../../.. &&
cat > user-config.jam << "EOF"
using gcc : : g++ : <cxxflags>"-std=c++14" <linkflags>"" ;
using python : 3.13 : /usr/bin/python3 : /usr/include/python3.13 : /usr/lib/python3.13 ;
EOF
# Build
./b2 -j4 --user-config=./user-config.jam --debug-building \
--toolset=gcc abi=${BABI} architecture=${BARCH} python=3.13 \
threading=multi runtime-link=shared link=shared,static &&
# Install bjam & b2
sudo -S mkdir -pv ${BUILD}/usr/bin &&
sudo -S cp -v tools/build/src/engine/b2 ${BUILD}/usr/bin
sudo -S ln -sv b2 ${BUILD}/usr/bin/bjam
# Install headers & libraries
sudo -S ./b2 --prefix=${BUILD}/usr abi=${BABI} architecture=${BARCH} \
--user-config=./user-config.jam --no-cmake-config \
python=3.13 threading=multi runtime-link=shared \
link=shared,static install
# Install Boost.Build
sudo -S mkdir -pv ${BUILD}/usr/share/boost-build &&
cd ./tools/build && sudo -S cp -av . ${BUILD}/usr/share/boost-build/ &&
sudo -S find ${BUILD}/usr/share/boost-build -type f -name \*.orig -exec rm -f {} \; &&
sudo -S rm -rvf ${BUILD}/usr/share/boost-build/src/engine/bootstrap &&
sudo -S rm -rvf ${BUILD}/usr/share/boost-build/src/engine/b2 &&
cat > /tmp/site-config.jam << "EOF"
# System wide configuration file for Boost.Build.
using gcc ;
EOF
sudo -S mkdir -pv ${BUILD}/etc
sudo -S mv -v /tmp/site-config.jam ${BUILD}/etc/
# Clean up
unset CXXFLAGS BARCH BABI
# Skip the rest if not using pkgtools or any other similar package manager
cd $BUILD && sudo -S mkdir -v install &&
cat > /tmp/slack-desc << "EOF"
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
boost: boost (Boost C++ Libraries)
boost:
boost: Boost provides free peer-reviewed portable C++ source libraries.
boost: The emphasis is on libraries that work well with the C++ Standard
boost: Library. One goal is to establish "existing practice" and provide
boost: reference implementations so that the Boost libraries are suitable
boost: for eventual standardization.
boost:
boost: Homepage: http://www.boost.org/
boost:
boost:
EOF
sudo -S mv -v /tmp/slack-desc install/ &&
sudo -S makepkg -l y -c n $PKGS/boost-$PVER-$PSUFFIX &&
sudo -S rm -rf $BUILD/*