samba: Switch to patchdir rather than applying in do_configure
[openembedded.git] / classes / native.bbclass
1 # We want native packages to be relocatable
2 inherit relocatable
3
4 # Native packages are built indirectly via dependency,
5 # no need for them to be a direct target of 'world'
6 EXCLUDE_FROM_WORLD = "1"
7
8 PACKAGES = ""
9 PACKAGES_virtclass-native = ""
10 PACKAGES_DYNAMIC = ""
11 PACKAGES_DYNAMIC_virtclass-native = ""
12 PACKAGE_ARCH = "${BUILD_ARCH}"
13
14 BASE_PACKAGE_ARCH = "${BUILD_ARCH}"
15 BASEPKG_HOST_SYS = "${BUILD_ARCH}${BUILD_VENDOR}-${BUILD_OS}"
16 BASEPKG_TARGET_SYS = "${BUILD_ARCH}${BUILD_VENDOR}-${BUILD_OS}"
17
18 # When this class has packaging enabled, setting 
19 # RPROVIDES becomes unnecessary.
20 RPROVIDES = "${PN}"
21
22 TARGET_ARCH = "${BUILD_ARCH}"
23 TARGET_OS = "${BUILD_OS}"
24 TARGET_VENDOR = "${BUILD_VENDOR}"
25 TARGET_PREFIX = "${BUILD_PREFIX}"
26 TARGET_CC_ARCH = "${BUILD_CC_ARCH}"
27 TARGET_EXEEXT = "${BUILD_EXEEXT}"
28
29 HOST_ARCH = "${BUILD_ARCH}"
30 HOST_OS = "${BUILD_OS}"
31 HOST_VENDOR = "${BUILD_VENDOR}"
32 HOST_PREFIX = "${BUILD_PREFIX}"
33 HOST_CC_ARCH = "${BUILD_CC_ARCH}"
34 HOST_EXEEXT = "${BUILD_EXEEXT}"
35
36 CPPFLAGS = "${BUILD_CPPFLAGS}"
37 CFLAGS = "${BUILD_CFLAGS}"
38 CXXFLAGS = "${BUILD_CFLAGS}"
39 LDFLAGS = "${BUILD_LDFLAGS}"
40 LDFLAGS_build-darwin = "-L${STAGING_LIBDIR_NATIVE} "
41
42 TOOLCHAIN_OPTIONS = ""
43
44 STAGING_BINDIR = "${STAGING_BINDIR_NATIVE}"
45 STAGING_BINDIR_CROSS = "${STAGING_BINDIR_NATIVE}"
46
47 STAGING_DIR_JAVA = "${STAGING_DATADIR_JAVA_NATIVE}"
48 DEPENDS_GETTEXT = "gettext-native"
49
50 # Don't use site files for native builds
51 export CONFIG_SITE = ""
52
53 # set the compiler as well. It could have been set to something else
54 export CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
55 export CXX = "${CCACHE}${HOST_PREFIX}g++ ${HOST_CC_ARCH}"
56 export F77 = "${CCACHE}${HOST_PREFIX}g77 ${HOST_CC_ARCH}"
57 export CPP = "${HOST_PREFIX}gcc -E"
58 export LD = "${HOST_PREFIX}ld"
59 export CCLD = "${CC}"
60 export AR = "${HOST_PREFIX}ar"
61 export AS = "${HOST_PREFIX}as"
62 export RANLIB = "${HOST_PREFIX}ranlib"
63 export STRIP = "${HOST_PREFIX}strip"
64
65 # Path prefixes
66 base_prefix = "${STAGING_DIR_NATIVE}"
67 prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
68 exec_prefix = "${STAGING_DIR_NATIVE}${prefix_native}"
69 libdir = ${base_prefix}${libdir_native}
70 base_libdir = ${base_prefix}${base_libdir_native}
71 # Since we actually install these into situ there is no staging prefix
72 STAGING_DIR_HOST = ""
73 STAGING_DIR_TARGET = ""
74 SHLIBSDIR = "${STAGING_DIR_NATIVE}/shlibs"
75 PKG_CONFIG_DIR = "${libdir}/pkgconfig"
76
77 do_stage_native () {
78         # If autotools is active, use the autotools staging function, else 
79         # use our "make install" equivalent
80         if [ "${AUTOTOOLS_NATIVE_STAGE_INSTALL}" = "1" ]
81         then
82                 autotools_stage_all
83         else
84                 oe_runmake install
85         fi
86 }
87
88 do_stage () {
89         do_stage_native
90 }
91
92 PKG_CONFIG_PATH .= "${EXTRA_NATIVE_PKGCONFIG_PATH}"
93 PKG_CONFIG_SYSROOT_DIR = ""
94
95 ORIG_DEPENDS := "${DEPENDS}"
96
97 DEPENDS_virtclass-native ?= "${ORIG_DEPENDS}"
98
99 def native_virtclass_override(d):
100     if "native" in (bb.data.getVar('BBCLASSEXTEND', d, True) or ""):
101         return 'virtclass-native:'
102
103 OVERRIDES =. "${@native_virtclass_override(d)}"
104
105 python __anonymous () {
106     # If we've a legacy native do_stage, we need to neuter do_install
107     stagefunc = bb.data.getVar('do_stage', d, True)
108
109     # For now, force legacy mode for native packages using autotools_stage_all
110     if (stagefunc.strip() == "autotools_stage_all"):
111         bb.debug(1, "Forcing legacy staging mode for %s" % bb.data.getVar('FILE', d, 1))
112         bb.data.setVar('FORCE_LEGACY_STAGING', "1", d)
113     elif (stagefunc.strip() != "do_stage_native" and stagefunc.strip() != "autotools_stage_all") and bb.data.getVar('AUTOTOOLS_NATIVE_STAGE_INSTALL', d, 1) == "1":
114         bb.data.setVar("do_install", "      :", d)
115
116     if "native" in (bb.data.getVar('BBCLASSEXTEND', d, True) or ""):
117         pn = bb.data.getVar("PN", d, True)
118         depends = bb.data.getVar("DEPENDS_virtclass-native", d, True)
119         deps = bb.utils.explode_deps(depends)
120         newdeps = []
121         for dep in deps:
122             if dep.endswith("-cross"):
123                 newdeps.append(dep.replace("-cross", "-native"))
124             elif not dep.endswith("-native"):
125      
126                 newdeps.append(dep + "-native")
127             else:
128                 newdeps.append(dep)
129         bb.data.setVar("DEPENDS_virtclass-native", " ".join(newdeps), d)
130         provides = bb.data.getVar("PROVIDES", d, True)
131         for prov in provides.split():
132             if prov.find(pn) != -1:
133                 continue
134             if not prov.endswith("-native"):
135     
136                 provides = provides.replace(prov, prov + "-native")
137         bb.data.setVar("PROVIDES", provides, d)
138 }
139