#!/bin/bash

if [ "${PLATFORM_FAMILY}" == SYNOPLAT_F_ARMV7 ]; then
	cxxflags+="-std=c++14"
else
	cxxflags+="-std=c++17"
fi

case ${ARCH} in
arm|arm64)
	abi="aapcs"
	architecture=arm
	;;
x86_64|x86)
	abi="sysv"
	architecture=x86
	;;
#powerpc)
#	abi="sysv"
#	architecture=power
#	;;
*)
	echo "error: unknown platform: ${ARCH}"
	exit -1
	;;
esac

./bootstrap.sh \
	--prefix=/usr \
	--with-icu \
	--with-libraries=atomic,chrono,context,coroutine,date_time,exception,filesystem,iostreams,locale,program_options,random,regex,serialization,system,test,thread,timer

sed -i -e "s#using gcc#using gcc : syno : ${CXX}#g" project-config.jam

./b2 headers

./b2 \
	-d 0 \
	variant=release \
	debug-symbols=on \
	threading=multi \
	architecture=${architecture} \
	address-model=${BUILD_ARCH} \
	abi=${abi} \
	runtime-link=shared \
	link=shared,static \
	toolset=gcc-syno \
	cxxflags="${cxxflags}" \
	-j$(nproc) \
	stage

#	--debug-configuration \
#	--debug-building \
#	--debug-generator \
