blob: 71da5e5409293115881ae1bccdb9fe874d46ecb7 [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}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006TARGET_CC_ARCH_append_libc-musl = " -mmusl"
7
Patrick Williamsc0f7c042017-02-23 20:41:17 -06008# default debug prefix map isn't valid in the SDK
9DEBUG_PREFIX_MAP = ""
10
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011# This function creates an environment-setup-script for use in a deployable SDK
12toolchain_create_sdk_env_script () {
Patrick Williamsc0f7c042017-02-23 20:41:17 -060013 # Create environment setup script. Remember that $SDKTARGETSYSROOT should
14 # only be expanded on the target at runtime.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050015 base_sbindir=${10:-${base_sbindir_nativesdk}}
16 base_bindir=${9:-${base_bindir_nativesdk}}
17 sbindir=${8:-${sbindir_nativesdk}}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018 sdkpathnative=${7:-${SDKPATHNATIVE}}
19 prefix=${6:-${prefix_nativesdk}}
20 bindir=${5:-${bindir_nativesdk}}
21 libdir=${4:-${libdir}}
22 sysroot=${3:-${SDKTARGETSYSROOT}}
23 multimach_target_sys=${2:-${REAL_MULTIMACH_TARGET_SYS}}
24 script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-$multimach_target_sys}
25 rm -f $script
26 touch $script
Brad Bishopd7bf8c12018-02-25 22:55:05 -050027
28 echo '# Check for LD_LIBRARY_PATH being set, which can break SDK and generally is a bad practice' >> $script
29 echo '# http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80' >> $script
30 echo '# http://xahlee.info/UnixResource_dir/_/ldpath.html' >> $script
31 echo '# Only disable this check if you are absolutely know what you are doing!' >> $script
32 echo 'if [ ! -z "$LD_LIBRARY_PATH" ]; then' >> $script
33 echo " echo \"Your environment is misconfigured, you probably need to 'unset LD_LIBRARY_PATH'\"" >> $script
34 echo " echo \"but please check why this was set in the first place and that it's safe to unset.\"" >> $script
35 echo ' echo "The SDK will not operate correctly in most cases when LD_LIBRARY_PATH is set."' >> $script
36 echo ' echo "For more references see:"' >> $script
37 echo ' echo " http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80"' >> $script
38 echo ' echo " http://xahlee.info/UnixResource_dir/_/ldpath.html"' >> $script
39 echo ' return 1' >> $script
40 echo 'fi' >> $script
41
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042 echo 'export SDKTARGETSYSROOT='"$sysroot" >> $script
43 EXTRAPATH=""
44 for i in ${CANADIANEXTRAOS}; do
45 EXTRAPATH="$EXTRAPATH:$sdkpathnative$bindir/${TARGET_ARCH}${TARGET_VENDOR}-$i"
46 done
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050047 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 -050048 echo 'export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT' >> $script
Patrick Williamsc0f7c042017-02-23 20:41:17 -060049 echo 'export PKG_CONFIG_PATH=$SDKTARGETSYSROOT'"$libdir"'/pkgconfig:$SDKTARGETSYSROOT'"$prefix"'/share/pkgconfig' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 echo 'export CONFIG_SITE=${SDKPATH}/site-config-'"${multimach_target_sys}" >> $script
51 echo "export OECORE_NATIVE_SYSROOT=\"$sdkpathnative\"" >> $script
52 echo 'export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"' >> $script
53 echo "export OECORE_ACLOCAL_OPTS=\"-I $sdkpathnative/usr/share/aclocal\"" >> $script
Patrick Williamsf1e5d692016-03-30 15:21:19 -050054 echo 'unset command_not_found_handle' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055
56 toolchain_shared_env_script
57}
58
59# This function creates an environment-setup-script in the TMPDIR which enables
60# a OE-core IDE to integrate with the build tree
61toolchain_create_tree_env_script () {
62 script=${TMPDIR}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
63 rm -f $script
64 touch $script
Brad Bishop316dfdd2018-06-25 12:45:53 -040065 echo 'orig=`pwd`; cd ${COREBASE}; . ./oe-init-build-env ${TOPDIR}; cd $orig' >> $script
66 echo 'export PATH=${STAGING_DIR_NATIVE}/usr/bin:${STAGING_BINDIR_TOOLCHAIN}:$PATH' >> $script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 echo 'export PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR}' >> $script
68 echo 'export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}' >> $script
69 echo 'export CONFIG_SITE="${@siteinfo_get_files(d)}"' >> $script
70 echo 'export SDKTARGETSYSROOT=${STAGING_DIR_TARGET}' >> $script
71 echo 'export OECORE_NATIVE_SYSROOT="${STAGING_DIR_NATIVE}"' >> $script
72 echo 'export OECORE_TARGET_SYSROOT="${STAGING_DIR_TARGET}"' >> $script
73 echo 'export OECORE_ACLOCAL_OPTS="-I ${STAGING_DIR_NATIVE}/usr/share/aclocal"' >> $script
74
75 toolchain_shared_env_script
76}
77
78toolchain_shared_env_script () {
79 echo 'export CC="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
80 echo 'export CXX="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
81 echo 'export CPP="${TARGET_PREFIX}gcc -E ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
82 echo 'export AS="${TARGET_PREFIX}as ${TARGET_AS_ARCH}"' >> $script
83 echo 'export LD="${TARGET_PREFIX}ld ${TARGET_LD_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
84 echo 'export GDB=${TARGET_PREFIX}gdb' >> $script
85 echo 'export STRIP=${TARGET_PREFIX}strip' >> $script
86 echo 'export RANLIB=${TARGET_PREFIX}ranlib' >> $script
87 echo 'export OBJCOPY=${TARGET_PREFIX}objcopy' >> $script
88 echo 'export OBJDUMP=${TARGET_PREFIX}objdump' >> $script
89 echo 'export AR=${TARGET_PREFIX}ar' >> $script
90 echo 'export NM=${TARGET_PREFIX}nm' >> $script
91 echo 'export M4=m4' >> $script
92 echo 'export TARGET_PREFIX=${TARGET_PREFIX}' >> $script
93 echo 'export CONFIGURE_FLAGS="--target=${TARGET_SYS} --host=${TARGET_SYS} --build=${SDK_ARCH}-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"' >> $script
94 echo 'export CFLAGS="${TARGET_CFLAGS}"' >> $script
95 echo 'export CXXFLAGS="${TARGET_CXXFLAGS}"' >> $script
96 echo 'export LDFLAGS="${TARGET_LDFLAGS}"' >> $script
97 echo 'export CPPFLAGS="${TARGET_CPPFLAGS}"' >> $script
98 echo 'export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"' >> $script
99 echo 'export OECORE_DISTRO_VERSION="${DISTRO_VERSION}"' >> $script
100 echo 'export OECORE_SDK_VERSION="${SDK_VERSION}"' >> $script
101 echo 'export ARCH=${ARCH}' >> $script
102 echo 'export CROSS_COMPILE=${TARGET_PREFIX}' >> $script
103
104 cat >> $script <<EOF
105
106# Append environment subscripts
107if [ -d "\$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then
108 for envfile in \$OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600109 . \$envfile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110 done
111fi
112if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then
113 for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600114 . \$envfile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115 done
116fi
117EOF
118}
119
Brad Bishop316dfdd2018-06-25 12:45:53 -0400120toolchain_create_post_relocate_script() {
121 script=$1
122 rm -f $script
123 touch $script
124
125 cat >> $script <<EOF
126if [ -d "${SDKPATHNATIVE}/post-relocate-setup.d/" ]; then
127 for s in ${SDKPATHNATIVE}/post-relocate-setup.d/*.sh; do
128 \$s "\$1"
129 done
130 rm -rf "${SDKPATHNATIVE}/post-relocate-setup.d"
131fi
132EOF
133}
134
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500135#we get the cached site config in the runtime
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600136TOOLCHAIN_CONFIGSITE_NOCACHE = "${@siteinfo_get_files(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500137TOOLCHAIN_CONFIGSITE_SYSROOTCACHE = "${STAGING_DIR}/${MLPREFIX}${MACHINE}/${target_datadir}/${TARGET_SYS}_config_site.d"
138TOOLCHAIN_NEED_CONFIGSITE_CACHE ??= "virtual/${MLPREFIX}libc ncurses"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500139DEPENDS += "${TOOLCHAIN_NEED_CONFIGSITE_CACHE}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140
141#This function create a site config file
142toolchain_create_sdk_siteconfig () {
143 local siteconfig=$1
144
145 rm -f $siteconfig
146 touch $siteconfig
147
148 for sitefile in ${TOOLCHAIN_CONFIGSITE_NOCACHE} ; do
149 cat $sitefile >> $siteconfig
150 done
151
152 #get cached site config
153 for sitefile in ${TOOLCHAIN_NEED_CONFIGSITE_CACHE}; do
154 # Resolve virtual/* names to the real recipe name using sysroot-providers info
155 case $sitefile in virtual/*)
156 sitefile=`echo $sitefile | tr / _`
157 sitefile=`cat ${STAGING_DIR_TARGET}/sysroot-providers/$sitefile`
158 esac
159
160 if [ -r ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config ]; then
161 cat ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config >> $siteconfig
162 fi
163 done
164}
165# The immediate expansion above can result in unwanted path dependencies here
166toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE"
167
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168python __anonymous () {
169 import oe.classextend
170 deps = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500171 for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172 deps += " %s:do_populate_sysroot" % dep
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500173 for variant in (d.getVar('MULTILIB_VARIANTS') or "").split():
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174 clsextend = oe.classextend.ClassExtender(variant, d)
175 newdep = clsextend.extend_name(dep)
176 deps += " %s:do_populate_sysroot" % newdep
177 d.appendVarFlag('do_configure', 'depends', deps)
178}