blob: ffbc2167e3953b8c2a23ba9b5d9e58e9a63d682e [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"
Brad Bishop19323692019-04-05 15:28:33 -040011NATIVESDKLIBC ?= "libc-glibc"
12LIBCOVERRIDE = ":${NATIVESDKLIBC}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013CLASSOVERRIDE = "class-cross-canadian"
14STAGING_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#
19PACKAGE_ARCH = "${SDK_ARCH}-${SDKPKGSUFFIX}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020BASECANADIANEXTRAOS ?= "linux-musl"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021CANADIANEXTRAOS = "${BASECANADIANEXTRAOS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022CANADIANEXTRAVENDOR = ""
23MODIFYTOS ??= "1"
24python () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 archs = d.getVar('PACKAGE_ARCHS').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 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 Bishop6e60e8b2018-02-01 10:27:11 -050032 if d.getVar("MODIFYTOS") != "1":
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 return
34
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035 if d.getVar("TCLIBC") in [ 'baremetal', 'newlib' ]:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036 return
37
Brad Bishop6e60e8b2018-02-01 10:27:11 -050038 tos = d.getVar("TARGET_OS")
Andrew Geisslerc926e172021-05-07 16:11:35 -050039 whitelist = ["mingw32"]
Patrick Williamsc0f7c042017-02-23 20:41:17 -060040 extralibcs = [""]
Brad Bishop6e60e8b2018-02-01 10:27:11 -050041 if "musl" in d.getVar("BASECANADIANEXTRAOS"):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042 extralibcs.append("musl")
Andrew Geissler5199d832021-09-24 16:47:35 -050043 if "android" in tos:
44 extralibcs.append("android")
Brad Bishop316dfdd2018-06-25 12:45:53 -040045 for variant in ["", "spe", "x32", "eabi", "n32", "_ilp32"]:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060046 for libc in extralibcs:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047 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
54 whitelist.append(entry)
55 if tos not in whitelist:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050056 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 -050057
58 for n in ["PROVIDES", "DEPENDS"]:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050059 d.setVar(n, d.getVar(n))
60 d.setVar("STAGING_BINDIR_TOOLCHAIN", d.getVar("STAGING_BINDIR_TOOLCHAIN"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 for prefix in ["AR", "AS", "DLLTOOL", "CC", "CXX", "GCC", "LD", "LIPO", "NM", "OBJDUMP", "RANLIB", "STRIP", "WINDRES"]:
62 n = prefix + "_FOR_TARGET"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063 d.setVar(n, d.getVar(n))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064 # 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 Bishop6e60e8b2018-02-01 10:27:11 -050066 tarch = d.getVar("TARGET_ARCH")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 if tarch == "x86_64":
68 d.setVar("LIBCEXTENSION", "")
69 d.setVar("ABIEXTENSION", "")
Patrick Williamsc0f7c042017-02-23 20:41:17 -060070 d.appendVar("CANADIANEXTRAOS", " linux-gnux32")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050071 for extraos in d.getVar("BASECANADIANEXTRAOS").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060072 d.appendVar("CANADIANEXTRAOS", " " + extraos + "x32")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 elif tarch == "powerpc":
74 # PowerPC can build "linux" and "linux-gnuspe"
75 d.setVar("LIBCEXTENSION", "")
76 d.setVar("ABIEXTENSION", "")
Patrick Williamsc0f7c042017-02-23 20:41:17 -060077 d.appendVar("CANADIANEXTRAOS", " linux-gnuspe")
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 + "spe")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080 elif tarch == "mips64":
Patrick Williamsc0f7c042017-02-23 20:41:17 -060081 d.appendVar("CANADIANEXTRAOS", " linux-gnun32")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050082 for extraos in d.getVar("BASECANADIANEXTRAOS").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060083 d.appendVar("CANADIANEXTRAOS", " " + extraos + "n32")
Patrick Williamsf1e5d692016-03-30 15:21:19 -050084 if tarch == "arm" or tarch == "armeb":
Brad Bishopd7bf8c12018-02-25 22:55:05 -050085 d.appendVar("CANADIANEXTRAOS", " linux-gnueabi linux-musleabi")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086 d.setVar("TARGET_OS", "linux-gnueabi")
87 else:
88 d.setVar("TARGET_OS", "linux")
89
90 # Also need to handle multilib target vendors
Brad Bishop6e60e8b2018-02-01 10:27:11 -050091 vendors = d.getVar("CANADIANEXTRAVENDOR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092 if not vendors:
93 vendors = all_multilib_tune_values(d, 'TARGET_VENDOR')
Brad Bishop6e60e8b2018-02-01 10:27:11 -050094 origvendor = d.getVar("TARGET_VENDOR_MULTILIB_ORIGINAL")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 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}
101MULTIMACH_TARGET_SYS = "${PACKAGE_ARCH}${HOST_VENDOR}-${HOST_OS}"
102
103INHIBIT_DEFAULT_DEPS = "1"
104
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500105STAGING_DIR_HOST = "${RECIPE_SYSROOT}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500106
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500107TOOLCHAIN_OPTIONS = " --sysroot=${RECIPE_SYSROOT}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108
Patrick Williams213cb262021-08-07 19:21:33 -0500109PATH:append = ":${TMPDIR}/sysroots/${HOST_ARCH}/${bindir_cross}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110PKGHIST_DIR = "${TMPDIR}/pkghistory/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}/"
111
112HOST_ARCH = "${SDK_ARCH}"
113HOST_VENDOR = "${SDK_VENDOR}"
114HOST_OS = "${SDK_OS}"
115HOST_PREFIX = "${SDK_PREFIX}"
116HOST_CC_ARCH = "${SDK_CC_ARCH}"
117HOST_LD_ARCH = "${SDK_LD_ARCH}"
118HOST_AS_ARCH = "${SDK_AS_ARCH}"
119
120#assign DPKG_ARCH
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500121DPKG_ARCH = "${@debian_arch_map(d.getVar('SDK_ARCH'), '')}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122
123CPPFLAGS = "${BUILDSDK_CPPFLAGS}"
124CFLAGS = "${BUILDSDK_CFLAGS}"
125CXXFLAGS = "${BUILDSDK_CFLAGS}"
126LDFLAGS = "${BUILDSDK_LDFLAGS} \
127 -Wl,-rpath-link,${STAGING_LIBDIR}/.. \
128 -Wl,-rpath,${libdir}/.. "
129
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130#
131# We need chrpath >= 0.14 to ensure we can deal with 32 and 64 bit
132# binaries
133#
Patrick Williams213cb262021-08-07 19:21:33 -0500134DEPENDS:append = " chrpath-replacement-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500135EXTRANATIVEPATH += "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.
140target_base_prefix := "${base_prefix}"
141target_prefix := "${prefix}"
142target_exec_prefix := "${exec_prefix}"
143target_base_libdir = "${target_base_prefix}/${baselib}"
144target_libdir = "${target_exec_prefix}/${baselib}"
145target_includedir := "${includedir}"
146
147# Change to place files in SDKPATH
148base_prefix = "${SDKPATHNATIVE}"
149prefix = "${SDKPATHNATIVE}${prefix_nativesdk}"
150exec_prefix = "${SDKPATHNATIVE}${prefix_nativesdk}"
151bindir = "${exec_prefix}/bin/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
152sbindir = "${bindir}"
153base_bindir = "${bindir}"
154base_sbindir = "${bindir}"
155libdir = "${exec_prefix}/lib/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
156libexecdir = "${exec_prefix}/libexec/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
157
Patrick Williams213cb262021-08-07 19:21:33 -0500158FILES:${PN} = "${prefix}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159
Andrew Geissler09036742021-06-25 14:25:14 -0500160export PKG_CONFIG_DIR = "${STAGING_DIR_HOST}${exec_prefix}/lib/pkgconfig"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500161export PKG_CONFIG_SYSROOT_DIR = "${STAGING_DIR_HOST}"
162
163do_populate_sysroot[stamp-extra-info] = ""
164do_packagedata[stamp-extra-info] = ""
165
166USE_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.
170TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
171
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500172PKGDATA_DIR = "${TMPDIR}/pkgdata/${SDK_SYS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173# If MLPREFIX is set by multilib code, shlibs
174# points to the wrong place so force it
175SHLIBSDIRS = "${PKGDATA_DIR}/nativesdk-shlibs2"
176SHLIBSWORKDIR = "${PKGDATA_DIR}/nativesdk-shlibs2"
177
178cross_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}