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