1BPN = "libgcc" 2 3require gcc-configure-common.inc 4 5INHIBIT_DEFAULT_DEPS = "1" 6 7do_configure () { 8 install -d ${D}${base_libdir} ${D}${libdir} 9 mkdir -p ${B}/${BPN} 10 mkdir -p ${B}/${TARGET_SYS}/${BPN}/ 11 cd ${B}/${BPN} 12 chmod a+x ${S}/${BPN}/configure 13 relpath=${@os.path.relpath("${S}/${BPN}", "${B}/${BPN}")} 14 $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} 15} 16EXTRACONFFUNCS += "extract_stashed_builddir" 17do_configure[depends] += "${COMPILERDEP}" 18 19do_compile () { 20 cd ${B}/${BPN} 21 oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/ 22} 23 24do_install () { 25 cd ${B}/${BPN} 26 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/ install 27 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 if [ "${base_libdir}" != "${libdir}" ]; then 49 rmdir ${D}${base_libdir} 50 fi 51} 52do_install:append:libc-newlib () { 53 if [ "${base_libdir}" != "${libdir}" ]; then 54 rmdir ${D}${base_libdir} 55 fi 56} 57 58# No rpm package is actually created but -dev depends on it, avoid dnf error 59RDEPENDS:${PN}-dev:libc-baremetal = "" 60RDEPENDS:${PN}-dev:libc-newlib = "" 61 62BBCLASSEXTEND = "nativesdk" 63 64addtask multilib_install after do_install before do_package do_populate_sysroot 65# this makes multilib gcc files findable for target gcc 66# e.g. 67# /usr/lib/i586-pokymllib32-linux/4.7/ 68# by creating this symlink to it 69# /usr/lib64/x86_64-poky-linux/4.7/32 70 71fakeroot python do_multilib_install() { 72 import re 73 74 multilibs = d.getVar('MULTILIB_VARIANTS') 75 if not multilibs or bb.data.inherits_class('nativesdk', d): 76 return 77 78 binv = d.getVar('BINV') 79 80 mlprefix = d.getVar('MLPREFIX') 81 if ('%slibgcc' % mlprefix) != d.getVar('PN'): 82 return 83 84 if mlprefix: 85 orig_tune = d.getVar('DEFAULTTUNE_MULTILIB_ORIGINAL') 86 orig_tune_params = get_tune_parameters(orig_tune, d) 87 orig_tune_baselib = orig_tune_params['baselib'] 88 orig_tune_bitness = orig_tune_baselib.replace('lib', '') 89 if not orig_tune_bitness: 90 orig_tune_bitness = '32' 91 92 src = '../../../' + orig_tune_baselib + '/' + \ 93 d.getVar('TARGET_SYS_MULTILIB_ORIGINAL') + '/' + binv + '/' 94 95 dest = d.getVar('D') + d.getVar('libdir') + '/' + \ 96 d.getVar('TARGET_SYS') + '/' + binv + '/' + orig_tune_bitness 97 98 if os.path.lexists(dest): 99 os.unlink(dest) 100 os.symlink(src, dest) 101 return 102 103 104 for ml in multilibs.split(): 105 tune = d.getVar('DEFAULTTUNE:virtclass-multilib-' + ml) 106 if not tune: 107 bb.warn('DEFAULTTUNE:virtclass-multilib-%s is not defined. Skipping...' % ml) 108 continue 109 110 tune_parameters = get_tune_parameters(tune, d) 111 tune_baselib = tune_parameters['baselib'] 112 if not tune_baselib: 113 bb.warn("Tune %s doesn't have a baselib set. Skipping..." % tune) 114 continue 115 116 tune_arch = tune_parameters['arch'] 117 tune_bitness = tune_baselib.replace('lib', '') 118 if not tune_bitness: 119 tune_bitness = '32' # /lib => 32bit lib 120 121 tune_abiextension = tune_parameters['abiextension'] 122 if tune_abiextension: 123 libcextension = '-gnu' + tune_abiextension 124 else: 125 libcextension = '' 126 127 src = '../../../' + tune_baselib + '/' + \ 128 tune_arch + d.getVar('TARGET_VENDOR') + 'ml' + ml + \ 129 '-' + d.getVar('TARGET_OS') + libcextension + '/' + binv + '/' 130 131 dest = d.getVar('D') + d.getVar('libdir') + '/' + \ 132 d.getVar('TARGET_SYS') + '/' + binv + '/' + tune_bitness 133 134 if os.path.lexists(dest): 135 os.unlink(dest) 136 os.symlink(src, dest) 137} 138 139def get_original_os(d): 140 vendoros = d.expand('${TARGET_ARCH}${ORIG_TARGET_VENDOR}-${TARGET_OS}') 141 for suffix in [d.getVar('ABIEXTENSION'), d.getVar('LIBCEXTENSION')]: 142 if suffix and vendoros.endswith(suffix): 143 vendoros = vendoros[:-len(suffix)] 144 # Arm must use linux-gnueabi not linux as only the former is accepted by gcc 145 if vendoros.startswith("arm-") and not vendoros.endswith("-gnueabi"): 146 vendoros = vendoros + "-gnueabi" 147 return vendoros 148 149ORIG_TARGET_VENDOR := "${TARGET_VENDOR}" 150BASETARGET_SYS = "${@get_original_os(d)}" 151 152addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot 153fakeroot python do_extra_symlinks() { 154 if bb.data.inherits_class('nativesdk', d): 155 return 156 157 targetsys = d.getVar('BASETARGET_SYS') 158 159 if targetsys != d.getVar('TARGET_SYS'): 160 dest = d.getVar('D') + d.getVar('libdir') + '/' + targetsys 161 src = d.getVar('TARGET_SYS') 162 if not os.path.lexists(dest) and os.path.lexists(d.getVar('D') + d.getVar('libdir')): 163 os.symlink(src, dest) 164} 165