1 # This file contains the functions common to glibc and eglibc
3 # Build and install headers file
9 # Build and install headers and start files
10 do_libc_start_files() {
11 CT_DoStep INFO "Installing C library headers / start files"
13 mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
14 cd "${CT_BUILD_DIR}/build-libc-startfiles"
16 CT_DoLog EXTRA "Configuring C library"
18 if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then
19 CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config
22 cross_cc=$(CT_Which "${CT_TARGET}-gcc")
23 cross_cxx=$(CT_Which "${CT_TARGET}-g++")
24 cross_ar=$(CT_Which "${CT_TARGET}-ar")
25 cross_ranlib=$(CT_Which "${CT_TARGET}-ranlib")
27 CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
28 CT_DoLog DEBUG "Using g++ for target: '${cross_cxx}'"
29 CT_DoLog DEBUG "Using ar for target: '${cross_ar}'"
30 CT_DoLog DEBUG "Using ranlib for target: '${cross_ranlib}'"
32 BUILD_CC="${CT_BUILD}-gcc" \
36 RANLIB=${cross_ranlib} \
38 "${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/configure" \
40 --with-headers="${CT_HEADERS_DIR}" \
41 --build="${CT_BUILD}" \
42 --host="${CT_TARGET}" \
48 CT_DoLog EXTRA "Installing C library headers"
50 # use the 'install-headers' makefile target to install the
54 make install-headers \
55 install_root=${CT_SYSROOT_DIR} \
56 install-bootstrap-headers=yes
58 CT_DoLog EXTRA "Installing C library start files"
60 # there are a few object files needed to link shared libraries,
61 # which we build and install by hand
63 CT_DoExecLog ALL mkdir -p ${CT_SYSROOT_DIR}/usr/lib
64 CT_DoExecLog ALL make csu/subdir_lib
65 CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \
66 ${CT_SYSROOT_DIR}/usr/lib
68 # Finally, 'libgcc_s.so' requires a 'libc.so' to link against.
69 # However, since we will never actually execute its code,
70 # it doesn't matter what it contains. So, treating '/dev/null'
71 # as a C source file, we produce a dummy 'libc.so' in one step
73 CT_DoExecLog ALL ${cross_cc} -nostdlib -nostartfiles -shared -x c /dev/null -o ${CT_SYSROOT_DIR}/usr/lib/libc.so
78 # This function builds and install the full C library
82 CT_DoStep INFO "Installing C library"
84 mkdir -p "${CT_BUILD_DIR}/build-libc"
85 cd "${CT_BUILD_DIR}/build-libc"
87 CT_DoLog EXTRA "Configuring C library"
89 if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then
90 CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config
93 if [ "${CT_EGLIBC_OPT_SIZE}" = "y" ]; then
99 # Add some default glibc config options if not given by user.
100 # We don't need to be conditional on wether the user did set different
101 # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG is passed after extra_config
103 extra_config+=("--enable-kernel=$(echo ${CT_LIBC_GLIBC_MIN_KERNEL} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;')")
105 case "${CT_THREADS}" in
106 nptl) extra_config+=("--with-__thread" "--with-tls");;
107 linuxthreads) extra_config+=("--with-__thread" "--without-tls" "--without-nptl");;
108 none) extra_config+=("--without-__thread" "--without-nptl")
109 case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
111 *) extra_config+=("--without-tls");;
116 case "${CT_SHARED_LIBS}" in
117 y) extra_config+=("--enable-shared");;
118 *) extra_config+=("--disable-shared");;
121 case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
122 y,) extra_config+=("--with-fp");;
123 ,y) extra_config+=("--without-fp");;
126 if [ "${CT_LIBC_DISABLE_VERSIONING}" = "y" ]; then
127 extra_config+=("--disable-versioning")
130 if [ "${CT_LIBC_OLDEST_ABI}" != "" ]; then
131 extra_config+=("--enable-oldest-abi=${CT_LIBC_OLDEST_ABI}")
134 case "$(do_libc_add_ons_list ,)" in
136 *) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");;
139 extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}"
141 cross_cc=$(CT_Which "${CT_TARGET}-gcc")
143 CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
144 CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'"
145 CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'"
146 CT_DoLog DEBUG "Extra CC args passed : '${extra_cc_args}'"
148 # ./configure is mislead by our tools override wrapper for bash
149 # so just tell it where the real bash is _on_the_target_!
151 # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL
152 # - ${BASH_SHELL} is only used to set BASH
153 # - ${BASH} is only used to set the shebang
154 # in two scripts to run on the target
155 # So we can safely bypass bash detection at compile time.
156 # Should this change in a future eglibc release, we'd better
157 # directly mangle the generated scripts _after_ they get built,
158 # or even after they get installed... eglibc is such a sucker...
159 echo "ac_cv_path_BASH_SHELL=/bin/bash" >config.cache
161 BUILD_CC="${CT_BUILD}-gcc" \
162 CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} ${OPTIMIZE}" \
163 CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
165 RANLIB=${CT_TARGET}-ranlib \
167 "${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/configure" \
169 --with-headers="${CT_HEADERS_DIR}" \
170 --build=${CT_BUILD} \
171 --host=${CT_TARGET} \
175 --cache-file=config.cache \
176 "${extra_config[@]}" \
177 ${CT_LIBC_GLIBC_EXTRA_CONFIG}
179 CT_DoLog EXTRA "Building C library"
182 # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html
183 case "${CT_ARCH},${CT_ARCH_CPU}" in
185 CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)"
186 EGLIBC_BUILD_ASFLAGS="-DBROKEN_PPC_8xx_CPU15";;
189 CT_DoExecLog ALL make ASFLAGS="${EGLIBC_BUILD_ASFLAGS}"
191 CT_DoLog EXTRA "Installing C library"
193 CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
198 # This function finishes the C library install
204 # Build up the addons list, separated with $1
205 do_libc_add_ons_list() {
207 local addons_list=$(echo "${CT_LIBC_ADDONS_LIST//,/${sep}}" |tr -s ,)
208 case "${CT_THREADS}" in
210 *) addons_list="${addons_list}${sep}${CT_THREADS}";;
212 [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list}${sep}ports"
213 addons_list="${addons_list%%${sep}}"
214 echo "${addons_list##${sep}}"