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