blob: 0e11f2d7a09e631c4813154d7ed3f35d14a4e648 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001inherit toolchain-scripts-base siteinfo kernel-arch
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002
3# We want to be able to change the value of MULTIMACH_TARGET_SYS, because it
4# doesn't always match our expectations... but we default to the stock value
5REAL_MULTIMACH_TARGET_SYS ?= "${MULTIMACH_TARGET_SYS}"
6TARGET_CC_ARCH_append_libc-uclibc = " -muclibc"
7TARGET_CC_ARCH_append_libc-musl = " -mmusl"
8
Patrick Williamsc0f7c042017-02-23 20:41:17 -06009# default debug prefix map isn't valid in the SDK
10DEBUG_PREFIX_MAP = ""
11
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012# This function creates an environment-setup-script for use in a deployable SDK
13toolchain_create_sdk_env_script () {
Patrick Williamsc0f7c042017-02-23 20:41:17 -060014 # Create environment setup script. Remember that $SDKTARGETSYSROOT should
15 # only be expanded on the target at runtime.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050016 base_sbindir=${10:-${base_sbindir_nativesdk}}
17 base_bindir=${9:-${base_bindir_nativesdk}}
18 sbindir=${8:-${sbindir_nativesdk}}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 sdkpathnative=${7:-${SDKPATHNATIVE}}
20 prefix=${6:-${prefix_nativesdk}}
21 bindir=${5:-${bindir_nativesdk}}
22 libdir=${4:-${libdir}}
23 sysroot=${3:-${SDKTARGETSYSROOT}}
24 multimach_target_sys=${2:-${REAL_MULTIMACH_TARGET_SYS}}
25 script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-$multimach_target_sys}
26 rm -f $script
27 touch $script
28 echo 'export SDKTARGETSYSROOT='"$sysroot" >> $script
29 EXTRAPATH=""
30 for i in ${CANADIANEXTRAOS}; do
31 EXTRAPATH="$EXTRAPATH:$sdkpathnative$bindir/${TARGET_ARCH}${TARGET_VENDOR}-$i"
32 done
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 echo "export PATH=$sdkpathnative$bindir:$sdkpathnative$sbindir:$sdkpathnative$base_bindir:$sdkpathnative$base_sbindir:$sdkpathnative$bindir/../${HOST_SYS}/bin:$sdkpathnative$bindir/${TARGET_SYS}"$EXTRAPATH':$PATH' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 echo "export CCACHE_PATH=$sdkpathnative$bindir:$sdkpathnative$bindir/../${HOST_SYS}/bin:$sdkpathnative$bindir/${TARGET_SYS}"$EXTRAPATH':$CCACHE_PATH' >> $script
35 echo 'export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT' >> $script
Patrick Williamsc0f7c042017-02-23 20:41:17 -060036 echo 'export PKG_CONFIG_PATH=$SDKTARGETSYSROOT'"$libdir"'/pkgconfig:$SDKTARGETSYSROOT'"$prefix"'/share/pkgconfig' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 echo 'export CONFIG_SITE=${SDKPATH}/site-config-'"${multimach_target_sys}" >> $script
38 echo "export OECORE_NATIVE_SYSROOT=\"$sdkpathnative\"" >> $script
39 echo 'export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"' >> $script
40 echo "export OECORE_ACLOCAL_OPTS=\"-I $sdkpathnative/usr/share/aclocal\"" >> $script
Patrick Williamsf1e5d692016-03-30 15:21:19 -050041 echo 'unset command_not_found_handle' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042
43 toolchain_shared_env_script
44}
45
46# This function creates an environment-setup-script in the TMPDIR which enables
47# a OE-core IDE to integrate with the build tree
48toolchain_create_tree_env_script () {
49 script=${TMPDIR}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
50 rm -f $script
51 touch $script
52 echo 'export PATH=${STAGING_DIR_NATIVE}/usr/bin:${PATH}' >> $script
53 echo 'export CCACHE_PATH=${STAGING_DIR_NATIVE}/usr/bin:${CCACHE_PATH}' >> $script
54 echo 'export PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR}' >> $script
55 echo 'export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}' >> $script
56 echo 'export CONFIG_SITE="${@siteinfo_get_files(d)}"' >> $script
57 echo 'export SDKTARGETSYSROOT=${STAGING_DIR_TARGET}' >> $script
58 echo 'export OECORE_NATIVE_SYSROOT="${STAGING_DIR_NATIVE}"' >> $script
59 echo 'export OECORE_TARGET_SYSROOT="${STAGING_DIR_TARGET}"' >> $script
60 echo 'export OECORE_ACLOCAL_OPTS="-I ${STAGING_DIR_NATIVE}/usr/share/aclocal"' >> $script
61
62 toolchain_shared_env_script
63}
64
65toolchain_shared_env_script () {
66 echo 'export CC="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
67 echo 'export CXX="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
68 echo 'export CPP="${TARGET_PREFIX}gcc -E ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
69 echo 'export AS="${TARGET_PREFIX}as ${TARGET_AS_ARCH}"' >> $script
70 echo 'export LD="${TARGET_PREFIX}ld ${TARGET_LD_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
71 echo 'export GDB=${TARGET_PREFIX}gdb' >> $script
72 echo 'export STRIP=${TARGET_PREFIX}strip' >> $script
73 echo 'export RANLIB=${TARGET_PREFIX}ranlib' >> $script
74 echo 'export OBJCOPY=${TARGET_PREFIX}objcopy' >> $script
75 echo 'export OBJDUMP=${TARGET_PREFIX}objdump' >> $script
76 echo 'export AR=${TARGET_PREFIX}ar' >> $script
77 echo 'export NM=${TARGET_PREFIX}nm' >> $script
78 echo 'export M4=m4' >> $script
79 echo 'export TARGET_PREFIX=${TARGET_PREFIX}' >> $script
80 echo 'export CONFIGURE_FLAGS="--target=${TARGET_SYS} --host=${TARGET_SYS} --build=${SDK_ARCH}-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"' >> $script
81 echo 'export CFLAGS="${TARGET_CFLAGS}"' >> $script
82 echo 'export CXXFLAGS="${TARGET_CXXFLAGS}"' >> $script
83 echo 'export LDFLAGS="${TARGET_LDFLAGS}"' >> $script
84 echo 'export CPPFLAGS="${TARGET_CPPFLAGS}"' >> $script
85 echo 'export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"' >> $script
86 echo 'export OECORE_DISTRO_VERSION="${DISTRO_VERSION}"' >> $script
87 echo 'export OECORE_SDK_VERSION="${SDK_VERSION}"' >> $script
88 echo 'export ARCH=${ARCH}' >> $script
89 echo 'export CROSS_COMPILE=${TARGET_PREFIX}' >> $script
90
91 cat >> $script <<EOF
92
93# Append environment subscripts
94if [ -d "\$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then
95 for envfile in \$OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do
Patrick Williamsc0f7c042017-02-23 20:41:17 -060096 . \$envfile
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097 done
98fi
99if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then
100 for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600101 . \$envfile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102 done
103fi
104EOF
105}
106
107#we get the cached site config in the runtime
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600108TOOLCHAIN_CONFIGSITE_NOCACHE = "${@siteinfo_get_files(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500109TOOLCHAIN_CONFIGSITE_SYSROOTCACHE = "${STAGING_DIR}/${MLPREFIX}${MACHINE}/${target_datadir}/${TARGET_SYS}_config_site.d"
110TOOLCHAIN_NEED_CONFIGSITE_CACHE ??= "virtual/${MLPREFIX}libc ncurses"
111
112#This function create a site config file
113toolchain_create_sdk_siteconfig () {
114 local siteconfig=$1
115
116 rm -f $siteconfig
117 touch $siteconfig
118
119 for sitefile in ${TOOLCHAIN_CONFIGSITE_NOCACHE} ; do
120 cat $sitefile >> $siteconfig
121 done
122
123 #get cached site config
124 for sitefile in ${TOOLCHAIN_NEED_CONFIGSITE_CACHE}; do
125 # Resolve virtual/* names to the real recipe name using sysroot-providers info
126 case $sitefile in virtual/*)
127 sitefile=`echo $sitefile | tr / _`
128 sitefile=`cat ${STAGING_DIR_TARGET}/sysroot-providers/$sitefile`
129 esac
130
131 if [ -r ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config ]; then
132 cat ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config >> $siteconfig
133 fi
134 done
135}
136# The immediate expansion above can result in unwanted path dependencies here
137toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"
138
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139python __anonymous () {
140 import oe.classextend
141 deps = ""
142 for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE', True) or "").split():
143 deps += " %s:do_populate_sysroot" % dep
144 for variant in (d.getVar('MULTILIB_VARIANTS', True) or "").split():
145 clsextend = oe.classextend.ClassExtender(variant, d)
146 newdep = clsextend.extend_name(dep)
147 deps += " %s:do_populate_sysroot" % newdep
148 d.appendVarFlag('do_configure', 'depends', deps)
149}