changeset 1083:cb4dbdb7f2cd

Make BUILD_STATIC take comma separated list of packages, or "all" or "none". Default behavior should remain the same.
author Rob Landley <rob@landley.net>
date Sun, 16 May 2010 02:26:03 -0500
parents 255488af0bbb
children b52ba5df878d
files build.sh config native-compiler.sh root-filesystem.sh sources/functions.sh sources/include.sh sources/sections/busybox.build sources/sections/toybox.build sources/utility_functions.sh
diffstat 9 files changed, 19 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/build.sh	Sat May 15 12:41:14 2010 -0500
+++ b/build.sh	Sun May 16 02:26:03 2010 -0500
@@ -68,7 +68,7 @@
   # the host (to build the executables) and one for the target (to build
   # the libraries).
 
-  BUILD_STATIC=1 FROM_ARCH="$STATIC_CC_HOST" STAGE_NAME=cross-compiler \
+  BUILD_STATIC=all FROM_ARCH="$STATIC_CC_HOST" STAGE_NAME=cross-compiler \
     ./native-compiler.sh "$ARCH" || exit 1
 
   if [ ! -z "$CROSS_SMOKE_TEST" ]
--- a/config	Sat May 15 12:41:14 2010 -0500
+++ b/config	Sun May 16 02:26:03 2010 -0500
@@ -19,16 +19,16 @@
 
 # export ROOT_NODIRS=1
 
-# Busybox and the native compiler are built statically by default.
-# (Using a static busybox provides a 20% performance boost to autoconf
-# under qemu, and building the native compiler static makes it much more
-# portable to other root filesystems.)
+# 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).
 
-# To make those dynamic, set this to "none".  Set it to any other
-# value to link all packages statically.
+# By default, busybox and the native compiler are built statically.
+# (Using a static busybox on the target provides a 20% performance boost to
+# autoconf under qemu, and building the native compiler static makes it much
+# more portable to other target root filesystems.)
 
-# export BUILD_STATIC=none
-# export BUILD_STATIC=1
+# export BUILD_STATIC=busybox,binutils,gcc-core,gcc-g++
 
 # If this is set, build.sh will build a cross compiler statically linked
 # against uClibc.  This indicates which host that compiler should run on.
--- a/native-compiler.sh	Sat May 15 12:41:14 2010 -0500
+++ b/native-compiler.sh	Sun May 16 02:26:03 2010 -0500
@@ -6,8 +6,8 @@
 # This can be used to build a native compiler for an aribitrary target, or to
 # build a more portable and capable cross compiler for an arbitrary host.
 
-# The new compiler is built --with-shared and has uClibc++ installed, and is
-# statically linked against uClibc (for portability) unless BUILD_STATIC=none.
+# The new compiler is built --with-shared, with thread support, has uClibc++
+# installed, and is linked against uClibc (see BUILD_STATIC in config).
 
 source sources/include.sh && read_arch_dir "$1" || exit 1
 check_for_base_arch || exit 0
@@ -21,8 +21,6 @@
 
 mkdir -p "$STAGE_DIR/bin" || dienow
 
-STATIC_FLAGS="$STATIC_DEFAULT_FLAGS"
-
 # Build C Library
 
 build_section linux-headers
--- a/root-filesystem.sh	Sat May 15 12:41:14 2010 -0500
+++ b/root-filesystem.sh	Sun May 16 02:26:03 2010 -0500
@@ -44,14 +44,14 @@
 
 "${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -o "$STAGE_DIR/bin/hello-dynamic" || dienow
 
-if [ ! -z "$BUILD_STATIC" ] && [ "$BUILD_STATIC" != none ]
+if [ "$BUILD_STATIC" != none ]
 then
   "${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -static -o "$STAGE_DIR/bin/hello-static" || dienow
 fi
 
 # Do we need shared libraries?
 
-if [ ! -z "$BUILD_STATIC" ] && [ "$BUILD_STATIC" != none ]
+if [ "$BUILD_STATIC" != all ]
 then
   echo Copying compiler libraries...
   mkdir -p "$STAGE_DIR/lib" || dienow
--- a/sources/functions.sh	Sat May 15 12:41:14 2010 -0500
+++ b/sources/functions.sh	Sun May 16 02:26:03 2010 -0500
@@ -70,11 +70,6 @@
   export PATH="$(cc_path "$ARCH")$PATH"
   [ "$FROM_ARCH" != "$ARCH" ] && PATH="$(cc_path "$FROM_ARCH")$PATH"
 
-  # Check this here because it could be set in "settings"
-
-  [ "$BUILD_STATIC" != none ] && STATIC_DEFAULT_FLAGS="--static"
-  [ ! -z "$BUILD_STATIC" ] && STATIC_FLAGS="$STATIC_DEFAULT_FLAGS"
-
   DO_CROSS="CROSS_COMPILE=${ARCH}-"
 
   return 0
@@ -85,6 +80,7 @@
 
 build_section()
 {
+  is_in_list $1 $BUILD_STATIC && STATIC_FLAGS="--static"
   if [ -e "$SOURCES/sections/$1".build ]
   then
     setupfor "$1"
--- a/sources/include.sh	Sat May 15 12:41:14 2010 -0500
+++ b/sources/include.sh	Sun May 16 02:26:03 2010 -0500
@@ -53,6 +53,8 @@
 export_if_blank STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`
 [ ! -z "$BUILD_VERBOSE" ] && VERBOSITY="V=1"
 
+export_if_blank BUILD_STATIC=busybox,binutils,gcc-core,gcc-g++
+
 # Adjust $PATH
 
 export OLDPATH="$PATH"
--- a/sources/sections/busybox.build	Sat May 15 12:41:14 2010 -0500
+++ b/sources/sections/busybox.build	Sun May 16 02:26:03 2010 -0500
@@ -6,7 +6,7 @@
 
 make allyesconfig KCONFIG_ALLCONFIG="${SOURCES}/trimconfig-busybox" &&
 cp .config "$WORK"/config-busybox &&
-LDFLAGS="$LDFLAGS $STATIC_DEFAULT_FLAGS" make -j $CPUS $VERBOSITY $DO_CROSS &&
+LDFLAGS="$LDFLAGS $STATIC_FLAGS" make -j $CPUS $VERBOSITY $DO_CROSS &&
 make busybox.links || dienow
 
 [ -d "$STAGE_DIR/bin" ] && INSTDIR="$STAGE_DIR/bin" || INSTDIR="$STAGE_DIR"
--- a/sources/sections/toybox.build	Sat May 15 12:41:14 2010 -0500
+++ b/sources/sections/toybox.build	Sun May 16 02:26:03 2010 -0500
@@ -1,7 +1,7 @@
 # Build toybox
 
 yes "" | make defconfig &&
-CFLAGS="$CFLAGS $STATIC_DEFAULT_FLAGS" make $DO_CROSS || dienow
+CFLAGS="$CFLAGS $STATIC_FLAGS" make $DO_CROSS || dienow
 
 # Install into bin subdirectory if it exists
 
--- a/sources/utility_functions.sh	Sat May 15 12:41:14 2010 -0500
+++ b/sources/utility_functions.sh	Sun May 16 02:26:03 2010 -0500
@@ -177,5 +177,5 @@
 
 is_in_list()
 {
-  [ ! -z "$(echo ,"$2", | grep ,"$1",)" ]
+  [ "$2" == all ] || [ ! -z "$(echo ,"$2", | grep ,"$1",)" ]
 }