aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-external/gcc/libgcc-external.bb
blob: 0be1be4c607095d1820132471ef7eb6989edf062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
SUMMARY = "The GNU Compiler Collection - libgcc"
HOMEPAGE = "http://www.gnu.org/software/gcc/"
SECTION = "devel"
DEPENDS += "virtual/${TARGET_PREFIX}binutils"
PROVIDES += "libgcc-initial"
PV = "${GCC_VERSION}"

inherit external-toolchain

DEBUG_PREFIX_MAP:append = "\
    -fdebug-prefix-map=${WORKDIR}/libgcc=/usr/src/debug/gcc/${EXTENDPE}${GCC_VERSION}-${PR}/libgcc \
    -fdebug-prefix-map=${WORKDIR}/gcc-${GCC_VERSION}/libgcc=/usr/src/debug/gcc/${EXTENDPE}${GCC_VERSION}-${PR}/gcc-${GCC_VERSION}/libgcc \
"

LICENSE = "GPL-3.0-with-GCC-exception"

# libgcc needs libc, but glibc's utilities need libgcc, so short-circuit the
# interdependency here by manually specifying it rather than depending on the
# libc packagedata.
RDEPENDS:${PN} += "${@'${PREFERRED_PROVIDER_virtual/libc}' if '${PREFERRED_PROVIDER_virtual/libc}' else '${TCLIBC}'}"
INSANE_SKIP:${PN} += "build-deps file-rdeps"

# The dynamically loadable files belong to libgcc, since we really don't need the static files
# on the target, moreover linker won't be able to find them there (see original libgcc.bb recipe).
BINV = "${GCC_VERSION}"
FILES:${PN} = "${base_libdir}/libgcc_s.so.*"
LIBROOT_RELATIVE_RESOLVED = "${@os.path.relpath(os.path.realpath('${EXTERNAL_TOOLCHAIN_LIBROOT}'), os.path.realpath('${EXTERNAL_TOOLCHAIN_SYSROOT}'))}"
LIBROOT_RELATIVE = "${@os.path.relpath('${EXTERNAL_TOOLCHAIN_LIBROOT}', '${EXTERNAL_TOOLCHAIN_SYSROOT}')}"
FILES:${PN}-dev = "${base_libdir}/libgcc_s.so \
             /${LIBROOT_RELATIVE_RESOLVED} \
             /${LIBROOT_RELATIVE} \
"
INSANE_SKIP:${PN}-dev += "staticdev"
FILES:${PN}-dbg += "${base_libdir}/.debug/libgcc_s.so.*.debug"

# Follow any symlinks in the libroot (multilib build) to the main
# libroot and include any symlinks there that link to our libroot.
python add_ml_symlink () {
    pass
}
python add_ml_symlink:tcmode-external () {
    import pathlib

    def get_links(p):
        return (c for c in p.iterdir() if c.is_symlink())

    if not d.getVar('EXTERNAL_TOOLCHAIN'):
        return

    libroot = d.getVar('EXTERNAL_TOOLCHAIN_LIBROOT')
    if libroot != 'UNKNOWN':
        sysroot = pathlib.Path(d.getVar('EXTERNAL_TOOLCHAIN_SYSROOT')).resolve()
        libroot = pathlib.Path(libroot)
        for child in get_links(libroot):
            link_dest = child.resolve(strict=True)
            for other_child in get_links(link_dest):
                if other_child.resolve() == libroot.resolve():
                    other = other_child.parent.resolve() / other_child.name
                    relpath = other.relative_to(sysroot)
                    d.appendVar('SYSROOT_DIRS', ' /' + str(relpath.parent))
                    d.appendVar('FILES:${PN}-dev', ' /' + str(relpath))
}
add_ml_symlink[eventmask] = "bb.event.RecipePreFinalise"
addhandler add_ml_symlink

do_install_extra () {
    if [ -e "${D}${libdir}/${EXTERNAL_TARGET_SYS}" ] && [ -z "${MLPREFIX}" ]; then
        if ! [ -e "${D}${libdir}/${TARGET_SYS}" ]; then
            ln -s "${EXTERNAL_TARGET_SYS}" "${D}${libdir}/${TARGET_SYS}"
        fi
    fi

    # This belongs in gcc-runtime
    rm -rf ${D}${libdir}/${TARGET_SYS}/${BINV}/include
}

do_package[prefuncs] += "add_sys_symlink"

python add_sys_symlink () {
    import pathlib
    target_sys = pathlib.Path(d.expand('${D}${libdir}/${TARGET_SYS}'))
    if target_sys.exists():
        pn = d.getVar('PN')
        d.appendVar('FILES:%s-dev' % pn, ' ${libdir}/${TARGET_SYS}')
}