blob: e07b1bdb6cb3d84475499ccaa246610e68712f98 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#
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'.
10EXCLUDE_FROM_WORLD = "1"
11CLASSOVERRIDE = "class-cross-canadian"
12STAGING_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#
17PACKAGE_ARCH = "${SDK_ARCH}-${SDKPKGSUFFIX}"
18CANADIANEXTRAOS = "linux-uclibc linux-musl"
19CANADIANEXTRAVENDOR = ""
20MODIFYTOS ??= "1"
21python () {
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")
Patrick Williamsf1e5d692016-03-30 15:21:19 -050070 if tarch == "arm" or tarch == "armeb":
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 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}
86MULTIMACH_TARGET_SYS = "${PACKAGE_ARCH}${HOST_VENDOR}-${HOST_OS}"
87
88INHIBIT_DEFAULT_DEPS = "1"
89
90STAGING_DIR_HOST = "${STAGING_DIR}/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}"
91
92TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR}/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}"
93
94PATH_append = ":${TMPDIR}/sysroots/${HOST_ARCH}/${bindir_cross}"
95PKGHIST_DIR = "${TMPDIR}/pkghistory/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}/"
96
97HOST_ARCH = "${SDK_ARCH}"
98HOST_VENDOR = "${SDK_VENDOR}"
99HOST_OS = "${SDK_OS}"
100HOST_PREFIX = "${SDK_PREFIX}"
101HOST_CC_ARCH = "${SDK_CC_ARCH}"
102HOST_LD_ARCH = "${SDK_LD_ARCH}"
103HOST_AS_ARCH = "${SDK_AS_ARCH}"
104
105#assign DPKG_ARCH
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500106DPKG_ARCH = "${@debian_arch_map(d.getVar('SDK_ARCH', True), '')}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107
108CPPFLAGS = "${BUILDSDK_CPPFLAGS}"
109CFLAGS = "${BUILDSDK_CFLAGS}"
110CXXFLAGS = "${BUILDSDK_CFLAGS}"
111LDFLAGS = "${BUILDSDK_LDFLAGS} \
112 -Wl,-rpath-link,${STAGING_LIBDIR}/.. \
113 -Wl,-rpath,${libdir}/.. "
114
115DEPENDS_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#
121DEPENDS_append = " chrpath-replacement-native"
122EXTRANATIVEPATH += "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.
127target_base_prefix := "${base_prefix}"
128target_prefix := "${prefix}"
129target_exec_prefix := "${exec_prefix}"
130target_base_libdir = "${target_base_prefix}/${baselib}"
131target_libdir = "${target_exec_prefix}/${baselib}"
132target_includedir := "${includedir}"
133
134# Change to place files in SDKPATH
135base_prefix = "${SDKPATHNATIVE}"
136prefix = "${SDKPATHNATIVE}${prefix_nativesdk}"
137exec_prefix = "${SDKPATHNATIVE}${prefix_nativesdk}"
138bindir = "${exec_prefix}/bin/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
139sbindir = "${bindir}"
140base_bindir = "${bindir}"
141base_sbindir = "${bindir}"
142libdir = "${exec_prefix}/lib/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
143libexecdir = "${exec_prefix}/libexec/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
144
145FILES_${PN} = "${prefix}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500146
147export PKG_CONFIG_DIR = "${STAGING_DIR_HOST}${layout_libdir}/pkgconfig"
148export PKG_CONFIG_SYSROOT_DIR = "${STAGING_DIR_HOST}"
149
150do_populate_sysroot[stamp-extra-info] = ""
151do_packagedata[stamp-extra-info] = ""
152
153USE_NLS = "${SDKUSE_NLS}"
154
155# We have to us TARGET_ARCH but we care about the absolute value
156# and not any particular tune that is enabled.
157TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
158
159# If MLPREFIX is set by multilib code, shlibs
160# points to the wrong place so force it
161SHLIBSDIRS = "${PKGDATA_DIR}/nativesdk-shlibs2"
162SHLIBSWORKDIR = "${PKGDATA_DIR}/nativesdk-shlibs2"
163
164cross_canadian_bindirlinks () {
165 for i in linux ${CANADIANEXTRAOS}
166 do
167 for v in ${CANADIANEXTRAVENDOR}
168 do
169 d=${D}${bindir}/../${TARGET_ARCH}$v-$i
170 if [ -d $d ];
171 then
172 continue
173 fi
174 install -d $d
175 for j in `ls ${D}${bindir}`
176 do
177 p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
178 ln -s ../${TARGET_SYS}/$j $d/$p
179 done
180 done
181 done
182}