diff root-filesystem.sh @ 783:db06a8c1bfed

Lots of changes to move buildall.sh functionality into build.sh. Upgrade build.sh to be able to create static cross compilers and static native compilers via canadian cross. Teach build stages to use $STAGE_NAME for their output directory (and tarballs, and === notifications). Remove LFS style /tools support (since host-tools.sh performs an equivalent cleaning step and it's a pain to maintain it), add ROOT_NODIRS instead.
author Rob Landley <rob@landley.net>
date Sun, 05 Jul 2009 17:50:44 -0500
parents 5c6ebb711b72
children 81cf7ae7afce
line wrap: on
line diff
--- a/root-filesystem.sh	Sun Jul 05 17:30:01 2009 -0500
+++ b/root-filesystem.sh	Sun Jul 05 17:50:44 2009 -0500
@@ -10,7 +10,7 @@
 
 # If this target has a base architecture that's already been built, use that.
 
-check_for_base_arch root-filesystem || exit 0
+check_for_base_arch || exit 0
 
 # Die if our prerequisite isn't there.
 
@@ -26,38 +26,34 @@
 # Announce start of stage.
 
 echo -e "$NATIVE_COLOR"
-echo "=== Building minimal native development environment"
+echo "=== Building $STAGE_NAME"
 
 blank_tempdir "$WORK"
-blank_tempdir "$NATIVE_ROOT"
+blank_tempdir "$STAGE_DIR"
 
 # Determine which directory layout we're using
 
-if [ ! -z "${NATIVE_TOOLSDIR}" ]
+if [ -z "$ROOT_NODIRS" ]
 then
-  mkdir -p "${TOOLS}/bin" || dienow
-
-  # Tell the wrapper script where to find the dynamic linker.
-  export UCLIBC_DYNAMIC_LINKER=/tools/lib/ld-uClibc.so.0
-  UCLIBC_TOPDIR="${NATIVE_ROOT}"
-  UCLIBC_DLPREFIX="/tools"
-else
-  mkdir -p "${NATIVE_ROOT}"/{tmp,proc,sys,dev,home} || dienow
-  UCLIBC_TOPDIR="${TOOLS}"
+  ROOT_TOPDIR="$STAGE_DIR/usr"
+  mkdir -p "$STAGE_DIR"/{tmp,proc,sys,dev,home} || dienow
   for i in bin sbin lib etc
   do
-    mkdir -p "$TOOLS/$i" || dienow
-    ln -s "usr/$i" "${NATIVE_ROOT}/$i" || dienow
+    mkdir -p "$ROOT_TOPDIR/$i" || dienow
+    ln -s "usr/$i" "$STAGE_DIR/$i" || dienow
   done
+else
+  ROOT_TOPDIR="$STAGE_DIR"
+  mkdir -p "$STAGE_DIR/bin" || dienow
 fi
 
 # Install Linux kernel headers.
 
 setupfor linux
 # Install Linux kernel headers (for use by uClibc).
-make headers_install -j "$CPUS" ARCH="${KARCH}" INSTALL_HDR_PATH="${TOOLS}" &&
+make headers_install -j "$CPUS" ARCH="${KARCH}" INSTALL_HDR_PATH="$ROOT_TOPDIR" &&
 # This makes some very old package builds happy.
-ln -s ../sys/user.h "${TOOLS}/include/asm/page.h" &&
+ln -s ../sys/user.h "$ROOT_TOPDIR/include/asm/page.h" &&
 cd ..
 
 cleanup linux
@@ -73,9 +69,9 @@
 # -j > 1, it dies.  Not SMP safe.
 for i in install install_utils
 do
-  make CROSS="${ARCH}-" KERNEL_HEADERS="${TOOLS}/include" \
-       PREFIX="${UCLIBC_TOPDIR}/" $VERBOSITY \
-       RUNTIME_PREFIX="$UCLIBC_DLPREFIX/" DEVEL_PREFIX="$UCLIBC_DLPREFIX/" \
+  make CROSS="${ARCH}-" KERNEL_HEADERS="$ROOT_TOPDIR/include" \
+       PREFIX="$ROOT_TOPDIR/" $VERBOSITY \
+       RUNTIME_PREFIX="/" DEVEL_PREFIX="/" \
        UCLIBC_LDSO_NAME=ld-uClibc -j $CPUS $i || dienow
 done
 
@@ -85,7 +81,7 @@
 then
   for i in ldd readelf
   do
-    mv "${TOOLS}"/bin/{"$i","${PROGRAM_PREFIX}$i"} || dienow
+    mv "$ROOT_TOPDIR"/bin/{"$i","${PROGRAM_PREFIX}$i"} || dienow
   done
 fi
 
@@ -98,9 +94,9 @@
     # If we're not installing a compiler, delete the headers, static libs,
 	# and example source code.
 
-    rm -rf "${TOOLS}"/include &&
-    rm -rf "${TOOLS}"/lib/*.a &&
-    rm -rf "${TOOLS}/src" || dienow
+    rm -rf "$ROOT_TOPDIR"/include &&
+    rm -rf "$ROOT_TOPDIR"/lib/*.a &&
+    rm -rf "$ROOT_TOPDIR/src" || dienow
 
 elif [ "$NATIVE_TOOLCHAIN" == "headers" ]
 then
@@ -114,7 +110,7 @@
 # Build and install native binutils
 
 setupfor binutils build-binutils
-CC="${FROM_ARCH}-cc" AR="${FROM_ARCH}-ar" "${CURSRC}/configure" --prefix="${TOOLS}" \
+CC="${FROM_ARCH}-cc" AR="${FROM_ARCH}-ar" "${CURSRC}/configure" --prefix="$ROOT_TOPDIR" \
   --build="${CROSS_HOST}" --host="${FROM_HOST}" --target="${CROSS_TARGET}" \
   --disable-nls --disable-shared --disable-multilib --disable-werror \
   --program-prefix="$PROGRAM_PREFIX" $BINUTILS_FLAGS &&
@@ -122,8 +118,8 @@
 make -j $CPUS CFLAGS="-O2 $STATIC_FLAGS" &&
 make -j $CPUS install &&
 cd .. &&
-mkdir -p "${TOOLS}/include" &&
-cp binutils/include/libiberty.h "${TOOLS}/include"
+mkdir -p "$ROOT_TOPDIR/include" &&
+cp binutils/include/libiberty.h "$ROOT_TOPDIR/include"
 
 cleanup binutils build-binutils
 
@@ -148,7 +144,7 @@
   ac_cv_path_NM_FOR_TARGET="${ARCH}-nm" \
   ac_cv_path_AS_FOR_TARGET="${ARCH}-as" \
   ac_cv_path_LD_FOR_TARGET="${ARCH}-ld" \
-  "${CURSRC}/configure" --prefix="${TOOLS}" --disable-multilib \
+  "${CURSRC}/configure" --prefix="$ROOT_TOPDIR" --disable-multilib \
   --build="${CROSS_HOST}" --host="${CROSS_TARGET}" --target="${CROSS_TARGET}" \
   --enable-long-long --enable-c99 --enable-shared --enable-threads=posix \
   --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \
@@ -159,49 +155,49 @@
 make -j $CPUS configure-host &&
 make -j $CPUS all-gcc LDFLAGS="$STATIC_FLAGS" &&
 # Work around gcc bug; we disabled multilib but it doesn't always notice.
-ln -s lib "$TOOLS/lib64" &&
+ln -s lib "$ROOT_TOPDIR/lib64" &&
 make -j $CPUS install-gcc &&
-rm "$TOOLS/lib64" &&
-ln -s "${PROGRAM_PREFIX}gcc" "${TOOLS}/bin/${PROGRAM_PREFIX}cc" &&
+rm "$ROOT_TOPDIR/lib64" &&
+ln -s "${PROGRAM_PREFIX}gcc" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}cc" &&
 # Now we need to beat libsupc++ out of gcc (which uClibc++ needs to build).
 # But don't want to build the whole of libstdc++-v3 because
 # A) we're using uClibc++ instead,  B) the build breaks.
 make -j $CPUS configure-target-libstdc++-v3 &&
 cd "$CROSS_TARGET"/libstdc++-v3/libsupc++ &&
 make -j $CPUS &&
-mv .libs/libsupc++.a "$TOOLS"/lib &&
+mv .libs/libsupc++.a "$ROOT_TOPDIR"/lib &&
 cd ../../../..
 
 cleanup gcc-core build-gcc
 
 # Move the gcc internal libraries and headers somewhere sane
 
-mkdir -p "${TOOLS}"/gcc &&
-mv "${TOOLS}"/lib/gcc/*/*/include "${TOOLS}"/gcc/include &&
-mv "${TOOLS}"/lib/gcc/*/* "${TOOLS}"/gcc/lib &&
+mkdir -p "$ROOT_TOPDIR"/gcc &&
+mv "$ROOT_TOPDIR"/lib/gcc/*/*/include "$ROOT_TOPDIR"/gcc/include &&
+mv "$ROOT_TOPDIR"/lib/gcc/*/* "$ROOT_TOPDIR"/gcc/lib &&
 
 # Rub gcc's nose in the binutils output.
-cd "${TOOLS}"/libexec/gcc/*/*/ &&
+cd "$ROOT_TOPDIR"/libexec/gcc/*/*/ &&
 cp -s "../../../../$CROSS_TARGET/bin/"* . &&
 
 # build and install gcc wrapper script.
-mv "${TOOLS}/bin/${PROGRAM_PREFIX}gcc" "${TOOLS}/bin/${PROGRAM_PREFIX}rawgcc" &&
+mv "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}gcc" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}rawgcc" &&
 "${FROM_ARCH}-cc" "${SOURCES}"/toys/ccwrap.c -Os -s \
-  -o "${TOOLS}/bin/${PROGRAM_PREFIX}gcc" -DGIMME_AN_S $STATIC_FLAGS \
+  -o "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}gcc" -DGIMME_AN_S $STATIC_FLAGS \
   -DGCC_UNWRAPPED_NAME='"'"${PROGRAM_PREFIX}rawgcc"'"' &&
 
 # Wrap C++
-mv "${TOOLS}/bin/${PROGRAM_PREFIX}g++" "${TOOLS}/bin/${PROGRAM_PREFIX}rawg++" &&
-ln "${TOOLS}/bin/${PROGRAM_PREFIX}gcc" "${TOOLS}/bin/${PROGRAM_PREFIX}g++" &&
-rm "${TOOLS}/bin/${PROGRAM_PREFIX}c++" &&
-ln -s "${PROGRAM_PREFIX}g++" "${TOOLS}/bin/${PROGRAM_PREFIX}c++"
+mv "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}g++" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}rawg++" &&
+ln "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}gcc" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}g++" &&
+rm "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}c++" &&
+ln -s "${PROGRAM_PREFIX}g++" "$ROOT_TOPDIR/bin/${PROGRAM_PREFIX}c++"
 
-cleanup "${TOOLS}"/{lib/gcc,gcc/lib/install-tools,bin/${ARCH}-unknown-*}
+cleanup "$ROOT_TOPDIR"/{lib/gcc,gcc/lib/install-tools,bin/${ARCH}-unknown-*}
 
-# Tell future packages to link against the libraries in root-filesystem,
+# Tell future packages to link against the libraries in the new root filesystem,
 # rather than the ones in the cross compiler directory.
 
-export WRAPPER_TOPDIR="${TOOLS}"
+export WRAPPER_TOPDIR="$ROOT_TOPDIR"
 
 # Build and install uClibc++
 
@@ -211,14 +207,14 @@
 sed -r -i '/UCLIBCXX_RUNTIME_PREFIX=/s/".*"/""/' .config &&
 CROSS= make oldconfig &&
 CROSS="$ARCH"- make &&
-CROSS= make install PREFIX="${TOOLS}/c++" &&
+CROSS= make install PREFIX="$ROOT_TOPDIR/c++" &&
 
 # Move libraries somewhere useful.
 
-mv "${TOOLS}"/c++/lib/* "${TOOLS}"/lib &&
-rm -rf "${TOOLS}"/c++/{lib,bin} &&
-ln -s libuClibc++.so "${TOOLS}"/lib/libstdc++.so &&
-ln -s libuClibc++.a "${TOOLS}"/lib/libstdc++.a &&
+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 &&
 cd ..
 
 cleanup uClibc++
@@ -230,14 +226,9 @@
 
 # Copy qemu setup script and so on.
 
-cp -r "${SOURCES}/native/." "${TOOLS}/" &&
-cp "$SRCDIR"/MANIFEST "${TOOLS}/src" &&
-cp "${WORK}/config-uClibc" "${TOOLS}/src/config-uClibc" || dienow
-
-if [ -z "${NATIVE_TOOLSDIR}" ]
-then
-  sed -i -e 's@/tools/@/usr/@g' "${TOOLS}/sbin/init.sh" || dienow
-fi
+cp -r "${SOURCES}/native/." "$ROOT_TOPDIR/" &&
+cp "$SRCDIR"/MANIFEST "$ROOT_TOPDIR/src" &&
+cp "${WORK}/config-uClibc" "$ROOT_TOPDIR/src/config-uClibc" || dienow
 
 # Build and install toybox
 
@@ -246,14 +237,14 @@
 if [ -z "$USE_TOYBOX" ]
 then
   CFLAGS="$CFLAGS $STATIC_FLAGS" make CROSS="${ARCH}-" &&
-  cp toybox "$TOOLS/bin" &&
-  ln -s toybox "$TOOLS/bin/patch" &&
-  ln -s toybox "$TOOLS/bin/oneit" &&
-  ln -s toybox "$TOOLS/bin/netcat" &&
+  cp toybox "$ROOT_TOPDIR/bin" &&
+  ln -s toybox "$ROOT_TOPDIR/bin/patch" &&
+  ln -s toybox "$ROOT_TOPDIR/bin/oneit" &&
+  ln -s toybox "$ROOT_TOPDIR/bin/netcat" &&
   cd ..
 else
   CFLAGS="$CFLAGS $STATIC_FLAGS" \
-    make install_flat PREFIX="${TOOLS}"/bin CROSS="${ARCH}-" &&
+    make install_flat PREFIX="$ROOT_TOPDIR"/bin CROSS="${ARCH}-" &&
   cd ..
 fi
 
@@ -263,18 +254,18 @@
 
 setupfor busybox
 make allyesconfig KCONFIG_ALLCONFIG="${SOURCES}/trimconfig-busybox" &&
-cp .config "${TOOLS}"/src/config-busybox &&
+cp .config "$ROOT_TOPDIR"/src/config-busybox &&
 LDFLAGS="$LDFLAGS $STATIC_FLAGS" \
   make -j $CPUS CROSS_COMPILE="${ARCH}-" $VERBOSITY &&
 make busybox.links &&
-cp busybox "${TOOLS}/bin"
+cp busybox "$ROOT_TOPDIR/bin"
 
 [ $? -ne 0 ] && dienow
 
 for i in $(sed 's@.*/@@' busybox.links)
 do
   # Allowed to fail.
-  ln -s busybox "${TOOLS}/bin/$i" 2>/dev/null
+  ln -s busybox "$ROOT_TOPDIR/bin/$i" 2>/dev/null
 done
 cd ..
 
@@ -283,7 +274,7 @@
 # Build and install make
 
 setupfor make
-CC="${ARCH}-cc" ./configure --prefix="${TOOLS}" --build="${CROSS_HOST}" \
+CC="${ARCH}-cc" ./configure --prefix="$ROOT_TOPDIR" --build="${CROSS_HOST}" \
   --host="${CROSS_TARGET}" &&
 make -j $CPUS &&
 make -j $CPUS install &&
@@ -295,7 +286,7 @@
 
 setupfor bash
 # Remove existing /bin/sh link (busybox) so the bash install doesn't get upset.
-#rm "$TOOLS"/bin/sh
+#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
@@ -303,28 +294,28 @@
 bash_cv_have_mbstate_t=yes
 bash_cv_getenv_redef=no
 EOF
-CC="${ARCH}-cc" RANLIB="${ARCH}-ranlib" ./configure --prefix="${TOOLS}" \
+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 "${TOOLS}/bin/sh" &&
+ln -sf bash "$ROOT_TOPDIR/bin/sh" &&
 cd ..
 
 cleanup bash
 
 setupfor distcc
-CC="${ARCH}-cc" ./configure --host="${CROSS_TARGET}" --prefix="${TOOLS}" \
+CC="${ARCH}-cc" ./configure --host="${CROSS_TARGET}" --prefix="$ROOT_TOPDIR" \
   --with-included-popt --disable-Werror &&
 make -j $CPUS &&
 make -j $CPUS install &&
-mkdir -p "${TOOLS}/distcc" || dienow
+mkdir -p "$ROOT_TOPDIR/distcc" || dienow
 
 for i in gcc cc g++ c++
 do
-  ln -s ../bin/distcc "${TOOLS}/distcc/$i" || dienow
+  ln -s ../bin/distcc "$ROOT_TOPDIR/distcc/$i" || dienow
 done
 cd ..
 
@@ -333,8 +324,8 @@
 # Put statically and dynamically linked hello world programs on there for
 # test purposes.
 
-"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os -s -o "${TOOLS}/bin/hello-dynamic" &&
-"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os -s -static -o "${TOOLS}/bin/hello-static"
+"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os -s -o "$ROOT_TOPDIR/bin/hello-dynamic" &&
+"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os -s -static -o "$ROOT_TOPDIR/bin/hello-static"
 
 [ $? -ne 0 ] && dienow
 
@@ -342,14 +333,14 @@
 
 # Delete some unneeded files
 
-rm -rf "${TOOLS}"/{info,man,libexec/gcc/*/*/install-tools}
+rm -rf "$ROOT_TOPDIR"/{info,man,libexec/gcc/*/*/install-tools}
 
 # Clean up and package the result
 
-"${ARCH}-strip" "${TOOLS}"/{bin/*,sbin/*,libexec/gcc/*/*/*}
-"${ARCH}-strip" --strip-unneeded "${TOOLS}"/lib/*.so
+"${ARCH}-strip" "$ROOT_TOPDIR"/{bin/*,sbin/*,libexec/gcc/*/*/*}
+"${ARCH}-strip" --strip-unneeded "$ROOT_TOPDIR"/lib/*.so
 
-create_stage_tarball root-filesystem
+create_stage_tarball
 
 # Color back to normal
 echo -e "\e[0mBuild complete"