Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # |
| 2 | # NOTE - When using this class the user is responsible for ensuring that |
| 3 | # TRANSLATED_TARGET_ARCH is added into PN. This ensures that if the TARGET_ARCH |
| 4 | # is changed, another nativesdk xxx-canadian-cross can be installed |
| 5 | # |
| 6 | |
| 7 | |
| 8 | # SDK packages are built either explicitly by the user, |
| 9 | # or indirectly via dependency. No need to be in 'world'. |
| 10 | EXCLUDE_FROM_WORLD = "1" |
| 11 | CLASSOVERRIDE = "class-cross-canadian" |
| 12 | STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${SDK_VENDOR}-${SDK_OS}:${STAGING_DIR_NATIVE}${bindir_native}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}" |
| 13 | |
| 14 | # |
| 15 | # Update BASE_PACKAGE_ARCH and PACKAGE_ARCHS |
| 16 | # |
| 17 | PACKAGE_ARCH = "${SDK_ARCH}-${SDKPKGSUFFIX}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 18 | BASECANADIANEXTRAOS ?= "linux-uclibc linux-musl" |
| 19 | CANADIANEXTRAOS = "${BASECANADIANEXTRAOS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | CANADIANEXTRAVENDOR = "" |
| 21 | MODIFYTOS ??= "1" |
| 22 | python () { |
| 23 | archs = d.getVar('PACKAGE_ARCHS', True).split() |
| 24 | sdkarchs = [] |
| 25 | for arch in archs: |
| 26 | sdkarchs.append(arch + '-${SDKPKGSUFFIX}') |
| 27 | d.setVar('PACKAGE_ARCHS', " ".join(sdkarchs)) |
| 28 | |
| 29 | # Allow the following code segment to be disabled, e.g. meta-environment |
| 30 | if d.getVar("MODIFYTOS", True) != "1": |
| 31 | return |
| 32 | |
| 33 | if d.getVar("TCLIBC", True) == "baremetal": |
| 34 | return |
| 35 | |
| 36 | tos = d.getVar("TARGET_OS", True) |
| 37 | whitelist = [] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 38 | extralibcs = [""] |
| 39 | if "uclibc" in d.getVar("BASECANADIANEXTRAOS", True): |
| 40 | extralibcs.append("uclibc") |
| 41 | if "musl" in d.getVar("BASECANADIANEXTRAOS", True): |
| 42 | extralibcs.append("musl") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 43 | for variant in ["", "spe", "x32", "eabi", "n32"]: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 44 | for libc in extralibcs: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | entry = "linux" |
| 46 | if variant and libc: |
| 47 | entry = entry + "-" + libc + variant |
| 48 | elif variant: |
| 49 | entry = entry + "-gnu" + variant |
| 50 | elif libc: |
| 51 | entry = entry + "-" + libc |
| 52 | whitelist.append(entry) |
| 53 | if tos not in whitelist: |
| 54 | bb.fatal("Building cross-candian for an unknown TARGET_SYS (%s), please update cross-canadian.bbclass" % d.getVar("TARGET_SYS", True)) |
| 55 | |
| 56 | for n in ["PROVIDES", "DEPENDS"]: |
| 57 | d.setVar(n, d.getVar(n, True)) |
| 58 | d.setVar("STAGING_BINDIR_TOOLCHAIN", d.getVar("STAGING_BINDIR_TOOLCHAIN", True)) |
| 59 | for prefix in ["AR", "AS", "DLLTOOL", "CC", "CXX", "GCC", "LD", "LIPO", "NM", "OBJDUMP", "RANLIB", "STRIP", "WINDRES"]: |
| 60 | n = prefix + "_FOR_TARGET" |
| 61 | d.setVar(n, d.getVar(n, True)) |
| 62 | # This is a bit ugly. We need to zero LIBC/ABI extension which will change TARGET_OS |
| 63 | # however we need the old value in some variables. We expand those here first. |
| 64 | tarch = d.getVar("TARGET_ARCH", True) |
| 65 | if tarch == "x86_64": |
| 66 | d.setVar("LIBCEXTENSION", "") |
| 67 | d.setVar("ABIEXTENSION", "") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 68 | d.appendVar("CANADIANEXTRAOS", " linux-gnux32") |
| 69 | for extraos in d.getVar("BASECANADIANEXTRAOS", True).split(): |
| 70 | d.appendVar("CANADIANEXTRAOS", " " + extraos + "x32") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | elif tarch == "powerpc": |
| 72 | # PowerPC can build "linux" and "linux-gnuspe" |
| 73 | d.setVar("LIBCEXTENSION", "") |
| 74 | d.setVar("ABIEXTENSION", "") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 75 | d.appendVar("CANADIANEXTRAOS", " linux-gnuspe") |
| 76 | for extraos in d.getVar("BASECANADIANEXTRAOS", True).split(): |
| 77 | d.appendVar("CANADIANEXTRAOS", " " + extraos + "spe") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 78 | elif tarch == "mips64": |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 79 | d.appendVar("CANADIANEXTRAOS", " linux-gnun32") |
| 80 | for extraos in d.getVar("BASECANADIANEXTRAOS", True).split(): |
| 81 | d.appendVar("CANADIANEXTRAOS", " " + extraos + "n32") |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 82 | if tarch == "arm" or tarch == "armeb": |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 83 | d.appendVar("CANADIANEXTRAOS", " linux-gnueabi linux-musleabi linux-uclibceabi") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | d.setVar("TARGET_OS", "linux-gnueabi") |
| 85 | else: |
| 86 | d.setVar("TARGET_OS", "linux") |
| 87 | |
| 88 | # Also need to handle multilib target vendors |
| 89 | vendors = d.getVar("CANADIANEXTRAVENDOR", True) |
| 90 | if not vendors: |
| 91 | vendors = all_multilib_tune_values(d, 'TARGET_VENDOR') |
| 92 | origvendor = d.getVar("TARGET_VENDOR_MULTILIB_ORIGINAL", True) |
| 93 | if origvendor: |
| 94 | d.setVar("TARGET_VENDOR", origvendor) |
| 95 | if origvendor not in vendors.split(): |
| 96 | vendors = origvendor + " " + vendors |
| 97 | d.setVar("CANADIANEXTRAVENDOR", vendors) |
| 98 | } |
| 99 | MULTIMACH_TARGET_SYS = "${PACKAGE_ARCH}${HOST_VENDOR}-${HOST_OS}" |
| 100 | |
| 101 | INHIBIT_DEFAULT_DEPS = "1" |
| 102 | |
| 103 | STAGING_DIR_HOST = "${STAGING_DIR}/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}" |
| 104 | |
| 105 | TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR}/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}" |
| 106 | |
| 107 | PATH_append = ":${TMPDIR}/sysroots/${HOST_ARCH}/${bindir_cross}" |
| 108 | PKGHIST_DIR = "${TMPDIR}/pkghistory/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}/" |
| 109 | |
| 110 | HOST_ARCH = "${SDK_ARCH}" |
| 111 | HOST_VENDOR = "${SDK_VENDOR}" |
| 112 | HOST_OS = "${SDK_OS}" |
| 113 | HOST_PREFIX = "${SDK_PREFIX}" |
| 114 | HOST_CC_ARCH = "${SDK_CC_ARCH}" |
| 115 | HOST_LD_ARCH = "${SDK_LD_ARCH}" |
| 116 | HOST_AS_ARCH = "${SDK_AS_ARCH}" |
| 117 | |
| 118 | #assign DPKG_ARCH |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 119 | DPKG_ARCH = "${@debian_arch_map(d.getVar('SDK_ARCH', True), '')}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | |
| 121 | CPPFLAGS = "${BUILDSDK_CPPFLAGS}" |
| 122 | CFLAGS = "${BUILDSDK_CFLAGS}" |
| 123 | CXXFLAGS = "${BUILDSDK_CFLAGS}" |
| 124 | LDFLAGS = "${BUILDSDK_LDFLAGS} \ |
| 125 | -Wl,-rpath-link,${STAGING_LIBDIR}/.. \ |
| 126 | -Wl,-rpath,${libdir}/.. " |
| 127 | |
| 128 | DEPENDS_GETTEXT = "gettext-native nativesdk-gettext" |
| 129 | |
| 130 | # |
| 131 | # We need chrpath >= 0.14 to ensure we can deal with 32 and 64 bit |
| 132 | # binaries |
| 133 | # |
| 134 | DEPENDS_append = " chrpath-replacement-native" |
| 135 | EXTRANATIVEPATH += "chrpath-native" |
| 136 | |
| 137 | # Path mangling needed by the cross packaging |
| 138 | # Note that we use := here to ensure that libdir and includedir are |
| 139 | # target paths. |
| 140 | target_base_prefix := "${base_prefix}" |
| 141 | target_prefix := "${prefix}" |
| 142 | target_exec_prefix := "${exec_prefix}" |
| 143 | target_base_libdir = "${target_base_prefix}/${baselib}" |
| 144 | target_libdir = "${target_exec_prefix}/${baselib}" |
| 145 | target_includedir := "${includedir}" |
| 146 | |
| 147 | # Change to place files in SDKPATH |
| 148 | base_prefix = "${SDKPATHNATIVE}" |
| 149 | prefix = "${SDKPATHNATIVE}${prefix_nativesdk}" |
| 150 | exec_prefix = "${SDKPATHNATIVE}${prefix_nativesdk}" |
| 151 | bindir = "${exec_prefix}/bin/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}" |
| 152 | sbindir = "${bindir}" |
| 153 | base_bindir = "${bindir}" |
| 154 | base_sbindir = "${bindir}" |
| 155 | libdir = "${exec_prefix}/lib/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}" |
| 156 | libexecdir = "${exec_prefix}/libexec/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}" |
| 157 | |
| 158 | FILES_${PN} = "${prefix}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 159 | |
| 160 | export PKG_CONFIG_DIR = "${STAGING_DIR_HOST}${layout_libdir}/pkgconfig" |
| 161 | export PKG_CONFIG_SYSROOT_DIR = "${STAGING_DIR_HOST}" |
| 162 | |
| 163 | do_populate_sysroot[stamp-extra-info] = "" |
| 164 | do_packagedata[stamp-extra-info] = "" |
| 165 | |
| 166 | USE_NLS = "${SDKUSE_NLS}" |
| 167 | |
| 168 | # We have to us TARGET_ARCH but we care about the absolute value |
| 169 | # and not any particular tune that is enabled. |
| 170 | TARGET_ARCH[vardepsexclude] = "TUNE_ARCH" |
| 171 | |
| 172 | # If MLPREFIX is set by multilib code, shlibs |
| 173 | # points to the wrong place so force it |
| 174 | SHLIBSDIRS = "${PKGDATA_DIR}/nativesdk-shlibs2" |
| 175 | SHLIBSWORKDIR = "${PKGDATA_DIR}/nativesdk-shlibs2" |
| 176 | |
| 177 | cross_canadian_bindirlinks () { |
| 178 | for i in linux ${CANADIANEXTRAOS} |
| 179 | do |
| 180 | for v in ${CANADIANEXTRAVENDOR} |
| 181 | do |
| 182 | d=${D}${bindir}/../${TARGET_ARCH}$v-$i |
| 183 | if [ -d $d ]; |
| 184 | then |
| 185 | continue |
| 186 | fi |
| 187 | install -d $d |
| 188 | for j in `ls ${D}${bindir}` |
| 189 | do |
| 190 | p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,` |
| 191 | ln -s ../${TARGET_SYS}/$j $d/$p |
| 192 | done |
| 193 | done |
| 194 | done |
| 195 | } |