blob: 982446c06836d5036dfa1b9fb3fa7b65707c5b92 [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
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05005ARM_INSTRUCTION_SET_armv4 = "arm"
6ARM_INSTRUCTION_SET_armv5 = "arm"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007
8BOOST_LIBS = "\
9 atomic \
10 chrono \
11 date_time \
12 filesystem \
13 graph \
14 iostreams \
15 log \
16 program_options \
17 random \
18 regex \
19 serialization \
20 signals \
21 system \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050022 timer \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 test \
24 thread \
25 "
26
27# optional boost-python library
28PACKAGECONFIG ??= ""
29PACKAGECONFIG[python] = ",,python python3"
30BOOST_LIBS += "${@bb.utils.contains('PACKAGECONFIG', 'python', 'python python3', '', d)}"
31inherit python-dir
32PYTHON_ROOT = "${STAGING_DIR_HOST}/${prefix}"
33
34# Make a package for each library, plus -dev
35PACKAGES = "${PN}-dbg ${BOOST_PACKAGES}"
36python __anonymous () {
37 packages = []
38 extras = []
39 for lib in d.getVar('BOOST_LIBS', True).split( ):
40 # BJAM does not know '--with-python3' (only --with-python)
41 if lib != "python3":
42 extras.append("--with-%s" % lib)
43 pkg = "boost-%s" % lib.replace("_", "-")
44 packages.append(pkg)
45 if lib == "python":
46 # special: python*.so matches python3.so !!
47 if not d.getVar("FILES_%s" % pkg, True):
48 d.setVar("FILES_%s" % pkg, "${libdir}/libboost_%s.so.*" % lib)
49 else:
50 if not d.getVar("FILES_%s" % pkg, True):
51 d.setVar("FILES_%s" % pkg, "${libdir}/libboost_%s*.so.*" % lib)
52 d.setVar("BOOST_PACKAGES", " ".join(packages))
53 d.setVar("BJAM_EXTRA", " ".join(extras))
54}
55
56# Override the contents of specific packages
57FILES_boost-serialization = "${libdir}/libboost_serialization*.so.* \
58 ${libdir}/libboost_wserialization*.so.*"
59FILES_boost-test = "${libdir}/libboost_prg_exec_monitor*.so.* \
60 ${libdir}/libboost_unit_test_framework*.so.*"
61
62# -dev last to pick up the remaining stuff
63PACKAGES += "${PN}-dev ${PN}-staticdev"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050064FILES_${PN} = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065FILES_${PN}-dev = "${includedir} ${libdir}/libboost_*.so"
66FILES_${PN}-staticdev = "${libdir}/libboost_*.a"
67
68# "boost" is a metapackage which pulls in all boost librabries
69PACKAGES += "${PN}"
70RRECOMMENDS_${PN} += "${BOOST_PACKAGES}"
71RRECOMMENDS_${PN}_class-native = ""
72ALLOW_EMPTY_${PN} = "1"
73
74# to avoid GNU_HASH QA errors added LDFLAGS to ARCH; a little bit dirty but at least it works
75TARGET_CC_ARCH += "${LDFLAGS}"
76
77# Oh yippee, a new build system, it's sooo cooool I could eat my own
78# foot. inlining=on lets the compiler choose, I think. At least this
79# stuff is documented...
80# NOTE: if you leave <debug-symbols>on then in a debug build the build sys
81# objcopy will be invoked, and that won't work. Building debug apparently
82# requires hacking gcc-tools.jam
83#
84# Sometimes I wake up screaming. Famous figures are gathered in the nightmare,
85# Steve Bourne, Larry Wall, the whole of the ANSI C committee. They're just
86# standing there, waiting, but the truely terrifying thing is what they carry
87# in their hands. At first sight each seems to bear the same thing, but it is
88# not so for the forms in their grasp are ever so slightly different one from
89# the other. Each is twisted in some grotesque way from the other to make each
90# an unspeakable perversion impossible to perceive without the onset of madness.
91# True insanity awaits anyone who perceives all of these horrors together.
92#
93# Quotation marks, there might be an easier way to do this, but I can't find
94# it. The problem is that the user.hpp configuration file must receive a
95# pre-processor macro defined as the appropriate string - complete with "'s
96# around it. (<> is a possibility here but the danger to that is that the
97# failure case interprets the < and > as shell redirections, creating
98# random files in the source tree.)
99#
100#bjam: '-DBOOST_PLATFORM_CONFIG=\"config\"'
101#do_compile: '-sGCC=... '"'-DBOOST_PLATFORM_CONFIG=\"config\"'"
102SQD = '"'
103EQD = '\"'
104#boost.bb: "... '-sGCC=... '${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}config${EQD}'${SQD} ..."
105BJAM_CONF = "${SQD}'-DBOOST_PLATFORM_CONFIG=${EQD}boost/config/platform/${TARGET_OS}.hpp${EQD}'${SQD}"
106
107BJAM_TOOLS = "--ignore-site-config \
108 '-sTOOLS=gcc' \
109 '-sGCC=${CC} '${BJAM_CONF} \
110 '-sGXX=${CXX} '${BJAM_CONF} \
111 '-sGCC_INCLUDE_DIRECTORY=${STAGING_INCDIR}' \
112 '-sGCC_STDLIB_DIRECTORY=${STAGING_LIBDIR}' \
113 '-sBUILD=release <optimization>space <threading>multi <inlining>on <debug-symbols>off' \
114 '-sPYTHON_ROOT=${PYTHON_ROOT}' \
115 '--layout=system' \
116 "
117
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500118# use PARALLEL_MAKE to speed up the build, but limit it by -j 64, greater parallelism causes bjam to segfault or to ignore -j
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119# https://svn.boost.org/trac/boost/ticket/7634
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500120def get_boost_parallel_make(d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121 pm = d.getVar('PARALLEL_MAKE', True)
122 if pm:
123 # look for '-j' and throw other options (e.g. '-l') away
124 # because they might have different meaning in bjam
125 pm = pm.split()
126 while pm:
127 v = None
128 opt = pm.pop(0)
129 if opt == '-j':
130 v = pm.pop(0)
131 elif opt.startswith('-j'):
132 v = opt[2:].strip()
133 else:
134 v = None
135
136 if v:
137 v = min(64, int(v))
138 return '-j' + str(v)
139
140 return ""
141
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500142BOOST_PARALLEL_MAKE = "${@get_boost_parallel_make(d)}"
143BJAM_OPTS = '${BOOST_PARALLEL_MAKE} -d+2 -q \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 ${BJAM_TOOLS} \
145 -sBOOST_BUILD_USER_CONFIG=${S}/tools/build/example/user-config.jam \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500146 --build-dir=${S}/${TARGET_SYS} \
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
153do_boostconfig() {
154 cp -f boost/config/platform/linux.hpp boost/config/platform/linux-gnueabi.hpp
155
156 # D2194:Fixing the failure of "error: duplicate initialization of gcc with the following parameters" during compilation.
157 sed -i "/^using gcc : 4.3.1/d" ${S}/tools/build/example/user-config.jam
158 sed -i "/^using python : ${PYTHON_BASEVERSION}"/d ${S}/tools/build/example/user-config.jam
159 echo 'using gcc : 4.3.1 : ${CXX} : <cflags>"${CFLAGS}" <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;' >> ${S}/tools/build/example/user-config.jam
160 echo "using python : ${PYTHON_BASEVERSION} : : ${STAGING_INCDIR}/python${PYTHON_BASEVERSION} ;" >> ${S}/tools/build/example/user-config.jam
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500161 echo "using python : 3.5 : : ${STAGING_INCDIR}/python3.5m ;" >> ${S}/tools/build/example/user-config.jam
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162
163 CC="${BUILD_CC}" CFLAGS="${BUILD_CFLAGS}" ./bootstrap.sh --with-bjam=bjam --with-toolset=gcc --with-python-root=${PYTHON_ROOT}
164 sed -i '/^using python/d' project-config.jam
165}
166
167do_boostconfig[dirs] = "${S}"
168addtask do_boostconfig after do_patch before do_configure
169
170do_compile() {
171 set -ex
172 bjam ${BJAM_OPTS} --prefix=${prefix} \
173 --exec-prefix=${exec_prefix} \
174 --libdir=${libdir} \
175 --includedir=${includedir}
176}
177
178do_install() {
179 set -ex
180 bjam ${BJAM_OPTS} \
181 --libdir=${D}${libdir} \
182 --includedir=${D}${includedir} \
183 install
184 for lib in ${BOOST_LIBS}; do
185 if [ -e ${D}${libdir}/libboost_${lib}.a ]; then
186 ln -s libboost_${lib}.a ${D}${libdir}/libboost_${lib}-mt.a
187 fi
188 if [ -e ${D}${libdir}/libboost_${lib}.so ]; then
189 ln -s libboost_${lib}.so ${D}${libdir}/libboost_${lib}-mt.so
190 fi
191 done
192
193}
194
195BBCLASSEXTEND = "native nativesdk"