# HG changeset patch # User Rob Landley # Date 1276983889 18000 # Node ID e5f9681a8b3c90d73aa76b227142e5d3dceddc5c # Parent 1f51b4a0517b148be83f06f44d8d69e275108eda Lots of comment updates. Add a NO_HOST_TOOLS=1 config option, and a few "time" calls to stages that didn't have them. Put native-compiler.sh after root-filesystem.sh in build so it's slightly easier to document. diff -r 1f51b4a0517b -r e5f9681a8b3c build.sh --- a/build.sh Sat Jun 19 16:42:03 2010 -0500 +++ b/build.sh Sat Jun 19 16:44:49 2010 -0500 @@ -2,31 +2,58 @@ # Run all the steps needed to build a system image from scratch. -# Simplest: download, simple-cross-compiler, simple-root-filesystem, -# system-image. +# The default set of stages run by this script is: +# download, host-tools, simple-cross-compiler, simple-root-filesystem, +# native-compiler, root-filesystem, system-image. + +# That sanitizes the host build environment and builds a cross compiler, +# cross compiles a root filesystem and a native toolchain for the target, +# and finally packages the root filesystem up into a system image bootable +# by qemu. -# More likely: download, host-tools, simple-cross-compiler, cross-compiler, -# native-compiler, simple-root-filesystem, root-filesystem, system-image +# The simplest set of stages is: +# download, simple-cross-compiler, simple-root-filesystem, system-image. +# +# That skips sanitizing the host environment, and skips building the native +# compiler. It builds a system image containing just enough code to boot to +# a command prompt. To invoke that, do: +# +# NO_HOST_TOOLS=1 NO_NATIVE_COMPILER=1 ./build.sh $TARGET -# If run with no arguments, list architectures. +# The optional cross-compiler stage (after simple-cross-compiler but before +# simple-root-filesystem) creates a more powerful and portable cross compiler +# that can be used to cross compile more stuff (if you're into that sort of +# thing). To enable it, "export CROSS_HOST_ARCH=i686" (or whichever target +# you want the new cross compiler to run on). + +# Start with some housekeeping stuff. If this script was run with no +# arguments, list available architectures out of sources/targets. if [ $# -ne 1 ] then - echo "Usage: $0 ARCH" - . sources/include.sh - read_arch_dir + echo "Usage: $0 TARGET" + + echo "Supported architectures:" + cd sources/targets + ls + + exit 1 fi ARCH="$1" +# Use environment variables persistently set in the config file. + [ -e config ] && source config +# Allow the output directory to be overridden. This hasn't been tested in +# forever and probably doesn't work. + [ -z "$BUILD" ] && BUILD="build" -# A function to skip stages that have already been done (because the -# tarball they create is already there). Stages delete the tarballs of -# later stages as a simple form of dependency tracking. +# Very simple dependency tracking: skip stages that have already been done +# (because the tarball they create is already there). -# If you need to rebuild a stage and everything after it, delete its +# If you need to rebuild a stage (and everything after it), delete its # tarball out of "build" and re-run build.sh. not_already() @@ -51,7 +78,10 @@ # Build host tools. This populates a single directory with every command the # build needs, so we can ditch the host's $PATH afterwards. -time ./host-tools.sh || exit 1 +if [ -z "$NO_HOST_TOOLS" ] +then + time ./host-tools.sh || exit 1 +fi # Do we need to build the simple cross compiler? @@ -72,20 +102,10 @@ then rm -rf "$BUILD/simple-root-filesystem-$ARCH.tar.bz2" - ./cross_compiler.sh "$ARCH" || exit 1 + time ./cross_compiler.sh "$ARCH" || exit 1 fi -# Build a native compiler. It's statically linked by default so it can -# run on an arbitrary host system. - -if not_already native-compiler && [ -z "$NO_NATIVE_COMPILER" ] -then - rm -rf "$BUILD/root-filesystem-$ARCH.tar.bz2" - - ./native-compiler.sh "$ARCH" || exit 1 -fi - -# Do we need to build the root filesystem? +# Build the basic root filesystem. if not_already simple-root-filesystem then @@ -99,7 +119,17 @@ fi -# Install the native compiler into the root filesystem (if any). +# Build a native compiler. It's statically linked by default so it can +# run on an arbitrary host system. + +if not_already native-compiler && [ -z "$NO_NATIVE_COMPILER" ] +then + rm -rf "$BUILD/root-filesystem-$ARCH.tar.bz2" + + time ./native-compiler.sh "$ARCH" || exit 1 +fi + +# Install the native compiler into the root filesystem, if necessary. if not_already root-filesystem && [ -z "$NO_NATIVE_COMPILER" ] then @@ -108,6 +138,8 @@ time ./root-filesystem.sh "$ARCH" || exit 1 fi +# Package it up into something qemu can boot. + if not_already system-image then time ./system-image.sh $1 || exit 1 @@ -121,5 +153,6 @@ mkdir -p "$BUILD/rw-system-image-$ARCH" && cp "$BUILD/system-image-$ARCH"/zImage-* "$BUILD/rw-system-image-$ARCH" - STAGE_NAME=rw-system-image SYSIMAGE_TYPE=ext2 SYSIMAGE_HDA_MEGS=2048 time ./system-image.sh $1 || exit 1 + STAGE_NAME=rw-system-image SYSIMAGE_TYPE=ext2 SYSIMAGE_HDA_MEGS=2048 \ + time ./system-image.sh $1 || exit 1 fi diff -r 1f51b4a0517b -r e5f9681a8b3c config --- a/config Sat Jun 19 16:42:03 2010 -0500 +++ b/config Sat Jun 19 16:44:49 2010 -0500 @@ -19,6 +19,13 @@ # export ROOT_NODIRS=1 +# Setting this tells build.sh to use the existing $PATH commands to build +# everything, which probably won't work out of the box. Cross compiling is +# an insanely delicate process which requires a carefully configured host +# environment. If we don't set up our own, you'll have to supply one. + +# export NO_HOST_TOOLS=1 + # Set this to a comma separated list of packages to build statically, # or "none" to build all packages dynamically. Set to "all" to build all # packages statically (and not install static libraries on the target). diff -r 1f51b4a0517b -r e5f9681a8b3c host-tools.sh --- a/host-tools.sh Sat Jun 19 16:42:03 2010 -0500 +++ b/host-tools.sh Sat Jun 19 16:44:49 2010 -0500 @@ -1,6 +1,6 @@ #!/bin/bash -# Set up a known host environment, providing known versions all required +# Set up a known host environment, providing known versions of all required # prerequisites, built from source. # This script serves a similar purpose to the temporary chroot system in diff -r 1f51b4a0517b -r e5f9681a8b3c root-filesystem.sh --- a/root-filesystem.sh Sat Jun 19 16:42:03 2010 -0500 +++ b/root-filesystem.sh Sat Jun 19 16:44:49 2010 -0500 @@ -1,6 +1,6 @@ #!/bin/bash -# Combine simple-root-filesystem and native-compiler. +# Combine the output of simple-root-filesystem and native-compiler. . sources/include.sh || exit 1 @@ -14,6 +14,8 @@ echo "No $BUILD/native-compiler-$ARCH" >&2 && exit 1 +cp -a "$BUILD/simple-root-filesystem-$ARCH/." "$STAGE_DIR" || dienow + # Remove shared libraries copied from cross compiler. rm -rf "$BUILD/root-filesystem-$ARCH/usr/lib" 2>/dev/null diff -r 1f51b4a0517b -r e5f9681a8b3c simple-root-filesystem.sh --- a/simple-root-filesystem.sh Sat Jun 19 16:42:03 2010 -0500 +++ b/simple-root-filesystem.sh Sat Jun 19 16:44:49 2010 -0500 @@ -2,6 +2,10 @@ # Build a basic busybox+uClibc root filesystem for a given target. +# Requires a cross-compiler (or simple-cross-compiler) in the $PATH or in +# the build directory. In theory you can supply your own as long as the +# prefix- name is correct. + source sources/include.sh || exit 1 read_arch_dir "$1" check_for_base_arch || exit 0