scripts/build/libc/eglibc.sh
author Bryan Hundven <bryanhundven@gmail.com>
Sun Jun 26 03:26:54 2011 -0700 (2011-06-26)
changeset 2515 364b06df9e3a
parent 2496 cc9b84a83b34
child 2520 e3523df95b6b
permissions -rw-r--r--
glibc: Refactor startfiles/headers into do_libc_backend()

Refactor the contents of 'do_libc_start_files()' and 'do_libc()' into a
parameterized 'do_libc_backend()'. 'do_libc_start_files()' and 'do_libc()'
call 'do_libc_backend()' with either 'libc_mode=startfiles' or
'libc_mode=final' (respectively) so that the startfiles/headers and
the final libc builds are configured and built with the same options.

One example of where this is needed is when building a mips toolchain.
Previously, if you were building an n32 toolchain, you wouldn't have
noticed an issue, because if '-mabi' is not in CFLAGS, n32 is the
default:

http://sourceware.org/git/?p=glibc-ports.git;a=blob;f=sysdeps/mips/preconfigure;hb=HEAD

But when trying to build an o32 or n64 toolchain the build would
have failed. This is because (e)glibc expects "-mabi={o32,n32,n64}" to be
in CFLAGS, but was not previously provided in 'do_libc_start_files()'.
The build failure would happen in the shared-core gcc when it tries to
configure an n64 or o32 gcc with an n32 libc.

A simpler solution would have been to just add TARGET_CFLAGS to configure
in 'do_libc_start_files()', but this way makes configure and make
consistent for both steps.

Signed-off-by: Bryan Hundven <bryanhundven@gmail.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 glibc
    13 # eglibc is only available through subversion, there are no
    14 # snapshots available.
    15 do_libc_get() {
    16     local addon
    17     local svn_base="svn://svn.eglibc.org"
    18 
    19     case "${CT_LIBC_VERSION}" in
    20         trunk)  svn_base+="/trunk";;
    21         *)      svn_base+="/branches/eglibc-${CT_LIBC_VERSION}";;
    22     esac
    23 
    24     CT_GetSVN "eglibc-${CT_LIBC_VERSION}"   \
    25               "${svn_base}/libc"            \
    26               "${CT_EGLIBC_REVISION:-HEAD}"
    27 
    28     for addon in $(do_libc_add_ons_list " "); do
    29         # Never ever try to download these add-ons,
    30         # they've always been internal
    31         case "${addon}" in
    32             nptl)   continue;;
    33         esac
    34 
    35         if ! CT_GetSVN "eglibc-${addon}-${CT_LIBC_VERSION}" \
    36                        "${svn_base}/${addon}"               \
    37                        "${CT_EGLIBC_REVISION:-HEAD}"
    38         then
    39             # Some add-ons are bundled with the main sources
    40             # so failure to download them is expected
    41             CT_DoLog DEBUG "Addon '${addon}' could not be downloaded."
    42             CT_DoLog DEBUG "We'll see later if we can find it in the source tree"
    43         fi
    44     done
    45 }
    46 
    47 # Copy user provided eglibc configuration file if provided
    48 do_libc_check_config() {
    49     if [ "${CT_EGLIBC_CUSTOM_CONFIG}" != "y" ]; then
    50         return 0
    51     fi
    52 
    53     CT_DoStep INFO "Checking C library configuration"
    54 
    55     CT_TestOrAbort "You did not provide an eglibc config file!" \
    56         -n "${CT_EGLIBC_OPTION_GROUPS_FILE}" -a \
    57         -f "${CT_EGLIBC_OPTION_GROUPS_FILE}"
    58 
    59     CT_DoExecLog ALL cp "${CT_EGLIBC_OPTION_GROUPS_FILE}" "${CT_CONFIG_DIR}/eglibc.config"
    60 
    61     # NSS configuration
    62     if grep -E '^OPTION_EGLIBC_NSSWITCH[[:space:]]*=[[:space:]]*n' "${CT_EGLIBC_OPTION_GROUPS_FILE}" >/dev/null 2>&1; then
    63         CT_DoLog DEBUG "Using fixed-configuration nsswitch facility"
    64 
    65         if [ "${CT_EGLIBC_BUNDLED_NSS_CONFIG}" = "y" ]; then
    66             nss_config="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.conf"
    67         else
    68             nss_config="${CT_EGLIBC_NSS_CONFIG_FILE}"
    69         fi
    70         CT_TestOrAbort "NSS config file not found!" -n "${nss_config}" -a -f "${nss_config}"
    71 
    72         CT_DoExecLog ALL cp "${nss_config}" "${CT_CONFIG_DIR}/nsswitch.config"
    73         echo "OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG = ${CT_CONFIG_DIR}/nsswitch.config" \
    74             >> "${CT_CONFIG_DIR}/eglibc.config"
    75 
    76         if [ "${CT_EGLIBC_BUNDLED_NSS_FUNCTIONS}" = "y" ]; then
    77             nss_functions="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.functions"
    78         else
    79             nss_functions="${CT_EGLIBC_NSS_FUNCTIONS_FILE}"
    80         fi
    81         CT_TestOrAbort "NSS functions file not found!" -n "${nss_functions}" -a -f "${nss_functions}"
    82 
    83         CT_DoExecLog ALL cp "${nss_functions}" "${CT_CONFIG_DIR}/nsswitch.functions"
    84         echo "OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS = ${CT_CONFIG_DIR}/nsswitch.functions" \
    85             >> "${CT_CONFIG_DIR}/eglibc.config"
    86     else
    87         CT_DoLog DEBUG "Using full-blown nsswitch facility"
    88     fi
    89 
    90     CT_EndStep
    91 }