scripts/build/libc/eglibc.sh
author "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
Tue May 31 20:12:35 2011 +0200 (2011-05-31)
changeset 2487 481cd34691f0
parent 2482 af25723a794f
child 2495 98b02f85db29
permissions -rw-r--r--
gcc: promote PKGVERSION and BUGURL options to toolchain level

This patch promotes the PKGVERSION and BUGURL options to toolchain level so that
all toolchain components supporting them can benefit from them.

These options are passed to configure through --with-pkgversion and
--with-bugurl.

They are supported by binutils 2.18+, gcc 4.3+, eglibc 2.9+ and gdb 7.0+.

Signed-off-by: "Benoît THÉBAUDEAU" <benoit.thebaudeau@advansee.com>
     1 # eglibc build functions (initially by Thomas JOURDAN).
     2 
     3 # Add the definitions common to glibc and eglibc
     4 #   do_libc_extract
     5 #   do_libc_start_files
     6 #   do_libc
     7 #   do_libc_finish
     8 #   do_libc_add_ons_list
     9 #   do_libc_min_kernel_config
    10 . "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
    11 
    12 # Download eglibc repository
    13 do_eglibc_get() {
    14     CT_HasOrAbort svn
    15 
    16     case "${CT_LIBC_VERSION}" in
    17         trunk)  svn_url="svn://svn.eglibc.org/trunk";;
    18         *)      svn_url="svn://svn.eglibc.org/branches/eglibc-${CT_LIBC_VERSION}";;
    19     esac
    20 
    21     case "${CT_EGLIBC_CHECKOUT}" in
    22         y)  svn_action="checkout";;
    23         *)  svn_action="export --force";;
    24     esac
    25 
    26     CT_DoExecLog ALL svn ${svn_action} -r "${CT_EGLIBC_REVISION:-HEAD}" "${svn_url}" "$(pwd)"
    27 
    28     # Compress eglibc
    29     CT_DoExecLog ALL mv libc "eglibc-${CT_LIBC_VERSION}"
    30     CT_DoExecLog ALL tar cjf "eglibc-${CT_LIBC_VERSION}.tar.bz2" "eglibc-${CT_LIBC_VERSION}"
    31 
    32     # Compress linuxthreads, localedef and ports
    33     # Assign them the name the way ct-ng like it
    34     for addon in linuxthreads localedef ports; do
    35         CT_DoExecLog ALL mv "${addon}" "eglibc-${addon}-${CT_LIBC_VERSION}"
    36         CT_DoExecLog ALL tar cjf "eglibc-${addon}-${CT_LIBC_VERSION}.tar.bz2" "eglibc-${addon}-${CT_LIBC_VERSION}"
    37     done
    38 }
    39 
    40 # Download glibc
    41 do_libc_get() {
    42     # eglibc is only available through subversion, there are no
    43     # snapshots available. Moreover, addons will be downloaded
    44     # simultaneously.
    45 
    46     # build filename
    47     eglibc="eglibc-${CT_LIBC_VERSION}.tar.bz2"
    48     eglibc_linuxthreads="${CT_LIBC}-linuxthreads-${CT_LIBC_VERSION}.tar.bz2"
    49     eglibc_localedef="${CT_LIBC}-localedef-${CT_LIBC_VERSION}.tar.bz2"
    50     eglibc_ports="${CT_LIBC}-ports-${CT_LIBC_VERSION}.tar.bz2"
    51 
    52     # Check if every tarballs are already present
    53     if [    -f "${CT_TARBALLS_DIR}/${eglibc}"                   \
    54          -a -f "${CT_TARBALLS_DIR}/${eglibc_linuxthreads}"      \
    55          -a -f "${CT_TARBALLS_DIR}/${eglibc_localedef}"         \
    56          -a -f "${CT_TARBALLS_DIR}/${eglibc_ports}"             \
    57        ]; then
    58         CT_DoLog DEBUG "Already have 'eglibc-${CT_LIBC_VERSION}'"
    59         return 0
    60     fi
    61 
    62     if [    -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc}"                 \
    63          -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_linuxthreads}"    \
    64          -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_localedef}"       \
    65          -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_ports}"           \
    66          -a "${CT_FORCE_DOWNLOAD}" != "y"                           \
    67        ]; then
    68         CT_DoLog DEBUG "Got 'eglibc-${CT_LIBC_VERSION}' from local storage"
    69         for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
    70             CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
    71         done
    72         return 0
    73     fi
    74 
    75     # Not found locally, try from the network
    76     CT_DoLog EXTRA "Retrieving 'eglibc-${CT_LIBC_VERSION}'"
    77 
    78     CT_MktempDir tmp_dir
    79     CT_Pushd "${tmp_dir}"
    80 
    81     do_eglibc_get
    82     CT_DoLog DEBUG "Moving 'eglibc-${CT_LIBC_VERSION}' to tarball directory"
    83     for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
    84         CT_DoExecLog ALL mv -f "${file}" "${CT_TARBALLS_DIR}"
    85     done
    86 
    87     CT_Popd
    88 
    89     # Remove source files
    90     CT_DoExecLog ALL rm -rf "${tmp_dir}"
    91 
    92     if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
    93         CT_DoLog EXTRA "Saving 'eglibc-${CT_LIBC_VERSION}' to local storage"
    94         for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
    95             CT_DoExecLog ALL mv -f "${CT_TARBALLS_DIR}/${file}" "${CT_LOCAL_TARBALLS_DIR}"
    96             CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
    97         done
    98     fi
    99 
   100     return 0
   101 }
   102 
   103 # Copy user provided eglibc configuration file if provided
   104 do_libc_check_config() {
   105     if [ "${CT_EGLIBC_CUSTOM_CONFIG}" != "y" ]; then
   106         return 0
   107     fi
   108 
   109     CT_DoStep INFO "Checking C library configuration"
   110 
   111     CT_TestOrAbort "You did not provide an eglibc config file!" \
   112         -n "${CT_EGLIBC_OPTION_GROUPS_FILE}" -a \
   113         -f "${CT_EGLIBC_OPTION_GROUPS_FILE}"
   114 
   115     CT_DoExecLog ALL cp "${CT_EGLIBC_OPTION_GROUPS_FILE}" "${CT_CONFIG_DIR}/eglibc.config"
   116 
   117     # NSS configuration
   118     if grep -E '^OPTION_EGLIBC_NSSWITCH[[:space:]]*=[[:space:]]*n' "${CT_EGLIBC_OPTION_GROUPS_FILE}" >/dev/null 2>&1; then
   119         CT_DoLog DEBUG "Using fixed-configuration nsswitch facility"
   120 
   121         if [ "${CT_EGLIBC_BUNDLED_NSS_CONFIG}" = "y" ]; then
   122             nss_config="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.conf"
   123         else
   124             nss_config="${CT_EGLIBC_NSS_CONFIG_FILE}"
   125         fi
   126         CT_TestOrAbort "NSS config file not found!" -n "${nss_config}" -a -f "${nss_config}"
   127 
   128         CT_DoExecLog ALL cp "${nss_config}" "${CT_CONFIG_DIR}/nsswitch.config"
   129         echo "OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG = ${CT_CONFIG_DIR}/nsswitch.config" \
   130             >> "${CT_CONFIG_DIR}/eglibc.config"
   131 
   132         if [ "${CT_EGLIBC_BUNDLED_NSS_FUNCTIONS}" = "y" ]; then
   133             nss_functions="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.functions"
   134         else
   135             nss_functions="${CT_EGLIBC_NSS_FUNCTIONS_FILE}"
   136         fi
   137         CT_TestOrAbort "NSS functions file not found!" -n "${nss_functions}" -a -f "${nss_functions}"
   138 
   139         CT_DoExecLog ALL cp "${nss_functions}" "${CT_CONFIG_DIR}/nsswitch.functions"
   140         echo "OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS = ${CT_CONFIG_DIR}/nsswitch.functions" \
   141             >> "${CT_CONFIG_DIR}/eglibc.config"
   142     else
   143         CT_DoLog DEBUG "Using full-blown nsswitch facility"
   144     fi
   145 
   146     CT_EndStep
   147 }