blob: cbf9cad70717aa4b68e75760e9ad6530a443e8c7 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Free peer-reviewed portable C++ source libraries"
2SECTION = "libs"
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -05003DEPENDS = "boost-build-native zlib bzip2"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004
Brad Bishop96ff1982019-08-19 13:50:42 -04005CVE_PRODUCT = "boost:boost"
6
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05007ARM_INSTRUCTION_SET_armv4 = "arm"
8ARM_INSTRUCTION_SET_armv5 = "arm"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
Andrew Geisslerc3d88e42020-10-02 09:45:00 -050010B = "${WORKDIR}/build"
11do_configure[cleandirs] = "${B}"
12
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013BOOST_LIBS = "\
14 atomic \
15 chrono \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060016 container \
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -050017 context \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080018 contract \
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -050019 coroutine \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 date_time \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021 exception \
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -050022 fiber \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 filesystem \
24 graph \
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -050025 headers \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 iostreams \
27 log \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060028 math \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029 program_options \
30 random \
31 regex \
32 serialization \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 system \
34 test \
35 thread \
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -050036 timer \
37 type_erasure \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060038 wave \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039 "
40
Patrick Williamsc0f7c042017-02-23 20:41:17 -060041# optional libraries
Brad Bishopd7bf8c12018-02-25 22:55:05 -050042PACKAGECONFIG ??= "locale python"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060043PACKAGECONFIG[locale] = ",,icu"
44PACKAGECONFIG[graph_parallel] = ",,,boost-mpi mpich"
45PACKAGECONFIG[mpi] = ",,mpich"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050046PACKAGECONFIG[python] = ",,python3"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060047
48BOOST_LIBS += "\
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049 ${@bb.utils.filter('PACKAGECONFIG', 'locale python', d)} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060050 ${@bb.utils.contains('PACKAGECONFIG', 'graph_parallel', 'graph_parallel mpi', \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050051 bb.utils.filter('PACKAGECONFIG', 'mpi', d), d)} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060052"
53
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054inherit python3-dir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}"
56
57# Make a package for each library, plus -dev
58PACKAGES = "${PN}-dbg ${BOOST_PACKAGES}"
59python __anonymous () {
60 packages = []
61 extras = []
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050062 mlprefix = d.getVar("MLPREFIX")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063 for lib in d.getVar('BOOST_LIBS').split():
64 extras.append("--with-%s" % lib)
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050065 pkg = "boost-%s" % (lib.replace("_", "-"))
66 packages.append(mlprefix + pkg)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050067 if not d.getVar("FILES_%s" % pkg):
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050068 d.setVar("FILES_%s%s" % (mlprefix, pkg), "${libdir}/libboost_%s*.so.*" % lib)
69 else:
70 d.setVar("FILES_%s%s" % (mlprefix, pkg), d.getVar("FILES_%s" % pkg))
71
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072 d.setVar("BOOST_PACKAGES", " ".join(packages))
73 d.setVar("BJAM_EXTRA", " ".join(extras))
74}
75
76# Override the contents of specific packages
Patrick Williamsc0f7c042017-02-23 20:41:17 -060077FILES_${PN}-graph_parallel = "${libdir}/libboost_graph_parallel.so.*"
78FILES_${PN}-locale = "${libdir}/libboost_locale.so.*"
79FILES_${PN}-mpi = "${libdir}/mpi.so ${libdir}/libboost_mpi*.so.*"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080FILES_boost-serialization = "${libdir}/libboost_serialization*.so.* \
81 ${libdir}/libboost_wserialization*.so.*"
82FILES_boost-test = "${libdir}/libboost_prg_exec_monitor*.so.* \
83 ${libdir}/libboost_unit_test_framework*.so.*"
84
85# -dev last to pick up the remaining stuff
86PACKAGES += "${PN}-dev ${PN}-staticdev"
Brad Bishop79641f22019-09-10 07:20:22 -040087FILES_${PN}-dev = "${includedir} ${libdir}/libboost_*.so ${libdir}/cmake"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088FILES_${PN}-staticdev = "${libdir}/libboost_*.a"
89
90# "boost" is a metapackage which pulls in all boost librabries
91PACKAGES += "${PN}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050092FILES_${PN} = ""
93ALLOW_EMPTY_${PN} = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094RRECOMMENDS_${PN} += "${BOOST_PACKAGES}"
95RRECOMMENDS_${PN}_class-native = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096
97# to avoid GNU_HASH QA errors added LDFLAGS to ARCH; a little bit dirty but at least it works
98TARGET_CC_ARCH += "${LDFLAGS}"
99
100# Oh yippee, a new build system, it's sooo cooool I could eat my own
101# foot. inlining=on lets the compiler choose, I think. At least this
102# stuff is documented...
103# NOTE: if you leave <debug-symbols>on then in a debug build the build sys
104# objcopy will be invoked, and that won't work. Building debug apparently
105# requires hacking gcc-tools.jam
106#
107# Sometimes I wake up screaming. Famous figures are gathered in the nightmare,
108# Steve Bourne, Larry Wall, the whole of the ANSI C committee. They're just
109# standing there, waiting, but the truely terrifying thing is what they carry
110# in their hands. At first sight each seems to bear the same thing, but it is
111# not so for the forms in their grasp are ever so slightly different one from
112# the other. Each is twisted in some grotesque way from the other to make each
113# an unspeakable perversion impossible to perceive without the onset of madness.
114# True insanity awaits anyone who perceives all of these horrors together.
115#
116# Quotation marks, there might be an easier way to do this, but I can't find
117# it. The problem is that the user.hpp configuration file must receive a
118# pre-processor macro defined as the appropriate string - complete with "'s
119# around it. (<> is a possibility here but the danger to that is that the
120# failure case interprets the < and > as shell redirections, creating
121# random files in the source tree.)
122#
123#bjam: '-DBOOST_PLATFORM_CONFIG=\"config\"'
124#do_compile: '-sGCC=... '"'-DBOOST_PLATFORM_CONFIG=\"config\"'"
125SQD = '"'
126EQD = '\"'
127#boost.bb: "... '-sGCC=... '${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}config${EQD}'${SQD} ..."
128BJAM_CONF = "${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}boost/config/platform/${TARGET_OS}.hpp${EQD}'${SQD}"
129
130BJAM_TOOLS = "--ignore-site-config \
131 '-sTOOLS=gcc' \
132 '-sGCC=${CC} '${BJAM_CONF} \
133 '-sGXX=${CXX} '${BJAM_CONF} \
134 '-sGCC_INCLUDE_DIRECTORY=${STAGING_INCDIR}' \
135 '-sGCC_STDLIB_DIRECTORY=${STAGING_LIBDIR}' \
136 '-sBUILD=release <optimization>space <threading>multi <inlining>on <debug-symbols>off' \
137 '-sPYTHON_ROOT=${PYTHON_ROOT}' \
138 '--layout=system' \
139 "
140
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800141# use PARALLEL_MAKE to speed up the build
142BOOST_PARALLEL_MAKE = "${@oe.utils.parallel_make_argument(d, '-j%d')}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500143BJAM_OPTS = '${BOOST_PARALLEL_MAKE} -d+2 -q \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 ${BJAM_TOOLS} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600145 -sBOOST_BUILD_USER_CONFIG=${WORKDIR}/user-config.jam \
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500146 --build-dir=${B} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147 --disable-icu \
148 ${BJAM_EXTRA}'
149
150# Native compilation of bzip2 isn't working
151BJAM_OPTS_append_class-native = ' -sNO_BZIP2=1'
152
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500153# Adjust the build for x32
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500154BJAM_OPTS_append_x86-x32 = " abi=x32 address-model=64"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500155
Vernon Mauery0d70daf2018-09-25 14:17:59 -0700156# cross compiling for arm fails to detect abi, so provide some help
157BJAM_OPTS_append_arm = " abi=aapcs architecture=arm"
Brad Bishop08902b02019-08-20 09:16:51 -0400158BJAM_OPTS_append_aarch64 = " abi=aapcs address-model=64 architecture=arm"
Vernon Mauery0d70daf2018-09-25 14:17:59 -0700159
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600160do_configure() {
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500161 cd ${S}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600162 cp -f ${S}/boost/config/platform/linux.hpp ${S}/boost/config/platform/linux-gnueabi.hpp
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500163
164 # D2194:Fixing the failure of "error: duplicate initialization of gcc with the following parameters" during compilation.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600165 rm -f ${WORKDIR}/user-config.jam
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -0500166 echo 'using gcc : : ${CXX} : <cflags>"${CFLAGS}" <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;' >> ${WORKDIR}/user-config.jam
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500167
168 # If we want Python then we need to tell Boost *exactly* where to find it
169 if ${@bb.utils.contains('BOOST_LIBS', 'python', 'true', 'false', d)}; then
170 echo "using python : ${PYTHON_BASEVERSION} : ${STAGING_DIR_HOST}${bindir}/python3 : ${STAGING_DIR_HOST}${includedir}/${PYTHON_DIR}${PYTHON_ABI} : ${STAGING_DIR_HOST}${libdir}/${PYTHON_DIR} ;" >> ${WORKDIR}/user-config.jam
171 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600172
173 if ${@bb.utils.contains('BOOST_LIBS', 'mpi', 'true', 'false', d)}; then
174 echo "using mpi : : <find-shared-library>mpi ;" >> ${WORKDIR}/user-config.jam
175 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -0500177 CC="${BUILD_CC}" CFLAGS="${BUILD_CFLAGS}" ./bootstrap.sh --with-bjam=b2 --with-toolset=gcc
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500178
179 # Boost can't be trusted to find Python on it's own, so remove any mention
180 # of it from the boost configuration
181 sed -i '/using python/d' ${S}/project-config.jam
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182}
183
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500184do_compile() {
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500185 cd ${S}
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -0500186 b2 ${BJAM_OPTS} \
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500187 --prefix=${prefix} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188 --exec-prefix=${exec_prefix} \
189 --libdir=${libdir} \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500190 --includedir=${includedir} \
191 --debug-configuration
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500192}
193
194do_install() {
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500195 cd ${S}
Andrew Geissleraf5e4ef2020-10-16 10:22:50 -0500196 b2 ${BJAM_OPTS} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500197 --libdir=${D}${libdir} \
198 --includedir=${D}${includedir} \
199 install
200 for lib in ${BOOST_LIBS}; do
201 if [ -e ${D}${libdir}/libboost_${lib}.a ]; then
202 ln -s libboost_${lib}.a ${D}${libdir}/libboost_${lib}-mt.a
203 fi
204 if [ -e ${D}${libdir}/libboost_${lib}.so ]; then
205 ln -s libboost_${lib}.so ${D}${libdir}/libboost_${lib}-mt.so
206 fi
207 done
208
Andrew Geissler82c905d2020-04-13 13:39:40 -0500209 # Cmake files reference full paths to image
210 find ${D}${libdir}/cmake -type f | \
211 grep 'cmake$' | \
212 xargs -n 1 sed -e 's,${D}${libdir}/cmake,${libdir}/cmake,' -i
213
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500214}
215
216BBCLASSEXTEND = "native nativesdk"