scripts/build/libc/eglibc.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Feb 13 21:47:25 2012 +0100 (2012-02-13)
changeset 2883 cea814c9932a
parent 2776 5f557056c530
child 3041 b9f695c2f5b7
permissions -rw-r--r--
libc/glibc: do not consume parameters when parsing them

Currently, there are two constructs used to parse arguments in
glibc backends, one that consumes args as they are parsed, and
one that does not.

Always use the construct that does not eat args as they are parsed.

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_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 -a extra_addons
    18     local svn_base
    19 
    20     if [ "${CT_EGLIBC_HTTP}" = "y" ]; then
    21         svn_base="http://www.eglibc.org/svn"
    22     else
    23         svn_base="svn://svn.eglibc.org"
    24     fi
    25 
    26     case "${CT_LIBC_VERSION}" in
    27         trunk)  svn_base+="/trunk";;
    28         *)      svn_base+="/branches/eglibc-${CT_LIBC_VERSION}";;
    29     esac
    30 
    31     CT_GetSVN "eglibc-${CT_LIBC_VERSION}"   \
    32               "${svn_base}/libc"            \
    33               "${CT_EGLIBC_REVISION:-HEAD}"
    34 
    35     if [ "${CT_LIBC_LOCALES}" = "y" ]; then
    36         extra_addons+=("localedef")
    37     fi
    38 
    39     for addon in $(do_libc_add_ons_list " ") "${extra_addons[@]}"; do
    40         # Never ever try to download these add-ons,
    41         # they've always been internal
    42         case "${addon}" in
    43             nptl)   continue;;
    44         esac
    45 
    46         if ! CT_GetSVN "eglibc-${addon}-${CT_LIBC_VERSION}" \
    47                        "${svn_base}/${addon}"               \
    48                        "${CT_EGLIBC_REVISION:-HEAD}"
    49         then
    50             # Some add-ons are bundled with the main sources
    51             # so failure to download them is expected
    52             CT_DoLog DEBUG "Addon '${addon}' could not be downloaded."
    53             CT_DoLog DEBUG "We'll see later if we can find it in the source tree"
    54         fi
    55     done
    56 }
    57 
    58 # Copy user provided eglibc configuration file if provided
    59 do_libc_check_config() {
    60     if [ "${CT_EGLIBC_CUSTOM_CONFIG}" != "y" ]; then
    61         return 0
    62     fi
    63 
    64     CT_DoStep INFO "Checking C library configuration"
    65 
    66     CT_TestOrAbort "You did not provide an eglibc config file!" \
    67         -n "${CT_EGLIBC_OPTION_GROUPS_FILE}" -a \
    68         -f "${CT_EGLIBC_OPTION_GROUPS_FILE}"
    69 
    70     CT_DoExecLog ALL cp "${CT_EGLIBC_OPTION_GROUPS_FILE}" "${CT_CONFIG_DIR}/eglibc.config"
    71 
    72     # NSS configuration
    73     if grep -E '^OPTION_EGLIBC_NSSWITCH[[:space:]]*=[[:space:]]*n' "${CT_EGLIBC_OPTION_GROUPS_FILE}" >/dev/null 2>&1; then
    74         CT_DoLog DEBUG "Using fixed-configuration nsswitch facility"
    75 
    76         if [ "${CT_EGLIBC_BUNDLED_NSS_CONFIG}" = "y" ]; then
    77             nss_config="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.conf"
    78         else
    79             nss_config="${CT_EGLIBC_NSS_CONFIG_FILE}"
    80         fi
    81         CT_TestOrAbort "NSS config file not found!" -n "${nss_config}" -a -f "${nss_config}"
    82 
    83         CT_DoExecLog ALL cp "${nss_config}" "${CT_CONFIG_DIR}/nsswitch.config"
    84         echo "OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG = ${CT_CONFIG_DIR}/nsswitch.config" \
    85             >> "${CT_CONFIG_DIR}/eglibc.config"
    86 
    87         if [ "${CT_EGLIBC_BUNDLED_NSS_FUNCTIONS}" = "y" ]; then
    88             nss_functions="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.functions"
    89         else
    90             nss_functions="${CT_EGLIBC_NSS_FUNCTIONS_FILE}"
    91         fi
    92         CT_TestOrAbort "NSS functions file not found!" -n "${nss_functions}" -a -f "${nss_functions}"
    93 
    94         CT_DoExecLog ALL cp "${nss_functions}" "${CT_CONFIG_DIR}/nsswitch.functions"
    95         echo "OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS = ${CT_CONFIG_DIR}/nsswitch.functions" \
    96             >> "${CT_CONFIG_DIR}/eglibc.config"
    97     else
    98         CT_DoLog DEBUG "Using full-blown nsswitch facility"
    99     fi
   100 
   101     CT_EndStep
   102 }
   103 
   104 # Extract the files required for the libc locales
   105 do_libc_locales_extract() {
   106     CT_Extract "eglibc-localedef-${CT_LIBC_VERSION}"
   107     CT_Patch "eglibc" "localedef-${CT_LIBC_VERSION}"
   108 }
   109 
   110 # Build and install the libc locales
   111 do_libc_locales() {
   112     local libc_src_dir="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}"
   113     local src_dir="${CT_SRC_DIR}/eglibc-localedef-${CT_LIBC_VERSION}"
   114     local -a extra_config
   115     local -a localedef_opts
   116 
   117     mkdir -p "${CT_BUILD_DIR}/build-localedef"
   118     cd "${CT_BUILD_DIR}/build-localedef"
   119 
   120     CT_DoLog EXTRA "Configuring C library localedef"
   121 
   122     if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
   123         extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
   124         [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
   125     fi
   126 
   127     CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
   128 
   129     # ./configure is misled by our tools override wrapper for bash
   130     # so just tell it where the real bash is _on_the_target_!
   131     # Notes:
   132     # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
   133     # - ${BASH_SHELL}            is only used to set BASH
   134     # - ${BASH}                  is only used to set the shebang
   135     #                            in two scripts to run on the target
   136     # So we can safely bypass bash detection at compile time.
   137     # Should this change in a future eglibc release, we'd better
   138     # directly mangle the generated scripts _after_ they get built,
   139     # or even after they get installed... eglibc is such a sucker...
   140     echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache
   141 
   142     # Configure with --prefix the way we want it on the target...
   143 
   144     CT_DoExecLog CFG                                                \
   145     CPPFLAGS="-DNOT_IN_libc"                                        \
   146     "${src_dir}/configure"                                          \
   147         --prefix=/usr                                               \
   148         --cache-file="$(pwd)/config.cache"                          \
   149         --with-glibc="${libc_src_dir}"                              \
   150         "${extra_config[@]}"
   151 
   152     CT_DoLog EXTRA "Building C library localedef"
   153     CT_DoExecLog ALL make ${JOBSFLAGS}
   154 
   155     # Set the localedef endianness option
   156     case "${CT_ARCH_ENDIAN}" in
   157         big)    localedef_opts+=(--big-endian);;
   158         little) localedef_opts+=(--little-endian);;
   159     esac
   160 
   161     # Set the localedef option for the target's uint32_t alignment in bytes.
   162     # This is target-specific, but for now, 32-bit alignment should work for all
   163     # supported targets, even 64-bit ones.
   164     localedef_opts+=(--uint32-align=4)
   165 
   166     CT_DoLog EXTRA "Installing C library locales"
   167     CT_DoExecLog ALL make ${JOBSFLAGS}                              \
   168                           "LOCALEDEF_OPTS=${localedef_opts[*]}"     \
   169                           install_root="${CT_SYSROOT_DIR}"          \
   170                           install-locales
   171 }