blob: 49388d4cf2370e6c6e5622c5e72f7167ad3830ed [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}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060018BASECANADIANEXTRAOS ?= "linux-uclibc linux-musl"
19CANADIANEXTRAOS = "${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 "uclibc" in d.getVar("BASECANADIANEXTRAOS"):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060040 extralibcs.append("uclibc")
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")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043 for variant in ["", "spe", "x32", "eabi", "n32"]:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044 for libc in extralibcs:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045 entry = "linux"
46 if variant and libc:
47 entry = entry + "-" + libc + variant
48 elif variant:
49 entry = entry + "-gnu" + variant
50 elif libc:
51 entry = entry + "-" + libc
52 whitelist.append(entry)
53 if tos not in whitelist:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054 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 -050055
56 for n in ["PROVIDES", "DEPENDS"]:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057 d.setVar(n, d.getVar(n))
58 d.setVar("STAGING_BINDIR_TOOLCHAIN", d.getVar("STAGING_BINDIR_TOOLCHAIN"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 for prefix in ["AR", "AS", "DLLTOOL", "CC", "CXX", "GCC", "LD", "LIPO", "NM", "OBJDUMP", "RANLIB", "STRIP", "WINDRES"]:
60 n = prefix + "_FOR_TARGET"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050061 d.setVar(n, d.getVar(n))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062 # This is a bit ugly. We need to zero LIBC/ABI extension which will change TARGET_OS
63 # however we need the old value in some variables. We expand those here first.
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064 tarch = d.getVar("TARGET_ARCH")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065 if tarch == "x86_64":
66 d.setVar("LIBCEXTENSION", "")
67 d.setVar("ABIEXTENSION", "")
Patrick Williamsc0f7c042017-02-23 20:41:17 -060068 d.appendVar("CANADIANEXTRAOS", " linux-gnux32")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050069 for extraos in d.getVar("BASECANADIANEXTRAOS").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060070 d.appendVar("CANADIANEXTRAOS", " " + extraos + "x32")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 elif tarch == "powerpc":
72 # PowerPC can build "linux" and "linux-gnuspe"
73 d.setVar("LIBCEXTENSION", "")
74 d.setVar("ABIEXTENSION", "")
Patrick Williamsc0f7c042017-02-23 20:41:17 -060075 d.appendVar("CANADIANEXTRAOS", " linux-gnuspe")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050076 for extraos in d.getVar("BASECANADIANEXTRAOS").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060077 d.appendVar("CANADIANEXTRAOS", " " + extraos + "spe")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078 elif tarch == "mips64":
Patrick Williamsc0f7c042017-02-23 20:41:17 -060079 d.appendVar("CANADIANEXTRAOS", " linux-gnun32")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050080 for extraos in d.getVar("BASECANADIANEXTRAOS").split():
Patrick Williamsc0f7c042017-02-23 20:41:17 -060081 d.appendVar("CANADIANEXTRAOS", " " + extraos + "n32")
Patrick Williamsf1e5d692016-03-30 15:21:19 -050082 if tarch == "arm" or tarch == "armeb":
Patrick Williamsc0f7c042017-02-23 20:41:17 -060083 d.appendVar("CANADIANEXTRAOS", " linux-gnueabi linux-musleabi linux-uclibceabi")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 d.setVar("TARGET_OS", "linux-gnueabi")
85 else:
86 d.setVar("TARGET_OS", "linux")
87
88 # Also need to handle multilib target vendors
Brad Bishop6e60e8b2018-02-01 10:27:11 -050089 vendors = d.getVar("CANADIANEXTRAVENDOR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090 if not vendors:
91 vendors = all_multilib_tune_values(d, 'TARGET_VENDOR')
Brad Bishop6e60e8b2018-02-01 10:27:11 -050092 origvendor = d.getVar("TARGET_VENDOR_MULTILIB_ORIGINAL")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093 if origvendor:
94 d.setVar("TARGET_VENDOR", origvendor)
95 if origvendor not in vendors.split():
96 vendors = origvendor + " " + vendors
97 d.setVar("CANADIANEXTRAVENDOR", vendors)
98}
99MULTIMACH_TARGET_SYS = "${PACKAGE_ARCH}${HOST_VENDOR}-${HOST_OS}"
100
101INHIBIT_DEFAULT_DEPS = "1"
102
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500103STAGING_DIR_HOST = "${RECIPE_SYSROOT}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500105TOOLCHAIN_OPTIONS = " --sysroot=${RECIPE_SYSROOT}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500106
107PATH_append = ":${TMPDIR}/sysroots/${HOST_ARCH}/${bindir_cross}"
108PKGHIST_DIR = "${TMPDIR}/pkghistory/${HOST_ARCH}-${SDKPKGSUFFIX}${HOST_VENDOR}-${HOST_OS}/"
109
110HOST_ARCH = "${SDK_ARCH}"
111HOST_VENDOR = "${SDK_VENDOR}"
112HOST_OS = "${SDK_OS}"
113HOST_PREFIX = "${SDK_PREFIX}"
114HOST_CC_ARCH = "${SDK_CC_ARCH}"
115HOST_LD_ARCH = "${SDK_LD_ARCH}"
116HOST_AS_ARCH = "${SDK_AS_ARCH}"
117
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500118TARGET_CPPFLAGS = "${BUILDSDK_CPPFLAGS}"
119TARGET_CFLAGS = "${BUILDSDK_CFLAGS}"
120TARGET_CXXFLAGS = "${BUILDSDK_CXXFLAGS}"
121TARGET_LDFLAGS = "${BUILDSDK_LDFLAGS}"
122
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123#assign DPKG_ARCH
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124DPKG_ARCH = "${@debian_arch_map(d.getVar('SDK_ARCH'), '')}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125
126CPPFLAGS = "${BUILDSDK_CPPFLAGS}"
127CFLAGS = "${BUILDSDK_CFLAGS}"
128CXXFLAGS = "${BUILDSDK_CFLAGS}"
129LDFLAGS = "${BUILDSDK_LDFLAGS} \
130 -Wl,-rpath-link,${STAGING_LIBDIR}/.. \
131 -Wl,-rpath,${libdir}/.. "
132
133DEPENDS_GETTEXT = "gettext-native nativesdk-gettext"
134
135#
136# We need chrpath >= 0.14 to ensure we can deal with 32 and 64 bit
137# binaries
138#
139DEPENDS_append = " chrpath-replacement-native"
140EXTRANATIVEPATH += "chrpath-native"
141
142# Path mangling needed by the cross packaging
143# Note that we use := here to ensure that libdir and includedir are
144# target paths.
145target_base_prefix := "${base_prefix}"
146target_prefix := "${prefix}"
147target_exec_prefix := "${exec_prefix}"
148target_base_libdir = "${target_base_prefix}/${baselib}"
149target_libdir = "${target_exec_prefix}/${baselib}"
150target_includedir := "${includedir}"
151
152# Change to place files in SDKPATH
153base_prefix = "${SDKPATHNATIVE}"
154prefix = "${SDKPATHNATIVE}${prefix_nativesdk}"
155exec_prefix = "${SDKPATHNATIVE}${prefix_nativesdk}"
156bindir = "${exec_prefix}/bin/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
157sbindir = "${bindir}"
158base_bindir = "${bindir}"
159base_sbindir = "${bindir}"
160libdir = "${exec_prefix}/lib/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
161libexecdir = "${exec_prefix}/libexec/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}"
162
163FILES_${PN} = "${prefix}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164
165export PKG_CONFIG_DIR = "${STAGING_DIR_HOST}${layout_libdir}/pkgconfig"
166export PKG_CONFIG_SYSROOT_DIR = "${STAGING_DIR_HOST}"
167
168do_populate_sysroot[stamp-extra-info] = ""
169do_packagedata[stamp-extra-info] = ""
170
171USE_NLS = "${SDKUSE_NLS}"
172
173# We have to us TARGET_ARCH but we care about the absolute value
174# and not any particular tune that is enabled.
175TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
176
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500177PKGDATA_DIR = "${TMPDIR}/pkgdata/${SDK_SYS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178# If MLPREFIX is set by multilib code, shlibs
179# points to the wrong place so force it
180SHLIBSDIRS = "${PKGDATA_DIR}/nativesdk-shlibs2"
181SHLIBSWORKDIR = "${PKGDATA_DIR}/nativesdk-shlibs2"
182
183cross_canadian_bindirlinks () {
184 for i in linux ${CANADIANEXTRAOS}
185 do
186 for v in ${CANADIANEXTRAVENDOR}
187 do
188 d=${D}${bindir}/../${TARGET_ARCH}$v-$i
189 if [ -d $d ];
190 then
191 continue
192 fi
193 install -d $d
194 for j in `ls ${D}${bindir}`
195 do
196 p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
197 ln -s ../${TARGET_SYS}/$j $d/$p
198 done
199 done
200 done
201}