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