Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit siteinfo kernel-arch |
| 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 | |
| 9 | # This function creates an environment-setup-script for use in a deployable SDK |
| 10 | toolchain_create_sdk_env_script () { |
| 11 | # Create environment setup script |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 12 | base_sbindir=${10:-${base_sbindir_nativesdk}} |
| 13 | base_bindir=${9:-${base_bindir_nativesdk}} |
| 14 | sbindir=${8:-${sbindir_nativesdk}} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | sdkpathnative=${7:-${SDKPATHNATIVE}} |
| 16 | prefix=${6:-${prefix_nativesdk}} |
| 17 | bindir=${5:-${bindir_nativesdk}} |
| 18 | libdir=${4:-${libdir}} |
| 19 | sysroot=${3:-${SDKTARGETSYSROOT}} |
| 20 | multimach_target_sys=${2:-${REAL_MULTIMACH_TARGET_SYS}} |
| 21 | script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-$multimach_target_sys} |
| 22 | rm -f $script |
| 23 | touch $script |
| 24 | echo 'export SDKTARGETSYSROOT='"$sysroot" >> $script |
| 25 | EXTRAPATH="" |
| 26 | for i in ${CANADIANEXTRAOS}; do |
| 27 | EXTRAPATH="$EXTRAPATH:$sdkpathnative$bindir/${TARGET_ARCH}${TARGET_VENDOR}-$i" |
| 28 | done |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 29 | 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] | 30 | echo "export CCACHE_PATH=$sdkpathnative$bindir:$sdkpathnative$bindir/../${HOST_SYS}/bin:$sdkpathnative$bindir/${TARGET_SYS}"$EXTRAPATH':$CCACHE_PATH' >> $script |
| 31 | echo 'export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT' >> $script |
| 32 | echo 'export PKG_CONFIG_PATH=$SDKTARGETSYSROOT'"$libdir"'/pkgconfig' >> $script |
| 33 | echo 'export CONFIG_SITE=${SDKPATH}/site-config-'"${multimach_target_sys}" >> $script |
| 34 | echo "export OECORE_NATIVE_SYSROOT=\"$sdkpathnative\"" >> $script |
| 35 | echo 'export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"' >> $script |
| 36 | echo "export OECORE_ACLOCAL_OPTS=\"-I $sdkpathnative/usr/share/aclocal\"" >> $script |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 37 | echo 'unset command_not_found_handle' >> $script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | |
| 39 | toolchain_shared_env_script |
| 40 | } |
| 41 | |
| 42 | # This function creates an environment-setup-script in the TMPDIR which enables |
| 43 | # a OE-core IDE to integrate with the build tree |
| 44 | toolchain_create_tree_env_script () { |
| 45 | script=${TMPDIR}/environment-setup-${REAL_MULTIMACH_TARGET_SYS} |
| 46 | rm -f $script |
| 47 | touch $script |
| 48 | echo 'export PATH=${STAGING_DIR_NATIVE}/usr/bin:${PATH}' >> $script |
| 49 | echo 'export CCACHE_PATH=${STAGING_DIR_NATIVE}/usr/bin:${CCACHE_PATH}' >> $script |
| 50 | echo 'export PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR}' >> $script |
| 51 | echo 'export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}' >> $script |
| 52 | echo 'export CONFIG_SITE="${@siteinfo_get_files(d)}"' >> $script |
| 53 | echo 'export SDKTARGETSYSROOT=${STAGING_DIR_TARGET}' >> $script |
| 54 | echo 'export OECORE_NATIVE_SYSROOT="${STAGING_DIR_NATIVE}"' >> $script |
| 55 | echo 'export OECORE_TARGET_SYSROOT="${STAGING_DIR_TARGET}"' >> $script |
| 56 | echo 'export OECORE_ACLOCAL_OPTS="-I ${STAGING_DIR_NATIVE}/usr/share/aclocal"' >> $script |
| 57 | |
| 58 | toolchain_shared_env_script |
| 59 | } |
| 60 | |
| 61 | toolchain_shared_env_script () { |
| 62 | echo 'export CC="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script |
| 63 | echo 'export CXX="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script |
| 64 | echo 'export CPP="${TARGET_PREFIX}gcc -E ${TARGET_CC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script |
| 65 | echo 'export AS="${TARGET_PREFIX}as ${TARGET_AS_ARCH}"' >> $script |
| 66 | echo 'export LD="${TARGET_PREFIX}ld ${TARGET_LD_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script |
| 67 | echo 'export GDB=${TARGET_PREFIX}gdb' >> $script |
| 68 | echo 'export STRIP=${TARGET_PREFIX}strip' >> $script |
| 69 | echo 'export RANLIB=${TARGET_PREFIX}ranlib' >> $script |
| 70 | echo 'export OBJCOPY=${TARGET_PREFIX}objcopy' >> $script |
| 71 | echo 'export OBJDUMP=${TARGET_PREFIX}objdump' >> $script |
| 72 | echo 'export AR=${TARGET_PREFIX}ar' >> $script |
| 73 | echo 'export NM=${TARGET_PREFIX}nm' >> $script |
| 74 | echo 'export M4=m4' >> $script |
| 75 | echo 'export TARGET_PREFIX=${TARGET_PREFIX}' >> $script |
| 76 | echo 'export CONFIGURE_FLAGS="--target=${TARGET_SYS} --host=${TARGET_SYS} --build=${SDK_ARCH}-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"' >> $script |
| 77 | echo 'export CFLAGS="${TARGET_CFLAGS}"' >> $script |
| 78 | echo 'export CXXFLAGS="${TARGET_CXXFLAGS}"' >> $script |
| 79 | echo 'export LDFLAGS="${TARGET_LDFLAGS}"' >> $script |
| 80 | echo 'export CPPFLAGS="${TARGET_CPPFLAGS}"' >> $script |
| 81 | echo 'export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"' >> $script |
| 82 | echo 'export OECORE_DISTRO_VERSION="${DISTRO_VERSION}"' >> $script |
| 83 | echo 'export OECORE_SDK_VERSION="${SDK_VERSION}"' >> $script |
| 84 | echo 'export ARCH=${ARCH}' >> $script |
| 85 | echo 'export CROSS_COMPILE=${TARGET_PREFIX}' >> $script |
| 86 | |
| 87 | cat >> $script <<EOF |
| 88 | |
| 89 | # Append environment subscripts |
| 90 | if [ -d "\$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then |
| 91 | for envfile in \$OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do |
| 92 | source \$envfile |
| 93 | done |
| 94 | fi |
| 95 | if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then |
| 96 | for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do |
| 97 | source \$envfile |
| 98 | done |
| 99 | fi |
| 100 | EOF |
| 101 | } |
| 102 | |
| 103 | #we get the cached site config in the runtime |
| 104 | TOOLCHAIN_CONFIGSITE_NOCACHE = "${@siteinfo_get_files(d, True)}" |
| 105 | TOOLCHAIN_CONFIGSITE_SYSROOTCACHE = "${STAGING_DIR}/${MLPREFIX}${MACHINE}/${target_datadir}/${TARGET_SYS}_config_site.d" |
| 106 | TOOLCHAIN_NEED_CONFIGSITE_CACHE ??= "virtual/${MLPREFIX}libc ncurses" |
| 107 | |
| 108 | #This function create a site config file |
| 109 | toolchain_create_sdk_siteconfig () { |
| 110 | local siteconfig=$1 |
| 111 | |
| 112 | rm -f $siteconfig |
| 113 | touch $siteconfig |
| 114 | |
| 115 | for sitefile in ${TOOLCHAIN_CONFIGSITE_NOCACHE} ; do |
| 116 | cat $sitefile >> $siteconfig |
| 117 | done |
| 118 | |
| 119 | #get cached site config |
| 120 | for sitefile in ${TOOLCHAIN_NEED_CONFIGSITE_CACHE}; do |
| 121 | # Resolve virtual/* names to the real recipe name using sysroot-providers info |
| 122 | case $sitefile in virtual/*) |
| 123 | sitefile=`echo $sitefile | tr / _` |
| 124 | sitefile=`cat ${STAGING_DIR_TARGET}/sysroot-providers/$sitefile` |
| 125 | esac |
| 126 | |
| 127 | if [ -r ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config ]; then |
| 128 | cat ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config >> $siteconfig |
| 129 | fi |
| 130 | done |
| 131 | } |
| 132 | # The immediate expansion above can result in unwanted path dependencies here |
| 133 | toolchain_create_sdk_siteconfig[vardepsexclude] = "TOOLCHAIN_CONFIGSITE_SYSROOTCACHE" |
| 134 | |
| 135 | #This function create a version information file |
| 136 | toolchain_create_sdk_version () { |
| 137 | local versionfile=$1 |
| 138 | rm -f $versionfile |
| 139 | touch $versionfile |
| 140 | echo 'Distro: ${DISTRO}' >> $versionfile |
| 141 | echo 'Distro Version: ${DISTRO_VERSION}' >> $versionfile |
| 142 | echo 'Metadata Revision: ${METADATA_REVISION}' >> $versionfile |
| 143 | echo 'Timestamp: ${DATETIME}' >> $versionfile |
| 144 | } |
| 145 | toolchain_create_sdk_version[vardepsexclude] = "DATETIME" |
| 146 | |
| 147 | python __anonymous () { |
| 148 | import oe.classextend |
| 149 | deps = "" |
| 150 | for dep in (d.getVar('TOOLCHAIN_NEED_CONFIGSITE_CACHE', True) or "").split(): |
| 151 | deps += " %s:do_populate_sysroot" % dep |
| 152 | for variant in (d.getVar('MULTILIB_VARIANTS', True) or "").split(): |
| 153 | clsextend = oe.classextend.ClassExtender(variant, d) |
| 154 | newdep = clsextend.extend_name(dep) |
| 155 | deps += " %s:do_populate_sysroot" % newdep |
| 156 | d.appendVarFlag('do_configure', 'depends', deps) |
| 157 | } |