view sources/sections/ccwrap.sh @ 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 affef1edbdba
children 4021fb1183d7
line wrap: on
line source

# build and install gcc wrapper script.

# Which compiler do we build the wrapper with, and should it be static?

if [ -z "$HOST_ARCH" ] || [ "$BUILD_STATIC" == none ]
then
  TEMP="$CC"
  STATIC_FLAGS=
else
  TEMP="${HOST_ARCH}-cc"
  STATIC_FLAGS=--static
fi

# Copy compiler binaries (if not already present)

if false
then
  # Populate the wrapper directories (unfinished)

  # The purpose of this is to wrap an existing cross compiler by populating
  # a directory of symlinks in the layout ccwrap expects.  This requires
  # querying the existing compiler to find 1) system header dirs,
  # 2) compiler header dirs, 3) system library dirs, 4) compiler library dirs,
  # 5) binary search path for cpp and ld and such.

  mkdir -p "$STAGE_DIR"/{tools,include,lib,cc/{include,lib}} &&

  # Setup bin directory

  mkdir -p "$STAGE_DIR/bin" || dienow
  path_search "$PATH" "${PROGRAM_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

  # populate include

  SYSINC_PATH="$(echo '#include <stdio.h>' | "$ARCH-cc" -E - | \
    sed -n 's@.*"\(.*\)/stdio\.h".*@\1@p;T;q')"

  # populate lib

    # Need both /lib and /usr/lib.  What if libc.so linker script points to
    # other directory?  --print-search-dirs, perhaps?

  # populate cc/include

  # This is the trick uClibc build uses.

  CCINC_PATH="$(gcc --print-file-name=include)"

  # populate cc/lib

  CCLIB_PATH="$(gcc --print-file-name=crtbegin.o | sed 's@crtbegin.o$@@')"
  # or maybe --print-search-dirs "libraries"?

  # Populate tools
fi

# Build wrapper binary

"$TEMP" "$SOURCES/toys/ccwrap.c" -Os $CFLAGS \
  -o "$STAGE_DIR/bin/${PROGRAM_PREFIX}cc" $STATIC_FLAGS || dienow