scripts/build/libc_eglibc.sh
changeset 850 ef8549b58b6f
parent 849 777bf06ddd8b
child 851 6add2c0b63cd
     1.1 --- a/scripts/build/libc_eglibc.sh	Thu Sep 11 09:02:00 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,283 +0,0 @@
     1.4 -# eglibc build functions (initially by Thomas JOURDAN).
     1.5 -
     1.6 -do_print_filename() {
     1.7 -    [ "${CT_LIBC}" = "eglibc" ] || return 0
     1.8 -    echo "eglibc-${CT_LIBC_VERSION}"
     1.9 -    for addon in $(do_libc_add_ons_list " "); do
    1.10 -        # NPTL addon is not to be downloaded, in any case
    1.11 -        [ "${addon}" = "nptl" ] && continue || true
    1.12 -        echo "eglibc-${addon}-${CT_LIBC_VERSION}"
    1.13 -    done
    1.14 -}
    1.15 -
    1.16 -# Download eglibc repository
    1.17 -do_eglibc_get() {
    1.18 -    CT_HasOrAbort svn
    1.19 -
    1.20 -    case "${CT_LIBC_VERSION}" in
    1.21 -        trunk)  svn_url="svn://svn.eglibc.org/trunk";;
    1.22 -        *)      svn_url="svn://svn.eglibc.org/branches/eglibc-${CT_LIBC_VERSION}";;
    1.23 -    esac
    1.24 -
    1.25 -    CT_MktempDir tmp_dir
    1.26 -    CT_Pushd "${tmp_dir}"
    1.27 -
    1.28 -    case "${CT_EGLIBC_CHECKOUT}" in
    1.29 -        y)  svn_action="checkout";;
    1.30 -        *)  svn_action="export --force";;
    1.31 -    esac
    1.32 -
    1.33 -    CT_DoSetProxy ${CT_PROXY_TYPE}
    1.34 -    CT_DoExecLog ALL svn ${svn_action} -r "${CT_EGLIBC_REVISION:-HEAD}" "${svn_url}" . 2>&1
    1.35 -
    1.36 -    # Compress eglibc
    1.37 -    CT_DoExecLog ALL mv libc "${CT_LIBC_FILE}"
    1.38 -    CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${CT_LIBC_FILE}.tar.bz2" "${CT_LIBC_FILE}"
    1.39 -
    1.40 -    # Compress linuxthreads, localedef and ports
    1.41 -    # Assign them the name the way ct-ng like it
    1.42 -    for addon in linuxthreads localedef ports; do
    1.43 -        CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${CT_LIBC}-${addon}-${CT_LIBC_VERSION}.tar.bz2" "${addon}"
    1.44 -    done
    1.45 -
    1.46 -    CT_Popd
    1.47 -
    1.48 -    # Remove source files
    1.49 -    CT_DoExecLog ALL rm -rf "${tmp_dir}"
    1.50 -}
    1.51 -
    1.52 -# Download glibc
    1.53 -do_libc_get() {
    1.54 -    # eglibc is only available through subversion, there are no
    1.55 -    # snapshots available. Moreover, addons will be downloaded
    1.56 -    # simultaneously.
    1.57 -
    1.58 -    # build filename
    1.59 -    eglibc="${CT_LIBC_FILE}.tar.bz2"
    1.60 -    eglibc_linuxthreads="${CT_LIBC}-linuxthreads-${CT_LIBC_VERSION}.tar.bz2"
    1.61 -    eglibc_localedef="${CT_LIBC}-localedef-${CT_LIBC_VERSION}.tar.bz2"
    1.62 -    eglibc_ports="${CT_LIBC}-ports-${CT_LIBC_VERSION}.tar.bz2"
    1.63 -
    1.64 -    # Check if every tarballs are already present
    1.65 -    if [ -a "${CT_TARBALLS_DIR}/${eglibc}" ]              && \
    1.66 -       [ -a "${CT_TARBALLS_DIR}/${eglibc_linuxthreads}" ] && \
    1.67 -       [ -a "${CT_TARBALLS_DIR}/${eglibc_localedef}" ]    && \
    1.68 -       [ -a "${CT_TARBALLS_DIR}/${eglibc_ports}" ]; then
    1.69 -        CT_DoLog DEBUG "Already have 'eglibc-${CT_LIBC_VERSION}'"
    1.70 -        return 0
    1.71 -    fi
    1.72 -
    1.73 -    if [ -a "${CT_LOCAL_TARBALLS_DIR}/${eglibc}" ]              && \
    1.74 -       [ -a "${CT_LOCAL_TARBALLS_DIR}/${eglibc_linuxthreads}" ] && \
    1.75 -       [ -a "${CT_LOCAL_TARBALLS_DIR}/${eglibc_localedef}" ]    && \
    1.76 -       [ -a "${CT_LOCAL_TARBALLS_DIR}/${eglibc_ports}" ]        && \
    1.77 -       [ "${CT_FORCE_DOWNLOAD}" != "y" ]; then
    1.78 -        CT_DoLog DEBUG "Got 'eglibc-${CT_LIBC_VERSION}' from local storage"
    1.79 -        for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
    1.80 -            CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
    1.81 -        done
    1.82 -        return 0
    1.83 -    fi
    1.84 -
    1.85 -    # Not found locally, try from the network
    1.86 -    CT_DoLog EXTRA "Retrieving 'eglibc-${CT_LIBC_VERSION}'"
    1.87 -    do_eglibc_get
    1.88 -
    1.89 -    if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
    1.90 -        CT_DoLog EXTRA "Saving 'eglibc-${CT_LIBC_VERSION}' to local storage"
    1.91 -        for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
    1.92 -            CT_DoExecLog ALL mv -f "${CT_TARBALLS_DIR}/${file}" "${CT_LOCAL_TARBALLS_DIR}"
    1.93 -            CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
    1.94 -        done
    1.95 -    fi
    1.96 -
    1.97 -    return 0
    1.98 -}
    1.99 -
   1.100 -# Extract eglibc
   1.101 -do_libc_extract() {
   1.102 -    CT_ExtractAndPatch "${CT_LIBC_FILE}"
   1.103 -
   1.104 -    # C library addons
   1.105 -    for addon in $(do_libc_add_ons_list " "); do
   1.106 -        # NPTL addon is not to be extracted, in any case
   1.107 -        [ "${addon}" = "nptl" ] && continue || true
   1.108 -        CT_ExtractAndPatch "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
   1.109 -    done
   1.110 -
   1.111 -    return 0
   1.112 -}
   1.113 -
   1.114 -# There is nothing to do for eglibc check config
   1.115 -do_libc_check_config() {
   1.116 -    :
   1.117 -}
   1.118 -
   1.119 -# This function installs the glibc headers needed to build the core compiler
   1.120 -do_libc_headers() {
   1.121 -    # Instead of doing two time the same actions, headers will
   1.122 -    # be installed with start files
   1.123 -    :
   1.124 -}
   1.125 -
   1.126 -# Build and install start files
   1.127 -do_libc_start_files() {
   1.128 -    CT_DoStep INFO "Installing C library headers / start files"
   1.129 -
   1.130 -    mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
   1.131 -    cd "${CT_BUILD_DIR}/build-libc-startfiles"
   1.132 -
   1.133 -    CT_DoLog EXTRA "Configuring C library"
   1.134 -
   1.135 -    cross_cc=$(CT_Which "${CT_TARGET}-gcc")
   1.136 -    cross_cxx=$(CT_Which "${CT_TARGET}-g++")
   1.137 -    cross_ar=$(CT_Which "${CT_TARGET}-ar")
   1.138 -    cross_ranlib=$(CT_Which "${CT_TARGET}-ranlib")
   1.139 -    
   1.140 -    CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
   1.141 -    CT_DoLog DEBUG "Using g++ for target: '${cross_cxx}'"
   1.142 -    CT_DoLog DEBUG "Using ar for target: '${cross_ar}'"
   1.143 -    CT_DoLog DEBUG "Using ranlib for target: '${cross_ranlib}'"
   1.144 -
   1.145 -    BUILD_CC=${CT_CC_NATIVE}                    \
   1.146 -    CC=${cross_cc}                              \
   1.147 -    CXX=${cross_cxx}                            \
   1.148 -    AR=${cross_ar}                              \
   1.149 -    RANLIB=${cross_ranlib}                      \
   1.150 -    CT_DoExecLog ALL                            \
   1.151 -    "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"   \
   1.152 -        --prefix=/usr                           \
   1.153 -        --with-headers="${CT_HEADERS_DIR}"      \
   1.154 -        --build="${CT_UNIQ_BUILD}"              \
   1.155 -        --host="${CT_TARGET}"                   \
   1.156 -        --disable-profile                       \
   1.157 -        --without-gd                            \
   1.158 -        --without-cvs                           \
   1.159 -        --enable-add-ons
   1.160 -
   1.161 -    CT_DoLog EXTRA "Installing C library headers"
   1.162 -
   1.163 -    # use the 'install-headers' makefile target to install the
   1.164 -    # headers
   1.165 -
   1.166 -    CT_DoExecLog ALL                    \
   1.167 -    make install-headers                \
   1.168 -         install_root=${CT_SYSROOT_DIR} \
   1.169 -         install-bootstrap-headers=yes
   1.170 -
   1.171 -    CT_DoLog EXTRA "Installing C library start files"
   1.172 -
   1.173 -    # there are a few object files needed to link shared libraries,
   1.174 -    # which we build and install by hand
   1.175 -
   1.176 -    CT_DoExecLog ALL mkdir -p ${CT_SYSROOT_DIR}/usr/lib
   1.177 -    CT_DoExecLog ALL make csu/subdir_lib
   1.178 -    CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \
   1.179 -        ${CT_SYSROOT_DIR}/usr/lib
   1.180 -
   1.181 -    # Finally, 'libgcc_s.so' requires a 'libc.so' to link against.  
   1.182 -    # However, since we will never actually execute its code, 
   1.183 -    # it doesn't matter what it contains.  So, treating '/dev/null' 
   1.184 -    # as a C source file, we produce a dummy 'libc.so' in one step
   1.185 -
   1.186 -    CT_DoExecLog ALL ${cross_cc} -nostdlib -nostartfiles -shared -x c /dev/null -o ${CT_SYSROOT_DIR}/usr/lib/libc.so
   1.187 -
   1.188 -    CT_EndStep
   1.189 -}
   1.190 -
   1.191 -# This function builds and install the full glibc
   1.192 -do_libc() {
   1.193 -    CT_DoStep INFO "Installing C library"
   1.194 -
   1.195 -    mkdir -p "${CT_BUILD_DIR}/build-libc"
   1.196 -    cd "${CT_BUILD_DIR}/build-libc"
   1.197 -
   1.198 -    CT_DoLog EXTRA "Configuring C library"
   1.199 -
   1.200 -    # Add some default glibc config options if not given by user.
   1.201 -    # We don't need to be conditional on wether the user did set different
   1.202 -    # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG is passed after extra_config
   1.203 -
   1.204 -    extra_config="--enable-kernel=$(echo ${CT_LIBC_GLIBC_MIN_KERNEL} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;')"
   1.205 -
   1.206 -    case "${CT_THREADS}" in
   1.207 -        nptl)           extra_config="${extra_config} --with-__thread --with-tls";;
   1.208 -        linuxthreads)   extra_config="${extra_config} --with-__thread --without-tls --without-nptl";;
   1.209 -        none)           extra_config="${extra_config} --without-__thread --without-nptl"
   1.210 -                        case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
   1.211 -                            *-tls*) ;;
   1.212 -                            *) extra_config="${extra_config} --without-tls";;
   1.213 -                        esac
   1.214 -                        ;;
   1.215 -    esac
   1.216 -
   1.217 -    case "${CT_SHARED_LIBS}" in
   1.218 -        y) extra_config="${extra_config} --enable-shared";;
   1.219 -        *) extra_config="${extra_config} --disable-shared";;
   1.220 -    esac
   1.221 -
   1.222 -    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
   1.223 -        y,) extra_config="${extra_config} --with-fp";;
   1.224 -        ,y) extra_config="${extra_config} --without-fp";;
   1.225 -    esac
   1.226 -
   1.227 -    case "$(do_libc_add_ons_list ,)" in
   1.228 -        "") ;;
   1.229 -        *)  extra_config="${extra_config} --enable-add-ons=$(do_libc_add_ons_list ,)";;
   1.230 -    esac
   1.231 -
   1.232 -    extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
   1.233 -
   1.234 -    cross_cc=$(CT_Which "${CT_TARGET}-gcc")    
   1.235 -
   1.236 -    CT_DoLog DEBUG "Using gcc for target:     '${cross_cc}'"
   1.237 -    CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
   1.238 -    CT_DoLog DEBUG "Extra config args passed: '${extra_config}'"
   1.239 -    CT_DoLog DEBUG "Extra CC args passed    : '${extra_cc_args}'"
   1.240 -
   1.241 -    BUILD_CC=${CT_CC_NATIVE}                                        \
   1.242 -    CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O"   \
   1.243 -    CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
   1.244 -    AR=${CT_TARGET}-ar                                              \
   1.245 -    RANLIB=${CT_TARGET}-ranlib                                      \
   1.246 -    CT_DoExecLog ALL                                                \
   1.247 -    "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"                       \
   1.248 -        --prefix=/usr                                               \
   1.249 -        --with-headers="${CT_HEADERS_DIR}"                          \
   1.250 -        --build=${CT_UNIQ_BUILD}                                    \
   1.251 -        --host=${CT_TARGET}                                         \
   1.252 -        --disable-profile                                           \
   1.253 -        --without-gd                                                \
   1.254 -        --without-cvs                                               \
   1.255 -        ${extra_config}                                             \
   1.256 -        ${CT_LIBC_GLIBC_EXTRA_CONFIG}
   1.257 -    
   1.258 -    CT_DoLog EXTRA "Building C library"
   1.259 -
   1.260 -    CT_DoExecLog ALL make
   1.261 -
   1.262 -    CT_DoLog EXTRA "Installing C library"
   1.263 -
   1.264 -    CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
   1.265 -
   1.266 -    CT_EndStep
   1.267 -}
   1.268 -
   1.269 -# This function finishes the glibc install
   1.270 -do_libc_finish() {
   1.271 -    # Nothing to be done for eglibc
   1.272 -    :
   1.273 -}
   1.274 -
   1.275 -# Build up the addons list, separated with $1
   1.276 -do_libc_add_ons_list() {
   1.277 -    local sep="$1"
   1.278 -    local addons_list=$(echo "${CT_LIBC_ADDONS_LIST//,/${sep}}" |tr -s ,)
   1.279 -    case "${CT_THREADS}" in
   1.280 -        none)   ;;
   1.281 -        *)      addons_list="${addons_list}${sep}${CT_THREADS}";;
   1.282 -    esac
   1.283 -    [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list}${sep}ports"
   1.284 -    addons_list="${addons_list%%${sep}}"
   1.285 -    echo "${addons_list##${sep}}"
   1.286 -}