Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | inherit toolchain-scripts-base siteinfo kernel-arch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2 | |
| 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 |
| 5 | REAL_MULTIMACH_TARGET_SYS ?= "${MULTIMACH_TARGET_SYS}" |
| 6 | TARGET_CC_ARCH_append_libc-uclibc = " -muclibc" |
| 7 | TARGET_CC_ARCH_append_libc-musl = " -mmusl" |
| 8 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9 | # default debug prefix map isn't valid in the SDK |
| 10 | DEBUG_PREFIX_MAP = "" |
| 11 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12 | # This function creates an environment-setup-script for use in a deployable SDK |
| 13 | toolchain_create_sdk_env_script () { |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 14 | # Create environment setup script. Remember that $SDKTARGETSYSROOT should |
| 15 | # only be expanded on the target at runtime. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 16 | base_sbindir=${10:-${base_sbindir_nativesdk}} |
| 17 | base_bindir=${9:-${base_bindir_nativesdk}} |
| 18 | sbindir=${8:-${sbindir_nativesdk}} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 33 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | echo 'export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT' >> $script |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 35 | echo 'export PKG_CONFIG_PATH=$SDKTARGETSYSROOT'"$libdir"'/pkgconfig:$SDKTARGETSYSROOT'"$prefix"'/share/pkgconfig' >> $script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 40 | echo 'unset command_not_found_handle' >> $script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | |
| 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 |
| 47 | toolchain_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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | 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 | |
| 63 | toolchain_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 |
| 92 | if [ -d "\$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then |
| 93 | for envfile in \$OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 94 | . \$envfile |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | done |
| 96 | fi |
| 97 | if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then |
| 98 | for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 99 | . \$envfile |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | done |
| 101 | fi |
| 102 | EOF |
| 103 | } |
| 104 | |
| 105 | #we get the cached site config in the runtime |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 106 | TOOLCHAIN_CONFIGSITE_NOCACHE = "${@siteinfo_get_files(d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | TOOLCHAIN_CONFIGSITE_SYSROOTCACHE = "${STAGING_DIR}/${MLPREFIX}${MACHINE}/${target_datadir}/${TARGET_SYS}_config_site.d" |
| 108 | TOOLCHAIN_NEED_CONFIGSITE_CACHE ??= "virtual/${MLPREFIX}libc ncurses" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 109 | DEPENDS += "${TOOLCHAIN_NEED_CONFIGSITE_CACHE}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | |
| 111 | #This function create a site config file |
| 112 | toolchain_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 |
| 136 | toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE" |
| 137 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 138 | python __anonymous () { |
| 139 | import oe.classextend |
| 140 | deps = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 141 | for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE') or "").split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 142 | deps += " %s:do_populate_sysroot" % dep |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 143 | for variant in (d.getVar('MULTILIB_VARIANTS') or "").split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 144 | 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 | } |