blob: 848a476207b19c50cbe146dc3b3533ccc904eed4 [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 () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008 install -d ${D}${base_libdir} ${D}${libdir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009 mkdir -p ${B}/${BPN}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010 mkdir -p ${B}/${TARGET_SYS}/${BPN}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011 cd ${B}/${BPN}
12 chmod a+x ${S}/${BPN}/configure
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050013 relpath=${@os.path.relpath("${S}/${BPN}", "${B}/${BPN}")}
14 $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050016EXTRACONFFUNCS += "extract_stashed_builddir"
17do_configure[depends] += "${COMPILERDEP}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018
19do_compile () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 cd ${B}/${BPN}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021 oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022}
23
24do_install () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 cd ${B}/${BPN}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/ install
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027
28 # Move libgcc_s into /lib
29 mkdir -p ${D}${base_libdir}
30 if [ -f ${D}${libdir}/nof/libgcc_s.so ]; then
31 mv ${D}${libdir}/nof/libgcc* ${D}${base_libdir}
32 else
33 mv ${D}${libdir}/libgcc* ${D}${base_libdir} || true
34 fi
35
36 # install the runtime in /usr/lib/ not in /usr/lib/gcc on target
37 # so that cross-gcc can find it in the sysroot
38
39 mv ${D}${libdir}/gcc/* ${D}${libdir}
40 rm -rf ${D}${libdir}/gcc/
41 # unwind.h is installed here which is shipped in gcc-cross
42 # as well as target gcc and they are identical so we dont
43 # ship one with libgcc here
44 rm -rf ${D}${libdir}/${TARGET_SYS}/${BINV}/include
45}
46
47do_install_append_libc-baremetal () {
48 rmdir ${D}${base_libdir}
49}
50
51RDEPENDS_${PN}-dev_libc-baremetal = ""
52
53BBCLASSEXTEND = "nativesdk"
54
55addtask multilib_install after do_install before do_package do_populate_sysroot
56# this makes multilib gcc files findable for target gcc
57# e.g.
58# /usr/lib/i586-pokymllib32-linux/4.7/
59# by creating this symlink to it
60# /usr/lib64/x86_64-poky-linux/4.7/32
61
62fakeroot python do_multilib_install() {
63 import re
64
Brad Bishop6e60e8b2018-02-01 10:27:11 -050065 multilibs = d.getVar('MULTILIB_VARIANTS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066 if not multilibs or bb.data.inherits_class('nativesdk', d):
67 return
68
Brad Bishop6e60e8b2018-02-01 10:27:11 -050069 binv = d.getVar('BINV')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070
Brad Bishop6e60e8b2018-02-01 10:27:11 -050071 mlprefix = d.getVar('MLPREFIX')
72 if ('%slibgcc' % mlprefix) != d.getVar('PN'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 return
74
75 if mlprefix:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050076 orig_tune = d.getVar('DEFAULTTUNE_MULTILIB_ORIGINAL')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077 orig_tune_params = get_tune_parameters(orig_tune, d)
78 orig_tune_baselib = orig_tune_params['baselib']
79 orig_tune_bitness = orig_tune_baselib.replace('lib', '')
80 if not orig_tune_bitness:
81 orig_tune_bitness = '32'
82
83 src = '../../../' + orig_tune_baselib + '/' + \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050084 d.getVar('TARGET_SYS_MULTILIB_ORIGINAL') + '/' + binv + '/'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085
Brad Bishop6e60e8b2018-02-01 10:27:11 -050086 dest = d.getVar('D') + d.getVar('libdir') + '/' + \
87 d.getVar('TARGET_SYS') + '/' + binv + '/' + orig_tune_bitness
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088
89 if os.path.lexists(dest):
90 os.unlink(dest)
91 os.symlink(src, dest)
92 return
93
94
95 for ml in multilibs.split():
Brad Bishop6e60e8b2018-02-01 10:27:11 -050096 tune = d.getVar('DEFAULTTUNE_virtclass-multilib-' + ml)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097 if not tune:
98 bb.warn('DEFAULTTUNE_virtclass-multilib-%s is not defined. Skipping...' % ml)
99 continue
100
101 tune_parameters = get_tune_parameters(tune, d)
102 tune_baselib = tune_parameters['baselib']
103 if not tune_baselib:
104 bb.warn("Tune %s doesn't have a baselib set. Skipping..." % tune)
105 continue
106
107 tune_arch = tune_parameters['arch']
108 tune_bitness = tune_baselib.replace('lib', '')
109 if not tune_bitness:
110 tune_bitness = '32' # /lib => 32bit lib
111
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600112 tune_abiextension = tune_parameters['abiextension']
113 if tune_abiextension:
114 libcextension = '-gnu' + tune_abiextension
115 else:
116 libcextension = ''
117
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118 src = '../../../' + tune_baselib + '/' + \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500119 tune_arch + d.getVar('TARGET_VENDOR') + 'ml' + ml + \
120 '-' + d.getVar('TARGET_OS') + libcextension + '/' + binv + '/'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500122 dest = d.getVar('D') + d.getVar('libdir') + '/' + \
123 d.getVar('TARGET_SYS') + '/' + binv + '/' + tune_bitness
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124
125 if os.path.lexists(dest):
126 os.unlink(dest)
127 os.symlink(src, dest)
128}
129
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600130def get_original_os(d):
131 vendoros = d.expand('${TARGET_ARCH}${ORIG_TARGET_VENDOR}-${TARGET_OS}')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500132 for suffix in [d.getVar('ABIEXTENSION'), d.getVar('LIBCEXTENSION')]:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500133 if suffix and vendoros.endswith(suffix):
134 vendoros = vendoros[:-len(suffix)]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600135 # Arm must use linux-gnueabi not linux as only the former is accepted by gcc
136 if vendoros.startswith("arm-") and not vendoros.endswith("-gnueabi"):
137 vendoros = vendoros + "-gnueabi"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138 return vendoros
139
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600140ORIG_TARGET_VENDOR := "${TARGET_VENDOR}"
141BASETARGET_SYS = "${@get_original_os(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500142
143addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot
144fakeroot python do_extra_symlinks() {
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500145 if bb.data.inherits_class('nativesdk', d):
146 return
147
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500148 targetsys = d.getVar('BASETARGET_SYS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500149
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500150 if targetsys != d.getVar('TARGET_SYS'):
151 dest = d.getVar('D') + d.getVar('libdir') + '/' + targetsys
152 src = d.getVar('TARGET_SYS')
153 if not os.path.lexists(dest) and os.path.lexists(d.getVar('D') + d.getVar('libdir')):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154 os.symlink(src, dest)
155}