#!/bin/echo "This file is sourced, not run" # Avoid trouble from unexpected environment settings by unsetting all # environment variables that we don't know about, in case some crazy # person already exported $CROSS_COMPILE, $ARCH, $CDPATH, or who knows # what else. It's hard to know what might drive some package crazy, # so use a whitelist. if test -z $NO_SANITIZE_ENVIRONMENT { # Which variables are set in config? setglobal TEMP = $[echo $[sed -n 's/.*export[ \t]*\([^=]*\)=.*/\1/p' config] | sed 's/ /,/g] # What other variables should we keep? setglobal TEMP = ""$TEMP,LANG,PATH,SHELL,TERM,USER,USERNAME,LOGNAME,PWD,EDITOR,HOME"" setglobal TEMP = ""$TEMP,DISPLAY,_,TOPSHELL,START_TIME,STAGE_NAME,TOOLCHAIN_PREFIX"" setglobal TEMP = ""$TEMP,HOST_ARCH,WRAPPY_LOGPATH,OLDPATH,http_proxy,ftp_proxy"" setglobal TEMP = ""$TEMP,https_proxy,no_proxy,TEMP,TMPDIR,FORK,MUSL"" # Unset any variable we don't recognize. It can screw up the build. for i in [$[env | sed -n 's/=.*//p]] { is_in_list $i $TEMP && continue test $(i:0:7) == "DISTCC_" && continue test $(i:0:7) == "CCACHE_" && continue unset $i !2 >/dev/null } } # Assign (export) a variable only if current value is blank proc export_if_blank { test -z $[eval "echo \"\${$(1/=*/)}] && export $1 } # List of fallback mirrors to download package source from export_if_blank MIRROR_LIST="http://landley.net/code/aboriginal/mirror http://127.0.0.1/code/aboriginal/mirror" # Where are our working directories? export_if_blank TOP=$[pwd] export_if_blank SOURCES="$TOP/sources" export_if_blank SRCDIR="$TOP/packages" export_if_blank PATCHDIR="$SOURCES/patches" export_if_blank BUILD="$TOP/build" export_if_blank SRCTREE="$BUILD/packages" export_if_blank HOSTTOOLS="$BUILD/host" export_if_blank WRAPDIR="$BUILD/record-commands" test ! -z $MY_PATCH_DIR && export MY_PATCH_DIR="$[readlink -e $MY_PATCH_DIR]" # Set a default non-arch export WORK="$(BUILD)/host-temp" export ARCH_NAME=host # What host compiler should we use? export_if_blank CC=cc # How many processors should make -j use? setglobal MEMTOTAL = $[awk '/MemTotal:/{print $2}' /proc/meminfo] if test -z $CPUS { export CPUS=$[echo /sys/devices/system/cpu/cpu[0-9]* | wc -w] test $CPUS -lt 1 && setglobal CPUS = '1' # If we're not using hyper-threading, and there's plenty of memory, # use 50% more CPUS than we actually have to keep system busy test -z $[cat /proc/cpuinfo | grep '^flags' | head -n 1 | grep -w ht] && test $shExpr('$CPUS*512*1024') -le $MEMTOTAL && setglobal CPUS = $shExpr('($CPUS*3)/2') } export_if_blank STAGE_NAME=$[echo $0 | sed 's@.*/\(.*\)\.sh@\1@] test ! -z $BUILD_VERBOSE && setglobal VERBOSITY = '"V=1'" export_if_blank BUILD_STATIC=busybox,toybox,binutils,gcc-core,gcc-g++,make # If record-commands.sh set up a wrapper directory, adjust $PATH. export PATH if test -z $OLDPATH { export OLDPATH="$PATH" test -z $BUSYBOX || setglobal BUSYBOX = 'busybox' test -f "$HOSTTOOLS/$(BUSYBOX:-toybox)" && setglobal PATH = $[hosttools_path] || setglobal PATH = ""$[hosttools_path]:$PATH"" if test -f "$WRAPDIR/wrappy" { setglobal OLDPATH = $PATH mkdir -p "$BUILD/logs" test $Status -ne 0 && echo "Bad $WRAPDIR" > !2 && dienow setglobal PATH = $WRAPDIR } } export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.$ARCH_NAME.early"