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" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 11 | NATIVESDKLIBC ?= "libc-glibc" |
| 12 | LIBCOVERRIDE = ":${NATIVESDKLIBC}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | CLASSOVERRIDE = "class-cross-canadian" |
| 14 | 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}" |
| 15 | |
| 16 | # |
| 17 | # Update BASE_PACKAGE_ARCH and PACKAGE_ARCHS |
| 18 | # |
| 19 | PACKAGE_ARCH = "${SDK_ARCH}-${SDKPKGSUFFIX}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 20 | BASECANADIANEXTRAOS ?= "linux-musl" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 21 | CANADIANEXTRAOS = "${BASECANADIANEXTRAOS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 22 | CANADIANEXTRAVENDOR = "" |
| 23 | MODIFYTOS ??= "1" |
| 24 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 25 | archs = d.getVar('PACKAGE_ARCHS').split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | sdkarchs = [] |
| 27 | for arch in archs: |
| 28 | sdkarchs.append(arch + '-${SDKPKGSUFFIX}') |
| 29 | d.setVar('PACKAGE_ARCHS', " ".join(sdkarchs)) |
| 30 | |
| 31 | # Allow the following code segment to be disabled, e.g. meta-environment |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 32 | if d.getVar("MODIFYTOS") != "1": |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | return |
| 34 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | if d.getVar("TCLIBC") in [ 'baremetal', 'newlib' ]: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | return |
| 37 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 38 | tos = d.getVar("TARGET_OS") |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 39 | tos_known = ["mingw32"] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 40 | extralibcs = [""] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 41 | if "musl" in d.getVar("BASECANADIANEXTRAOS"): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 42 | extralibcs.append("musl") |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 43 | if "android" in tos: |
| 44 | extralibcs.append("android") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 45 | for variant in ["", "spe", "x32", "eabi", "n32", "_ilp32"]: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 46 | for libc in extralibcs: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | entry = "linux" |
| 48 | if variant and libc: |
| 49 | entry = entry + "-" + libc + variant |
| 50 | elif variant: |
| 51 | entry = entry + "-gnu" + variant |
| 52 | elif libc: |
| 53 | entry = entry + "-" + libc |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 54 | tos_known.append(entry) |
| 55 | if tos not in tos_known: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 56 | bb.fatal("Building cross-candian for an unknown TARGET_SYS (%s), please update cross-canadian.bbclass" % d.getVar("TARGET_SYS")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | |
| 58 | for n in ["PROVIDES", "DEPENDS"]: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 59 | d.setVar(n, d.getVar(n)) |
| 60 | d.setVar("STAGING_BINDIR_TOOLCHAIN", d.getVar("STAGING_BINDIR_TOOLCHAIN")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | for prefix in ["AR", "AS", "DLLTOOL", "CC", "CXX", "GCC", "LD", "LIPO", "NM", "OBJDUMP", "RANLIB", "STRIP", "WINDRES"]: |
| 62 | n = prefix + "_FOR_TARGET" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 63 | d.setVar(n, d.getVar(n)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | # This is a bit ugly. We need to zero LIBC/ABI extension which will change TARGET_OS |
| 65 | # however we need the old value in some variables. We expand those here first. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 66 | tarch = d.getVar("TARGET_ARCH") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | if tarch == "x86_64": |
| 68 | d.setVar("LIBCEXTENSION", "") |
| 69 | d.setVar("ABIEXTENSION", "") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 70 | d.appendVar("CANADIANEXTRAOS", " linux-gnux32") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 71 | for extraos in d.getVar("BASECANADIANEXTRAOS").split(): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 72 | d.appendVar("CANADIANEXTRAOS", " " + extraos + "x32") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | elif tarch == "powerpc": |
| 74 | # PowerPC can build "linux" and "linux-gnuspe" |
| 75 | d.setVar("LIBCEXTENSION", "") |
| 76 | d.setVar("ABIEXTENSION", "") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 77 | d.appendVar("CANADIANEXTRAOS", " linux-gnuspe") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 78 | for extraos in d.getVar("BASECANADIANEXTRAOS").split(): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 79 | d.appendVar("CANADIANEXTRAOS", " " + extraos + "spe") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 80 | elif tarch == "mips64": |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 81 | d.appendVar("CANADIANEXTRAOS", " linux-gnun32") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 82 | for extraos in d.getVar("BASECANADIANEXTRAOS").split(): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 83 | d.appendVar("CANADIANEXTRAOS", " " + extraos + "n32") |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 84 | if tarch == "arm" or tarch == "armeb": |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 85 | d.appendVar("CANADIANEXTRAOS", " linux-gnueabi linux-musleabi") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | d.setVar("TARGET_OS", "linux-gnueabi") |
| 87 | else: |
| 88 | d.setVar("TARGET_OS", "linux") |
| 89 | |
| 90 | # Also need to handle multilib target vendors |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 91 | vendors = d.getVar("CANADIANEXTRAVENDOR") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 92 | if not vendors: |
| 93 | vendors = all_multilib_tune_values(d, 'TARGET_VENDOR') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 94 | origvendor = d.getVar("TARGET_VENDOR_MULTILIB_ORIGINAL") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | if origvendor: |
| 96 | d.setVar("TARGET_VENDOR", origvendor) |
| 97 | if origvendor not in vendors.split(): |
| 98 | vendors = origvendor + " " + vendors |
| 99 | d.setVar("CANADIANEXTRAVENDOR", vendors) |
| 100 | } |
| 101 | MULTIMACH_TARGET_SYS = "${PACKAGE_ARCH}${HOST_VENDOR}-${HOST_OS}" |
| 102 | |
| 103 | INHIBIT_DEFAULT_DEPS = "1" |
| 104 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 105 | STAGING_DIR_HOST = "${RECIPE_SYSROOT}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 106 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 107 | TOOLCHAIN_OPTIONS = " --sysroot=${RECIPE_SYSROOT}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 109 | PATH:append = ":${TMPDIR}/sysroots/${HOST_ARCH}/${bindir_cross}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | PKGHIST_DIR = "${TMPDIR}/pkghistory/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}/" |
| 111 | |
| 112 | HOST_ARCH = "${SDK_ARCH}" |
| 113 | HOST_VENDOR = "${SDK_VENDOR}" |
| 114 | HOST_OS = "${SDK_OS}" |
| 115 | HOST_PREFIX = "${SDK_PREFIX}" |
| 116 | HOST_CC_ARCH = "${SDK_CC_ARCH}" |
| 117 | HOST_LD_ARCH = "${SDK_LD_ARCH}" |
| 118 | HOST_AS_ARCH = "${SDK_AS_ARCH}" |
| 119 | |
| 120 | #assign DPKG_ARCH |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 121 | DPKG_ARCH = "${@debian_arch_map(d.getVar('SDK_ARCH'), '')}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 122 | |
| 123 | CPPFLAGS = "${BUILDSDK_CPPFLAGS}" |
| 124 | CFLAGS = "${BUILDSDK_CFLAGS}" |
| 125 | CXXFLAGS = "${BUILDSDK_CFLAGS}" |
| 126 | LDFLAGS = "${BUILDSDK_LDFLAGS} \ |
| 127 | -Wl,-rpath-link,${STAGING_LIBDIR}/.. \ |
| 128 | -Wl,-rpath,${libdir}/.. " |
| 129 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 130 | # |
| 131 | # We need chrpath >= 0.14 to ensure we can deal with 32 and 64 bit |
| 132 | # binaries |
| 133 | # |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 134 | DEPENDS:append = " chrpath-replacement-native" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 158 | FILES:${PN} = "${prefix}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 159 | |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 160 | export PKG_CONFIG_DIR = "${STAGING_DIR_HOST}${exec_prefix}/lib/pkgconfig" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 172 | PKGDATA_DIR = "${PKGDATA_DIR_SDK}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 173 | # If MLPREFIX is set by multilib code, shlibs |
| 174 | # points to the wrong place so force it |
| 175 | SHLIBSDIRS = "${PKGDATA_DIR}/nativesdk-shlibs2" |
| 176 | SHLIBSWORKDIR = "${PKGDATA_DIR}/nativesdk-shlibs2" |
| 177 | |
| 178 | cross_canadian_bindirlinks () { |
| 179 | for i in linux ${CANADIANEXTRAOS} |
| 180 | do |
| 181 | for v in ${CANADIANEXTRAVENDOR} |
| 182 | do |
| 183 | d=${D}${bindir}/../${TARGET_ARCH}$v-$i |
| 184 | if [ -d $d ]; |
| 185 | then |
| 186 | continue |
| 187 | fi |
| 188 | install -d $d |
| 189 | for j in `ls ${D}${bindir}` |
| 190 | do |
| 191 | p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,` |
| 192 | ln -s ../${TARGET_SYS}/$j $d/$p |
| 193 | done |
| 194 | done |
| 195 | done |
| 196 | } |