changeset 938:609bc05b0d6a

Teach build_section to run "*.build" sections (with setupfor/cleanup called for them) as well as "*.sh" sections which do their own setup/cleanup.
author Rob Landley <rob@landley.net>
date Sat, 19 Dec 2009 00:51:16 -0600
parents f2b4d7297c9d
children abff74b958a1
files sources/functions.sh sources/sections/README sources/sections/binutils.build sources/sections/binutils.sh sources/sections/busybox.build sources/sections/busybox.sh sources/sections/toybox.build sources/sections/toybox.sh sources/sections/uClibc++.build sources/sections/uClibc++.sh sources/sections/uClibc.build sources/sections/uClibc.sh
diffstat 12 files changed, 175 insertions(+), 172 deletions(-) [+]
line wrap: on
line diff
--- a/sources/functions.sh	Fri Dec 18 03:38:21 2009 -0600
+++ b/sources/functions.sh	Sat Dec 19 00:51:16 2009 -0600
@@ -93,8 +93,15 @@
 
 function build_section()
 {
-  echo "=== build section $1"
-  . "$SOURCES"/sections/"$1".sh
+  if [ -e "$SOURCES/sections/$1".build ]
+  then
+    setupfor "$1"
+    . "$SOURCES/sections/$1".build
+    cleanup
+  else
+    echo "=== build section $1"
+    . "$SOURCES"/sections/"$1".sh
+  fi
 }
 
 # Figure out if we're using the stable or unstable versions of a package.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/sections/README	Sat Dec 19 00:51:16 2009 -0600
@@ -0,0 +1,7 @@
+These shell script snippets contain the logic to actually build each package.
+They're called by "build_stage" in sources/functions.sh.
+
+The "name.build" files have "setupfor name" called before running them,
+and "cleanup" called afterwards.
+
+The "name.sh" files do their own setup/cleanup (if any).
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/sections/binutils.build	Sat Dec 19 00:51:16 2009 -0600
@@ -0,0 +1,52 @@
+# Build binutils, c wrapper, and uClibc++
+
+# Build binutils, which provides the linker and assembler and such.
+
+# PROGRAM_PREFIX affects the name of the generated tools, ala "${ARCH}-".
+
+# The binutils ./configure stage is _really_stupid_, and we need to define
+# lots of environment variables to make it behave.
+
+function configure_binutils()
+{
+  "$CURSRC/configure" --prefix="$STAGE_DIR" \
+    --build="$CROSS_HOST" --host="$FROM_HOST" --target="$CROSS_TARGET" \
+    --disable-nls --disable-shared --disable-multilib --disable-werror \
+    --with-lib-path=lib --program-prefix="$PROGRAM_PREFIX" $BINUTILS_FLAGS
+
+  [ $? -ne 0 ] && dienow
+}
+
+if [ -z "$FROM_ARCH" ]
+then
+  # Create a simple cross compiler, from this host to target $ARCH.
+  # This has no prerequisites.
+
+  # The binutils ./configure stage is _really_stupid_.  Define lots of
+  # environment variables to make it behave.
+
+  AR=ar AS=as LD=ld NM=nm OBJDUMP=objdump OBJCOPY=objcopy configure_binutils
+else
+  # Canadian cross for an arbitrary host/target.  The new compiler will run
+  # on $FROM_ARCH as its host, and build executables for $ARCH as its target.
+  # (Use host==target to produce a native compiler.)  Doing this requires
+  # existing host ($FROM_ARCH) _and_ target ($ARCH) cross compilers as
+  # prerequisites.
+
+  AR="${FROM_ARCH}-ar" CC="${FROM_ARCH}-cc" configure_binutils
+fi
+
+# Now that it's configured, build and install binutils
+
+make -j $CPUS configure-host &&
+make -j $CPUS CFLAGS="-O2 $STATIC_FLAGS" &&
+make -j $CPUS install &&
+
+# Fix up install
+
+mkdir -p "$STAGE_DIR/include" &&
+cp "$CURSRC/include/libiberty.h" "$STAGE_DIR/include" &&
+
+# ln -sf ../../../../tools/bin/ld  ${STAGE_DIR}/libexec/gcc/*/*/collect2 || dienow
+
+rm -rf "$WORK/build-binutils"
--- a/sources/sections/binutils.sh	Fri Dec 18 03:38:21 2009 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-# Build binutils, c wrapper, and uClibc++
-
-# Build binutils, which provides the linker and assembler and such.
-
-# PROGRAM_PREFIX affects the name of the generated tools, ala "${ARCH}-".
-
-setupfor binutils
-
-# The binutils ./configure stage is _really_stupid_, and we need to define
-# lots of environment variables to make it behave.
-
-function configure_binutils()
-{
-  "$CURSRC/configure" --prefix="$STAGE_DIR" \
-    --build="$CROSS_HOST" --host="$FROM_HOST" --target="$CROSS_TARGET" \
-    --disable-nls --disable-shared --disable-multilib --disable-werror \
-    --with-lib-path=lib --program-prefix="$PROGRAM_PREFIX" $BINUTILS_FLAGS
-
-  [ $? -ne 0 ] && dienow
-}
-
-if [ -z "$FROM_ARCH" ]
-then
-  # Create a simple cross compiler, from this host to target $ARCH.
-  # This has no prerequisites.
-
-  # The binutils ./configure stage is _really_stupid_.  Define lots of
-  # environment variables to make it behave.
-
-  AR=ar AS=as LD=ld NM=nm OBJDUMP=objdump OBJCOPY=objcopy configure_binutils
-else
-  # Canadian cross for an arbitrary host/target.  The new compiler will run
-  # on $FROM_ARCH as its host, and build executables for $ARCH as its target.
-  # (Use host==target to produce a native compiler.)  Doing this requires
-  # existing host ($FROM_ARCH) _and_ target ($ARCH) cross compilers as
-  # prerequisites.
-
-  AR="${FROM_ARCH}-ar" CC="${FROM_ARCH}-cc" configure_binutils
-fi
-
-# Now that it's configured, build and install binutils
-
-make -j $CPUS configure-host &&
-make -j $CPUS CFLAGS="-O2 $STATIC_FLAGS" &&
-make -j $CPUS install &&
-
-# Fix up install
-
-mkdir -p "$STAGE_DIR/include" &&
-cp "$CURSRC/include/libiberty.h" "$STAGE_DIR/include" &&
-
-# ln -sf ../../../../tools/bin/ld  ${STAGE_DIR}/libexec/gcc/*/*/collect2 || dienow
-
-cleanup build-binutils
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/sections/busybox.build	Sat Dec 19 00:51:16 2009 -0600
@@ -0,0 +1,19 @@
+# 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 &&
+make busybox.links &&
+cp busybox${SKIP_STRIP:+_unstripped} "${STAGE_DIR}/busybox" || dienow
+
+for i in $(sed 's@.*/@@' busybox.links)
+do
+  [ ! -f "${STAGE_DIR}/$i" ] &&
+    (ln -sf busybox "${STAGE_DIR}/$i" || dienow)
+done
--- a/sources/sections/busybox.sh	Fri Dec 18 03:38:21 2009 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-# 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
-
-setupfor busybox
-make allyesconfig KCONFIG_ALLCONFIG="${SOURCES}/trimconfig-busybox" &&
-cp .config "$WORK"/config-busybox &&
-LDFLAGS="$LDFLAGS $BUSYBOX_STATIC" make -j $CPUS $VERBOSITY $DO_CROSS &&
-make busybox.links &&
-cp busybox${SKIP_STRIP:+_unstripped} "${STAGE_DIR}/busybox" || dienow
-
-for i in $(sed 's@.*/@@' busybox.links)
-do
-  [ ! -f "${STAGE_DIR}/$i" ] &&
-    (ln -sf busybox "${STAGE_DIR}/$i" || dienow)
-done
-
-cleanup
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/sections/toybox.build	Sat Dec 19 00:51:16 2009 -0600
@@ -0,0 +1,17 @@
+# Build toybox
+
+[ ! -z "$ARCH" ] && DO_CROSS=CROSS_COMPILE=${ARCH}-
+
+make defconfig &&
+CFLAGS="$CFLAGS $STATIC_FLAGS" make $DO_CROSS || dienow
+
+if [ -z "$USE_TOYBOX" ]
+then
+  ln -sf toybox "$STAGE_DIR"/patch &&
+  ln -sf toybox "$STAGE_DIR"/oneit &&
+  ln -sf toybox "$STAGE_DIR"/netcat || dienow
+else
+  make install_flat PREFIX="$STAGE_DIR" || dienow
+fi
+
+cp toybox${SKIP_STRIP:+_unstripped} "$STAGE_DIR/toybox"
--- a/sources/sections/toybox.sh	Fri Dec 18 03:38:21 2009 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-# Build toybox
-
-[ ! -z "$ARCH" ] && DO_CROSS=CROSS_COMPILE=${ARCH}-
-
-setupfor toybox
-make defconfig &&
-CFLAGS="$CFLAGS $STATIC_FLAGS" make $DO_CROSS || dienow
-
-if [ -z "$USE_TOYBOX" ]
-then
-  ln -sf toybox "$STAGE_DIR"/patch &&
-  ln -sf toybox "$STAGE_DIR"/oneit &&
-  ln -sf toybox "$STAGE_DIR"/netcat || dienow
-else
-  make install_flat PREFIX="$STAGE_DIR" || dienow
-fi
-
-cp toybox${SKIP_STRIP:+_unstripped} "$STAGE_DIR/toybox"
-
-cleanup
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/sections/uClibc++.build	Sat Dec 19 00:51:16 2009 -0600
@@ -0,0 +1,15 @@
+# Build and install uClibc++
+
+CROSS= make defconfig &&
+sed -r -i 's/(UCLIBCXX_HAS_(TLS|LONG_DOUBLE))=y/# \1 is not set/' .config &&
+sed -r -i '/UCLIBCXX_RUNTIME_PREFIX=/s/".*"/""/' .config &&
+CROSS= make oldconfig &&
+CROSS="$ARCH"- make &&
+CROSS= make install PREFIX="$ROOT_TOPDIR/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
--- a/sources/sections/uClibc++.sh	Fri Dec 18 03:38:21 2009 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-# Build and install uClibc++
-
-setupfor uClibc++
-CROSS= make defconfig &&
-sed -r -i 's/(UCLIBCXX_HAS_(TLS|LONG_DOUBLE))=y/# \1 is not set/' .config &&
-sed -r -i '/UCLIBCXX_RUNTIME_PREFIX=/s/".*"/""/' .config &&
-CROSS= make oldconfig &&
-CROSS="$ARCH"- make &&
-CROSS= make install PREFIX="$ROOT_TOPDIR/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
-
-cleanup
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/sections/uClibc.build	Sat Dec 19 00:51:16 2009 -0600
@@ -0,0 +1,56 @@
+# Build and install uClibc
+
+make_uClibc()
+{
+ make -j $CPUS $VERBOSITY CROSS="${ARCH}-" \
+  UCLIBC_LDSO_NAME=ld-uClibc KERNEL_HEADERS="$STAGE_DIR/include" \
+  PREFIX="$STAGE_DIR/" RUNTIME_PREFIX=/ DEVEL_PREFIX=/ $1
+}
+
+# Configure
+
+if unstable uClibc && [ -e "$CONFIG_DIR/$ARCH/miniconfig-alt-uClibc" ]
+then
+  cp "$CONFIG_DIR/$ARCH/miniconfig-alt-uClibc" "$WORK/mini.conf" || dienow
+  echo using miniconfig-alt-uClibc
+else
+  cp "$SOURCES/baseconfig-uClibc" "$WORK/mini.conf" &&
+  echo "$UCLIBC_CONFIG" >> "$WORK/mini.conf" || dienow
+  echo Creating miniconfig for uClibc
+fi
+
+# Build and install
+
+make KCONFIG_ALLCONFIG="$WORK/mini.conf" allnoconfig &&
+cp .config "$WORK/config-uClibc" &&
+make_uClibc install || dienow
+
+if [ -d "$ROOT_TOPDIR/src" ]
+then
+  cp "${WORK}/config-uClibc" "$ROOT_TOPDIR/src/config-uClibc" || dienow
+fi
+
+# Do we need host or target versions of ldd and such?
+
+if [ ! -z "$HOST_UTILS" ]
+then
+  make_uClibc hostutils || dienow
+
+  for i in $(cd utils; ls *.host | sed 's/\.host//')
+  do
+    cp utils/"$i".host "$STAGE_DIR/bin/$ARCH-$i" || dienow
+  done
+else
+  make_uClibc install_utils || dienow
+
+  # There's no way to specify a prefix for the uClibc utils; rename by hand.
+
+  if [ ! -z "$PROGRAM_PREFIX" ]
+  then
+    mv "${STAGE_DIR}"/{sbin,bin}/ldconfig || dienow
+    for i in ldd readelf ldconfig
+    do
+      mv "$STAGE_DIR/bin/"{"$i","${PROGRAM_PREFIX}$i"}
+    done
+  fi
+fi
--- a/sources/sections/uClibc.sh	Fri Dec 18 03:38:21 2009 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-# Build and install uClibc
-
-make_uClibc()
-{
- make -j $CPUS $VERBOSITY CROSS="${ARCH}-" \
-  UCLIBC_LDSO_NAME=ld-uClibc KERNEL_HEADERS="$STAGE_DIR/include" \
-  PREFIX="$STAGE_DIR/" RUNTIME_PREFIX=/ DEVEL_PREFIX=/ $1 || dienow
-}
-
-setupfor uClibc
-
-if unstable uClibc && [ -e "$CONFIG_DIR/$ARCH/miniconfig-alt-uClibc" ]
-then
-  cp "$CONFIG_DIR/$ARCH/miniconfig-alt-uClibc" "$WORK/mini.conf" || dienow
-  echo using miniconfig-alt-uClibc
-else
-  cp "$SOURCES/baseconfig-uClibc" "$WORK/mini.conf" &&
-  echo "$UCLIBC_CONFIG" >> "$WORK/mini.conf" || dienow
-  echo Creating miniconfig for uClibc
-fi
-make KCONFIG_ALLCONFIG="$WORK/mini.conf" allnoconfig &&
-cp .config "$WORK/config-uClibc" || dienow
-
-make_uClibc install
-
-if [ -d "$ROOT_TOPDIR/src" ]
-then
-  cp "${WORK}/config-uClibc" "$ROOT_TOPDIR/src/config-uClibc" || dienow
-fi
-
-# Do we need host or target versions of ldd and such?
-
-if [ ! -z "$HOST_UTILS" ]
-then
-  make_uClibc hostutils
-
-  for i in $(cd utils; ls *.host | sed 's/\.host//')
-  do
-    cp utils/"$i".host "$STAGE_DIR/bin/$ARCH-$i" || dienow
-  done
-else
-  make_uClibc install_utils
-
-  # There's no way to specify a prefix for the uClibc utils; rename by hand.
-
-  if [ ! -z "$PROGRAM_PREFIX" ]
-  then
-    mv "${STAGE_DIR}"/{sbin,bin}/ldconfig || dienow
-    for i in ldd readelf ldconfig
-    do
-      mv "$STAGE_DIR/bin/"{"$i","${PROGRAM_PREFIX}$i"}
-    done
-  fi
-fi
-
-cleanup