Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | BPN = "libgcc" |
| 2 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3 | require gcc-configure-common.inc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | |
| 5 | INHIBIT_DEFAULT_DEPS = "1" |
| 6 | |
| 7 | do_configure () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | install -d ${D}${base_libdir} ${D}${libdir} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | mkdir -p ${B}/${BPN} |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 10 | mkdir -p ${B}/${TARGET_SYS}/${BPN}/ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11 | cd ${B}/${BPN} |
| 12 | chmod a+x ${S}/${BPN}/configure |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 13 | relpath=${@os.path.relpath("${S}/${BPN}", "${B}/${BPN}")} |
| 14 | $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | } |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 16 | EXTRACONFFUNCS += "extract_stashed_builddir" |
| 17 | do_configure[depends] += "${COMPILERDEP}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | |
| 19 | do_compile () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | cd ${B}/${BPN} |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 21 | oe_runmake MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | do_install () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | cd ${B}/${BPN} |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 26 | oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/${BPN}/ install |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 47 | do_install_append_libc-baremetal () { |
| 48 | rmdir ${D}${base_libdir} |
| 49 | } |
| 50 | |
| 51 | RDEPENDS_${PN}-dev_libc-baremetal = "" |
| 52 | |
| 53 | BBCLASSEXTEND = "nativesdk" |
| 54 | |
| 55 | addtask 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 | |
| 62 | fakeroot python do_multilib_install() { |
| 63 | import re |
| 64 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 65 | multilibs = d.getVar('MULTILIB_VARIANTS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 66 | if not multilibs or bb.data.inherits_class('nativesdk', d): |
| 67 | return |
| 68 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 69 | binv = d.getVar('BINV') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 71 | mlprefix = d.getVar('MLPREFIX') |
| 72 | if ('%slibgcc' % mlprefix) != d.getVar('PN'): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | return |
| 74 | |
| 75 | if mlprefix: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 76 | orig_tune = d.getVar('DEFAULTTUNE_MULTILIB_ORIGINAL') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 77 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 84 | d.getVar('TARGET_SYS_MULTILIB_ORIGINAL') + '/' + binv + '/' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 86 | dest = d.getVar('D') + d.getVar('libdir') + '/' + \ |
| 87 | d.getVar('TARGET_SYS') + '/' + binv + '/' + orig_tune_bitness |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | |
| 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 96 | tune = d.getVar('DEFAULTTUNE_virtclass-multilib-' + ml) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 97 | 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 112 | tune_abiextension = tune_parameters['abiextension'] |
| 113 | if tune_abiextension: |
| 114 | libcextension = '-gnu' + tune_abiextension |
| 115 | else: |
| 116 | libcextension = '' |
| 117 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 118 | src = '../../../' + tune_baselib + '/' + \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 119 | tune_arch + d.getVar('TARGET_VENDOR') + 'ml' + ml + \ |
| 120 | '-' + d.getVar('TARGET_OS') + libcextension + '/' + binv + '/' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 121 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 122 | dest = d.getVar('D') + d.getVar('libdir') + '/' + \ |
| 123 | d.getVar('TARGET_SYS') + '/' + binv + '/' + tune_bitness |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 124 | |
| 125 | if os.path.lexists(dest): |
| 126 | os.unlink(dest) |
| 127 | os.symlink(src, dest) |
| 128 | } |
| 129 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 130 | def get_original_os(d): |
| 131 | vendoros = d.expand('${TARGET_ARCH}${ORIG_TARGET_VENDOR}-${TARGET_OS}') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 132 | for suffix in [d.getVar('ABIEXTENSION'), d.getVar('LIBCEXTENSION')]: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 133 | if suffix and vendoros.endswith(suffix): |
| 134 | vendoros = vendoros[:-len(suffix)] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 135 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 138 | return vendoros |
| 139 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 140 | ORIG_TARGET_VENDOR := "${TARGET_VENDOR}" |
| 141 | BASETARGET_SYS = "${@get_original_os(d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 142 | |
| 143 | addtask extra_symlinks after do_multilib_install before do_package do_populate_sysroot |
| 144 | fakeroot python do_extra_symlinks() { |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 145 | if bb.data.inherits_class('nativesdk', d): |
| 146 | return |
| 147 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 148 | targetsys = d.getVar('BASETARGET_SYS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 149 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 150 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | os.symlink(src, dest) |
| 155 | } |