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