boost.inc 7.4 KB

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