blob: ca140d595fd4e6e0709dd377096ca0193ddb15ca [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
10BOOST_LIBS = "\
11 atomic \
12 chrono \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060013 container \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080014 contract \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 date_time \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060016 exception \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 filesystem \
18 graph \
19 iostreams \
20 log \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021 math \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 program_options \
23 random \
24 regex \
25 serialization \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 system \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050027 timer \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028 test \
29 thread \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060030 wave \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 "
32
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033# only supported by x86 and powerpc
34BOOST_LIBS_append_x86 = " context coroutine"
35BOOST_LIBS_append_x86-64 = " context coroutine"
36BOOST_LIBS_append_powerpc = " context coroutine"
Vernon Mauery0d70daf2018-09-25 14:17:59 -070037BOOST_LIBS_append_arm = " context coroutine"
Brad Bishop08902b02019-08-20 09:16:51 -040038BOOST_LIBS_append_aarch64 = " context coroutine"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060039# need consistent settings for native builds (x86 override not applied for native)
40BOOST_LIBS_remove_class-native = " context coroutine"
Brad Bishop37a0e4d2017-12-04 01:01:44 -050041# does not compile
42BOOST_LIBS_remove_mips16e = "wave"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060043
44# optional libraries
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045PACKAGECONFIG ??= "locale python"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060046PACKAGECONFIG[locale] = ",,icu"
47PACKAGECONFIG[graph_parallel] = ",,,boost-mpi mpich"
48PACKAGECONFIG[mpi] = ",,mpich"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049PACKAGECONFIG[python] = ",,python3"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060050
51BOOST_LIBS += "\
Brad Bishop6e60e8b2018-02-01 10:27:11 -050052 ${@bb.utils.filter('PACKAGECONFIG', 'locale python', d)} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060053 ${@bb.utils.contains('PACKAGECONFIG', 'graph_parallel', 'graph_parallel mpi', \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054 bb.utils.filter('PACKAGECONFIG', 'mpi', d), d)} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060055"
56
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057inherit python3-dir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}"
59
60# Make a package for each library, plus -dev
61PACKAGES = "${PN}-dbg ${BOOST_PACKAGES}"
62python __anonymous () {
63 packages = []
64 extras = []
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050065 mlprefix = d.getVar("MLPREFIX")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050066 for lib in d.getVar('BOOST_LIBS').split():
67 extras.append("--with-%s" % lib)
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050068 pkg = "boost-%s" % (lib.replace("_", "-"))
69 packages.append(mlprefix + pkg)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070 if not d.getVar("FILES_%s" % pkg):
Andrew Geissler1e34c2d2020-05-29 16:02:59 -050071 d.setVar("FILES_%s%s" % (mlprefix, pkg), "${libdir}/libboost_%s*.so.*" % lib)
72 else:
73 d.setVar("FILES_%s%s" % (mlprefix, pkg), d.getVar("FILES_%s" % pkg))
74
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075 d.setVar("BOOST_PACKAGES", " ".join(packages))
76 d.setVar("BJAM_EXTRA", " ".join(extras))
77}
78
79# Override the contents of specific packages
Patrick Williamsc0f7c042017-02-23 20:41:17 -060080FILES_${PN}-graph_parallel = "${libdir}/libboost_graph_parallel.so.*"
81FILES_${PN}-locale = "${libdir}/libboost_locale.so.*"
82FILES_${PN}-mpi = "${libdir}/mpi.so ${libdir}/libboost_mpi*.so.*"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083FILES_boost-serialization = "${libdir}/libboost_serialization*.so.* \
84 ${libdir}/libboost_wserialization*.so.*"
85FILES_boost-test = "${libdir}/libboost_prg_exec_monitor*.so.* \
86 ${libdir}/libboost_unit_test_framework*.so.*"
87
88# -dev last to pick up the remaining stuff
89PACKAGES += "${PN}-dev ${PN}-staticdev"
Brad Bishop79641f22019-09-10 07:20:22 -040090FILES_${PN}-dev = "${includedir} ${libdir}/libboost_*.so ${libdir}/cmake"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091FILES_${PN}-staticdev = "${libdir}/libboost_*.a"
92
93# "boost" is a metapackage which pulls in all boost librabries
94PACKAGES += "${PN}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050095FILES_${PN} = ""
96ALLOW_EMPTY_${PN} = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097RRECOMMENDS_${PN} += "${BOOST_PACKAGES}"
98RRECOMMENDS_${PN}_class-native = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099
100# to avoid GNU_HASH QA errors added LDFLAGS to ARCH; a little bit dirty but at least it works
101TARGET_CC_ARCH += "${LDFLAGS}"
102
103# Oh yippee, a new build system, it's sooo cooool I could eat my own
104# foot. inlining=on lets the compiler choose, I think. At least this
105# stuff is documented...
106# NOTE: if you leave <debug-symbols>on then in a debug build the build sys
107# objcopy will be invoked, and that won't work. Building debug apparently
108# requires hacking gcc-tools.jam
109#
110# Sometimes I wake up screaming. Famous figures are gathered in the nightmare,
111# Steve Bourne, Larry Wall, the whole of the ANSI C committee. They're just
112# standing there, waiting, but the truely terrifying thing is what they carry
113# in their hands. At first sight each seems to bear the same thing, but it is
114# not so for the forms in their grasp are ever so slightly different one from
115# the other. Each is twisted in some grotesque way from the other to make each
116# an unspeakable perversion impossible to perceive without the onset of madness.
117# True insanity awaits anyone who perceives all of these horrors together.
118#
119# Quotation marks, there might be an easier way to do this, but I can't find
120# it. The problem is that the user.hpp configuration file must receive a
121# pre-processor macro defined as the appropriate string - complete with "'s
122# around it. (<> is a possibility here but the danger to that is that the
123# failure case interprets the < and > as shell redirections, creating
124# random files in the source tree.)
125#
126#bjam: '-DBOOST_PLATFORM_CONFIG=\"config\"'
127#do_compile: '-sGCC=... '"'-DBOOST_PLATFORM_CONFIG=\"config\"'"
128SQD = '"'
129EQD = '\"'
130#boost.bb: "... '-sGCC=... '${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}config${EQD}'${SQD} ..."
131BJAM_CONF = "${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}boost/config/platform/${TARGET_OS}.hpp${EQD}'${SQD}"
132
133BJAM_TOOLS = "--ignore-site-config \
134 '-sTOOLS=gcc' \
135 '-sGCC=${CC} '${BJAM_CONF} \
136 '-sGXX=${CXX} '${BJAM_CONF} \
137 '-sGCC_INCLUDE_DIRECTORY=${STAGING_INCDIR}' \
138 '-sGCC_STDLIB_DIRECTORY=${STAGING_LIBDIR}' \
139 '-sBUILD=release <optimization>space <threading>multi <inlining>on <debug-symbols>off' \
140 '-sPYTHON_ROOT=${PYTHON_ROOT}' \
141 '--layout=system' \
142 "
143
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800144# use PARALLEL_MAKE to speed up the build
145BOOST_PARALLEL_MAKE = "${@oe.utils.parallel_make_argument(d, '-j%d')}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500146BJAM_OPTS = '${BOOST_PARALLEL_MAKE} -d+2 -q \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147 ${BJAM_TOOLS} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600148 -sBOOST_BUILD_USER_CONFIG=${WORKDIR}/user-config.jam \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500149 --build-dir=${S}/${TARGET_SYS} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150 --disable-icu \
151 ${BJAM_EXTRA}'
152
153# Native compilation of bzip2 isn't working
154BJAM_OPTS_append_class-native = ' -sNO_BZIP2=1'
155
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500156# Adjust the build for x32
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500157BJAM_OPTS_append_x86-x32 = " abi=x32 address-model=64"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158
Vernon Mauery0d70daf2018-09-25 14:17:59 -0700159# cross compiling for arm fails to detect abi, so provide some help
160BJAM_OPTS_append_arm = " abi=aapcs architecture=arm"
Brad Bishop08902b02019-08-20 09:16:51 -0400161BJAM_OPTS_append_aarch64 = " abi=aapcs address-model=64 architecture=arm"
Vernon Mauery0d70daf2018-09-25 14:17:59 -0700162
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600163do_configure() {
164 cp -f ${S}/boost/config/platform/linux.hpp ${S}/boost/config/platform/linux-gnueabi.hpp
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500165
166 # D2194:Fixing the failure of "error: duplicate initialization of gcc with the following parameters" during compilation.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600167 rm -f ${WORKDIR}/user-config.jam
168 echo 'using gcc : 4.3.1 : ${CXX} : <cflags>"${CFLAGS}" <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;' >> ${WORKDIR}/user-config.jam
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500169
170 # If we want Python then we need to tell Boost *exactly* where to find it
171 if ${@bb.utils.contains('BOOST_LIBS', 'python', 'true', 'false', d)}; then
172 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
173 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600174
175 if ${@bb.utils.contains('BOOST_LIBS', 'mpi', 'true', 'false', d)}; then
176 echo "using mpi : : <find-shared-library>mpi ;" >> ${WORKDIR}/user-config.jam
177 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500179 CC="${BUILD_CC}" CFLAGS="${BUILD_CFLAGS}" ./bootstrap.sh --with-bjam=bjam --with-toolset=gcc
180
181 # Boost can't be trusted to find Python on it's own, so remove any mention
182 # of it from the boost configuration
183 sed -i '/using python/d' ${S}/project-config.jam
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500184}
185
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500186do_compile() {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600187 rm -rf ${S}/${TARGET_SYS}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188 bjam ${BJAM_OPTS} --prefix=${prefix} \
189 --exec-prefix=${exec_prefix} \
190 --libdir=${libdir} \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500191 --includedir=${includedir} \
192 --debug-configuration
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500193}
194
195do_install() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500196 bjam ${BJAM_OPTS} \
197 --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"