blob: ea1bc123b86bdb5cddecb45040ca104cff13a23b [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Free peer-reviewed portable C++ source libraries"
2SECTION = "libs"
3DEPENDS = "bjam-native zlib bzip2"
4
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 \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080017 contract \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018 date_time \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019 exception \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 filesystem \
21 graph \
22 iostreams \
23 log \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060024 math \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 program_options \
26 random \
27 regex \
28 serialization \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029 system \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050030 timer \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 test \
32 thread \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 wave \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 "
35
Patrick Williamsc0f7c042017-02-23 20:41:17 -060036# only supported by x86 and powerpc
37BOOST_LIBS_append_x86 = " context coroutine"
38BOOST_LIBS_append_x86-64 = " context coroutine"
39BOOST_LIBS_append_powerpc = " context coroutine"
Vernon Mauery0d70daf2018-09-25 14:17:59 -070040BOOST_LIBS_append_arm = " context coroutine"
Brad Bishop08902b02019-08-20 09:16:51 -040041BOOST_LIBS_append_aarch64 = " context coroutine"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042# need consistent settings for native builds (x86 override not applied for native)
43BOOST_LIBS_remove_class-native = " context coroutine"
Brad Bishop37a0e4d2017-12-04 01:01:44 -050044# does not compile
45BOOST_LIBS_remove_mips16e = "wave"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060046
47# optional libraries
Brad Bishopd7bf8c12018-02-25 22:55:05 -050048PACKAGECONFIG ??= "locale python"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060049PACKAGECONFIG[locale] = ",,icu"
50PACKAGECONFIG[graph_parallel] = ",,,boost-mpi mpich"
51PACKAGECONFIG[mpi] = ",,mpich"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050052PACKAGECONFIG[python] = ",,python3"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060053
54BOOST_LIBS += "\
Brad Bishop6e60e8b2018-02-01 10:27:11 -050055 ${@bb.utils.filter('PACKAGECONFIG', 'locale python', d)} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060056 ${@bb.utils.contains('PACKAGECONFIG', 'graph_parallel', 'graph_parallel mpi', \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057 bb.utils.filter('PACKAGECONFIG', 'mpi', d), d)} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060058"
59
Brad Bishop6e60e8b2018-02-01 10:27:11 -050060inherit python3-dir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}"
62
63# Make a package for each library, plus -dev
64PACKAGES = "${PN}-dbg ${BOOST_PACKAGES}"
65python __anonymous () {
66 packages = []
67 extras = []
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050068 mlprefix = d.getVar("MLPREFIX")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050069 for lib in d.getVar('BOOST_LIBS').split():
70 extras.append("--with-%s" % lib)
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050071 pkg = "boost-%s" % (lib.replace("_", "-"))
72 packages.append(mlprefix + pkg)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050073 if not d.getVar("FILES_%s" % pkg):
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050074 d.setVar("FILES_%s%s" % (mlprefix, pkg), "${libdir}/libboost_%s*.so.*" % lib)
75 else:
76 d.setVar("FILES_%s%s" % (mlprefix, pkg), d.getVar("FILES_%s" % pkg))
77
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078 d.setVar("BOOST_PACKAGES", " ".join(packages))
79 d.setVar("BJAM_EXTRA", " ".join(extras))
80}
81
82# Override the contents of specific packages
Patrick Williamsc0f7c042017-02-23 20:41:17 -060083FILES_${PN}-graph_parallel = "${libdir}/libboost_graph_parallel.so.*"
84FILES_${PN}-locale = "${libdir}/libboost_locale.so.*"
85FILES_${PN}-mpi = "${libdir}/mpi.so ${libdir}/libboost_mpi*.so.*"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086FILES_boost-serialization = "${libdir}/libboost_serialization*.so.* \
87 ${libdir}/libboost_wserialization*.so.*"
88FILES_boost-test = "${libdir}/libboost_prg_exec_monitor*.so.* \
89 ${libdir}/libboost_unit_test_framework*.so.*"
90
91# -dev last to pick up the remaining stuff
92PACKAGES += "${PN}-dev ${PN}-staticdev"
Brad Bishop79641f22019-09-10 07:20:22 -040093FILES_${PN}-dev = "${includedir} ${libdir}/libboost_*.so ${libdir}/cmake"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050094FILES_${PN}-staticdev = "${libdir}/libboost_*.a"
95
96# "boost" is a metapackage which pulls in all boost librabries
97PACKAGES += "${PN}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050098FILES_${PN} = ""
99ALLOW_EMPTY_${PN} = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100RRECOMMENDS_${PN} += "${BOOST_PACKAGES}"
101RRECOMMENDS_${PN}_class-native = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102
103# to avoid GNU_HASH QA errors added LDFLAGS to ARCH; a little bit dirty but at least it works
104TARGET_CC_ARCH += "${LDFLAGS}"
105
106# Oh yippee, a new build system, it's sooo cooool I could eat my own
107# foot. inlining=on lets the compiler choose, I think. At least this
108# stuff is documented...
109# NOTE: if you leave <debug-symbols>on then in a debug build the build sys
110# objcopy will be invoked, and that won't work. Building debug apparently
111# requires hacking gcc-tools.jam
112#
113# Sometimes I wake up screaming. Famous figures are gathered in the nightmare,
114# Steve Bourne, Larry Wall, the whole of the ANSI C committee. They're just
115# standing there, waiting, but the truely terrifying thing is what they carry
116# in their hands. At first sight each seems to bear the same thing, but it is
117# not so for the forms in their grasp are ever so slightly different one from
118# the other. Each is twisted in some grotesque way from the other to make each
119# an unspeakable perversion impossible to perceive without the onset of madness.
120# True insanity awaits anyone who perceives all of these horrors together.
121#
122# Quotation marks, there might be an easier way to do this, but I can't find
123# it. The problem is that the user.hpp configuration file must receive a
124# pre-processor macro defined as the appropriate string - complete with "'s
125# around it. (<> is a possibility here but the danger to that is that the
126# failure case interprets the < and > as shell redirections, creating
127# random files in the source tree.)
128#
129#bjam: '-DBOOST_PLATFORM_CONFIG=\"config\"'
130#do_compile: '-sGCC=... '"'-DBOOST_PLATFORM_CONFIG=\"config\"'"
131SQD = '"'
132EQD = '\"'
133#boost.bb: "... '-sGCC=... '${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}config${EQD}'${SQD} ..."
134BJAM_CONF = "${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}boost/config/platform/${TARGET_OS}.hpp${EQD}'${SQD}"
135
136BJAM_TOOLS = "--ignore-site-config \
137 '-sTOOLS=gcc' \
138 '-sGCC=${CC} '${BJAM_CONF} \
139 '-sGXX=${CXX} '${BJAM_CONF} \
140 '-sGCC_INCLUDE_DIRECTORY=${STAGING_INCDIR}' \
141 '-sGCC_STDLIB_DIRECTORY=${STAGING_LIBDIR}' \
142 '-sBUILD=release <optimization>space <threading>multi <inlining>on <debug-symbols>off' \
143 '-sPYTHON_ROOT=${PYTHON_ROOT}' \
144 '--layout=system' \
145 "
146
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800147# use PARALLEL_MAKE to speed up the build
148BOOST_PARALLEL_MAKE = "${@oe.utils.parallel_make_argument(d, '-j%d')}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500149BJAM_OPTS = '${BOOST_PARALLEL_MAKE} -d+2 -q \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150 ${BJAM_TOOLS} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600151 -sBOOST_BUILD_USER_CONFIG=${WORKDIR}/user-config.jam \
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500152 --build-dir=${B} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153 --disable-icu \
154 ${BJAM_EXTRA}'
155
156# Native compilation of bzip2 isn't working
157BJAM_OPTS_append_class-native = ' -sNO_BZIP2=1'
158
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500159# Adjust the build for x32
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500160BJAM_OPTS_append_x86-x32 = " abi=x32 address-model=64"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500161
Vernon Mauery0d70daf2018-09-25 14:17:59 -0700162# cross compiling for arm fails to detect abi, so provide some help
163BJAM_OPTS_append_arm = " abi=aapcs architecture=arm"
Brad Bishop08902b02019-08-20 09:16:51 -0400164BJAM_OPTS_append_aarch64 = " abi=aapcs address-model=64 architecture=arm"
Vernon Mauery0d70daf2018-09-25 14:17:59 -0700165
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600166do_configure() {
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500167 cd ${S}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600168 cp -f ${S}/boost/config/platform/linux.hpp ${S}/boost/config/platform/linux-gnueabi.hpp
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169
170 # D2194:Fixing the failure of "error: duplicate initialization of gcc with the following parameters" during compilation.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600171 rm -f ${WORKDIR}/user-config.jam
172 echo 'using gcc : 4.3.1 : ${CXX} : <cflags>"${CFLAGS}" <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;' >> ${WORKDIR}/user-config.jam
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500173
174 # If we want Python then we need to tell Boost *exactly* where to find it
175 if ${@bb.utils.contains('BOOST_LIBS', 'python', 'true', 'false', d)}; then
176 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
177 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600178
179 if ${@bb.utils.contains('BOOST_LIBS', 'mpi', 'true', 'false', d)}; then
180 echo "using mpi : : <find-shared-library>mpi ;" >> ${WORKDIR}/user-config.jam
181 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500183 CC="${BUILD_CC}" CFLAGS="${BUILD_CFLAGS}" ./bootstrap.sh --with-bjam=bjam --with-toolset=gcc
184
185 # Boost can't be trusted to find Python on it's own, so remove any mention
186 # of it from the boost configuration
187 sed -i '/using python/d' ${S}/project-config.jam
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188}
189
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500190do_compile() {
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500191 cd ${S}
192 bjam ${BJAM_OPTS} \
193 --prefix=${prefix} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500194 --exec-prefix=${exec_prefix} \
195 --libdir=${libdir} \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500196 --includedir=${includedir} \
197 --debug-configuration
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500198}
199
200do_install() {
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500201 cd ${S}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500202 bjam ${BJAM_OPTS} \
203 --libdir=${D}${libdir} \
204 --includedir=${D}${includedir} \
205 install
206 for lib in ${BOOST_LIBS}; do
207 if [ -e ${D}${libdir}/libboost_${lib}.a ]; then
208 ln -s libboost_${lib}.a ${D}${libdir}/libboost_${lib}-mt.a
209 fi
210 if [ -e ${D}${libdir}/libboost_${lib}.so ]; then
211 ln -s libboost_${lib}.so ${D}${libdir}/libboost_${lib}-mt.so
212 fi
213 done
214
Andrew Geissler82c905d2020-04-13 13:39:40 -0500215 # Cmake files reference full paths to image
216 find ${D}${libdir}/cmake -type f | \
217 grep 'cmake$' | \
218 xargs -n 1 sed -e 's,${D}${libdir}/cmake,${libdir}/cmake,' -i
219
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500220}
221
222BBCLASSEXTEND = "native nativesdk"