# HG changeset patch # User Rob Landley # Date 1262559879 21600 # Node ID fc134a13357e33af1a34aa2a19f6ae0eb1c8a97d # Parent 7f2e6bdfcdcb53e07f5577edd496711d4248c100 Largeish refactoring and cleanup of compiler build: Break out native-compiler.sh from root-filesystem.sh NATIVE_TOOLCHAIN=* went away now NO_NATIVE_COMPILER=1 affecting build.sh root-filesystem.sh: Much simplified No more ROOT_TOPDIR, adjust STAGE_DIR=$STAGE_DIR/usr instead. Doesn't build native-compiler, instead copies existing native-compiler else installs library binaries out of cross compiler. Only build make/bash/distcc when we have a native compiler. native-compiler.sh: No more BUILD_STATIC_NATIVE_COMPILER, now built/packaged separately by default (NO_NATIVE_COMPILER=1 to skip), then incorporated into root-filesystem. now static by default, use BUILD_STATIC=none to override This script also makes the (optional) full cross-compiler renamed STATIC_CROSS_COMPILER_HOST to STATIC_CC_HOST Rename cross-compiler stage to simple-cross-compiler diff -r 7f2e6bdfcdcb -r fc134a13357e build.sh --- a/build.sh Sun Jan 03 05:04:35 2010 -0600 +++ b/build.sh Sun Jan 03 17:04:39 2010 -0600 @@ -12,15 +12,6 @@ fi ARCH="$1" -# Download source code and build host tools. - -time ./download.sh || exit 1 - -# host-tools populates one directory with every command the build needs, -# so we can ditch the old $PATH afterwards. - -time ./host-tools.sh || exit 1 - # A function to skip stages that have already been done (because the # tarball they create is already there). @@ -35,17 +26,26 @@ return 0 } +# Download source code and build host tools. + +time ./download.sh || exit 1 + +# host-tools populates one directory with every command the build needs, +# so we can ditch the old $PATH afterwards. + +time ./host-tools.sh || exit 1 + # Do we need to build the simple cross compiler? # This version has no thread support, no libgcc_s.so, doesn't include # uClibc++, and is dynamically linked against the host's shared libraries. -if not_already cross-compiler +if not_already simple-cross-compiler then # If we need to build cross compiler, assume root filesystem is stale. rm -rf "build/root-filesystem-$ARCH.tar.bz2" - time ./cross-compiler.sh "$ARCH" || exit 1 + time ./simple-cross-compiler.sh "$ARCH" || exit 1 fi # Optionally, we can build a statically linked compiler via canadian cross. @@ -53,7 +53,7 @@ # We don't autodetect the host because i686 is more portable (running on # both 64 and 32 bit hosts), but x86_64 is (slightly) faster on a 64 bit host. -if [ ! -z "$STATIC_CROSS_COMPILER_HOST" ] && not_already cross-static +if [ ! -z "$STATIC_CC_HOST" ] && not_already cross-compiler then # These are statically linked against uClibc on the host (for portability), @@ -63,21 +63,20 @@ # the host (to build the executables) and one for the target (to build # the libraries). - BUILD_STATIC=1 FROM_ARCH="$STATIC_CROSS_COMPILER_HOST" NATIVE_TOOLCHAIN=only \ - ROOT_NODIRS=1 STAGE_NAME=cross-static ./root-filesystem.sh "$ARCH" || exit 1 + BUILD_STATIC=1 FROM_ARCH="$STATIC_CC_HOST" STAGE_NAME=cross-compiler \ + ./native-compiler.sh "$ARCH" || exit 1 fi -# Optionally, we can build a static native compiler. (The one in -# root-filesystem is dynamically linked against uClibc, this one can -# presumably be untarred and run on any appropriate host system.) +# Build a native compiler. It's statically linked by default so it can be +# run on an arbitrary host system. -if [ ! -z "$BUILD_STATIC_NATIVE_COMPILER" ] && not_already native-compiler +# If this compiler exists, root-filesystem will pick it up and incorpoate it. + +if not_already native-compiler && [ -z "$NO_NATIVE_COMPILER" ] then - - # Build static native compilers for each target, possibly in parallel + rm -rf "build/root-filesystem-$ARCH.tar.bz2" - BUILD_STATIC=1 NATIVE_TOOLCHAIN=only STAGE_NAME=native-compiler \ - ./root-filesystem.sh "$ARCH" + BUILD_STATIC={$BUILD_STATIC:-1} ./native-compiler.sh "$ARCH" || exit 1 fi # Do we need to build the root filesystem? diff -r 7f2e6bdfcdcb -r fc134a13357e config --- a/config Sun Jan 03 05:04:35 2010 -0600 +++ b/config Sun Jan 03 17:04:39 2010 -0600 @@ -5,43 +5,33 @@ # are left blank by the build. Feel free to replace this file with your # own version, or to set these as environment variables on the command line. -# By default root-filesystem.sh will build a native toolchain (binutils, gcc, -# make, bash, distcc). Set this variable to "none" to skip all that, and -# build a root filesystem containing only uClibc and busybox. You can also -# set it to "headers" to retain the linux/uClibc kernel headers (in case you'd -# like to build your own native toolchain based on a different compiler). -# If you set it to "only", it'll build a native toolchain (binutils, gcc, -# uClibc, and the kernel headers) and nothing else. +# Set this to tell build.sh not to build a native toolchain. (This means +# root-filesystem.sh won't have it either.) -# export NATIVE_TOOLCHAIN=none -# export NATIVE_TOOLCHAIN=headers -# export NATIVE_TOOLCHAIN=only +# export NO_NATIVE_COMPILER=1 # If this is set, root-filesystem.sh won't bother to create the normal # directory hierarchy of /usr, /tmp, /etc, and so on. # export ROOT_NODIRS=1 -# By default, only busybox is built statically (doing so provides a 20% -# performance boost to autoconf under qemu). +# By default, busybox and the native compiler are built statically. +# (Building busybox static provides a 20% performance boost to autoconf +# under qemu, and building the native compiler static makes it more +# portable to other root filesystems.) -# To make busybox dynamic, set this to "none". Set it to any other +# To make those dynamic, set this to "none". Set it to any other # value to link all packages statically. # export BUILD_STATIC=none # export BUILD_STATIC=1 -# If this is set, build.sh will build a compiler statically linked +# If this is set, build.sh will build a cross compiler statically linked # against uClibc. This indicates which host that compiler should run on. # Note that most x86_64 systems can run a statically linked i686 binary even -# if they don't have the 32-bit libraries installed. - -# export STATIC_CROSS_COMPILER_HOST=i686 +# if they don't have the 32-bit libraries installed, so that's a good default. -# If this is set, build a standalone statically linked native compiler, to -# use an a target system that doesn't have development tools. - -# export BUILD_STATIC_NATIVE_COMPILER=1 +# export STATIC_CC_HOST=i686 # This may be set by the target's "details" file, but you can override it here. # You can set it to ext2, initramfs, or squashfs. It defaults to squashfs diff -r 7f2e6bdfcdcb -r fc134a13357e cross-compiler.sh --- a/cross-compiler.sh Sun Jan 03 05:04:35 2010 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -#!/bin/bash - -# Build a cross compiler for the specified target. - -# Get lots of predefined environment variables and shell functions. - -source sources/include.sh || exit 1 - -# Parse the sources/targets/$1 directory - -read_arch_dir "$1" - -# If this target has a base architecture that's already been built, use that. - -check_for_base_arch || exit 0 - -# Ok, we have work to do. Announce start of stage. - -echo "=== Building $STAGE_NAME" - -# Build binutils, gcc, and ccwrap - -FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section binutils -FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section gcc -FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section ccwrap - -# Build C Library - -build_section linux-headers -HOST_UTILS=1 build_section uClibc - -cat > "${STAGE_DIR}"/README << EOF && -Cross compiler for $ARCH -From http://impactlinux.com/fwl - -To use: Add the "bin" subdirectory to your \$PATH, and use "$ARCH-cc" as -your compiler. - -The syntax used to build the Linux kernel is: - - make ARCH=${KARCH} CROSS_COMPILE=${ARCH}- - -EOF - -# Strip the binaries - -if [ -z "$SKIP_STRIP" ] -then - cd "$STAGE_DIR" - for i in `find bin -type f` `find "$CROSS_TARGET" -type f` - do - strip "$i" 2> /dev/null - done -fi - -# Tar it up - -create_stage_tarball - -# A quick hello world program to test the cross compiler out. -# Build hello.c dynamic, then static, to verify header/library paths. - -echo "Sanity test: building Hello World." - -"${ARCH}-gcc" -Os "${SOURCES}/toys/hello.c" -o "$WORK"/hello && -"${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello && -if [ ! -z "$CROSS_SMOKE_TEST" ] && which qemu-"${QEMU_TEST}" > /dev/null -then - [ x"$(qemu-"${QEMU_TEST}" "${WORK}"/hello)" == x"Hello world!" ] && - echo Cross-toolchain seems to work. -fi - -[ $? -ne 0 ] && dienow - -echo -e "\e[32mCross compiler toolchain build complete.\e[0m" diff -r 7f2e6bdfcdcb -r fc134a13357e root-filesystem.sh --- a/root-filesystem.sh Sun Jan 03 05:04:35 2010 -0600 +++ b/root-filesystem.sh Sun Jan 03 17:04:39 2010 -0600 @@ -6,7 +6,6 @@ read_arch_dir "$1" check_for_base_arch || exit 0 check_prerequisite "${ARCH}-cc" -check_prerequisite "${FROM_ARCH}-cc" # Announce start of stage. @@ -16,140 +15,124 @@ if [ -z "$ROOT_NODIRS" ] then - ROOT_TOPDIR="$STAGE_DIR/usr" mkdir -p "$STAGE_DIR"/{tmp,proc,sys,dev,home,mnt} && chmod a+rwxt "$STAGE_DIR/tmp" || dienow for i in bin sbin lib etc do - mkdir -p "$ROOT_TOPDIR/$i" || dienow + mkdir -p "$STAGE_DIR/usr/$i" && ln -s "usr/$i" "$STAGE_DIR/$i" || dienow done + + STAGE_DIR="$STAGE_DIR/usr" else - ROOT_TOPDIR="$STAGE_DIR" mkdir -p "$STAGE_DIR/bin" || dienow fi -# Build C Library - -STAGE_DIR="$ROOT_TOPDIR" build_section linux-headers -STAGE_DIR="$ROOT_TOPDIR" build_section uClibc - -if [ "$NATIVE_TOOLCHAIN" == "none" ] -then - # If we're not installing a compiler, delete the headers, static libs, - # and example source code. - - rm -rf "$ROOT_TOPDIR"/include && - rm -rf "$ROOT_TOPDIR"/lib/*.[ao] && - rm -rf "$ROOT_TOPDIR/src" || dienow - -elif [ "$NATIVE_TOOLCHAIN" == "headers" ] -then - -# If you want to use a compiler other than gcc, you need to keep the headers, -# so do nothing here. - echo - -else - -# Build binutils, gcc, and ccwrap - -STAGE_DIR="$ROOT_TOPDIR" build_section binutils -STAGE_DIR="$ROOT_TOPDIR" build_section gcc -STAGE_DIR="$ROOT_TOPDIR" build_section ccwrap - -# Tell future packages to link against the libraries in the new root filesystem, -# rather than the ones in the cross compiler directory. - -export "$(echo $ARCH | sed 's/-/_/g')"_CCWRAP_TOPDIR="$ROOT_TOPDIR" - -STAGE_DIR="$ROOT_TOPDIR" build_section uClibc++ - -fi # End of NATIVE_TOOLCHAIN build - -if [ "$NATIVE_TOOLCHAIN" != "only" ] -then - # Copy qemu setup script and so on. -cp -r "${SOURCES}/native/." "$ROOT_TOPDIR/" && -cp "$SRCDIR"/MANIFEST "$ROOT_TOPDIR/src" || dienow - -STAGE_DIR="$ROOT_TOPDIR"/bin build_section busybox -cp "$WORK"/config-busybox "$ROOT_TOPDIR"/src || dienow - -STAGE_DIR="$ROOT_TOPDIR"/bin build_section toybox - -# Build and install make +cp -r "${SOURCES}/native/." "$STAGE_DIR/" && +cp "$SRCDIR"/MANIFEST "$STAGE_DIR/src" || dienow -setupfor make -LDFLAGS="$STATIC_FLAGS $LDFLAGS" CC="${ARCH}-cc" ./configure \ - --prefix="$ROOT_TOPDIR" --build="${CROSS_HOST}" --host="${CROSS_TARGET}" && -make -j $CPUS && -make -j $CPUS install - -cleanup - -# Build and install bash. (Yes, this is an old version. It's intentional.) +# Build busybox and toybox -setupfor bash -# Remove existing /bin/sh link (busybox) so the bash install doesn't get upset. -#rm "$ROOT_TOPDIR"/bin/sh -# wire around some tests ./configure can't run when cross-compiling. -cat > config.cache << EOF && -ac_cv_func_setvbuf_reversed=no -bash_cv_sys_named_pipes=yes -bash_cv_have_mbstate_t=yes -bash_cv_getenv_redef=no -EOF -LDFLAGS="$STATIC_FLAGS $LDFLAGS" CC="${ARCH}-cc" RANLIB="${ARCH}-ranlib" \ - ./configure --prefix="$ROOT_TOPDIR" \ - --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --cache-file=config.cache \ - --without-bash-malloc --disable-readline && -# note: doesn't work with -j -make && -make install && -# Make bash the default shell. -ln -sf bash "$ROOT_TOPDIR/bin/sh" +STAGE_DIR="$STAGE_DIR"/bin build_section busybox +cp "$WORK"/config-busybox "$STAGE_DIR"/src || dienow -cleanup - -setupfor distcc -rsync_cv_HAVE_C99_VSNPRINTF=yes \ -LDFLAGS="$STATIC_FLAGS $LDFLAGS" CC="${ARCH}-cc" ./configure \ - --host="${CROSS_TARGET}" --prefix="$ROOT_TOPDIR" \ - --with-included-popt --disable-Werror && -make -j $CPUS && -make -j $CPUS install && -mkdir -p "$ROOT_TOPDIR/distcc" || dienow - -for i in gcc cc g++ c++ -do - ln -s ../bin/distcc "$ROOT_TOPDIR/distcc/$i" || dienow -done - -cleanup +STAGE_DIR="$STAGE_DIR"/bin build_section toybox # Put statically and dynamically linked hello world programs on there for # test purposes. -"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -o "$ROOT_TOPDIR/bin/hello-dynamic" && -"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -static -o "$ROOT_TOPDIR/bin/hello-static" +"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -o "$STAGE_DIR/bin/hello-dynamic" && +"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -static -o "$STAGE_DIR/bin/hello-static" || dienow + +# If no native compiler exists for this target... + +if [ ! -d "$BUILD/native-compiler-$ARCH" ] +then + + # Do we need shared libraries? + + if [ ! -z "$BUILD_STATIC" ] + then + echo Copying compiler libraries... + mkdir -p "$STAGE_DIR/lib" || dienow + (path_search \ + "$("$ARCH-cc" --print-search-dirs | sed -n 's/^libraries: =*//p')" \ + "*.so*" 'cp -H "$DIR/$FILE" "$STAGE_DIR/lib/$FILE"' \ + || dienow) | dotprogress + fi + + # Since we're not installing a compiler, delete the example source code. + rm -rf "$STAGE_DIR/src/*.c*" || dienow + +# If a native compiler exists for this target, use it and add supplementary +# development tools + +else + + # Copy native compiler + + cp -a "$BUILD/native-compiler-$ARCH/." "$STAGE_DIR/" || dienow + + # Build and install make + + setupfor make + LDFLAGS="$STATIC_FLAGS $LDFLAGS" CC="${ARCH}-cc" ./configure \ + --prefix="$STAGE_DIR" --build="${CROSS_HOST}" --host="${CROSS_TARGET}" && + make -j $CPUS && + make -j $CPUS install + + cleanup -[ $? -ne 0 ] && dienow + # Build and install bash. (Yes, this is an old version. It's intentional.) + + setupfor bash + # wire around some tests ./configure can't run when cross-compiling. + echo -e "ac_cv_func_setvbuf_reversed=no\nbash_cv_sys_named_pipes=yes\nbash_cv_have_mbstate_t=yes\nbash_cv_getenv_redef=no" > config.cache && + LDFLAGS="$STATIC_FLAGS $LDFLAGS" CC="${ARCH}-cc" RANLIB="${ARCH}-ranlib" \ + ./configure --prefix="$STAGE_DIR" \ + --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --cache-file=config.cache \ + --without-bash-malloc --disable-readline && + # note: doesn't work with -j + make && + make install && + # Make bash the default shell. + ln -sf bash "$STAGE_DIR/bin/sh" + + cleanup + + # Build and install distcc -fi # End of NATIVE_TOOLCHAIN != only + setupfor distcc + rsync_cv_HAVE_C99_VSNPRINTF=yes \ + LDFLAGS="$STATIC_FLAGS $LDFLAGS" CC="${ARCH}-cc" ./configure \ + --host="${CROSS_TARGET}" --prefix="$STAGE_DIR" \ + --with-included-popt --disable-Werror && + make -j $CPUS && + make -j $CPUS install && + mkdir -p "$STAGE_DIR/distcc" || dienow + + for i in gcc cc g++ c++ + do + ln -s ../bin/distcc "$STAGE_DIR/distcc/$i" || dienow + done + + cleanup + + # Delete some unneeded files + + [ -z "$SKIP_STRIP" ] && + rm -rf "$STAGE_DIR"/{info,man,libexec/gcc/*/*/install-tools} + +fi # native compiler + +# Clean up and package the result if [ -z "$SKIP_STRIP" ] then - # Delete some unneeded files - - rm -rf "$ROOT_TOPDIR"/{info,man,libexec/gcc/*/*/install-tools} - - # Clean up and package the result - - "${ARCH}-strip" "$ROOT_TOPDIR"/{bin/*,sbin/*,libexec/gcc/*/*/*} - "${ARCH}-strip" --strip-unneeded "$ROOT_TOPDIR"/lib/*.so + "${ARCH}-strip" "$STAGE_DIR"/{bin/*,sbin/*,libexec/gcc/*/*/*} + "${ARCH}-strip" --strip-unneeded "$STAGE_DIR"/lib/*.so fi create_stage_tarball diff -r 7f2e6bdfcdcb -r fc134a13357e run-from-build.sh --- a/run-from-build.sh Sun Jan 03 05:04:35 2010 -0600 +++ b/run-from-build.sh Sun Jan 03 17:04:39 2010 -0600 @@ -2,7 +2,7 @@ # Grab cross compiler (for distcc) and run development environment. -export PATH="$(pwd)/build/host:$(pwd)/build/cross-compiler-$1/bin:$PATH" +export PATH="$(pwd)/build/host:$(pwd)/build/"{,simple-}"cross-compiler-$1/bin:$PATH" # Run development environment. diff -r 7f2e6bdfcdcb -r fc134a13357e simple-cross-compiler.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simple-cross-compiler.sh Sun Jan 03 17:04:39 2010 -0600 @@ -0,0 +1,75 @@ +#!/bin/bash + +# Build a cross compiler for the specified target. + +# Get lots of predefined environment variables and shell functions. + +source sources/include.sh || exit 1 + +# Parse the sources/targets/$1 directory + +read_arch_dir "$1" + +# If this target has a base architecture that's already been built, use that. + +check_for_base_arch || exit 0 + +# Ok, we have work to do. Announce start of stage. + +echo "=== Building $STAGE_NAME" + +# Build binutils, gcc, and ccwrap + +FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section binutils +FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section gcc +FROM_ARCH= PROGRAM_PREFIX="${ARCH}-" build_section ccwrap + +# Build C Library + +build_section linux-headers +HOST_UTILS=1 build_section uClibc + +cat > "${STAGE_DIR}"/README << EOF && +Cross compiler for $ARCH +From http://impactlinux.com/fwl + +To use: Add the "bin" subdirectory to your \$PATH, and use "$ARCH-cc" as +your compiler. + +The syntax used to build the Linux kernel is: + + make ARCH=${KARCH} CROSS_COMPILE=${ARCH}- + +EOF + +# Strip the binaries + +if [ -z "$SKIP_STRIP" ] +then + cd "$STAGE_DIR" + for i in `find bin -type f` `find "$CROSS_TARGET" -type f` + do + strip "$i" 2> /dev/null + done +fi + +# Tar it up + +create_stage_tarball + +# A quick hello world program to test the cross compiler out. +# Build hello.c dynamic, then static, to verify header/library paths. + +echo "Sanity test: building Hello World." + +"${ARCH}-gcc" -Os "${SOURCES}/toys/hello.c" -o "$WORK"/hello && +"${ARCH}-gcc" -Os -static "${SOURCES}/toys/hello.c" -o "$WORK"/hello && +if [ ! -z "$CROSS_SMOKE_TEST" ] && which qemu-"${QEMU_TEST}" > /dev/null +then + [ x"$(qemu-"${QEMU_TEST}" "${WORK}"/hello)" == x"Hello world!" ] && + echo Cross-toolchain seems to work. +fi + +[ $? -ne 0 ] && dienow + +echo -e "\e[32mCross compiler toolchain build complete.\e[0m" diff -r 7f2e6bdfcdcb -r fc134a13357e sources/functions.sh --- a/sources/functions.sh Sun Jan 03 05:04:35 2010 -0600 +++ b/sources/functions.sh Sun Jan 03 17:04:39 2010 -0600 @@ -10,7 +10,7 @@ { local i - for i in "$BUILD"/cross-{static,compiler}-"$1/bin" + for i in "$BUILD"/{,simple-}cross-compiler-"$1/bin" do [ -e "$i/$1-cc" ] && break done @@ -73,6 +73,9 @@ # Check this here because it could be set in "settings" [ ! -z "$BUILD_STATIC" ] && STATIC_FLAGS="--static" + [ "$BUILD_STATIC" != none ] && STATIC_DEFAULT_FLAGS="--static" + + DO_CROSS="CROSS_COMPILE=${ARCH}-" return 0 } diff -r 7f2e6bdfcdcb -r fc134a13357e sources/more/buildall.sh --- a/sources/more/buildall.sh Sun Jan 03 05:04:35 2010 -0600 +++ b/sources/more/buildall.sh Sun Jan 03 17:04:39 2010 -0600 @@ -5,8 +5,7 @@ . sources/functions.sh || exit 1 -[ -z "$STATIC_CROSS_COMPILER_HOST" ] && export STATIC_CROSS_COMPILER_HOST=i686 -export BUILD_STATIC_NATIVE_COMPILER=1 +[ -z "$STATIC_CC_HOST" ] && export STATIC_CC_HOST=i686 export FAIL_QUIET=1 [ -z "${ARCHES}" ] && @@ -32,7 +31,7 @@ mkdir -p build/logs && (./download.sh --extract 2>&1 && ./host-tools.sh 2>&1 && - ./cross-compiler.sh 2>&1 "$STATIC_CROSS_COMPILER_HOST" || + ./cross-compiler.sh 2>&1 "$STATIC_CC_HOST" || dienow) | tee build/logs/build-host-cc.txt | maybe_quiet cp packages/MANIFEST build || dienow diff -r 7f2e6bdfcdcb -r fc134a13357e sources/sections/busybox.build --- a/sources/sections/busybox.build Sun Jan 03 05:04:35 2010 -0600 +++ b/sources/sections/busybox.build Sun Jan 03 17:04:39 2010 -0600 @@ -1,14 +1,11 @@ # Build busybox statically by default, but don't statically link against # glibc because glibc is buggy and can't combine --static with --gc-sections. -[ "$BUILD_STATIC" != "none" ] && [ ! -z "$ARCH" ] && BUSYBOX_STATIC="--static" -[ ! -z "$ARCH" ] && DO_CROSS=CROSS_COMPILE=${ARCH}- - # Build busybox make allyesconfig KCONFIG_ALLCONFIG="${SOURCES}/trimconfig-busybox" && cp .config "$WORK"/config-busybox && -LDFLAGS="$LDFLAGS $BUSYBOX_STATIC" make -j $CPUS $VERBOSITY $DO_CROSS && +LDFLAGS="$LDFLAGS $STATIC_DEFAULT_FLAGS" make -j $CPUS $VERBOSITY $DO_CROSS && make busybox.links && cp busybox${SKIP_STRIP:+_unstripped} "${STAGE_DIR}/busybox" || dienow diff -r 7f2e6bdfcdcb -r fc134a13357e sources/sections/toybox.build --- a/sources/sections/toybox.build Sun Jan 03 05:04:35 2010 -0600 +++ b/sources/sections/toybox.build Sun Jan 03 17:04:39 2010 -0600 @@ -1,9 +1,7 @@ # Build toybox -[ ! -z "$ARCH" ] && DO_CROSS=CROSS_COMPILE=${ARCH}- - make defconfig && -CFLAGS="$CFLAGS $STATIC_FLAGS" make $DO_CROSS || dienow +CFLAGS="$CFLAGS $STATIC_DEFAULT_FLAGS" make $DO_CROSS || dienow if [ -z "$USE_TOYBOX" ] then diff -r 7f2e6bdfcdcb -r fc134a13357e sources/sections/uClibc++.build --- a/sources/sections/uClibc++.build Sun Jan 03 05:04:35 2010 -0600 +++ b/sources/sections/uClibc++.build Sun Jan 03 17:04:39 2010 -0600 @@ -5,11 +5,11 @@ sed -r -i '/UCLIBCXX_RUNTIME_PREFIX=/s/".*"/""/' .config && CROSS= make oldconfig && CROSS="$ARCH"- make && -CROSS= make install PREFIX="$ROOT_TOPDIR/c++" && +CROSS= make install PREFIX="$STAGE_DIR/c++" && # Move libraries somewhere useful. -mv "$ROOT_TOPDIR"/c++/lib/* "$ROOT_TOPDIR"/lib && -rm -rf "$ROOT_TOPDIR"/c++/{lib,bin} && -ln -s libuClibc++.so "$ROOT_TOPDIR"/lib/libstdc++.so && -ln -s libuClibc++.a "$ROOT_TOPDIR"/lib/libstdc++.a +mv "$STAGE_DIR"/c++/lib/* "$STAGE_DIR"/lib && +rm -rf "$STAGE_DIR"/c++/{lib,bin} && +ln -s libuClibc++.so "$STAGE_DIR"/lib/libstdc++.so && +ln -s libuClibc++.a "$STAGE_DIR"/lib/libstdc++.a diff -r 7f2e6bdfcdcb -r fc134a13357e sources/toys/run-emulator.sh --- a/sources/toys/run-emulator.sh Sun Jan 03 05:04:35 2010 -0600 +++ b/sources/toys/run-emulator.sh Sun Jan 03 17:04:39 2010 -0600 @@ -73,11 +73,11 @@ if [ -z "$DISTCC_PATH" ] then - [ ! -f "cross-compiler-$ARCH/bin/$ARCH-cc" ] && - DISTCC_PATH="$(pwd)/cross-compiler-$ARCH/bin" - - [ ! -f "$HOME/cross-compiler-$ARCH/bin/$ARCH-cc" ] && - DISTCC_PATH="$HOME/cross-compiler-$ARCH/bin" + for i in {"$(pwd)","$HOME"/}{,simple-}cross-compiler-"$ARCH"/bin + do + [ -f "$i/$ARCH-cc" ] && DISTCC_PATH="$i" + break + done fi if [ -z "$(which distccd)" ] diff -r 7f2e6bdfcdcb -r fc134a13357e sources/utility_functions.sh --- a/sources/utility_functions.sh Sun Jan 03 05:04:35 2010 -0600 +++ b/sources/utility_functions.sh Sun Jan 03 17:04:39 2010 -0600 @@ -131,12 +131,37 @@ done } +# Abort if we haven't got a prerequisite in the $PATH + check_prerequisite() { if [ -z "$(which "$1")" ] then - [ -z "$FAIL_QUIET" ] && echo No "$i" in '$PATH'. >&2 - exit 1 + [ -z "$FAIL_QUIET" ] && echo No "$1" in '$PATH'. >&2 + dienow fi } +# Search through all the files under a directory and collapse together +# identical files into hardlinks + +collapse_hardlinks() +{ + SHA1LIST="" + find "$1" -type f | while read FILE + do + echo "$FILE" + SHA1=$(sha1file "$FILE") + MATCH=$(echo "$SHA1LIST" | grep "^$SHA1") + if [ -z "$MATCH" ] + then + # Yes, the quote spanning two lines here is intentional + SHA1LIST="$SHA1LIST +$SHA1 $FILE" + else + FILE2="$(echo "$MATCH" | sed 's/[^ ]* //')" + cmp -s "$FILE" "$FILE2" || continue + ln -f "$FILE" "$FILE2" || dienow + fi + done +} diff -r 7f2e6bdfcdcb -r fc134a13357e system-image.sh --- a/system-image.sh Sun Jan 03 05:04:35 2010 -0600 +++ b/system-image.sh Sun Jan 03 17:04:39 2010 -0600 @@ -46,20 +46,17 @@ # Build a linux kernel for the target setupfor linux -[ -z "$BOOT_KARCH" ] && BOOT_KARCH="$KARCH" +[ -z "$BOOT_KARCH" ] && BOOT_KARCH=$KARCH cp "$(getconfig linux)" mini.conf || dienow [ "$SYSIMAGE_TYPE" == "initramfs" ] && (echo "CONFIG_BLK_DEV_INITRD=y" >> mini.conf || dienow) -make ARCH="${BOOT_KARCH}" KCONFIG_ALLCONFIG=mini.conf $LINUX_FLAGS \ +make ARCH=$BOOT_KARCH KCONFIG_ALLCONFIG=mini.conf $LINUX_FLAGS \ allnoconfig >/dev/null || dienow # Build kernel in parallel with initramfs -echo make -j $CPUS ARCH="${BOOT_KARCH}" CROSS_COMPILE="${ARCH}-" $LINUX_FLAGS \ - $VERBOSITY - -( make -j $CPUS ARCH="${BOOT_KARCH}" CROSS_COMPILE="${ARCH}-" $LINUX_FLAGS \ - $VERBOSITY || dienow ) & +echo "make -j $CPUS ARCH=$BOOT_KARCH $DO_CROSS $LINUX_FLAGS $VERBOSITY" +( make -j $CPUS ARCH=$BOOT_KARCH $DO_CROSS $LINUX_FLAGS $VERBOSITY || dienow ) & # Embed an initramfs image in the kernel? @@ -91,8 +88,7 @@ [ -f initramfs_data.cpio.gz ] && touch initramfs_data.cpio.gz && mv initramfs_data.cpio.gz usr && - make -j $CPUS ARCH="${BOOT_KARCH}" CROSS_COMPILE="${ARCH}-" $LINUX_FLAGS \ - || dienow + make -j $CPUS ARCH=$BOOT_KARCH $DO_CROSS $LINUX_FLAGS || dienow # No need to supply an hda image to emulator.