blob: 4263e645de1cf5eef21292461c40ba3490476a7e [file] [log] [blame]
Ed Tanousaa097b12022-11-30 15:36:22 -08001SUMMARY = "Free peer-reviewed portable C++ source libraries"
2DESCRIPTION = "Provides free peer-reviewed portable C++ source libraries. The emphasis is on libraries which work well with the C++ \
3Standard Library. One goal is to establish 'existing practice' and \
4provide reference implementations so that the Boost libraries are suitable for eventual standardization. Some of the libraries have already been proposed for inclusion in the C++ Standards Committee's \
5upcoming C++ Standard Library Technical Report."
6SECTION = "libs"
7DEPENDS = "boost-build-native zlib bzip2"
8
9CVE_PRODUCT = "boost:boost"
10
11ARM_INSTRUCTION_SET:armv4 = "arm"
12ARM_INSTRUCTION_SET:armv5 = "arm"
13
14B = "${WORKDIR}/build"
15do_configure[cleandirs] = "${B}"
16
17BOOST_LIBS = "\
18 atomic \
19 chrono \
20 container \
21 context \
22 contract \
23 coroutine \
24 date_time \
25 exception \
26 fiber \
27 filesystem \
28 graph \
29 headers \
30 iostreams \
31 json \
32 log \
33 math \
34 program_options \
35 random \
36 regex \
37 serialization \
38 system \
39 test \
40 thread \
41 timer \
42 type_erasure \
43 wave \
44 "
45
46# optional libraries
47PACKAGECONFIG ??= "locale python"
48PACKAGECONFIG[locale] = ",,icu"
49PACKAGECONFIG[graph_parallel] = ",,,boost-mpi mpich"
50PACKAGECONFIG[mpi] = ",,mpich"
51PACKAGECONFIG[python] = ",,python3"
52
53BOOST_LIBS += "\
54 ${@bb.utils.filter('PACKAGECONFIG', 'locale python', d)} \
55 ${@bb.utils.contains('PACKAGECONFIG', 'graph_parallel', 'graph_parallel mpi', \
56 bb.utils.filter('PACKAGECONFIG', 'mpi', d), d)} \
57"
58
59inherit python3-dir
60PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}"
61
62# Make a package for each library, plus -dev
63PACKAGES = "${PN}-dbg ${BOOST_PACKAGES}"
64python __anonymous () {
65 packages = []
66 extras = []
67 pn = d.getVar("PN")
68 mlprefix = d.getVar("MLPREFIX")
69 for lib in d.getVar('BOOST_LIBS').split():
70 extras.append("--with-%s" % lib)
71 pkg = "boost-%s" % (lib.replace("_", "-"))
72 if "-native" in pn:
73 pkg = pkg + "-native"
74 packages.append(mlprefix + pkg)
75 if not d.getVar("FILES:%s" % pkg):
76 d.setVar("FILES:%s%s" % (mlprefix, pkg), "${libdir}/libboost_%s*.so.*" % lib)
77 else:
78 d.setVar("FILES:%s%s" % (mlprefix, pkg), d.getVar("FILES:%s" % pkg))
79
80 d.setVar("BOOST_PACKAGES", " ".join(packages))
81 d.setVar("BJAM_EXTRA", " ".join(extras))
82}
83
84# Override the contents of specific packages
85FILES:${PN}-graph_parallel = "${libdir}/libboost_graph_parallel.so.*"
86FILES:${PN}-locale = "${libdir}/libboost_locale.so.*"
87FILES:${PN}-mpi = "${libdir}/mpi.so ${libdir}/libboost_mpi*.so.*"
88FILES:boost-serialization = "${libdir}/libboost_serialization*.so.* \
89 ${libdir}/libboost_wserialization*.so.*"
90FILES:boost-test = "${libdir}/libboost_prg_exec_monitor*.so.* \
91 ${libdir}/libboost_unit_test_framework*.so.*"
92
93# -dev last to pick up the remaining stuff
94PACKAGES += "${PN}-dev ${PN}-staticdev"
95FILES:${PN}-dev = "${includedir} ${libdir}/libboost_*.so ${libdir}/cmake"
96FILES:${PN}-staticdev = "${libdir}/libboost_*.a"
97
98# "boost" is a metapackage which pulls in all boost librabries
99PACKAGES += "${PN}"
100FILES:${PN} = ""
101ALLOW_EMPTY:${PN} = "1"
102RRECOMMENDS:${PN} += "${BOOST_PACKAGES}"
103RRECOMMENDS:${PN}:class-native = ""
104
105# to avoid GNU_HASH QA errors added LDFLAGS to ARCH; a little bit dirty but at least it works
106TARGET_CC_ARCH += "${LDFLAGS}"
107
108# Oh yippee, a new build system, it's sooo cooool I could eat my own
109# foot. inlining=on lets the compiler choose, I think. At least this
110# stuff is documented...
111# NOTE: if you leave <debug-symbols>on then in a debug build the build sys
112# objcopy will be invoked, and that won't work. Building debug apparently
113# requires hacking gcc-tools.jam
114#
115# Sometimes I wake up screaming. Famous figures are gathered in the nightmare,
116# Steve Bourne, Larry Wall, the whole of the ANSI C committee. They're just
117# standing there, waiting, but the truely terrifying thing is what they carry
118# in their hands. At first sight each seems to bear the same thing, but it is
119# not so for the forms in their grasp are ever so slightly different one from
120# the other. Each is twisted in some grotesque way from the other to make each
121# an unspeakable perversion impossible to perceive without the onset of madness.
122# True insanity awaits anyone who perceives all of these horrors together.
123#
124# Quotation marks, there might be an easier way to do this, but I can't find
125# it. The problem is that the user.hpp configuration file must receive a
126# pre-processor macro defined as the appropriate string - complete with "'s
127# around it. (<> is a possibility here but the danger to that is that the
128# failure case interprets the < and > as shell redirections, creating
129# random files in the source tree.)
130#
131#bjam: '-DBOOST_PLATFORM_CONFIG=\"config\"'
132#do_compile: '-sGCC=... '"'-DBOOST_PLATFORM_CONFIG=\"config\"'"
133SQD = '"'
134EQD = '\"'
135#boost.bb: "... '-sGCC=... '${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}config${EQD}'${SQD} ..."
136BJAM_CONF = "${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}boost/config/platform/${TARGET_OS}.hpp${EQD}'${SQD}"
137
138BJAM_TOOLS = "--ignore-site-config \
139 '-sTOOLS=gcc' \
140 '-sGCC=${CC} '${BJAM_CONF} \
141 '-sGXX=${CXX} '${BJAM_CONF} \
142 '-sGCC_INCLUDE_DIRECTORY=${STAGING_INCDIR}' \
143 '-sGCC_STDLIB_DIRECTORY=${STAGING_LIBDIR}' \
144 '-sBUILD=release <optimization>space <threading>multi <inlining>on <debug-symbols>off' \
145 '-sPYTHON_ROOT=${PYTHON_ROOT}' \
146 '--layout=system' \
147 "
148
149# use PARALLEL_MAKE to speed up the build
150BOOST_PARALLEL_MAKE = "${@oe.utils.parallel_make_argument(d, '-j%d')}"
151BJAM_OPTS = '${BOOST_PARALLEL_MAKE} -d+2 -q \
152 ${BJAM_TOOLS} \
153 -sBOOST_BUILD_USER_CONFIG=${WORKDIR}/user-config.jam \
154 -sICU_PATH=${STAGING_EXECPREFIXDIR} \
155 --build-dir=${B} \
156 --disable-icu \
157 ${BJAM_EXTRA}'
158
159# Native compilation of bzip2 isn't working
160BJAM_OPTS:append:class-native = ' -sNO_BZIP2=1'
161
162# Adjust the build for x32
163BJAM_OPTS:append:x86-x32 = " abi=x32 address-model=64"
164
165# cross compiling for arm fails to detect abi, so provide some help
166BJAM_OPTS:append:arm = " abi=aapcs architecture=arm"
167BJAM_OPTS:append:aarch64 = " abi=aapcs address-model=64 architecture=arm"
168
169do_configure() {
170 cd ${S}
171 cp -f ${S}/boost/config/platform/linux.hpp ${S}/boost/config/platform/linux-gnueabi.hpp
172
173 # D2194:Fixing the failure of "error: duplicate initialization of gcc with the following parameters" during compilation.
174 rm -f ${WORKDIR}/user-config.jam
175 echo 'using gcc : : ${CXX} : <cflags>"${CFLAGS}" <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;' >> ${WORKDIR}/user-config.jam
176
177 # If we want Python then we need to tell Boost *exactly* where to find it
178 if ${@bb.utils.contains('BOOST_LIBS', 'python', 'true', 'false', d)}; then
179 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
180 fi
181
182 if ${@bb.utils.contains('BOOST_LIBS', 'mpi', 'true', 'false', d)}; then
183 echo "using mpi : : <find-shared-library>mpi ;" >> ${WORKDIR}/user-config.jam
184 fi
185
186 CC="${BUILD_CC}" CFLAGS="${BUILD_CFLAGS}" ./bootstrap.sh --with-bjam=b2 --with-toolset=gcc
187
188 # Boost can't be trusted to find Python on it's own, so remove any mention
189 # of it from the boost configuration
190 sed -i '/using python/d' ${S}/project-config.jam
191}
192
193do_compile() {
194 cd ${S}
195 b2 ${BJAM_OPTS} \
196 --prefix=${prefix} \
197 --exec-prefix=${exec_prefix} \
198 --libdir=${libdir} \
199 --includedir=${includedir} \
200 --debug-configuration
201}
202
203do_install() {
204 cd ${S}
205 b2 ${BJAM_OPTS} \
206 --libdir=${D}${libdir} \
207 --includedir=${D}${includedir} \
208 install
209 for lib in ${BOOST_LIBS}; do
210 if [ -e ${D}${libdir}/libboost_${lib}.a ]; then
211 ln -s libboost_${lib}.a ${D}${libdir}/libboost_${lib}-mt.a
212 fi
213 if [ -e ${D}${libdir}/libboost_${lib}.so ]; then
214 ln -s libboost_${lib}.so ${D}${libdir}/libboost_${lib}-mt.so
215 fi
216 done
217
218 # Cmake files reference full paths to image
219 find ${D}${libdir}/cmake -type f | \
220 grep 'cmake$' | \
221 xargs -n 1 sed -e 's,${D}${libdir}/cmake,${libdir}/cmake,' -i
222
223}
224
225BBCLASSEXTEND = "native nativesdk"