1 # eglibc build functions (initially by Thomas JOURDAN).
3 # Add the definitions common to glibc and eglibc
9 . "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common"
11 # Download eglibc repository
15 case "${CT_LIBC_VERSION}" in
16 trunk) svn_url="svn://svn.eglibc.org/trunk";;
17 *) svn_url="svn://svn.eglibc.org/branches/eglibc-${CT_LIBC_VERSION}";;
20 case "${CT_EGLIBC_CHECKOUT}" in
21 y) svn_action="checkout";;
22 *) svn_action="export --force";;
25 CT_DoExecLog ALL svn ${svn_action} -r "${CT_EGLIBC_REVISION:-HEAD}" "${svn_url}" "$(pwd)"
28 CT_DoExecLog ALL mv libc "eglibc-${CT_LIBC_VERSION}"
29 CT_DoExecLog ALL tar cjf "eglibc-${CT_LIBC_VERSION}.tar.bz2" "eglibc-${CT_LIBC_VERSION}"
31 # Compress linuxthreads, localedef and ports
32 # Assign them the name the way ct-ng like it
33 for addon in linuxthreads localedef ports; do
34 CT_DoExecLog ALL mv "${addon}" "eglibc-${addon}-${CT_LIBC_VERSION}"
35 CT_DoExecLog ALL tar cjf "eglibc-${addon}-${CT_LIBC_VERSION}.tar.bz2" "eglibc-${addon}-${CT_LIBC_VERSION}"
41 # eglibc is only available through subversion, there are no
42 # snapshots available. Moreover, addons will be downloaded
46 eglibc="eglibc-${CT_LIBC_VERSION}.tar.bz2"
47 eglibc_linuxthreads="${CT_LIBC}-linuxthreads-${CT_LIBC_VERSION}.tar.bz2"
48 eglibc_localedef="${CT_LIBC}-localedef-${CT_LIBC_VERSION}.tar.bz2"
49 eglibc_ports="${CT_LIBC}-ports-${CT_LIBC_VERSION}.tar.bz2"
51 # Check if every tarballs are already present
52 if [ -f "${CT_TARBALLS_DIR}/${eglibc}" \
53 -a -f "${CT_TARBALLS_DIR}/${eglibc_linuxthreads}" \
54 -a -f "${CT_TARBALLS_DIR}/${eglibc_localedef}" \
55 -a -f "${CT_TARBALLS_DIR}/${eglibc_ports}" \
57 CT_DoLog DEBUG "Already have 'eglibc-${CT_LIBC_VERSION}'"
61 if [ -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc}" \
62 -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_linuxthreads}" \
63 -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_localedef}" \
64 -a -f "${CT_LOCAL_TARBALLS_DIR}/${eglibc_ports}" \
65 -a "${CT_FORCE_DOWNLOAD}" != "y" \
67 CT_DoLog DEBUG "Got 'eglibc-${CT_LIBC_VERSION}' from local storage"
68 for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
69 CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
74 # Not found locally, try from the network
75 CT_DoLog EXTRA "Retrieving 'eglibc-${CT_LIBC_VERSION}'"
81 CT_DoLog DEBUG "Moving 'eglibc-${CT_LIBC_VERSION}' to tarball directory"
82 for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
83 CT_DoExecLog ALL mv -f "${file}" "${CT_TARBALLS_DIR}"
89 CT_DoExecLog ALL rm -rf "${tmp_dir}"
91 if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
92 CT_DoLog EXTRA "Saving 'eglibc-${CT_LIBC_VERSION}' to local storage"
93 for file in ${eglibc} ${eglibc_linuxthreads} ${eglibc_localedef} ${eglibc_ports}; do
94 CT_DoExecLog ALL mv -f "${CT_TARBALLS_DIR}/${file}" "${CT_LOCAL_TARBALLS_DIR}"
95 CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}" "${CT_TARBALLS_DIR}/${file}"
104 CT_Extract "eglibc-${CT_LIBC_VERSION}"
105 CT_Patch "eglibc" "${CT_LIBC_VERSION}"
108 for addon in $(do_libc_add_ons_list " "); do
109 # NPTL addon is not to be extracted, in any case
110 [ "${addon}" = "nptl" ] && continue || true
111 CT_Pushd "${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}"
112 CT_Extract nochdir "eglibc-${addon}-${CT_LIBC_VERSION}"
113 # Some addons have the 'long' name, while others have the
114 # 'short' name, but patches are non-uniformly built with
115 # either the 'long' or 'short' name, whatever the addons name
116 # so we have to make symlinks from the existing to the missing
117 # Fortunately for us, [ -d foo ], when foo is a symlink to a
118 # directory, returns true!
119 [ -d "${addon}" ] || ln -s "eglibc-${addon}-${CT_LIBC_VERSION}" "${addon}"
120 [ -d "eglibc-${addon}-${CT_LIBC_VERSION}" ] || ln -s "${addon}" "eglibc-${addon}-${CT_LIBC_VERSION}"
121 CT_Patch nochdir "eglibc" "${addon}-${CT_LIBC_VERSION}"
125 # The configure files may be older than the configure.in files
126 # if using a snapshot (or even some tarballs). Fake them being
128 find "${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}" -type f -name configure -exec touch {} \; 2>&1 |CT_DoLog ALL
133 # Copy user provided eglibc configuration file if provided
134 do_libc_check_config() {
135 if [ "${CT_EGLIBC_CUSTOM_CONFIG}" != "y" ]; then
139 CT_DoStep INFO "Checking C library configuration"
141 CT_TestOrAbort "You did not provide an eglibc config file!" \
142 -n "${CT_EGLIBC_OPTION_GROUPS_FILE}" -a \
143 -f "${CT_EGLIBC_OPTION_GROUPS_FILE}"
145 CT_DoExecLog ALL cp "${CT_EGLIBC_OPTION_GROUPS_FILE}" "${CT_CONFIG_DIR}/eglibc.config"
148 if grep -E '^OPTION_EGLIBC_NSSWITCH[[:space:]]*=[[:space:]]*n' "${CT_EGLIBC_OPTION_GROUPS_FILE}" >/dev/null 2>&1; then
149 CT_DoLog DEBUG "Using fixed-configuration nsswitch facility"
151 if [ "${CT_EGLIBC_BUNDLED_NSS_CONFIG}" = "y" ]; then
152 nss_config="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.conf"
154 nss_config="${CT_EGLIBC_NSS_CONFIG_FILE}"
156 CT_TestOrAbort "NSS config file not found!" -n "${nss_config}" -a -f "${nss_config}"
158 CT_DoExecLog ALL cp "${nss_config}" "${CT_CONFIG_DIR}/nsswitch.config"
159 echo "OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG = ${CT_CONFIG_DIR}/nsswitch.config" \
160 >> "${CT_CONFIG_DIR}/eglibc.config"
162 if [ "${CT_EGLIBC_BUNDLED_NSS_FUNCTIONS}" = "y" ]; then
163 nss_functions="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.functions"
165 nss_functions="${CT_EGLIBC_NSS_FUNCTIONS_FILE}"
167 CT_TestOrAbort "NSS functions file not found!" -n "${nss_functions}" -a -f "${nss_functions}"
169 CT_DoExecLog ALL cp "${nss_functions}" "${CT_CONFIG_DIR}/nsswitch.functions"
170 echo "OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS = ${CT_CONFIG_DIR}/nsswitch.functions" \
171 >> "${CT_CONFIG_DIR}/eglibc.config"
173 CT_DoLog DEBUG "Using full-blown nsswitch facility"