blob: dae07e96da537fe9f84c2db0f891a3d3c8186624 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001BPN = "libgcc"
2
3require gcc-shared-source.inc
4
5INHIBIT_DEFAULT_DEPS = "1"
6
7do_configure () {
8 target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
9 install -d ${D}${base_libdir} ${D}${libdir}
10 hardlinkdir ${STAGING_INCDIR_NATIVE}/${LIBGCCBUILDTREENAME}$target/ ${B}
11 mkdir -p ${B}/${BPN}
12 mkdir -p ${B}/$target/${BPN}/
13 cd ${B}/${BPN}
14 chmod a+x ${S}/${BPN}/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050015 relpath=${@os.path.relpath("${S}/${BPN}", "${B}/${BPN}")}
16 $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017}
18
19do_compile () {
20 target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
21 cd ${B}/${BPN}
22 oe_runmake MULTIBUILDTOP=${B}/$target/${BPN}/
23}
24
25do_install () {
26 target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
27 cd ${B}/${BPN}
28 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/$target/${BPN}/ install
29
30 # Move libgcc_s into /lib
31 mkdir -p ${D}${base_libdir}
32 if [ -f ${D}${libdir}/nof/libgcc_s.so ]; then
33 mv ${D}${libdir}/nof/libgcc* ${D}${base_libdir}
34 else
35 mv ${D}${libdir}/libgcc* ${D}${base_libdir} || true
36 fi
37
38 # install the runtime in /usr/lib/ not in /usr/lib/gcc on target
39 # so that cross-gcc can find it in the sysroot
40
41 mv ${D}${libdir}/gcc/* ${D}${libdir}
42 rm -rf ${D}${libdir}/gcc/
43 # unwind.h is installed here which is shipped in gcc-cross
44 # as well as target gcc and they are identical so we dont
45 # ship one with libgcc here
46 rm -rf ${D}${libdir}/${TARGET_SYS}/${BINV}/include
47}
48
49do_install_append_libc-baremetal () {
50 rmdir ${D}${base_libdir}
51}
52
53RDEPENDS_${PN}-dev_libc-baremetal = ""
54
55BBCLASSEXTEND = "nativesdk"
56
57addtask multilib_install after do_install before do_package do_populate_sysroot
58# this makes multilib gcc files findable for target gcc
59# e.g.
60# /usr/lib/i586-pokymllib32-linux/4.7/
61# by creating this symlink to it
62# /usr/lib64/x86_64-poky-linux/4.7/32
63
64fakeroot python do_multilib_install() {
65 import re
66
67 multilibs = d.getVar('MULTILIB_VARIANTS', True)
68 if not multilibs or bb.data.inherits_class('nativesdk', d):
69 return
70
71 binv = d.getVar('BINV', True)
72
73 mlprefix = d.getVar('MLPREFIX', True)
74 if ('%slibgcc' % mlprefix) != d.getVar('PN', True):
75 return
76
77 if mlprefix:
78 orig_tune = d.getVar('DEFAULTTUNE_MULTILIB_ORIGINAL', True)
79 orig_tune_params = get_tune_parameters(orig_tune, d)
80 orig_tune_baselib = orig_tune_params['baselib']
81 orig_tune_bitness = orig_tune_baselib.replace('lib', '')
82 if not orig_tune_bitness:
83 orig_tune_bitness = '32'
84
85 src = '../../../' + orig_tune_baselib + '/' + \
86 d.getVar('TARGET_SYS_MULTILIB_ORIGINAL', True) + '/' + binv + '/'
87
88 dest = d.getVar('D', True) + d.getVar('libdir', True) + '/' + \
89 d.getVar('TARGET_SYS', True) + '/' + binv + '/' + orig_tune_bitness
90
91 if os.path.lexists(dest):
92 os.unlink(dest)
93 os.symlink(src, dest)
94 return
95
96
97 for ml in multilibs.split():
98 tune = d.getVar('DEFAULTTUNE_virtclass-multilib-' + ml, True)
99 if not tune:
100 bb.warn('DEFAULTTUNE_virtclass-multilib-%s is not defined. Skipping...' % ml)
101 continue
102
103 tune_parameters = get_tune_parameters(tune, d)
104 tune_baselib = tune_parameters['baselib']
105 if not tune_baselib:
106 bb.warn("Tune %s doesn't have a baselib set. Skipping..." % tune)
107 continue
108
109 tune_arch = tune_parameters['arch']
110 tune_bitness = tune_baselib.replace('lib', '')
111 if not tune_bitness:
112 tune_bitness = '32' # /lib => 32bit lib
113
114 src = '../../../' + tune_baselib + '/' + \
115 tune_arch + d.getVar('TARGET_VENDOR', True) + 'ml' + ml + \
116 '-' + d.getVar('TARGET_OS', True) + '/' + binv + '/'
117
118 dest = d.getVar('D', True) + d.getVar('libdir', True) + '/' + \
119 d.getVar('TARGET_SYS', True) + '/' + binv + '/' + tune_bitness
120
121 if os.path.lexists(dest):
122 os.unlink(dest)
123 os.symlink(src, dest)
124}
125
126def get_original_vendoros(d):
127 vendoros = d.expand('${TARGET_VENDOR}-${TARGET_OS}')
128 for suffix in [d.getVar('ABIEXTENSION', True), d.getVar('LIBCEXTENSION', True)]:
129 if suffix and vendoros.endswith(suffix):
130 vendoros = vendoros[:-len(suffix)]
131 return vendoros
132
133ORIG_TARGET_VENDOROS := "${@get_original_vendoros(d)}"
134BASETARGET_SYS = "${TARGET_ARCH}${ORIG_TARGET_VENDOROS}"
135
136addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot
137fakeroot python do_extra_symlinks() {
138 targetsys = d.getVar('BASETARGET_SYS', True)
139
140 if targetsys != d.getVar('TARGET_SYS', True):
141 dest = d.getVar('D', True) + d.getVar('libdir', True) + '/' + targetsys
142 src = d.getVar('TARGET_SYS', True)
143 if not os.path.lexists(dest) and os.path.lexists(d.getVar('D', True) + d.getVar('libdir', True)):
144 os.symlink(src, dest)
145}