Tidy up a bit the uClibc config munging.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jul 28 11:59:37 2007 +0000 (2007-07-28)
changeset 297c3a912d6acdc
parent 296 5859cc5065a7
child 298 f0118fc48571
Tidy up a bit the uClibc config munging.
scripts/build/libc_uClibc.sh
     1.1 --- a/scripts/build/libc_uClibc.sh	Sat Jul 28 11:57:42 2007 +0000
     1.2 +++ b/scripts/build/libc_uClibc.sh	Sat Jul 28 11:59:37 2007 +0000
     1.3 @@ -38,15 +38,13 @@
     1.4  
     1.5      CT_TestOrAbort "You did not provide a uClibc config file!" -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" -a -f "${CT_LIBC_UCLIBC_CONFIG_FILE}"
     1.6  
     1.7 -    cp "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_SRC_DIR}/uClibc.config"
     1.8 -
     1.9      if egrep '^KERNEL_SOURCE=' "${CT_LIBC_UCLIBC_CONFIG_FILE}" >/dev/null 2>&1; then
    1.10          CT_DoLog WARN "Your uClibc version refers to the kernel _sources_, which is bad."
    1.11          CT_DoLog WARN "I can't guarantee that our little hack will work. Please try to upgrade."
    1.12      fi
    1.13  
    1.14      CT_DoLog EXTRA "Munging uClibc configuration"
    1.15 -    mungeuClibcConfig "${CT_SRC_DIR}/uClibc.config"
    1.16 +    mungeuClibcConfig "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_BUILD_DIR}/uClibc.config"
    1.17  
    1.18      CT_EndStep
    1.19  }
    1.20 @@ -67,7 +65,7 @@
    1.21      { cd "${CT_SRC_DIR}/${CT_LIBC_FILE}"; tar cf - .; } |tar xf -
    1.22  
    1.23      # Retrieve the config file
    1.24 -    cp "${CT_SRC_DIR}/uClibc.config" .config
    1.25 +    cp "${CT_BUILD_DIR}/uClibc.config" .config
    1.26  
    1.27      # uClibc uses the CROSS environment variable as a prefix to the
    1.28      # compiler tools to use.  Setting it to the empty string forces
    1.29 @@ -102,7 +100,7 @@
    1.30      { cd "${CT_SRC_DIR}/${CT_LIBC_FILE}"; tar cf - .; } |tar xf -
    1.31  
    1.32      # Retrieve the config file
    1.33 -    cp "${CT_SRC_DIR}/uClibc.config" .config
    1.34 +    cp "${CT_BUILD_DIR}/uClibc.config" .config
    1.35  
    1.36      # uClibc uses the CROSS environment variable as a prefix to the compiler
    1.37      # tools to use.  The newly built tools should be in our path, so we need
    1.38 @@ -147,14 +145,19 @@
    1.39  }
    1.40  
    1.41  # Initialises the .config file to sensible values
    1.42 +# $1: original file
    1.43 +# $2: munged file
    1.44  mungeuClibcConfig() {
    1.45 -    config_file="$1"
    1.46 +    src_config_file="$1"
    1.47 +    dst_config_file="$2"
    1.48      munge_file="${CT_BUILD_DIR}/munge-uClibc-config.sed"
    1.49  
    1.50 +    echo -n >"${munge_file}"
    1.51 +
    1.52      # Hack our target in the config file.
    1.53      # Also remove stripping: its the responsibility of the
    1.54      # firmware builder to strip or not.
    1.55 -    cat > "${munge_file}" <<-ENDSED
    1.56 +    cat >>"${munge_file}" <<-ENDSED
    1.57  s/^(TARGET_.*)=y$/# \\1 is not set/
    1.58  s/^# TARGET_${CT_KERNEL_ARCH} is not set/TARGET_${CT_KERNEL_ARCH}=y/
    1.59  s/^TARGET_ARCH=".*"/TARGET_ARCH="${CT_KERNEL_ARCH}"/
    1.60 @@ -164,14 +167,14 @@
    1.61      # Accomodate for old and new uClibc versions, where the
    1.62      # way to select between big/little endian has changed
    1.63      case "${CT_ARCH_BE},${CT_ARCH_LE}" in
    1.64 -        y,) cat >> "${munge_file}" <<-ENDSED
    1.65 +        y,) cat >>"${munge_file}" <<-ENDSED
    1.66  s/.*(ARCH_LITTLE_ENDIAN).*/# \\1 is not set/
    1.67  s/.*(ARCH_BIG_ENDIAN).*/\\1=y/
    1.68  s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/# \\1 is not set/
    1.69  s/.*(ARCH_WANTS_BIG_ENDIAN).*/\\1=y/
    1.70  ENDSED
    1.71          ;;
    1.72 -        ,y) cat >> "${munge_file}" <<-ENDSED
    1.73 +        ,y) cat >>"${munge_file}" <<-ENDSED
    1.74  s/.*(ARCH_LITTLE_ENDIAN).*/\\1=y/
    1.75  s/.*(ARCH_BIG_ENDIAN).*/# \\1 is not set/
    1.76  s/.*(ARCH_WANTS_LITTLE_ENDIAN).*/\\1=y/
    1.77 @@ -183,12 +186,12 @@
    1.78      # Accomodate for old and new uClibc version, where the
    1.79      # way to select between hard/soft float has changed
    1.80      case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
    1.81 -        y,) cat >> "${munge_file}" <<-ENDSED
    1.82 +        y,) cat >>"${munge_file}" <<-ENDSED
    1.83  s/.*(HAS_FPU).*/\\1=y/
    1.84  s/.*(UCLIBC_HAS_FPU).*/\\1=y/
    1.85  ENDSED
    1.86              ;;
    1.87 -        ,y) cat >> "${munge_file}" <<-ENDSED
    1.88 +        ,y) cat >>"${munge_file}" <<-ENDSED
    1.89  s/.*(HAS_FPU).*/\\# \\1 is not set/
    1.90  s/.*(UCLIBC_HAS_FPU).*/# \\1 is not set/
    1.91  ENDSED
    1.92 @@ -205,7 +208,7 @@
    1.93      # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, wich is the correct value of ${PREFIX}/${TARGET}
    1.94      # Some (old) versions of uClibc use KERNEL_SOURCE (which is _wrong_), and
    1.95      # newer versions use KERNEL_HEADERS (which is right). See:
    1.96 -    cat >> "${munge_file}" <<-ENDSED
    1.97 +    cat >>"${munge_file}" <<-ENDSED
    1.98  s/^DEVEL_PREFIX=".*"/DEVEL_PREFIX="\\/usr\\/"/
    1.99  s/^RUNTIME_PREFIX=".*"/RUNTIME_PREFIX="\\/"/
   1.100  s/^SHARED_LIB_LOADER_PREFIX=.*/SHARED_LIB_LOADER_PREFIX="\\/lib\\/"/
   1.101 @@ -217,7 +220,7 @@
   1.102      if [ "${CT_USE_PIPES}" = "y" ]; then
   1.103          if grep UCLIBC_EXTRA_CFLAGS extra/Configs/Config.in >/dev/null 2>&1; then
   1.104              # Good, there is special provision for such things as -pipe!
   1.105 -            cat >> "${munge_file}" <<-ENDSED
   1.106 +            cat >>"${munge_file}" <<-ENDSED
   1.107  s/^(UCLIBC_EXTRA_CFLAGS=".*)"$/\\1 -pipe"/
   1.108  ENDSED
   1.109          else
   1.110 @@ -237,7 +240,7 @@
   1.111      # pregenerated locales is not compatible with crosstool; besides,
   1.112      # crosstool downloads them as part of getandpatch.sh.
   1.113      if [ "${CT_CC_LANG_CXX}" = "y" ]; then
   1.114 -        cat >> "${munge_file}" <<-ENDSED
   1.115 +        cat >>"${munge_file}" <<-ENDSED
   1.116  s/^# DO_C99_MATH is not set/DO_C99_MATH=y/
   1.117  s/^# UCLIBC_CTOR_DTOR is not set/UCLIBC_CTOR_DTOR=y/
   1.118  # Add these three lines when doing C++?
   1.119 @@ -283,6 +286,5 @@
   1.120  ENDSED
   1.121          ;;
   1.122      esac
   1.123 -    sed -r -i -f "${munge_file}" "${config_file}"
   1.124 -    rm -f "${munge_file}"
   1.125 +    sed -r -f "${munge_file}" "${src_config_file}" >"${dst_config_file}"
   1.126  }