view sources/include.sh @ 744:759adf5a0fe9

Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
author Rob Landley <rob@landley.net>
date Thu, 11 Jun 2009 05:42:51 -0500
parents 5e745e03408a
children 5f793a1ca658
line wrap: on
line source

#!/bin/bash

umask 022

# Tell bash not to cache the $PATH because we modify it.  Without this, bash
# won't find new executables added after startup.
set +h

# Include two other files:

[ -e config ] && source config
source sources/functions.sh

# The rest of this file is devoted to setting environment variables.

unset CFLAGS CXXFLAGS

# What host compiler should we use?

[ -z "$CC" ] && export CC=cc

# How many processors should make -j use?

if [ -z "$CPUS" ]
then
  export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
  [ "$CPUS" -lt 1 ] && CPUS=1
fi

# Where are our working directories?

TOP=`pwd`
export SOURCES="${TOP}/sources"
export SRCDIR="${TOP}/packages"
export BUILD="${TOP}/build"
export HOSTTOOLS="${BUILD}/host"

# Set a default non-arch

ARCH_NAME=host
export WORK="${BUILD}/host-temp"

# Retain old $PATH in case we re-run host-tools.sh with different options.

export OLDPATH="$PATH"

# Adjust $PATH

if [ "$PATH" != "$HOSTTOOLS" ]
then
  if [ -f "$HOSTTOOLS/busybox" ]
  then
    PATH="$HOSTTOOLS"
  else
    PATH="${HOSTTOOLS}:$PATH"
  fi
fi

# Setup for $RECORD_COMMANDS

# WRAPPY_LOGPATH is set unconditionally in case host-tools.sh needs to
# enable wrapping partway through its own build.  Extra environment variables
# don't actually affect much, it's changing $PATH that changes behavior.

[ -z "$STAGE_NAME" ] && STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`
[ -z "$WRAPPY_LOGDIR" ] && WRAPPY_LOGDIR="$BUILD"
export WRAPPY_LOGPATH="$WRAPPY_LOGDIR/cmdlines.${STAGE_NAME}.setupfor"
if [ ! -z "$RECORD_COMMANDS" ] && [ -f "$BUILD/wrapdir/wrappy" ]
then
  export WRAPPY_REALPATH="$PATH"
  PATH="$BUILD/wrapdir"
fi

[ ! -z "$BUILD_VERBOSE" ] && VERBOSITY="V=1"

# This is an if instead of && so the exit code of include.sh is reliably 0
if [ ! -z "$BUILD_STATIC" ]
then
  STATIC_FLAGS="--static"
fi