view sources/include.sh @ 581:9dffdd74c186

More changes for initramfs and hw- targets with a base architecture. The $BASE_ARCH approach didn't work because targets need to override things like KERNEL_PATH, so they need to source the relevant details file themselves. Shuffle things around so they can do that: move $CROSS into cross-compiler.sh, add cross compiler to $PATH independently of that, remove $ARCH from CONFIG_DIR and change users to add it, have getconfig check $ARCH_NAME directory first, redo qemu_defaults to chop out initramfs options less uncleanly...
author Rob Landley <rob@landley.net>
date Mon, 12 Jan 2009 02:47:32 -0600
parents 715c94bd059e
children dd03aa5996e6
line wrap: on
line source

#!/bin/bash


[ -e config ] && source config

source sources/functions.sh

# What host compiler should we use?

[ -z "$CC" ] && CC=gcc

# 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

umask 022
unset CFLAGS CXXFLAGS

# Find/create directories

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

[ -z "$WRAPPY_LOGDIR" ] && WRAPPY_LOGDIR="$BUILD"

# Adjust $PATH

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

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

mkdir -p "${SRCDIR}" || dienow

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

# Get target platform from first command line argument.

if [ -z "$NO_ARCH" ]
then
  ARCH_NAME="$1"
  if [ ! -f "${TOP}/sources/targets/${ARCH_NAME}/details" ]
  then
    echo "Supported architectures: "
    (cd "${TOP}/sources/targets" && ls)
    exit 1
  fi

  # Read the relevant config file.

  ARCH="$ARCH_NAME"
  CONFIG_DIR="${TOP}/sources/targets"
  source "${CONFIG_DIR}/${ARCH}/details"

  # Which platform are we building for?

  export WORK="${BUILD}/temp-$ARCH"
  rm -rf "${WORK}"
  mkdir -p "${WORK}" || dienow

  # Say "unknown" in two different ways so it doesn't assume we're NOT
  # cross compiling when the host and target are the same processor.  (If host
  # and target match, the binutils/gcc/make builds won't use the cross compiler
  # during mini-native.sh, and the host compiler links binaries against the
  # wrong libc.)
  [ -z "$CROSS_HOST" ] && export CROSS_HOST=`uname -m`-walrus-linux
  [ -z "$CROSS_TARGET" ] && export CROSS_TARGET=${ARCH}-unknown-linux

  # Setup directories and add the cross compiler to the start of the path.

  export NATIVE="${BUILD}/mini-native-$ARCH"
  export PATH="${BUILD}/cross-compiler-$ARCH/bin:$PATH"

  if [ ! -z "${NATIVE_TOOLSDIR}" ]
  then
    TOOLS="${NATIVE}/tools"
  else
    TOOLS="${NATIVE}/usr"
  fi
else
  HW_ARCH=host
  export WORK="${BUILD}/host-temp"
  mkdir -p "${WORK}" || dienow
fi