blob: 260ece967685afe74dd634d4c46f9d8793fa6224 [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 PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT' >> $script
Patrick Williamsc0f7c042017-02-23 20:41:17 -060035 echo 'export PKG_CONFIG_PATH=$SDKTARGETSYSROOT'"$libdir"'/pkgconfig:$SDKTARGETSYSROOT'"$prefix"'/share/pkgconfig' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036 echo 'export CONFIG_SITE=${SDKPATH}/site-config-'"${multimach_target_sys}" >> $script
37 echo "export OECORE_NATIVE_SYSROOT=\"$sdkpathnative\"" >> $script
38 echo 'export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"' >> $script
39 echo "export OECORE_ACLOCAL_OPTS=\"-I $sdkpathnative/usr/share/aclocal\"" >> $script
Patrick Williamsf1e5d692016-03-30 15:21:19 -050040 echo 'unset command_not_found_handle' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041
42 toolchain_shared_env_script
43}
44
45# This function creates an environment-setup-script in the TMPDIR which enables
46# a OE-core IDE to integrate with the build tree
47toolchain_create_tree_env_script () {
48 script=${TMPDIR}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
49 rm -f $script
50 touch $script
51 echo 'export PATH=${STAGING_DIR_NATIVE}/usr/bin:${PATH}' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 echo 'export PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR}' >> $script
53 echo 'export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}' >> $script
54 echo 'export CONFIG_SITE="${@siteinfo_get_files(d)}"' >> $script
55 echo 'export SDKTARGETSYSROOT=${STAGING_DIR_TARGET}' >> $script
56 echo 'export OECORE_NATIVE_SYSROOT="${STAGING_DIR_NATIVE}"' >> $script
57 echo 'export OECORE_TARGET_SYSROOT="${STAGING_DIR_TARGET}"' >> $script
58 echo 'export OECORE_ACLOCAL_OPTS="-I ${STAGING_DIR_NATIVE}/usr/share/aclocal"' >> $script
59
60 toolchain_shared_env_script
61}
62
63toolchain_shared_env_script () {
64 echo 'export CC="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
65 echo 'export CXX="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
66 echo 'export CPP="${TARGET_PREFIX}gcc -E ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
67 echo 'export AS="${TARGET_PREFIX}as ${TARGET_AS_ARCH}"' >> $script
68 echo 'export LD="${TARGET_PREFIX}ld ${TARGET_LD_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
69 echo 'export GDB=${TARGET_PREFIX}gdb' >> $script
70 echo 'export STRIP=${TARGET_PREFIX}strip' >> $script
71 echo 'export RANLIB=${TARGET_PREFIX}ranlib' >> $script
72 echo 'export OBJCOPY=${TARGET_PREFIX}objcopy' >> $script
73 echo 'export OBJDUMP=${TARGET_PREFIX}objdump' >> $script
74 echo 'export AR=${TARGET_PREFIX}ar' >> $script
75 echo 'export NM=${TARGET_PREFIX}nm' >> $script
76 echo 'export M4=m4' >> $script
77 echo 'export TARGET_PREFIX=${TARGET_PREFIX}' >> $script
78 echo 'export CONFIGURE_FLAGS="--target=${TARGET_SYS} --host=${TARGET_SYS} --build=${SDK_ARCH}-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"' >> $script
79 echo 'export CFLAGS="${TARGET_CFLAGS}"' >> $script
80 echo 'export CXXFLAGS="${TARGET_CXXFLAGS}"' >> $script
81 echo 'export LDFLAGS="${TARGET_LDFLAGS}"' >> $script
82 echo 'export CPPFLAGS="${TARGET_CPPFLAGS}"' >> $script
83 echo 'export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"' >> $script
84 echo 'export OECORE_DISTRO_VERSION="${DISTRO_VERSION}"' >> $script
85 echo 'export OECORE_SDK_VERSION="${SDK_VERSION}"' >> $script
86 echo 'export ARCH=${ARCH}' >> $script
87 echo 'export CROSS_COMPILE=${TARGET_PREFIX}' >> $script
88
89 cat >> $script <<EOF
90
91# Append environment subscripts
92if [ -d "\$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then
93 for envfile in \$OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do
Patrick Williamsc0f7c042017-02-23 20:41:17 -060094 . \$envfile
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 done
96fi
97if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then
98 for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do
Patrick Williamsc0f7c042017-02-23 20:41:17 -060099 . \$envfile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100 done
101fi
102EOF
103}
104
105#we get the cached site config in the runtime
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600106TOOLCHAIN_CONFIGSITE_NOCACHE = "${@siteinfo_get_files(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107TOOLCHAIN_CONFIGSITE_SYSROOTCACHE = "${STAGING_DIR}/${MLPREFIX}${MACHINE}/${target_datadir}/${TARGET_SYS}_config_site.d"
108TOOLCHAIN_NEED_CONFIGSITE_CACHE ??= "virtual/${MLPREFIX}libc ncurses"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500109DEPENDS += "${TOOLCHAIN_NEED_CONFIGSITE_CACHE}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110
111#This function create a site config file
112toolchain_create_sdk_siteconfig () {
113 local siteconfig=$1
114
115 rm -f $siteconfig
116 touch $siteconfig
117
118 for sitefile in ${TOOLCHAIN_CONFIGSITE_NOCACHE} ; do
119 cat $sitefile >> $siteconfig
120 done
121
122 #get cached site config
123 for sitefile in ${TOOLCHAIN_NEED_CONFIGSITE_CACHE}; do
124 # Resolve virtual/* names to the real recipe name using sysroot-providers info
125 case $sitefile in virtual/*)
126 sitefile=`echo $sitefile | tr / _`
127 sitefile=`cat ${STAGING_DIR_TARGET}/sysroot-providers/$sitefile`
128 esac
129
130 if [ -r ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config ]; then
131 cat ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config >> $siteconfig
132 fi
133 done
134}
135# The immediate expansion above can result in unwanted path dependencies here
136toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"
137
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138python __anonymous () {
139 import oe.classextend
140 deps = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500141 for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500142 deps += " %s:do_populate_sysroot" % dep
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500143 for variant in (d.getVar('MULTILIB_VARIANTS') or "").split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 clsextend = oe.classextend.ClassExtender(variant, d)
145 newdep = clsextend.extend_name(dep)
146 deps += " %s:do_populate_sysroot" % newdep
147 d.appendVarFlag('do_configure', 'depends', deps)
148}