libc/eglibc: cleanup common code for sharing with glibc
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 17 23:04:57 2011 +0100 (2011-01-17)
changeset 227142ebee266fe5
parent 2270 287e1e00dea4
child 2272 0ff5b3570cd6
libc/eglibc: cleanup common code for sharing with glibc

Some stuff is eglibc-specific, so needs to be conditonal.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
scripts/build/libc/glibc-eglibc.sh-common
     1.1 --- a/scripts/build/libc/glibc-eglibc.sh-common	Mon Jan 17 23:04:37 2011 +0100
     1.2 +++ b/scripts/build/libc/glibc-eglibc.sh-common	Mon Jan 17 23:04:57 2011 +0100
     1.3 @@ -8,6 +8,8 @@
     1.4  
     1.5  # Build and install headers and start files
     1.6  do_libc_start_files() {
     1.7 +    local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
     1.8 +
     1.9      CT_DoStep INFO "Installing C library headers / start files"
    1.10  
    1.11      mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
    1.12 @@ -15,15 +17,19 @@
    1.13  
    1.14      CT_DoLog EXTRA "Configuring C library"
    1.15  
    1.16 -    if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then
    1.17 -        CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config
    1.18 -    fi
    1.19 +    case "${CT_LIBC}" in
    1.20 +        eglibc)
    1.21 +            if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then
    1.22 +                CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config
    1.23 +            fi
    1.24 +            ;;
    1.25 +    esac
    1.26  
    1.27      cross_cc=$(CT_Which "${CT_TARGET}-gcc")
    1.28      cross_cxx=$(CT_Which "${CT_TARGET}-g++")
    1.29      cross_ar=$(CT_Which "${CT_TARGET}-ar")
    1.30      cross_ranlib=$(CT_Which "${CT_TARGET}-ranlib")
    1.31 -    
    1.32 +
    1.33      CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
    1.34      CT_DoLog DEBUG "Using g++ for target: '${cross_cxx}'"
    1.35      CT_DoLog DEBUG "Using ar for target: '${cross_ar}'"
    1.36 @@ -35,7 +41,7 @@
    1.37      AR=${cross_ar}                                      \
    1.38      RANLIB=${cross_ranlib}                              \
    1.39      CT_DoExecLog CFG                                    \
    1.40 -    "${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/configure" \
    1.41 +    "${src_dir}/configure"                              \
    1.42          --prefix=/usr                                   \
    1.43          --with-headers="${CT_HEADERS_DIR}"              \
    1.44          --build="${CT_BUILD}"                           \
    1.45 @@ -49,7 +55,6 @@
    1.46  
    1.47      # use the 'install-headers' makefile target to install the
    1.48      # headers
    1.49 -
    1.50      CT_DoExecLog ALL                    \
    1.51      make install-headers                \
    1.52           install_root=${CT_SYSROOT_DIR} \
    1.53 @@ -59,25 +64,29 @@
    1.54  
    1.55      # there are a few object files needed to link shared libraries,
    1.56      # which we build and install by hand
    1.57 -
    1.58 -    CT_DoExecLog ALL mkdir -p ${CT_SYSROOT_DIR}/usr/lib
    1.59 +    CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
    1.60      CT_DoExecLog ALL make csu/subdir_lib
    1.61      CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \
    1.62 -        ${CT_SYSROOT_DIR}/usr/lib
    1.63 +                        "${CT_SYSROOT_DIR}/usr/lib"
    1.64  
    1.65 -    # Finally, 'libgcc_s.so' requires a 'libc.so' to link against.  
    1.66 -    # However, since we will never actually execute its code, 
    1.67 -    # it doesn't matter what it contains.  So, treating '/dev/null' 
    1.68 +    # Finally, 'libgcc_s.so' requires a 'libc.so' to link against.
    1.69 +    # However, since we will never actually execute its code,
    1.70 +    # it doesn't matter what it contains.  So, treating '/dev/null'
    1.71      # as a C source file, we produce a dummy 'libc.so' in one step
    1.72 -
    1.73 -    CT_DoExecLog ALL ${cross_cc} -nostdlib -nostartfiles -shared -x c /dev/null -o ${CT_SYSROOT_DIR}/usr/lib/libc.so
    1.74 +    CT_DoExecLog ALL "${cross_cc}" -nostdlib        \
    1.75 +                                   -nostartfiles    \
    1.76 +                                   -shared          \
    1.77 +                                   -x c /dev/null   \
    1.78 +                                   -o "${CT_SYSROOT_DIR}/usr/lib/libc.so"
    1.79  
    1.80      CT_EndStep
    1.81  }
    1.82  
    1.83  # This function builds and install the full C library
    1.84  do_libc() {
    1.85 +    local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
    1.86      local -a extra_config
    1.87 +    local -a extra_make_args
    1.88  
    1.89      CT_DoStep INFO "Installing C library"
    1.90  
    1.91 @@ -86,15 +95,18 @@
    1.92  
    1.93      CT_DoLog EXTRA "Configuring C library"
    1.94  
    1.95 -    if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then
    1.96 -        CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config
    1.97 -    fi
    1.98 -
    1.99 -    if [ "${CT_EGLIBC_OPT_SIZE}" = "y" ]; then
   1.100 -        OPTIMIZE=-Os
   1.101 -    else
   1.102 -        OPTIMIZE=-O2
   1.103 -    fi
   1.104 +    case "${CT_LIBC}" in
   1.105 +        eglibc)
   1.106 +            if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then
   1.107 +                CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config
   1.108 +            fi
   1.109 +            if [ "${CT_EGLIBC_OPT_SIZE}" = "y" ]; then
   1.110 +                OPTIMIZE=-Os
   1.111 +            else
   1.112 +                OPTIMIZE=-O2
   1.113 +            fi
   1.114 +            ;;
   1.115 +    esac
   1.116  
   1.117      # Add some default glibc config options if not given by user.
   1.118      # We don't need to be conditional on wether the user did set different
   1.119 @@ -164,7 +176,7 @@
   1.120      AR=${CT_TARGET}-ar                                              \
   1.121      RANLIB=${CT_TARGET}-ranlib                                      \
   1.122      CT_DoExecLog CFG                                                \
   1.123 -    "${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/configure"             \
   1.124 +    "${src_dir}/configure"                                          \
   1.125          --prefix=/usr                                               \
   1.126          --with-headers="${CT_HEADERS_DIR}"                          \
   1.127          --build=${CT_BUILD}                                         \
   1.128 @@ -179,18 +191,23 @@
   1.129      CT_DoLog EXTRA "Building C library"
   1.130  
   1.131      # eglibc build hacks
   1.132 -    # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html
   1.133 -    case "${CT_ARCH},${CT_ARCH_CPU}" in
   1.134 -        powerpc,8??)
   1.135 -            CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)"
   1.136 -            EGLIBC_BUILD_ASFLAGS="-DBROKEN_PPC_8xx_CPU15";;
   1.137 +    case "${CT_LIBC}" in
   1.138 +        eglibc)
   1.139 +            case "${CT_ARCH},${CT_ARCH_CPU}" in
   1.140 +                powerpc,8??)
   1.141 +                    # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html
   1.142 +                    CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)"
   1.143 +                    extra_make_args+=( ASFLAGS="-DBROKEN_PPC_8xx_CPU15" )
   1.144 +                    ;;
   1.145 +            esac
   1.146 +            ;;
   1.147      esac
   1.148  
   1.149 -    CT_DoExecLog ALL make ASFLAGS="${EGLIBC_BUILD_ASFLAGS}"
   1.150 +    CT_DoExecLog ALL make -j${CT_PARALLEL_JOBS} "${extra_make_args[@]}"
   1.151  
   1.152      CT_DoLog EXTRA "Installing C library"
   1.153  
   1.154 -    CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
   1.155 +    CT_DoExecLog ALL make install "${extra_make_args[@]}" install_root="${CT_SYSROOT_DIR}"
   1.156  
   1.157      CT_EndStep
   1.158  }