Mercurial > hg > aboriginal
changeset 984:9840847885e8
Add export_if_blank and make lots of build paths overrideable.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 24 Feb 2010 10:08:38 -0600 |
parents | 2932487b59fa |
children | c7fd7c400d3b |
files | build.sh sources/functions.sh sources/include.sh sources/utility_functions.sh |
diffstat | 4 files changed, 25 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/build.sh Sun Feb 21 17:07:55 2010 -0600 +++ b/build.sh Wed Feb 24 10:08:38 2010 -0600 @@ -12,12 +12,14 @@ fi ARCH="$1" +[ -z "$BUILD" ] && BUILD="build" + # A function to skip stages that have already been done (because the # tarball they create is already there). not_already() { - if [ -f "build/$1-$ARCH.tar.bz2" ] + if [ -f "$BUILD/$1-$ARCH.tar.bz2" ] then echo "=== Skipping $1-$ARCH (already there)" return 1 @@ -44,7 +46,7 @@ then # If we need to build cross compiler, assume root filesystem is stale. - rm -rf "build/root-filesystem-$ARCH.tar.bz2" + rm -rf "$BUILD/root-filesystem-$ARCH.tar.bz2" time ./simple-cross-compiler.sh "$ARCH" || exit 1 fi @@ -74,7 +76,7 @@ if not_already native-compiler && [ -z "$NO_NATIVE_COMPILER" ] then - rm -rf "build/root-filesystem-$ARCH.tar.bz2" + rm -rf "$BUILD/root-filesystem-$ARCH.tar.bz2" BUILD_STATIC={$BUILD_STATIC:-1} ./native-compiler.sh "$ARCH" || exit 1 fi @@ -86,7 +88,7 @@ # If we need to build root filesystem, assume system image is stale. - rm -rf "build/system-image-$ARCH.tar.bz2" + rm -rf "$BUILD/system-image-$ARCH.tar.bz2" time ./root-filesystem.sh "$ARCH" || exit 1 fi
--- a/sources/functions.sh Sun Feb 21 17:07:55 2010 -0600 +++ b/sources/functions.sh Wed Feb 24 10:08:38 2010 -0600 @@ -45,7 +45,7 @@ # and target match, the binutils/gcc/make builds won't use the cross compiler # during root-filesystem.sh, and the host compiler links binaries against the # wrong libc.) - [ -z "$CROSS_HOST" ] && export CROSS_HOST=`uname -m`-walrus-linux + export_if_blank CROSS_HOST=`uname -m`-walrus-linux if [ -z "$CROSS_TARGET" ] then export CROSS_TARGET=${ARCH}-unknown-linux @@ -61,7 +61,7 @@ else [ -z "$PROGRAM_PREFIX" ] && PROGRAM_PREFIX="${ARCH}-" fi - [ -z "$FROM_HOST" ] && FROM_HOST="${FROM_ARCH}-thingy-linux" + export_if_blank FROM_HOST="${FROM_ARCH}-thingy-linux" # Setup directories and add the cross compiler to the start of the path. @@ -206,7 +206,6 @@ function extract() { FILENAME="$1" - SRCTREE="${BUILD}/packages" SHA1FILE="$(echo "${SRCTREE}/${PACKAGE}/sha1-for-source.txt")" # Sanity check: don't ever "rm -rf /". Just don't.
--- a/sources/include.sh Sun Feb 21 17:07:55 2010 -0600 +++ b/sources/include.sh Wed Feb 24 10:08:38 2010 -0600 @@ -15,13 +15,14 @@ # Where are our working directories? -TOP=`pwd` -export SOURCES="$TOP/sources" -export SRCDIR="$TOP/packages" -export PATCHDIR="$SOURCES/patches" -export BUILD="$TOP/build" -export HOSTTOOLS="$BUILD/host" -export WRAPDIR="$BUILD/wrapdir" +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/wrapdir" # Set a default non-arch @@ -30,7 +31,7 @@ # What host compiler should we use? -[ -z "$CC" ] && export CC=cc +export_if_blank CC=cc # How many processors should make -j use? @@ -45,7 +46,7 @@ [ $(($CPUS*512*1024)) -le $MEMTOTAL ] && CPUS=$((($CPUS*3)/2)) fi -[ -z "$STAGE_NAME" ] && STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'` +export_if_blank STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'` [ ! -z "$BUILD_VERBOSE" ] && VERBOSITY="V=1" # Adjust $PATH
--- a/sources/utility_functions.sh Sun Feb 21 17:07:55 2010 -0600 +++ b/sources/utility_functions.sh Wed Feb 24 10:08:38 2010 -0600 @@ -2,6 +2,13 @@ # This file contains generic functions, presumably reusable in other contexts. +# Assign (export) a variable only if current value is blank + +export_if_blank() +{ + [ -z "$(eval "echo \"\${${1/=*/}}\"")" ] && export "$1" +} + # Create a blank directory at first argument, deleting existing contents if any blank_tempdir()