1.1 --- a/scripts/build/libc/glibc-eglibc.sh-common Wed Jun 22 22:54:14 2011 +0200
1.2 +++ b/scripts/build/libc/glibc-eglibc.sh-common Sun Jun 26 03:26:54 2011 -0700
1.3 @@ -51,131 +51,38 @@
1.4
1.5 # Build and install headers and start files
1.6 do_libc_start_files() {
1.7 - local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
1.8 -
1.9 - CT_DoStep INFO "Installing C library headers & start files"
1.10 -
1.11 - mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
1.12 - cd "${CT_BUILD_DIR}/build-libc-startfiles"
1.13 -
1.14 - CT_DoLog EXTRA "Configuring C library"
1.15 -
1.16 - case "${CT_LIBC}" in
1.17 - eglibc)
1.18 - if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then
1.19 - CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config
1.20 - fi
1.21 - ;;
1.22 - esac
1.23 -
1.24 - cross_cc=$(CT_Which "${CT_TARGET}-gcc")
1.25 - cross_cxx=$(CT_Which "${CT_TARGET}-g++")
1.26 - cross_ar=$(CT_Which "${CT_TARGET}-ar")
1.27 - cross_ranlib=$(CT_Which "${CT_TARGET}-ranlib")
1.28 -
1.29 - CT_DoLog DEBUG "Using gcc for target: '${cross_cc}'"
1.30 - CT_DoLog DEBUG "Using g++ for target: '${cross_cxx}'"
1.31 - CT_DoLog DEBUG "Using ar for target: '${cross_ar}'"
1.32 - CT_DoLog DEBUG "Using ranlib for target: '${cross_ranlib}'"
1.33 -
1.34 - touch config.cache
1.35 - if [ "${CT_LIBC_GLIBC_FORCE_UNWIND}" = "y" ]; then
1.36 - echo "libc_cv_forced_unwind=yes" >>config.cache
1.37 - echo "libc_cv_c_cleanup=yes" >>config.cache
1.38 - fi
1.39 -
1.40 - # Pre-seed the configparms file with values from the config option
1.41 - printf "${CT_LIBC_GLIBC_CONFIGPARMS}\n" > configparms
1.42 -
1.43 - CT_DoExecLog CFG \
1.44 - BUILD_CC="${CT_BUILD}-gcc" \
1.45 - CC=${cross_cc} \
1.46 - CXX=${cross_cxx} \
1.47 - AR=${cross_ar} \
1.48 - RANLIB=${cross_ranlib} \
1.49 - "${src_dir}/configure" \
1.50 - --prefix=/usr \
1.51 - --with-headers="${CT_HEADERS_DIR}" \
1.52 - --build="${CT_BUILD}" \
1.53 - --host="${CT_TARGET}" \
1.54 - --cache-file="$(pwd)/config.cache" \
1.55 - --disable-profile \
1.56 - --without-gd \
1.57 - --without-cvs \
1.58 - --enable-add-ons
1.59 -
1.60 - CT_DoLog EXTRA "Installing C library headers"
1.61 -
1.62 - # use the 'install-headers' makefile target to install the
1.63 - # headers
1.64 - CT_DoExecLog ALL make ${JOBSFLAGS} \
1.65 - install_root=${CT_SYSROOT_DIR} \
1.66 - install-bootstrap-headers=yes \
1.67 - install-headers
1.68 -
1.69 - # For glibc, a few headers need to be manually installed
1.70 - if [ "${CT_LIBC}" = "glibc" ]; then
1.71 - # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
1.72 - # so do them by hand. We can tolerate an empty stubs.h for the moment.
1.73 - # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
1.74 - mkdir -p "${CT_HEADERS_DIR}/gnu"
1.75 - CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
1.76 - CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \
1.77 - "${CT_HEADERS_DIR}/features.h"
1.78 -
1.79 - # Building the bootstrap gcc requires either setting inhibit_libc, or
1.80 - # having a copy of stdio_lim.h... see
1.81 - # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
1.82 - CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
1.83 -
1.84 - # Following error building gcc-4.0.0's gcj:
1.85 - # error: bits/syscall.h: No such file or directory
1.86 - # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
1.87 - # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
1.88 - case "${CT_ARCH}" in
1.89 - arm) ;;
1.90 - *) CT_DoExecLog ALL cp -v "misc/syscall-list.h" \
1.91 - "${CT_HEADERS_DIR}/bits/syscall.h"
1.92 - ;;
1.93 - esac
1.94 - fi
1.95 -
1.96 - if [ "${CT_THREADS}" = "nptl" ]; then
1.97 - CT_DoLog EXTRA "Installing C library start files"
1.98 -
1.99 - # there are a few object files needed to link shared libraries,
1.100 - # which we build and install by hand
1.101 - CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
1.102 - CT_DoExecLog ALL make ${JOBSFLAGS} csu/subdir_lib
1.103 - CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \
1.104 - "${CT_SYSROOT_DIR}/usr/lib"
1.105 -
1.106 - # Finally, 'libgcc_s.so' requires a 'libc.so' to link against.
1.107 - # However, since we will never actually execute its code,
1.108 - # it doesn't matter what it contains. So, treating '/dev/null'
1.109 - # as a C source file, we produce a dummy 'libc.so' in one step
1.110 - CT_DoExecLog ALL "${cross_cc}" -nostdlib \
1.111 - -nostartfiles \
1.112 - -shared \
1.113 - -x c /dev/null \
1.114 - -o "${CT_SYSROOT_DIR}/usr/lib/libc.so"
1.115 - fi # threads == nptl
1.116 -
1.117 - CT_EndStep
1.118 + # Start files and Headers should be configured the same way as the
1.119 + # final libc, but built and installed differently.
1.120 + do_libc_backend libc_mode=startfiles
1.121 }
1.122
1.123 # This function builds and install the full C library
1.124 do_libc() {
1.125 + do_libc_backend libc_mode=final
1.126 +}
1.127 +
1.128 +do_libc_backend() {
1.129 local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
1.130 + local libc_mode=final
1.131 local extra_cc_args
1.132 local -a extra_config
1.133 local -a extra_make_args
1.134 local glibc_cflags
1.135
1.136 - CT_DoStep INFO "Installing C library"
1.137 + while [ $# -ne 0 ]; do
1.138 + eval "${1}"
1.139 + shift
1.140 + done
1.141
1.142 - mkdir -p "${CT_BUILD_DIR}/build-libc"
1.143 - cd "${CT_BUILD_DIR}/build-libc"
1.144 + if [ "${libc_mode}" = "startfiles" ]; then
1.145 + CT_DoStep INFO "Installing C library headers & start files"
1.146 + mkdir -p "${CT_BUILD_DIR}/build-libc-start-files"
1.147 + cd "${CT_BUILD_DIR}/build-libc-start-files"
1.148 + else # libc_mode = final
1.149 + CT_DoStep INFO "Installing C library"
1.150 + mkdir -p "${CT_BUILD_DIR}/build-libc"
1.151 + cd "${CT_BUILD_DIR}/build-libc"
1.152 + fi
1.153
1.154 CT_DoLog EXTRA "Configuring C library"
1.155
1.156 @@ -316,16 +223,78 @@
1.157 ;;
1.158 esac
1.159
1.160 - CT_DoLog EXTRA "Building C library"
1.161 - CT_DoExecLog ALL make ${JOBSFLAGS} \
1.162 - "${extra_make_args[@]}" \
1.163 - all
1.164 + if [ "${libc_mode}" = "startfiles" ]; then
1.165 + CT_DoLog EXTRA "Installing C library headers"
1.166
1.167 - CT_DoLog EXTRA "Installing C library"
1.168 - CT_DoExecLog ALL make ${JOBSFLAGS} \
1.169 - "${extra_make_args[@]}" \
1.170 - install_root="${CT_SYSROOT_DIR}" \
1.171 - install
1.172 + # use the 'install-headers' makefile target to install the
1.173 + # headers
1.174 + CT_DoExecLog ALL make ${JOBSFLAGS} \
1.175 + install_root=${CT_SYSROOT_DIR} \
1.176 + install-bootstrap-headers=yes \
1.177 + "${extra_make_args[@]}" \
1.178 + install-headers
1.179 +
1.180 + # For glibc, a few headers need to be manually installed
1.181 + if [ "${CT_LIBC}" = "glibc" ]; then
1.182 + # Two headers -- stubs.h and features.h -- aren't installed by install-headers,
1.183 + # so do them by hand. We can tolerate an empty stubs.h for the moment.
1.184 + # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html
1.185 + mkdir -p "${CT_HEADERS_DIR}/gnu"
1.186 + CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h"
1.187 + CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \
1.188 + "${CT_HEADERS_DIR}/features.h"
1.189 +
1.190 + # Building the bootstrap gcc requires either setting inhibit_libc, or
1.191 + # having a copy of stdio_lim.h... see
1.192 + # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html
1.193 + CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h"
1.194 +
1.195 + # Following error building gcc-4.0.0's gcj:
1.196 + # error: bits/syscall.h: No such file or directory
1.197 + # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html
1.198 + # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
1.199 + case "${CT_ARCH}" in
1.200 + arm) ;;
1.201 + *) CT_DoExecLog ALL cp -v "misc/syscall-list.h" \
1.202 + "${CT_HEADERS_DIR}/bits/syscall.h"
1.203 + ;;
1.204 + esac
1.205 + fi
1.206 +
1.207 + if [ "${CT_THREADS}" = "nptl" ]; then
1.208 + CT_DoLog EXTRA "Installing C library start files"
1.209 +
1.210 + # there are a few object files needed to link shared libraries,
1.211 + # which we build and install by hand
1.212 + CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
1.213 + CT_DoExecLog ALL make ${JOBSFLAGS} \
1.214 + "${extra_make_args[@]}" \
1.215 + csu/subdir_lib
1.216 + CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \
1.217 + "${CT_SYSROOT_DIR}/usr/lib"
1.218 +
1.219 + # Finally, 'libgcc_s.so' requires a 'libc.so' to link against.
1.220 + # However, since we will never actually execute its code,
1.221 + # it doesn't matter what it contains. So, treating '/dev/null'
1.222 + # as a C source file, we produce a dummy 'libc.so' in one step
1.223 + CT_DoExecLog ALL "${cross_cc}" -nostdlib \
1.224 + -nostartfiles \
1.225 + -shared \
1.226 + -x c /dev/null \
1.227 + -o "${CT_SYSROOT_DIR}/usr/lib/libc.so"
1.228 + fi # threads == nptl
1.229 + else # libc_mode = final
1.230 + CT_DoLog EXTRA "Building C library"
1.231 + CT_DoExecLog ALL make ${JOBSFLAGS} \
1.232 + "${extra_make_args[@]}" \
1.233 + all
1.234 +
1.235 + CT_DoLog EXTRA "Installing C library"
1.236 + CT_DoExecLog ALL make ${JOBSFLAGS} \
1.237 + "${extra_make_args[@]}" \
1.238 + install_root="${CT_SYSROOT_DIR}" \
1.239 + install
1.240 + fi
1.241
1.242 CT_EndStep
1.243 }