scripts/build/libc/eglibc.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jan 22 22:36:20 2011 +0100 (2011-01-22)
changeset 2278 e86826b8621a
parent 2270 287e1e00dea4
child 2482 af25723a794f
permissions -rw-r--r--
libc: remove now unneeded do_libc_headers

do_libc_headers is now a noop, and is no longer used, so remove that step.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 # eglibc build functions (initially by Thomas JOURDAN).
     2 
     3 # Add the definitions common to glibc and eglibc
     4 #   do_libc_start_files
     5 #   do_libc
     6 #   do_libc_finish
     7 #   do_libc_add_ons_list
     8 . "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
     9 
    10 # Download eglibc repository
    11 do_eglibc_get() {
    12     CT_HasOrAbort svn
    13 
    14     case "${CT_LIBC_VERSION}" in
    15         trunk)  svn_url="svn://svn.eglibc.org/trunk";;
    16         *)      svn_url="svn://svn.eglibc.org/branches/eglibc-${CT_LIBC_VERSION}";;
    17     esac
    18 
    19     case "${CT_EGLIBC_CHECKOUT}" in
    20         y)  svn_action="checkout";;
    21         *)  svn_action="export --force";;
    22     esac
    23 
    24     CT_DoExecLog ALL svn ${svn_action} -r "${CT_EGLIBC_REVISION:-HEAD}" "${svn_url}" "$(pwd)"
    25 
    26     # Compress eglibc
    27     CT_DoExecLog ALL mv libc "eglibc-${CT_LIBC_VERSION}"
    28     CT_DoExecLog ALL tar cjf "eglibc-${CT_LIBC_VERSION}.tar.bz2" "eglibc-${CT_LIBC_VERSION}"
    29 
    30     # Compress linuxthreads, localedef and ports
    31     # Assign them the name the way ct-ng like it
    32     for addon in linuxthreads localedef ports; do
    33         CT_DoExecLog ALL mv "${addon}" "eglibc-${addon}-${CT_LIBC_VERSION}"
    34         CT_DoExecLog ALL tar cjf "eglibc-${addon}-${CT_LIBC_VERSION}.tar.bz2" "eglibc-${addon}-${CT_LIBC_VERSION}"
    35     done
    36 }
    37 
    38 # Download glibc
    39 do_libc_get() {
    40     # eglibc is only available through subversion, there are no
    41     # snapshots available. Moreover, addons will be downloaded
    42     # simultaneously.
    43 
    44     # build filename
    45     eglibc="eglibc-${CT_LIBC_VERSION}.tar.bz2"
    46     eglibc_linuxthreads="${CT_LIBC}-linuxthreads-${CT_LIBC_VERSION}.tar.bz2"
    47     eglibc_localedef="${CT_LIBC}-localedef-${CT_LIBC_VERSION}.tar.bz2"
    48     eglibc_ports="${CT_LIBC}-ports-${CT_LIBC_VERSION}.tar.bz2"
    49 
    50     # Check if every tarballs are already present
    51     if [    -f "${CT_TARBALLS_DIR}/${eglibc}"                   \
    52          -a -f "${CT_TARBALLS_DIR}/${eglibc_linuxthreads}"      \
    53          -a -f "${CT_TARBALLS_DIR}/${eglibc_localedef}"         \
    54          -a -f "${CT_TARBALLS_DIR}/${eglibc_ports}"             \
    55        ]; then
    56         CT_DoLog DEBUG "Already have 'eglibc-${CT_LIBC_VERSION}'"
    57         return 0
    58     fi
    59 
    60     if [    -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc}"                 \
    61          -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_linuxthreads}"    \
    62          -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_localedef}"       \
    63          -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_ports}"           \
    64          -a "${CT_FORCE_DOWNLOAD}" != "y"                           \
    65        ]; then
    66         CT_DoLog DEBUG "Got 'eglibc-${CT_LIBC_VERSION}' from local storage"
    67         for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
    68             CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
    69         done
    70         return 0
    71     fi
    72 
    73     # Not found locally, try from the network
    74     CT_DoLog EXTRA "Retrieving 'eglibc-${CT_LIBC_VERSION}'"
    75 
    76     CT_MktempDir tmp_dir
    77     CT_Pushd "${tmp_dir}"
    78 
    79     do_eglibc_get
    80     CT_DoLog DEBUG "Moving 'eglibc-${CT_LIBC_VERSION}' to tarball directory"
    81     for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
    82         CT_DoExecLog ALL mv -f "${file}" "${CT_TARBALLS_DIR}"
    83     done
    84 
    85     CT_Popd
    86 
    87     # Remove source files
    88     CT_DoExecLog ALL rm -rf "${tmp_dir}"
    89 
    90     if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
    91         CT_DoLog EXTRA "Saving 'eglibc-${CT_LIBC_VERSION}' to local storage"
    92         for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
    93             CT_DoExecLog ALL mv -f "${CT_TARBALLS_DIR}/${file}" "${CT_LOCAL_TARBALLS_DIR}"
    94             CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
    95         done
    96     fi
    97 
    98     return 0
    99 }
   100 
   101 # Extract eglibc
   102 do_libc_extract() {
   103     CT_Extract "eglibc-${CT_LIBC_VERSION}"
   104     CT_Patch "eglibc" "${CT_LIBC_VERSION}"
   105 
   106     # C library addons
   107     for addon in $(do_libc_add_ons_list " "); do
   108         # NPTL addon is not to be extracted, in any case
   109         [ "${addon}" = "nptl" ] && continue || true
   110         CT_Pushd "${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}"
   111         CT_Extract nochdir "eglibc-${addon}-${CT_LIBC_VERSION}"
   112         # Some addons have the 'long' name, while others have the
   113         # 'short' name, but patches are non-uniformly built with
   114         # either the 'long' or 'short' name, whatever the addons name
   115         # so we have to make symlinks from the existing to the missing
   116         # Fortunately for us, [ -d foo ], when foo is a symlink to a
   117         # directory, returns true!
   118         [ -d "${addon}" ] || ln -s "eglibc-${addon}-${CT_LIBC_VERSION}" "${addon}"
   119         [ -d "eglibc-${addon}-${CT_LIBC_VERSION}" ] || ln -s "${addon}" "eglibc-${addon}-${CT_LIBC_VERSION}"
   120         CT_Patch nochdir "eglibc" "${addon}-${CT_LIBC_VERSION}"
   121         CT_Popd
   122     done
   123 
   124     # The configure files may be older than the configure.in files
   125     # if using a snapshot (or even some tarballs). Fake them being
   126     # up to date.
   127     find "${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}" -type f -name configure -exec touch {} \; 2>&1 |CT_DoLog ALL
   128 
   129     return 0
   130 }
   131 
   132 # Copy user provided eglibc configuration file if provided
   133 do_libc_check_config() {
   134     if [ "${CT_EGLIBC_CUSTOM_CONFIG}" != "y" ]; then
   135         return 0
   136     fi
   137 
   138     CT_DoStep INFO "Checking C library configuration"
   139 
   140     CT_TestOrAbort "You did not provide an eglibc config file!" \
   141         -n "${CT_EGLIBC_OPTION_GROUPS_FILE}" -a \
   142         -f "${CT_EGLIBC_OPTION_GROUPS_FILE}"
   143 
   144     CT_DoExecLog ALL cp "${CT_EGLIBC_OPTION_GROUPS_FILE}" "${CT_CONFIG_DIR}/eglibc.config"
   145 
   146     # NSS configuration
   147     if grep -E '^OPTION_EGLIBC_NSSWITCH[[:space:]]*=[[:space:]]*n' "${CT_EGLIBC_OPTION_GROUPS_FILE}" >/dev/null 2>&1; then
   148         CT_DoLog DEBUG "Using fixed-configuration nsswitch facility"
   149 
   150         if [ "${CT_EGLIBC_BUNDLED_NSS_CONFIG}" = "y" ]; then
   151             nss_config="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.conf"
   152         else
   153             nss_config="${CT_EGLIBC_NSS_CONFIG_FILE}"
   154         fi
   155         CT_TestOrAbort "NSS config file not found!" -n "${nss_config}" -a -f "${nss_config}"
   156 
   157         CT_DoExecLog ALL cp "${nss_config}" "${CT_CONFIG_DIR}/nsswitch.config"
   158         echo "OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG = ${CT_CONFIG_DIR}/nsswitch.config" \
   159             >> "${CT_CONFIG_DIR}/eglibc.config"
   160 
   161         if [ "${CT_EGLIBC_BUNDLED_NSS_FUNCTIONS}" = "y" ]; then
   162             nss_functions="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.functions"
   163         else
   164             nss_functions="${CT_EGLIBC_NSS_FUNCTIONS_FILE}"
   165         fi
   166         CT_TestOrAbort "NSS functions file not found!" -n "${nss_functions}" -a -f "${nss_functions}"
   167 
   168         CT_DoExecLog ALL cp "${nss_functions}" "${CT_CONFIG_DIR}/nsswitch.functions"
   169         echo "OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS = ${CT_CONFIG_DIR}/nsswitch.functions" \
   170             >> "${CT_CONFIG_DIR}/eglibc.config"
   171     else
   172         CT_DoLog DEBUG "Using full-blown nsswitch facility"
   173     fi
   174 
   175     CT_EndStep
   176 }