blob: 561cc23f6837e6ef5fc736b532ca5b6bf3786b5a [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# We want native packages to be relocatable
2inherit relocatable
3
4# Native packages are built indirectly via dependency,
5# no need for them to be a direct target of 'world'
6EXCLUDE_FROM_WORLD = "1"
7
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008PACKAGE_ARCH = "${BUILD_ARCH}"
9
10# used by cmake class
11OECMAKE_RPATH = "${libdir}"
12OECMAKE_RPATH_class-native = "${libdir}"
13
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014TARGET_ARCH = "${BUILD_ARCH}"
15TARGET_OS = "${BUILD_OS}"
16TARGET_VENDOR = "${BUILD_VENDOR}"
17TARGET_PREFIX = "${BUILD_PREFIX}"
18TARGET_CC_ARCH = "${BUILD_CC_ARCH}"
19TARGET_LD_ARCH = "${BUILD_LD_ARCH}"
20TARGET_AS_ARCH = "${BUILD_AS_ARCH}"
21TARGET_CPPFLAGS = "${BUILD_CPPFLAGS}"
22TARGET_CFLAGS = "${BUILD_CFLAGS}"
23TARGET_CXXFLAGS = "${BUILD_CXXFLAGS}"
24TARGET_LDFLAGS = "${BUILD_LDFLAGS}"
25TARGET_FPU = ""
26
27HOST_ARCH = "${BUILD_ARCH}"
28HOST_OS = "${BUILD_OS}"
29HOST_VENDOR = "${BUILD_VENDOR}"
30HOST_PREFIX = "${BUILD_PREFIX}"
31HOST_CC_ARCH = "${BUILD_CC_ARCH}"
32HOST_LD_ARCH = "${BUILD_LD_ARCH}"
33HOST_AS_ARCH = "${BUILD_AS_ARCH}"
34
35CPPFLAGS = "${BUILD_CPPFLAGS}"
36CFLAGS = "${BUILD_CFLAGS}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050037CXXFLAGS = "${BUILD_CXXFLAGS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038LDFLAGS = "${BUILD_LDFLAGS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
40STAGING_BINDIR = "${STAGING_BINDIR_NATIVE}"
41STAGING_BINDIR_CROSS = "${STAGING_BINDIR_NATIVE}"
42
43# native pkg doesn't need the TOOLCHAIN_OPTIONS.
44TOOLCHAIN_OPTIONS = ""
45
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046# Don't build ptest natively
47PTEST_ENABLED = "0"
48
49# Don't use site files for native builds
50export CONFIG_SITE = "${COREBASE}/meta/site/native"
51
52# set the compiler as well. It could have been set to something else
53export CC = "${BUILD_CC}"
54export CXX = "${BUILD_CXX}"
55export FC = "${BUILD_FC}"
56export CPP = "${BUILD_CPP}"
57export LD = "${BUILD_LD}"
58export CCLD = "${BUILD_CCLD}"
59export AR = "${BUILD_AR}"
60export AS = "${BUILD_AS}"
61export RANLIB = "${BUILD_RANLIB}"
62export STRIP = "${BUILD_STRIP}"
63export NM = "${BUILD_NM}"
64
65# Path prefixes
66base_prefix = "${STAGING_DIR_NATIVE}"
67prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
68exec_prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
69
70bindir = "${STAGING_BINDIR_NATIVE}"
71sbindir = "${STAGING_SBINDIR_NATIVE}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080072base_libdir = "${STAGING_LIBDIR_NATIVE}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073libdir = "${STAGING_LIBDIR_NATIVE}"
74includedir = "${STAGING_INCDIR_NATIVE}"
75sysconfdir = "${STAGING_ETCDIR_NATIVE}"
76datadir = "${STAGING_DATADIR_NATIVE}"
77
78baselib = "lib"
79
Patrick Williamsc0f7c042017-02-23 20:41:17 -060080export lt_cv_sys_lib_dlsearch_path_spec = "${libdir} ${base_libdir} /lib /lib64 /usr/lib /usr/lib64"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081
82NATIVE_PACKAGE_PATH_SUFFIX ?= ""
83bindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Brad Bishopc342db32019-05-15 21:57:59 -040084sbindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080085base_libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
87libexecdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
88
89do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}/${STAGING_DIR_NATIVE}/"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050090do_populate_sysroot[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/${PN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091
92# Since we actually install these into situ there is no staging prefix
93STAGING_DIR_HOST = ""
94STAGING_DIR_TARGET = ""
95PKG_CONFIG_DIR = "${libdir}/pkgconfig"
96
97EXTRA_NATIVE_PKGCONFIG_PATH ?= ""
98PKG_CONFIG_PATH .= "${EXTRA_NATIVE_PKGCONFIG_PATH}"
99PKG_CONFIG_SYSROOT_DIR = ""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500100PKG_CONFIG_SYSTEM_LIBRARY_PATH[unexport] = "1"
101PKG_CONFIG_SYSTEM_INCLUDE_PATH[unexport] = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500103# we dont want libc-*libc to kick in for native recipes
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104LIBCOVERRIDE = ""
105CLASSOVERRIDE = "class-native"
106MACHINEOVERRIDES = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500107MACHINE_FEATURES = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108
109PATH_prepend = "${COREBASE}/scripts/native-intercept:"
110
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500111# This class encodes staging paths into its scripts data so can only be
112# reused if we manipulate the paths.
113SSTATE_SCAN_CMD ?= "${SSTATE_SCAN_CMD_NATIVE}"
114
Brad Bishop19323692019-04-05 15:28:33 -0400115# No strip sysroot when DEBUG_BUILD is enabled
116INHIBIT_SYSROOT_STRIP ?= "${@oe.utils.vartrue('DEBUG_BUILD', '1', '', d)}"
117
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118python native_virtclass_handler () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500119 pn = e.data.getVar("PN")
120 if not pn.endswith("-native"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121 return
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700122 bpn = e.data.getVar("BPN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124 # Set features here to prevent appends and distro features backfill
125 # from modifying native distro features
126 features = set(d.getVar("DISTRO_FEATURES_NATIVE").split())
127 filtered = set(bb.utils.filter("DISTRO_FEATURES", d.getVar("DISTRO_FEATURES_FILTER_NATIVE"), d).split())
128 d.setVar("DISTRO_FEATURES", " ".join(sorted(features | filtered)))
129
130 classextend = e.data.getVar('BBCLASSEXTEND') or ""
131 if "native" not in classextend:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500132 return
133
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600134 def map_dependencies(varname, d, suffix = "", selfref=True):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500135 if suffix:
136 varname = varname + "_" + suffix
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137 deps = d.getVar(varname)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138 if not deps:
139 return
140 deps = bb.utils.explode_deps(deps)
141 newdeps = []
142 for dep in deps:
143 if dep == pn:
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600144 if not selfref:
145 continue
146 newdeps.append(dep)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147 elif "-cross-" in dep:
148 newdeps.append(dep.replace("-cross", "-native"))
149 elif not dep.endswith("-native"):
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700150 # Replace ${PN} with ${BPN} in the dependency to make sure
151 # dependencies on, e.g., ${PN}-foo become ${BPN}-foo-native
152 # rather than ${BPN}-native-foo-native.
153 newdeps.append(dep.replace(pn, bpn) + "-native")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154 else:
155 newdeps.append(dep)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600156 d.setVar(varname, " ".join(newdeps), parsing=True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600158 map_dependencies("DEPENDS", e.data, selfref=False)
159 for pkg in e.data.getVar("PACKAGES", False).split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160 map_dependencies("RDEPENDS", e.data, pkg)
161 map_dependencies("RRECOMMENDS", e.data, pkg)
162 map_dependencies("RSUGGESTS", e.data, pkg)
163 map_dependencies("RPROVIDES", e.data, pkg)
164 map_dependencies("RREPLACES", e.data, pkg)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600165 map_dependencies("PACKAGES", e.data)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500167 provides = e.data.getVar("PROVIDES")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 nprovides = []
169 for prov in provides.split():
170 if prov.find(pn) != -1:
171 nprovides.append(prov)
172 elif not prov.endswith("-native"):
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700173 nprovides.append(prov + "-native")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174 else:
175 nprovides.append(prov)
176 e.data.setVar("PROVIDES", ' '.join(nprovides))
177
178
179}
180
181addhandler native_virtclass_handler
182native_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
183
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500184python do_addto_recipe_sysroot () {
185 bb.build.exec_func("extend_recipe_sysroot", d)
186}
187addtask addto_recipe_sysroot after do_populate_sysroot
Andrew Geissler82c905d2020-04-13 13:39:40 -0500188do_addto_recipe_sysroot[deptask] = "do_populate_sysroot"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500189
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500190inherit nopackages
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191
192do_packagedata[stamp-extra-info] = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500193
194USE_NLS = "no"
Brad Bishop19323692019-04-05 15:28:33 -0400195
196RECIPERDEPTASK = "do_populate_sysroot"
197do_populate_sysroot[rdeptask] = "${RECIPERDEPTASK}"