summaryrefslogtreecommitdiffstats
path: root/meta/classes/native.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/native.bbclass')
-rw-r--r--meta/classes/native.bbclass164
1 files changed, 164 insertions, 0 deletions
diff --git a/meta/classes/native.bbclass b/meta/classes/native.bbclass
new file mode 100644
index 0000000..5a318d2
--- /dev/null
+++ b/meta/classes/native.bbclass
@@ -0,0 +1,164 @@
1# 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
8PACKAGES = ""
9PACKAGES_class-native = ""
10PACKAGES_DYNAMIC = ""
11PACKAGES_DYNAMIC_class-native = ""
12PACKAGE_ARCH = "${BUILD_ARCH}"
13
14# used by cmake class
15OECMAKE_RPATH = "${libdir}"
16OECMAKE_RPATH_class-native = "${libdir}"
17
18# When this class has packaging enabled, setting
19# RPROVIDES becomes unnecessary.
20RPROVIDES = "${PN}"
21
22TARGET_ARCH = "${BUILD_ARCH}"
23TARGET_OS = "${BUILD_OS}"
24TARGET_VENDOR = "${BUILD_VENDOR}"
25TARGET_PREFIX = "${BUILD_PREFIX}"
26TARGET_CC_ARCH = "${BUILD_CC_ARCH}"
27TARGET_LD_ARCH = "${BUILD_LD_ARCH}"
28TARGET_AS_ARCH = "${BUILD_AS_ARCH}"
29TARGET_FPU = ""
30
31HOST_ARCH = "${BUILD_ARCH}"
32HOST_OS = "${BUILD_OS}"
33HOST_VENDOR = "${BUILD_VENDOR}"
34HOST_PREFIX = "${BUILD_PREFIX}"
35HOST_CC_ARCH = "${BUILD_CC_ARCH}"
36HOST_LD_ARCH = "${BUILD_LD_ARCH}"
37HOST_AS_ARCH = "${BUILD_AS_ARCH}"
38
39CPPFLAGS = "${BUILD_CPPFLAGS}"
40CFLAGS = "${BUILD_CFLAGS}"
41CXXFLAGS = "${BUILD_CFLAGS}"
42LDFLAGS = "${BUILD_LDFLAGS}"
43LDFLAGS_build-darwin = "-L${STAGING_LIBDIR_NATIVE} "
44
45STAGING_BINDIR = "${STAGING_BINDIR_NATIVE}"
46STAGING_BINDIR_CROSS = "${STAGING_BINDIR_NATIVE}"
47
48# native pkg doesn't need the TOOLCHAIN_OPTIONS.
49TOOLCHAIN_OPTIONS = ""
50
51DEPENDS_GETTEXT = "gettext-native"
52
53# Don't build ptest natively
54PTEST_ENABLED = "0"
55
56# Don't use site files for native builds
57export CONFIG_SITE = "${COREBASE}/meta/site/native"
58
59# set the compiler as well. It could have been set to something else
60export CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
61export CXX = "${CCACHE}${HOST_PREFIX}g++ ${HOST_CC_ARCH}"
62export FC = "${CCACHE}${HOST_PREFIX}gfortran ${HOST_CC_ARCH}"
63export CPP = "${HOST_PREFIX}gcc ${HOST_CC_ARCH} -E"
64export LD = "${HOST_PREFIX}ld ${HOST_LD_ARCH} "
65export CCLD = "${CC}"
66export AR = "${HOST_PREFIX}ar"
67export AS = "${HOST_PREFIX}as ${HOST_AS_ARCH}"
68export RANLIB = "${HOST_PREFIX}ranlib"
69export STRIP = "${HOST_PREFIX}strip"
70
71# Path prefixes
72base_prefix = "${STAGING_DIR_NATIVE}"
73prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
74exec_prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
75
76libdir = "${STAGING_DIR_NATIVE}${libdir_native}"
77
78baselib = "lib"
79
80# Libtool's default paths are correct for the native machine
81lt_cv_sys_lib_dlsearch_path_spec[unexport] = "1"
82
83NATIVE_PACKAGE_PATH_SUFFIX ?= ""
84bindir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
85libdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
86libexecdir .= "${NATIVE_PACKAGE_PATH_SUFFIX}"
87
88do_populate_sysroot[sstate-inputdirs] = "${SYSROOT_DESTDIR}/${STAGING_DIR_NATIVE}/"
89do_populate_sysroot[sstate-outputdirs] = "${STAGING_DIR_NATIVE}/"
90
91# Since we actually install these into situ there is no staging prefix
92STAGING_DIR_HOST = ""
93STAGING_DIR_TARGET = ""
94PKG_CONFIG_DIR = "${libdir}/pkgconfig"
95
96EXTRA_NATIVE_PKGCONFIG_PATH ?= ""
97PKG_CONFIG_PATH .= "${EXTRA_NATIVE_PKGCONFIG_PATH}"
98PKG_CONFIG_SYSROOT_DIR = ""
99
100# we dont want libc-uclibc or libc-glibc to kick in for native recipes
101LIBCOVERRIDE = ""
102CLASSOVERRIDE = "class-native"
103
104PATH_prepend = "${COREBASE}/scripts/native-intercept:"
105
106python native_virtclass_handler () {
107 classextend = e.data.getVar('BBCLASSEXTEND', True) or ""
108 if "native" not in classextend:
109 return
110
111 pn = e.data.getVar("PN", True)
112 if not pn.endswith("-native"):
113 return
114
115 def map_dependencies(varname, d, suffix = ""):
116 if suffix:
117 varname = varname + "_" + suffix
118 deps = d.getVar(varname, True)
119 if not deps:
120 return
121 deps = bb.utils.explode_deps(deps)
122 newdeps = []
123 for dep in deps:
124 if dep.endswith("-cross"):
125 newdeps.append(dep.replace("-cross", "-native"))
126 elif not dep.endswith("-native"):
127 newdeps.append(dep + "-native")
128 else:
129 newdeps.append(dep)
130 d.setVar(varname, " ".join(newdeps))
131
132 map_dependencies("DEPENDS", e.data)
133 for pkg in [e.data.getVar("PN", True), "", "${PN}"]:
134 map_dependencies("RDEPENDS", e.data, pkg)
135 map_dependencies("RRECOMMENDS", e.data, pkg)
136 map_dependencies("RSUGGESTS", e.data, pkg)
137 map_dependencies("RPROVIDES", e.data, pkg)
138 map_dependencies("RREPLACES", e.data, pkg)
139
140 provides = e.data.getVar("PROVIDES", True)
141 for prov in provides.split():
142 if prov.find(pn) != -1:
143 continue
144 if not prov.endswith("-native"):
145 provides = provides.replace(prov, prov + "-native")
146 e.data.setVar("PROVIDES", provides)
147
148 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + ":virtclass-native")
149}
150
151addhandler native_virtclass_handler
152native_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
153
154deltask package
155deltask packagedata
156deltask package_write_ipk
157deltask package_write_deb
158deltask package_write_rpm
159deltask package_write
160
161do_packagedata[stamp-extra-info] = ""
162do_populate_sysroot[stamp-extra-info] = ""
163
164USE_NLS = "no"