blob: 8a13f542c12298296967813c828e5566892dfc41 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001BPN = "libgcc"
2
Patrick Williamsc0f7c042017-02-23 20:41:17 -06003require gcc-configure-common.inc
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004
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
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600114 tune_abiextension = tune_parameters['abiextension']
115 if tune_abiextension:
116 libcextension = '-gnu' + tune_abiextension
117 else:
118 libcextension = ''
119
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500120 src = '../../../' + tune_baselib + '/' + \
121 tune_arch + d.getVar('TARGET_VENDOR', True) + 'ml' + ml + \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600122 '-' + d.getVar('TARGET_OS', True) + libcextension + '/' + binv + '/'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123
124 dest = d.getVar('D', True) + d.getVar('libdir', True) + '/' + \
125 d.getVar('TARGET_SYS', True) + '/' + binv + '/' + tune_bitness
126
127 if os.path.lexists(dest):
128 os.unlink(dest)
129 os.symlink(src, dest)
130}
131
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600132def get_original_os(d):
133 vendoros = d.expand('${TARGET_ARCH}${ORIG_TARGET_VENDOR}-${TARGET_OS}')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134 for suffix in [d.getVar('ABIEXTENSION', True), d.getVar('LIBCEXTENSION', True)]:
135 if suffix and vendoros.endswith(suffix):
136 vendoros = vendoros[:-len(suffix)]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600137 # Arm must use linux-gnueabi not linux as only the former is accepted by gcc
138 if vendoros.startswith("arm-") and not vendoros.endswith("-gnueabi"):
139 vendoros = vendoros + "-gnueabi"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140 return vendoros
141
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600142ORIG_TARGET_VENDOR := "${TARGET_VENDOR}"
143BASETARGET_SYS = "${@get_original_os(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144
145addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot
146fakeroot python do_extra_symlinks() {
147 targetsys = d.getVar('BASETARGET_SYS', True)
148
149 if targetsys != d.getVar('TARGET_SYS', True):
150 dest = d.getVar('D', True) + d.getVar('libdir', True) + '/' + targetsys
151 src = d.getVar('TARGET_SYS', True)
152 if not os.path.lexists(dest) and os.path.lexists(d.getVar('D', True) + d.getVar('libdir', True)):
153 os.symlink(src, dest)
154}