changeset 1130:c222ae88733a

Add NO_CPLUSPLUS config option, to skip c++ support entirely.
author Rob Landley <rob@landley.net>
date Sun, 20 Jun 2010 16:25:35 -0500
parents 3c8d91339f2a
children 5c9d74b49fb5
files config native-compiler.sh sources/sections/distcc.build sources/sections/gcc.sh sources/sections/uClibc.build
diffstat 5 files changed, 34 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/config	Sun Jun 20 14:54:00 2010 -0500
+++ b/config	Sun Jun 20 16:25:35 2010 -0500
@@ -44,6 +44,10 @@
 
 # export CROSS_HOST_ARCH=i686
 
+# If this is set, only build a C compiler and not C++
+
+# export NO_CPLUSPLUS=1
+
 # 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
 # if blank.
--- a/native-compiler.sh	Sun Jun 20 14:54:00 2010 -0500
+++ b/native-compiler.sh	Sun Jun 20 16:25:35 2010 -0500
@@ -42,7 +42,9 @@
 
 export "$(echo $ARCH | sed 's/-/_/g')"_CCWRAP_TOPDIR="$STAGE_DIR"
 
-build_section uClibc++
+# Add C++ standard library
+
+[ -z "$NO_CPLUSPLUS" ] && build_section uClibc++
 
 # For a native compiler, build make, bash, and distcc.  (Yes, this is an old
 # version of Bash.  It's intentional.)
--- a/sources/sections/distcc.build	Sun Jun 20 14:54:00 2010 -0500
+++ b/sources/sections/distcc.build	Sun Jun 20 16:25:35 2010 -0500
@@ -6,7 +6,9 @@
 make -j $CPUS install &&
 mkdir -p "$STAGE_DIR/distcc" || dienow
 
-for i in gcc cc g++ c++
+TEMP=""
+[ -z "$NO_CPLUSPLUS" ] && TEMP="g++ c++"
+for i in gcc cc $TEMP
 do
   ln -s ../bin/distcc "$STAGE_DIR/distcc/$i" || dienow
 done
--- a/sources/sections/gcc.sh	Sun Jun 20 14:54:00 2010 -0500
+++ b/sources/sections/gcc.sh	Sun Jun 20 16:25:35 2010 -0500
@@ -5,7 +5,7 @@
 # Force gcc to build, largely against its will.
 
 setupfor gcc-core build-gcc
-setupfor gcc-g++ build-gcc gcc-core
+[ -z "$NO_CPLUSPLUS" ] && setupfor gcc-g++ build-gcc gcc-core
 
 # GCC tries to "help out in the kitchen" by screwing up the kernel include
 # files.  Surgery with sed to cut out that horrible idea throw it away.
@@ -17,10 +17,20 @@
 
 function configure_gcc()
 {
+  # Are we building C only, or C and C++?
+  [ -z "$NO_CPLUSPLUS" ] &&
+    STUFF="--enable-languages=c,c++ --disable-libstdcxx-pch" ||
+    STUFF="--enable-languages=c"
+
+  # Configure gcc
   "$CURSRC/configure" --target="$CROSS_TARGET" --prefix="$STAGE_DIR" \
     --disable-multilib --disable-nls --enable-c99 --enable-long-long \
-    --enable-__cxa_atexit --enable-languages=c,c++ --disable-libstdcxx-pch \
-    --program-prefix="$PROGRAM_PREFIX" "$@" $GCC_FLAGS &&
+    --enable-__cxa_atexit $STUFF --program-prefix="$PROGRAM_PREFIX" \
+    "$@" $GCC_FLAGS &&
+
+  # Provide xgcc as a symlink to the target compiler, so gcc doesn't waste
+  # time trying to rebuild itself with itself.  (If we want that, we'll do it
+  # ourselves via canadian cross.)
   mkdir -p gcc &&
   ln -s "$(which ${CC_FOR_TARGET:-cc})" gcc/xgcc || dienow
 }
@@ -66,7 +76,7 @@
 
 mkdir -p "$STAGE_DIR"/cc/lib || dienow
 
-if [ ! -z "$HOST_ARCH" ]
+if [ ! -z "$HOST_ARCH" ] && [ -z "$NO_CPLUSPLUS" ]
 then
   # We also need to beat libsupc++ out of gcc (which uClibc++ needs to build).
   # But don't want to build the whole of libstdc++-v3 because
@@ -114,16 +124,19 @@
 
 # Wrap C++ too.
 
-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++" &&
-ln -s c++ "$STAGE_DIR/tools/bin/raw++" || dienow
+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++" &&
+  ln -s c++ "$STAGE_DIR/tools/bin/raw++" || dienow
+fi
 
 # Make sure "tools" has everything distccd needs.
 
 cd "$STAGE_DIR/tools" || dienow
 ln -s cc "$STAGE_DIR/tools/bin/gcc" 2>/dev/null
-ln -s c++ "$STAGE_DIR/tools/bin/g++" 2>/dev/null
+[ -z "$NO_CPLUSPLUS" ] && ln -s c++ "$STAGE_DIR/tools/bin/g++" 2>/dev/null
 
 rm -rf "${STAGE_DIR}"/{lib/gcc,libexec/gcc/install-tools,bin/${ARCH}-unknown-*}
 
--- a/sources/sections/uClibc.build	Sun Jun 20 14:54:00 2010 -0500
+++ b/sources/sections/uClibc.build	Sun Jun 20 16:25:35 2010 -0500
@@ -27,6 +27,8 @@
 cp .config "$STAGE_DIR/src/config-uClibc" &&
 make_uClibc install || dienow
 
+sed -i 's@/lib/@@g' "$STAGE_DIR/lib/libc.so" || dienow
+
 # Build ldd and friends
 
 if [ ! -z "$HOST_ARCH" ]