changeset 1207:4021fb1183d7

Environment sanitizing screwed up the cross-compiler.sh wrapper. Fix it, rename PROGRAM_PREFIX to TOOLCHAIN_PREFIX, and put a guard around sources/include.sh so it's safe to include multiple times.
author Rob Landley <rob@landley.net>
date Mon, 16 Aug 2010 15:00:35 -0500
parents 99c49806ea6d
children 74541aac72f9
files cross-compiler.sh native-compiler.sh sources/include.sh sources/sections/binutils.build sources/sections/ccwrap.sh sources/sections/gcc.sh sources/sections/uClibc.build sources/utility_functions.sh
diffstat 8 files changed, 32 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/cross-compiler.sh	Fri Aug 13 17:19:28 2010 -0500
+++ b/cross-compiler.sh	Mon Aug 16 15:00:35 2010 -0500
@@ -12,13 +12,15 @@
 # This is a simple wrapper for native-compiler.sh, we re-use the canadian
 # cross infrastructure in there to build a very similar compiler.
 
+. sources/include.sh || exit 1
 
 # Unless told otherwise, create statically linked i686 host binaries (which
 # should run on an x86-64 host just fine, even if it hasn't got 32-bit
 # libraries installed).
 
-HOST_ARCH="${CROSS_HOST_ARCH:-i686}" BUILD_STATIC=${BUILD_STATIC:-all} \
-  STAGE_NAME=cross-compiler ./native-compiler.sh "$1" || exit 1
+BUILD_STATIC=${BUILD_STATIC:-all} HOST_ARCH="${CROSS_HOST_ARCH:-i686}" \
+  TOOLCHAIN_PREFIX="${1}-" STAGE_NAME=cross-compiler \
+  ./native-compiler.sh "$1" || exit 1
 
 # Run the cross compiler smoke test if requested.
 
--- a/native-compiler.sh	Fri Aug 13 17:19:28 2010 -0500
+++ b/native-compiler.sh	Mon Aug 16 15:00:35 2010 -0500
@@ -13,16 +13,8 @@
 check_for_base_arch || exit 0
 
 check_prerequisite "${ARCH}-cc"
-if [ -z "$HOST_ARCH" ]
-then
-  # Build unprefixed native compiler
-  HOST_ARCH="$ARCH"
-else
-  # Build prefixed cross compiler via canadian cross.  Needs a host compiler
-  # to build the executables and a target compiler to build the libraries.
-  PROGRAM_PREFIX="$ARCH-"
-  check_prerequisite "${HOST_ARCH}-cc"
-fi
+
+[ -z "$HOST_ARCH" ] && HOST_ARCH="$ARCH" || check_prerequisite "${HOST_ARCH}-cc"
 
 mkdir -p "$STAGE_DIR/bin" || dienow
 
--- a/sources/include.sh	Fri Aug 13 17:19:28 2010 -0500
+++ b/sources/include.sh	Mon Aug 16 15:00:35 2010 -0500
@@ -1,5 +1,13 @@
 #!/bin/echo "This file is sourced, not run"
 
+if ! already_included_this 2>/dev/null
+then
+
+already_included_this()
+{
+  true
+}
+
 # Set up all the environment variables and functions for a build stage.
 # This file is sourced, not run.
 
@@ -82,3 +90,5 @@
 # Disable internationalization so sort and sed and such can cope with ASCII.
 
 export LC_ALL=C
+
+fi # already_included_this
--- a/sources/sections/binutils.build	Fri Aug 13 17:19:28 2010 -0500
+++ b/sources/sections/binutils.build	Mon Aug 16 15:00:35 2010 -0500
@@ -4,7 +4,7 @@
 {
   "$CURSRC/configure" --prefix="$STAGE_DIR" "$@" --target="$CROSS_TARGET" \
     --disable-nls --disable-shared --disable-multilib --disable-werror \
-    --with-lib-path=lib --program-prefix="$PROGRAM_PREFIX" $BINUTILS_FLAGS
+    --with-lib-path=lib --program-prefix="$TOOLCHAIN_PREFIX" $BINUTILS_FLAGS
 
   [ $? -ne 0 ] && dienow
 }
--- a/sources/sections/ccwrap.sh	Fri Aug 13 17:19:28 2010 -0500
+++ b/sources/sections/ccwrap.sh	Mon Aug 16 15:00:35 2010 -0500
@@ -28,12 +28,12 @@
   # Setup bin directory
 
   mkdir -p "$STAGE_DIR/bin" || dienow
-  path_search "$PATH" "${PROGRAM_PREFIX}*" \
+  path_search "$PATH" "${TOOLCHAIN_PREFIX}*" \
     'cp "$DIR/$FILE" "$STAGE_DIR/bin/$FILE"' | dotprogress
 
-  mv "$STAGE_DIR/"{bin/"${PROGRAM_PREFIX}"cc,tools/bin/cc} ||
-  mv "$STAGE_DIR/"{bin/"${PROGRAM_PREFIX}"gcc,tools/bin/cc} || dienow
-  ln -sf "${PROGRAM_PREFIX}cc" "$STAGE_DIR/bin/${PROGRAM_PREFIX}gcc" || dienow
+  mv "$STAGE_DIR/"{bin/"${TOOLCHAIN_PREFIX}"cc,tools/bin/cc} ||
+  mv "$STAGE_DIR/"{bin/"${TOOLCHAIN_PREFIX}"gcc,tools/bin/cc} || dienow
+  ln -sf "${TOOLCHAIN_PREFIX}cc" "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}gcc" || dienow
 
   # populate include
 
@@ -62,4 +62,4 @@
 # Build wrapper binary
 
 "$TEMP" "$SOURCES/toys/ccwrap.c" -Os $CFLAGS \
-  -o "$STAGE_DIR/bin/${PROGRAM_PREFIX}cc" $STATIC_FLAGS || dienow
+  -o "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}cc" $STATIC_FLAGS || dienow
--- a/sources/sections/gcc.sh	Fri Aug 13 17:19:28 2010 -0500
+++ b/sources/sections/gcc.sh	Mon Aug 16 15:00:35 2010 -0500
@@ -1,6 +1,6 @@
 # Build binutils, c wrapper, and uClibc++
 
-# PROGRAM_PREFIX affects the name of the generated tools, ala "${ARCH}-".
+# TOOLCHAIN_PREFIX affects the name of the generated tools, ala "${ARCH}-".
 
 # Force gcc to build, largely against its will.
 
@@ -27,7 +27,7 @@
   # Configure gcc
   "$CURSRC/configure" --target="$CROSS_TARGET" --prefix="$STAGE_DIR" \
     --disable-multilib --disable-nls --enable-c99 --enable-long-long \
-    --enable-__cxa_atexit $STUFF --program-prefix="$PROGRAM_PREFIX" \
+    --enable-__cxa_atexit $STUFF --program-prefix="$TOOLCHAIN_PREFIX" \
     "$@" $GCC_FLAGS &&
 
   # Provide xgcc as a symlink to the target compiler, so gcc doesn't waste
@@ -120,17 +120,17 @@
 
 # Prepare for ccwrap
 
-mv "$STAGE_DIR/bin/${PROGRAM_PREFIX}gcc" "$STAGE_DIR/tools/bin/cc" &&
-ln -sf "${PROGRAM_PREFIX}cc" "$STAGE_DIR/bin/${PROGRAM_PREFIX}gcc" &&
+mv "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}gcc" "$STAGE_DIR/tools/bin/cc" &&
+ln -sf "${TOOLCHAIN_PREFIX}cc" "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}gcc" &&
 ln -s cc "$STAGE_DIR/tools/bin/rawcc" &&
 
 # Wrap C++ too.
 
 if [ -z "$NO_CPLUSPLUS" ]
 then
-  mv "$STAGE_DIR/bin/${PROGRAM_PREFIX}g++" "$STAGE_DIR/tools/bin/c++" &&
-  ln -sf "${PROGRAM_PREFIX}cc" "$STAGE_DIR/bin/${PROGRAM_PREFIX}g++" &&
-  ln -sf "${PROGRAM_PREFIX}cc" "$STAGE_DIR/bin/${PROGRAM_PREFIX}c++" &&
+  mv "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}g++" "$STAGE_DIR/tools/bin/c++" &&
+  ln -sf "${TOOLCHAIN_PREFIX}cc" "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}g++" &&
+  ln -sf "${TOOLCHAIN_PREFIX}cc" "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}c++" &&
   ln -s c++ "$STAGE_DIR/tools/bin/raw++" || dienow
 fi
 
--- a/sources/sections/uClibc.build	Fri Aug 13 17:19:28 2010 -0500
+++ b/sources/sections/uClibc.build	Mon Aug 16 15:00:35 2010 -0500
@@ -31,9 +31,9 @@
   # The uClibc utils/Makefile.in is crazy.  There's no way to specify a prefix,
   # or to pass in --static via CFLAGS.  Just build 'em by hand.
 
-  "$ARCH-cc" utils/ldd.c -o "$STAGE_DIR/bin/${PROGRAM_PREFIX}ldd" --static \
+  "$ARCH-cc" utils/ldd.c -o "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}ldd" --static \
     -I ldso/include -DBUILDING_LINKAGE &&
   "$ARCH-cc" utils/ldconfig.c utils/chroot_realpath.c \
-    -o "$STAGE_DIR/bin/${PROGRAM_PREFIX}ldconfig" --static -I ldso/include \
+    -o "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}ldconfig" --static -I ldso/include \
     -DUCLIBC_RUNTIME_PREFIX='"/"' -DBUILDING_LINKAGE || dienow
 fi
--- a/sources/utility_functions.sh	Fri Aug 13 17:19:28 2010 -0500
+++ b/sources/utility_functions.sh	Mon Aug 16 15:00:35 2010 -0500
@@ -15,7 +15,7 @@
 
   # What other variables should we keep?
 
-  TEMP="$TEMP,LANG,PATH,TOPSHELL,START_TIME,STAGE_NAME"
+  TEMP="$TEMP,LANG,PATH,TOPSHELL,START_TIME,STAGE_NAME,TOOLCHAIN_PREFIX"
   TEMP="$TEMP,SHELL,TERM,USER,USERNAME,LOGNAME,PWD,EDITOR,HOME,DISPLAY,_"
 
   # Unset any variable we don't recognize.  It can screw up the build.