blob: 1928455cf7ab33335704229289216f4de087846b [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}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018BASECANADIANEXTRAOS ?= "linux-musl"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019CANADIANEXTRAOS = "${BASECANADIANEXTRAOS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020CANADIANEXTRAVENDOR = ""
21MODIFYTOS ??= "1"
22python () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 archs = d.getVar('PACKAGE_ARCHS').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 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 Bishop6e60e8b2018-02-01 10:27:11 -050030 if d.getVar("MODIFYTOS") != "1":
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 return
32
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033 if d.getVar("TCLIBC") == "baremetal":
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 return
35
Brad Bishop6e60e8b2018-02-01 10:27:11 -050036 tos = d.getVar("TARGET_OS")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 whitelist = []
Patrick Williamsc0f7c042017-02-23 20:41:17 -060038 extralibcs = [""]
Brad Bishop6e60e8b2018-02-01 10:27:11 -050039 if "musl" in d.getVar("BASECANADIANEXTRAOS"):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060040 extralibcs.append("musl")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041 for variant in ["", "spe", "x32", "eabi", "n32", "ilp32"]:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042 for libc in extralibcs:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043 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 Bishop6e60e8b2018-02-01 10:27:11 -050052 bb.fatal("Building cross-candian for an unknown TARGET_SYS (%s), please update cross-canadian.bbclass" % d.getVar("TARGET_SYS"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053
54 for n in ["PROVIDES", "DEPENDS"]:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050055 d.setVar(n, d.getVar(n))
56 d.setVar("STAGING_BINDIR_TOOLCHAIN", d.getVar("STAGING_BINDIR_TOOLCHAIN"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057 for prefix in ["AR", "AS", "DLLTOOL", "CC", "CXX", "GCC", "LD", "LIPO", "NM", "OBJDUMP", "RANLIB", "STRIP", "WINDRES"]:
58 n = prefix + "_FOR_TARGET"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050059 d.setVar(n, d.getVar(n))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 # 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 Bishop6e60e8b2018-02-01 10:27:11 -050062 tarch = d.getVar("TARGET_ARCH")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 if tarch == "x86_64":
64 d.setVar("LIBCEXTENSION", "")
65 d.setVar("ABIEXTENSION", "")
Patrick Williamsc0f7c042017-02-23 20:41:17 -060066 d.appendVar("CANADIANEXTRAOS", " linux-gnux32")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050067 for extraos in d.getVar("BASECANADIANEXTRAOS").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060068 d.appendVar("CANADIANEXTRAOS", " " + extraos + "x32")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069 elif tarch == "powerpc":
70 # PowerPC can build "linux" and "linux-gnuspe"
71 d.setVar("LIBCEXTENSION", "")
72 d.setVar("ABIEXTENSION", "")
Patrick Williamsc0f7c042017-02-23 20:41:17 -060073 d.appendVar("CANADIANEXTRAOS", " linux-gnuspe")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074 for extraos in d.getVar("BASECANADIANEXTRAOS").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060075 d.appendVar("CANADIANEXTRAOS", " " + extraos + "spe")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050076 elif tarch == "mips64":
Patrick Williamsc0f7c042017-02-23 20:41:17 -060077 d.appendVar("CANADIANEXTRAOS", " linux-gnun32")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050078 for extraos in d.getVar("BASECANADIANEXTRAOS").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060079 d.appendVar("CANADIANEXTRAOS", " " + extraos + "n32")
Patrick Williamsf1e5d692016-03-30 15:21:19 -050080 if tarch == "arm" or tarch == "armeb":
Brad Bishopd7bf8c12018-02-25 22:55:05 -050081 d.appendVar("CANADIANEXTRAOS", " linux-gnueabi linux-musleabi")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082 d.setVar("TARGET_OS", "linux-gnueabi")
83 else:
84 d.setVar("TARGET_OS", "linux")
85
86 # Also need to handle multilib target vendors
Brad Bishop6e60e8b2018-02-01 10:27:11 -050087 vendors = d.getVar("CANADIANEXTRAVENDOR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 if not vendors:
89 vendors = all_multilib_tune_values(d, 'TARGET_VENDOR')
Brad Bishop6e60e8b2018-02-01 10:27:11 -050090 origvendor = d.getVar("TARGET_VENDOR_MULTILIB_ORIGINAL")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091 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}
97MULTIMACH_TARGET_SYS = "${PACKAGE_ARCH}${HOST_VENDOR}-${HOST_OS}"
98
99INHIBIT_DEFAULT_DEPS = "1"
100
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500101STAGING_DIR_HOST = "${RECIPE_SYSROOT}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500103TOOLCHAIN_OPTIONS = " --sysroot=${RECIPE_SYSROOT}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104
105PATH_append = ":${TMPDIR}/sysroots/${HOST_ARCH}/${bindir_cross}"
106PKGHIST_DIR = "${TMPDIR}/pkghistory/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}/"
107
108HOST_ARCH = "${SDK_ARCH}"
109HOST_VENDOR = "${SDK_VENDOR}"
110HOST_OS = "${SDK_OS}"
111HOST_PREFIX = "${SDK_PREFIX}"
112HOST_CC_ARCH = "${SDK_CC_ARCH}"
113HOST_LD_ARCH = "${SDK_LD_ARCH}"
114HOST_AS_ARCH = "${SDK_AS_ARCH}"
115
116#assign DPKG_ARCH
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500117DPKG_ARCH = "${@debian_arch_map(d.getVar('SDK_ARCH'), '')}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118
119CPPFLAGS = "${BUILDSDK_CPPFLAGS}"
120CFLAGS = "${BUILDSDK_CFLAGS}"
121CXXFLAGS = "${BUILDSDK_CFLAGS}"
122LDFLAGS = "${BUILDSDK_LDFLAGS} \
123 -Wl,-rpath-link,${STAGING_LIBDIR}/.. \
124 -Wl,-rpath,${libdir}/.. "
125
126DEPENDS_GETTEXT = "gettext-native nativesdk-gettext"
127
128#
129# We need chrpath >= 0.14 to ensure we can deal with 32 and 64 bit
130# binaries
131#
132DEPENDS_append = " chrpath-replacement-native"
133EXTRANATIVEPATH += "chrpath-native"
134
135# Path mangling needed by the cross packaging
136# Note that we use := here to ensure that libdir and includedir are
137# target paths.
138target_base_prefix := "${base_prefix}"
139target_prefix := "${prefix}"
140target_exec_prefix := "${exec_prefix}"
141target_base_libdir = "${target_base_prefix}/${baselib}"
142target_libdir = "${target_exec_prefix}/${baselib}"
143target_includedir := "${includedir}"
144
145# Change to place files in SDKPATH
146base_prefix = "${SDKPATHNATIVE}"
147prefix = "${SDKPATHNATIVE}${prefix_nativesdk}"
148exec_prefix = "${SDKPATHNATIVE}${prefix_nativesdk}"
149bindir = "${exec_prefix}/bin/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
150sbindir = "${bindir}"
151base_bindir = "${bindir}"
152base_sbindir = "${bindir}"
153libdir = "${exec_prefix}/lib/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
154libexecdir = "${exec_prefix}/libexec/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
155
156FILES_${PN} = "${prefix}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157
158export PKG_CONFIG_DIR = "${STAGING_DIR_HOST}${layout_libdir}/pkgconfig"
159export PKG_CONFIG_SYSROOT_DIR = "${STAGING_DIR_HOST}"
160
161do_populate_sysroot[stamp-extra-info] = ""
162do_packagedata[stamp-extra-info] = ""
163
164USE_NLS = "${SDKUSE_NLS}"
165
166# We have to us TARGET_ARCH but we care about the absolute value
167# and not any particular tune that is enabled.
168TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
169
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500170PKGDATA_DIR = "${TMPDIR}/pkgdata/${SDK_SYS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171# If MLPREFIX is set by multilib code, shlibs
172# points to the wrong place so force it
173SHLIBSDIRS = "${PKGDATA_DIR}/nativesdk-shlibs2"
174SHLIBSWORKDIR = "${PKGDATA_DIR}/nativesdk-shlibs2"
175
176cross_canadian_bindirlinks () {
177 for i in linux ${CANADIANEXTRAOS}
178 do
179 for v in ${CANADIANEXTRAVENDOR}
180 do
181 d=${D}${bindir}/../${TARGET_ARCH}$v-$i
182 if [ -d $d ];
183 then
184 continue
185 fi
186 install -d $d
187 for j in `ls ${D}${bindir}`
188 do
189 p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
190 ln -s ../${TARGET_SYS}/$j $d/$p
191 done
192 done
193 done
194}