scripts/build/libc/eglibc.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Sep 28 21:34:11 2008 +0000 (2008-09-28)
changeset 884 35302e8a3483
parent 867 c91b266f4dfa
child 1041 2573519c00d6
permissions -rw-r--r--
In the glibc and eglibc trees, the 'configure' files may be older than their source 'configure.in', when used from an svn check out, or a snapshot tarball.
They are nonetheless in sync and need not be regenerated.
Fix that by touching the files to have 'make' believe they are up-to-date (which they are).

/trunk/scripts/build/libc/glibc.sh | 5 5 0 0 +++++
/trunk/scripts/build/libc/eglibc.sh | 7 6 1 0 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
yann@850
     1
# eglibc build functions (initially by Thomas JOURDAN).
yann@850
     2
yann@850
     3
do_print_filename() {
yann@850
     4
    [ "${CT_LIBC}" = "eglibc" ] || return 0
yann@850
     5
    echo "eglibc-${CT_LIBC_VERSION}"
yann@850
     6
    for addon in $(do_libc_add_ons_list " "); do
yann@850
     7
        # NPTL addon is not to be downloaded, in any case
yann@850
     8
        [ "${addon}" = "nptl" ] && continue || true
yann@850
     9
        echo "eglibc-${addon}-${CT_LIBC_VERSION}"
yann@850
    10
    done
yann@850
    11
}
yann@850
    12
yann@850
    13
# Download eglibc repository
yann@850
    14
do_eglibc_get() {
yann@850
    15
    CT_HasOrAbort svn
yann@850
    16
yann@850
    17
    case "${CT_LIBC_VERSION}" in
yann@850
    18
        trunk)  svn_url="svn://svn.eglibc.org/trunk";;
yann@850
    19
        *)      svn_url="svn://svn.eglibc.org/branches/eglibc-${CT_LIBC_VERSION}";;
yann@850
    20
    esac
yann@850
    21
yann@850
    22
    case "${CT_EGLIBC_CHECKOUT}" in
yann@850
    23
        y)  svn_action="checkout";;
yann@850
    24
        *)  svn_action="export --force";;
yann@850
    25
    esac
yann@850
    26
yann@850
    27
    CT_DoSetProxy ${CT_PROXY_TYPE}
yann@850
    28
    CT_DoExecLog ALL svn ${svn_action} -r "${CT_EGLIBC_REVISION:-HEAD}" "${svn_url}" . 2>&1
yann@850
    29
yann@850
    30
    # Compress eglibc
yann@850
    31
    CT_DoExecLog ALL mv libc "${CT_LIBC_FILE}"
yann@867
    32
    CT_DoExecLog ALL tar cjf "${CT_LIBC_FILE}.tar.bz2" "${CT_LIBC_FILE}"
yann@850
    33
yann@850
    34
    # Compress linuxthreads, localedef and ports
yann@850
    35
    # Assign them the name the way ct-ng like it
yann@850
    36
    for addon in linuxthreads localedef ports; do
yann@867
    37
        CT_DoExecLog ALL tar cjf "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}.tar.bz2" "${addon}"
yann@850
    38
    done
yann@850
    39
}
yann@850
    40
yann@850
    41
# Download glibc
yann@850
    42
do_libc_get() {
yann@850
    43
    # eglibc is only available through subversion, there are no
yann@850
    44
    # snapshots available. Moreover, addons will be downloaded
yann@850
    45
    # simultaneously.
yann@850
    46
yann@850
    47
    # build filename
yann@850
    48
    eglibc="${CT_LIBC_FILE}.tar.bz2"
yann@850
    49
    eglibc_linuxthreads="${CT_LIBC}-linuxthreads-${CT_LIBC_VERSION}.tar.bz2"
yann@850
    50
    eglibc_localedef="${CT_LIBC}-localedef-${CT_LIBC_VERSION}.tar.bz2"
yann@850
    51
    eglibc_ports="${CT_LIBC}-ports-${CT_LIBC_VERSION}.tar.bz2"
yann@850
    52
yann@850
    53
    # Check if every tarballs are already present
yann@850
    54
    if [ -a "${CT_TARBALLS_DIR}/${eglibc}" ]              && \
yann@850
    55
       [ -a "${CT_TARBALLS_DIR}/${eglibc_linuxthreads}" ] && \
yann@850
    56
       [ -a "${CT_TARBALLS_DIR}/${eglibc_localedef}" ]    && \
yann@850
    57
       [ -a "${CT_TARBALLS_DIR}/${eglibc_ports}" ]; then
yann@850
    58
        CT_DoLog DEBUG "Already have 'eglibc-${CT_LIBC_VERSION}'"
yann@850
    59
        return 0
yann@850
    60
    fi
yann@850
    61
yann@850
    62
    if [ -a "${CT_LOCAL_TARBALLS_DIR}/${eglibc}" ]              && \
yann@850
    63
       [ -a "${CT_LOCAL_TARBALLS_DIR}/${eglibc_linuxthreads}" ] && \
yann@850
    64
       [ -a "${CT_LOCAL_TARBALLS_DIR}/${eglibc_localedef}" ]    && \
yann@850
    65
       [ -a "${CT_LOCAL_TARBALLS_DIR}/${eglibc_ports}" ]        && \
yann@850
    66
       [ "${CT_FORCE_DOWNLOAD}" != "y" ]; then
yann@850
    67
        CT_DoLog DEBUG "Got 'eglibc-${CT_LIBC_VERSION}' from local storage"
yann@850
    68
        for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
yann@850
    69
            CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
yann@850
    70
        done
yann@850
    71
        return 0
yann@850
    72
    fi
yann@850
    73
yann@850
    74
    # Not found locally, try from the network
yann@850
    75
    CT_DoLog EXTRA "Retrieving 'eglibc-${CT_LIBC_VERSION}'"
yann@867
    76
yann@867
    77
    CT_MktempDir tmp_dir
yann@867
    78
    CT_Pushd "${tmp_dir}"
yann@867
    79
yann@850
    80
    do_eglibc_get
yann@867
    81
    CT_DoLog DEBUG "Moving 'eglibc-${CT_LIBC_VERSION}' to tarball directory"
yann@867
    82
    for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
yann@867
    83
        CT_DoExecLog ALL mv -f "${file}" "${CT_TARBALLS_DIR}"
yann@867
    84
    done
yann@867
    85
yann@867
    86
    CT_Popd
yann@867
    87
yann@867
    88
    # Remove source files
yann@867
    89
    CT_DoExecLog ALL rm -rf "${tmp_dir}"
yann@850
    90
yann@850
    91
    if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
yann@850
    92
        CT_DoLog EXTRA "Saving 'eglibc-${CT_LIBC_VERSION}' to local storage"
yann@850
    93
        for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
yann@850
    94
            CT_DoExecLog ALL mv -f "${CT_TARBALLS_DIR}/${file}" "${CT_LOCAL_TARBALLS_DIR}"
yann@850
    95
            CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
yann@850
    96
        done
yann@850
    97
    fi
yann@850
    98
yann@850
    99
    return 0
yann@850
   100
}
yann@850
   101
yann@850
   102
# Extract eglibc
yann@850
   103
do_libc_extract() {
yann@850
   104
    CT_ExtractAndPatch "${CT_LIBC_FILE}"
yann@850
   105
yann@850
   106
    # C library addons
yann@850
   107
    for addon in $(do_libc_add_ons_list " "); do
yann@850
   108
        # NPTL addon is not to be extracted, in any case
yann@850
   109
        [ "${addon}" = "nptl" ] && continue || true
yann@850
   110
        CT_ExtractAndPatch "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
yann@850
   111
    done
yann@850
   112
yann@884
   113
    # The configure files may be older than the configure.in files
yann@884
   114
    # if using a snapshot (or even some tarballs). Fake them being
yann@884
   115
    # up to date.
yann@884
   116
    find "${CT_SRC_DIR}/${CT_LIBC_FILE}" -type f -name configure -exec touch {} \; 2>&1 |CT_DoLog ALL
yann@884
   117
yann@850
   118
    return 0
yann@850
   119
}
yann@850
   120
yann@850
   121
# There is nothing to do for eglibc check config
yann@850
   122
do_libc_check_config() {
yann@850
   123
    :
yann@850
   124
}
yann@850
   125
yann@884
   126
# This function installs the eglibc headers needed to build the core compiler
yann@850
   127
do_libc_headers() {
yann@850
   128
    # Instead of doing two time the same actions, headers will
yann@850
   129
    # be installed with start files
yann@850
   130
    :
yann@850
   131
}
yann@850
   132
yann@850
   133
# Build and install start files
yann@850
   134
do_libc_start_files() {
yann@850
   135
    CT_DoStep INFO "Installing C library headers / start files"
yann@850
   136
yann@850
   137
    mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
yann@850
   138
    cd "${CT_BUILD_DIR}/build-libc-startfiles"
yann@850
   139
yann@850
   140
    CT_DoLog EXTRA "Configuring C library"
yann@850
   141
yann@850
   142
    cross_cc=$(CT_Which "${CT_TARGET}-gcc")
yann@850
   143
    cross_cxx=$(CT_Which "${CT_TARGET}-g++")
yann@850
   144
    cross_ar=$(CT_Which "${CT_TARGET}-ar")
yann@850
   145
    cross_ranlib=$(CT_Which "${CT_TARGET}-ranlib")
yann@850
   146
    
yann@850
   147
    CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
yann@850
   148
    CT_DoLog DEBUG "Using g++ for target: '${cross_cxx}'"
yann@850
   149
    CT_DoLog DEBUG "Using ar for target: '${cross_ar}'"
yann@850
   150
    CT_DoLog DEBUG "Using ranlib for target: '${cross_ranlib}'"
yann@850
   151
yann@850
   152
    BUILD_CC=${CT_CC_NATIVE}                    \
yann@850
   153
    CC=${cross_cc}                              \
yann@850
   154
    CXX=${cross_cxx}                            \
yann@850
   155
    AR=${cross_ar}                              \
yann@850
   156
    RANLIB=${cross_ranlib}                      \
yann@850
   157
    CT_DoExecLog ALL                            \
yann@850
   158
    "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"   \
yann@850
   159
        --prefix=/usr                           \
yann@850
   160
        --with-headers="${CT_HEADERS_DIR}"      \
yann@850
   161
        --build="${CT_UNIQ_BUILD}"              \
yann@850
   162
        --host="${CT_TARGET}"                   \
yann@850
   163
        --disable-profile                       \
yann@850
   164
        --without-gd                            \
yann@850
   165
        --without-cvs                           \
yann@850
   166
        --enable-add-ons
yann@850
   167
yann@850
   168
    CT_DoLog EXTRA "Installing C library headers"
yann@850
   169
yann@850
   170
    # use the 'install-headers' makefile target to install the
yann@850
   171
    # headers
yann@850
   172
yann@850
   173
    CT_DoExecLog ALL                    \
yann@850
   174
    make install-headers                \
yann@850
   175
         install_root=${CT_SYSROOT_DIR} \
yann@850
   176
         install-bootstrap-headers=yes
yann@850
   177
yann@850
   178
    CT_DoLog EXTRA "Installing C library start files"
yann@850
   179
yann@850
   180
    # there are a few object files needed to link shared libraries,
yann@850
   181
    # which we build and install by hand
yann@850
   182
yann@850
   183
    CT_DoExecLog ALL mkdir -p ${CT_SYSROOT_DIR}/usr/lib
yann@850
   184
    CT_DoExecLog ALL make csu/subdir_lib
yann@850
   185
    CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \
yann@850
   186
        ${CT_SYSROOT_DIR}/usr/lib
yann@850
   187
yann@850
   188
    # Finally, 'libgcc_s.so' requires a 'libc.so' to link against.  
yann@850
   189
    # However, since we will never actually execute its code, 
yann@850
   190
    # it doesn't matter what it contains.  So, treating '/dev/null' 
yann@850
   191
    # as a C source file, we produce a dummy 'libc.so' in one step
yann@850
   192
yann@850
   193
    CT_DoExecLog ALL ${cross_cc} -nostdlib -nostartfiles -shared -x c /dev/null -o ${CT_SYSROOT_DIR}/usr/lib/libc.so
yann@850
   194
yann@850
   195
    CT_EndStep
yann@850
   196
}
yann@850
   197
yann@850
   198
# This function builds and install the full glibc
yann@850
   199
do_libc() {
yann@850
   200
    CT_DoStep INFO "Installing C library"
yann@850
   201
yann@850
   202
    mkdir -p "${CT_BUILD_DIR}/build-libc"
yann@850
   203
    cd "${CT_BUILD_DIR}/build-libc"
yann@850
   204
yann@850
   205
    CT_DoLog EXTRA "Configuring C library"
yann@850
   206
yann@850
   207
    # Add some default glibc config options if not given by user.
yann@850
   208
    # We don't need to be conditional on wether the user did set different
yann@850
   209
    # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG is passed after extra_config
yann@850
   210
yann@850
   211
    extra_config="--enable-kernel=$(echo ${CT_LIBC_GLIBC_MIN_KERNEL} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;')"
yann@850
   212
yann@850
   213
    case "${CT_THREADS}" in
yann@850
   214
        nptl)           extra_config="${extra_config} --with-__thread --with-tls";;
yann@850
   215
        linuxthreads)   extra_config="${extra_config} --with-__thread --without-tls --without-nptl";;
yann@850
   216
        none)           extra_config="${extra_config} --without-__thread --without-nptl"
yann@850
   217
                        case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
yann@850
   218
                            *-tls*) ;;
yann@850
   219
                            *) extra_config="${extra_config} --without-tls";;
yann@850
   220
                        esac
yann@850
   221
                        ;;
yann@850
   222
    esac
yann@850
   223
yann@850
   224
    case "${CT_SHARED_LIBS}" in
yann@850
   225
        y) extra_config="${extra_config} --enable-shared";;
yann@850
   226
        *) extra_config="${extra_config} --disable-shared";;
yann@850
   227
    esac
yann@850
   228
yann@850
   229
    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
yann@850
   230
        y,) extra_config="${extra_config} --with-fp";;
yann@850
   231
        ,y) extra_config="${extra_config} --without-fp";;
yann@850
   232
    esac
yann@850
   233
yann@850
   234
    case "$(do_libc_add_ons_list ,)" in
yann@850
   235
        "") ;;
yann@850
   236
        *)  extra_config="${extra_config} --enable-add-ons=$(do_libc_add_ons_list ,)";;
yann@850
   237
    esac
yann@850
   238
yann@850
   239
    extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
yann@850
   240
yann@850
   241
    cross_cc=$(CT_Which "${CT_TARGET}-gcc")    
yann@850
   242
yann@850
   243
    CT_DoLog DEBUG "Using gcc for target:     '${cross_cc}'"
yann@850
   244
    CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
yann@850
   245
    CT_DoLog DEBUG "Extra config args passed: '${extra_config}'"
yann@850
   246
    CT_DoLog DEBUG "Extra CC args passed    : '${extra_cc_args}'"
yann@850
   247
yann@850
   248
    BUILD_CC=${CT_CC_NATIVE}                                        \
yann@850
   249
    CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O"   \
yann@850
   250
    CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
yann@850
   251
    AR=${CT_TARGET}-ar                                              \
yann@850
   252
    RANLIB=${CT_TARGET}-ranlib                                      \
yann@850
   253
    CT_DoExecLog ALL                                                \
yann@850
   254
    "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"                       \
yann@850
   255
        --prefix=/usr                                               \
yann@850
   256
        --with-headers="${CT_HEADERS_DIR}"                          \
yann@850
   257
        --build=${CT_UNIQ_BUILD}                                    \
yann@850
   258
        --host=${CT_TARGET}                                         \
yann@850
   259
        --disable-profile                                           \
yann@850
   260
        --without-gd                                                \
yann@850
   261
        --without-cvs                                               \
yann@850
   262
        ${extra_config}                                             \
yann@850
   263
        ${CT_LIBC_GLIBC_EXTRA_CONFIG}
yann@850
   264
    
yann@850
   265
    CT_DoLog EXTRA "Building C library"
yann@850
   266
yann@850
   267
    CT_DoExecLog ALL make
yann@850
   268
yann@850
   269
    CT_DoLog EXTRA "Installing C library"
yann@850
   270
yann@850
   271
    CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
yann@850
   272
yann@850
   273
    CT_EndStep
yann@850
   274
}
yann@850
   275
yann@850
   276
# This function finishes the glibc install
yann@850
   277
do_libc_finish() {
yann@850
   278
    # Nothing to be done for eglibc
yann@850
   279
    :
yann@850
   280
}
yann@850
   281
yann@850
   282
# Build up the addons list, separated with $1
yann@850
   283
do_libc_add_ons_list() {
yann@850
   284
    local sep="$1"
yann@850
   285
    local addons_list=$(echo "${CT_LIBC_ADDONS_LIST//,/${sep}}" |tr -s ,)
yann@850
   286
    case "${CT_THREADS}" in
yann@850
   287
        none)   ;;
yann@850
   288
        *)      addons_list="${addons_list}${sep}${CT_THREADS}";;
yann@850
   289
    esac
yann@850
   290
    [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list}${sep}ports"
yann@850
   291
    addons_list="${addons_list%%${sep}}"
yann@850
   292
    echo "${addons_list##${sep}}"
yann@850
   293
}