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