1.1 --- a/scripts/build/libc_glibc.sh Tue May 08 17:48:32 2007 +0000
1.2 +++ b/scripts/build/libc_glibc.sh Fri Jun 01 20:06:22 2007 +0000
1.3 @@ -11,10 +11,13 @@
1.4
1.5 # C library addons
1.6 addons_list=`echo "${CT_LIBC_ADDONS_LIST}" |sed -r -e 's/,/ /g; s/ $//g;'`
1.7 + case "${CT_THREADS}" in
1.8 + linuxthreads) addons_list="${addons_list} linuxthreads";;
1.9 + esac
1.10 + [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list} ports"
1.11 for addon in ${addons_list}; do
1.12 CT_GetFile "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" ftp://ftp.gnu.org/gnu/glibc
1.13 done
1.14 - [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_GetFile "${CT_LIBC}-ports-${CT_LIBC_VERSION}" ftp://ftp.gnu.org/gnu/glibc
1.15
1.16 return 0
1.17 }
1.18 @@ -25,10 +28,13 @@
1.19
1.20 # C library addons
1.21 addons_list=`echo "${CT_LIBC_ADDONS_LIST}" |sed -r -e 's/,/ /g; s/ $//g;'`
1.22 + case "${CT_THREADS}" in
1.23 + linuxthreads) addons_list="${addons_list} linuxthreads";;
1.24 + esac
1.25 + [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list} ports"
1.26 for addon in ${addons_list}; do
1.27 CT_ExtractAndPatch "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
1.28 done
1.29 - [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_ExtractAndPatch "${CT_LIBC}-ports-${CT_LIBC_VERSION}"
1.30
1.31 return 0
1.32 }
1.33 @@ -68,21 +74,27 @@
1.34 # 'a version of binutils that supports .machine "altivec" is needed'.
1.35
1.36 # We also need to use the ports addon if specified
1.37 - addons=
1.38 - [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons="${CT_LIBC}-ports-${CT_LIBC_VERSION}"
1.39 + addons_list=
1.40 + case "${CT_LIBC_ADDONS},${CT_LIBC_GLIBC_USE_PORTS}" in
1.41 + y,y) addons_list="${CT_LIBC_ADDONS_LIST},ports";;
1.42 + y,) addons_list="${CT_LIBC_ADDONS_LIST}";;
1.43 + ,y) addons_list="ports";;
1.44 + *) addons_list="";;
1.45 + esac
1.46 + addons_config="--enable-add-ons=`echo ${addons_list} |sed -r -e 's/,+/,/g; s/^,+//; s/,+$//;'`"
1.47
1.48 libc_cv_ppc_machine=yes \
1.49 CC=${CT_CC_NATIVE} \
1.50 "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure" \
1.51 - --build="${CT_BUILD}" \
1.52 + --build="${CT_UNIQ_BUILD}" \
1.53 --host="${CT_TARGET}" \
1.54 --prefix=/usr \
1.55 --with-headers="${CT_HEADERS_DIR}" \
1.56 --without-cvs \
1.57 --disable-sanity-checks \
1.58 --enable-hacker-mode \
1.59 - --enable-add-ons="${addons}" \
1.60 - --without-nptl 2>&1 |CT_DoLog ALL
1.61 + --without-nptl \
1.62 + ${addons_config} 2>&1 |CT_DoLog ALL
1.63
1.64 CT_DoLog EXTRA "Installing C library headers"
1.65
1.66 @@ -133,6 +145,131 @@
1.67 # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html
1.68 [ "${CT_ARCH}" != "arm" ] && cp misc/syscall-list.h "${CT_HEADERS_DIR}/bits/syscall.h" || true
1.69
1.70 + # Those headers are to be manually copied so gcc can build properly
1.71 + pthread_h=
1.72 + pthreadtypes_h=
1.73 + case "${CT_THREADS}" in
1.74 + nptl)
1.75 + # NOTE: for some archs, the pathes are different, but they are not
1.76 + # supported by ct-ng right now. See original crosstool when they are.
1.77 + pthread_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/${CT_THREADS}/sysdeps/pthread/pthread.h"
1.78 + pthreadtypes_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/nptl/sysdeps/unix/sysv/linux/${CT_KERNEL_ARCH}/bits/pthreadtypes.h"
1.79 + ;;
1.80 + linuxthreads)
1.81 + pthread_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/${CT_THREADS}/sysdeps/pthread/pthread.h"
1.82 + pthreadtypes_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h"
1.83 + ;;
1.84 + esac
1.85 + if [ -n "${pthread_h}" ]; then
1.86 + cp -v "${pthread_h}" "${CT_HEADERS_DIR}/pthread.h" 2>&1 |CT_DoLog ALL
1.87 + fi
1.88 + if [ -n "${pthreadtypes_h}" ]; then
1.89 + cp -v "${pthreadtypes_h}" "${CT_HEADERS_DIR}/bits/pthreadtypes.h" 2>&1 |CT_DoLog ALL
1.90 + fi
1.91 +
1.92 + CT_EndStep
1.93 +}
1.94 +
1.95 +# Build and install start files
1.96 +do_libc_start_files() {
1.97 + # Needed only in the NPTL case. Otherwise, return.
1.98 + [ "${CT_THREADS}" = "nptl" ] || return 0
1.99 +
1.100 + CT_DoStep INFO "Installing C library start files"
1.101 +
1.102 + mkdir -p "${CT_BUILD_DIR}/build-libc-startfiles"
1.103 + cd "${CT_BUILD_DIR}/build-libc-startfiles"
1.104 +
1.105 + CT_DoLog EXTRA "Configuring C library"
1.106 +
1.107 + # Add some default glibc config options if not given by user.
1.108 + extra_config=""
1.109 + case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.110 + *enable-kernel*) ;;
1.111 + *) extra_config="${extra_config} --enable-kernel=`echo ${CT_KERNEL_VERSION} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;'`"
1.112 + esac
1.113 + case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.114 + *-tls*) ;;
1.115 + *) extra_config="${extra_config} --with-tls"
1.116 + esac
1.117 + case "${CT_SHARED_LIBS}" in
1.118 + y) extra_config="${extra_config} --enable-shared";;
1.119 + *) extra_config="${extra_config} --disable-shared";;
1.120 + esac
1.121 + case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.122 + *--with-fp*) ;;
1.123 + *--without-fp*) ;;
1.124 + *) case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
1.125 + y,) extra_config="${extra_config} --with-fp";;
1.126 + ,y) extra_config="${extra_config} --without-fp";;
1.127 + esac;;
1.128 + esac
1.129 + # Obviously, we want threads, as we come here only for NPTL
1.130 + extra_config="${extra_config} --with-__thread"
1.131 +
1.132 + addons_list=
1.133 + case "${CT_LIBC_ADDONS},${CT_LIBC_GLIBC_USE_PORTS}" in
1.134 + y,y) addons_list="nptl,${CT_LIBC_ADDONS_LIST},ports";;
1.135 + y,) addons_list="nptl,${CT_LIBC_ADDONS_LIST}";;
1.136 + ,y) addons_list="nptl,ports";;
1.137 + *) addons_list="nptl";;
1.138 + esac
1.139 + addons_config="--enable-add-ons=`echo ${addons_list} |sed -r -e 's/,+/,/g; s/^,+//; s/,+$//;'`"
1.140 + extra_config="${extra_config} ${addons_config}"
1.141 +
1.142 + # Add some default CC args
1.143 + extra_cc_args="${CT_CFLAGS_FOR_HOST}"
1.144 + case "${CT_LIBC_EXTRA_CC_ARGS}" in
1.145 + *-mbig-endian*) ;;
1.146 + *-mlittle-endian*) ;;
1.147 + *) case "${CT_ARCH_BE},${CT_ARCH_LE}" in
1.148 + y,) extra_cc_args="${extra_cc_args} -mbig-endian";;
1.149 + ,y) extra_cc_args="${extra_cc_args} -mlittle-endian";;
1.150 + esac;;
1.151 + esac
1.152 +
1.153 + CT_DoLog DEBUG "Configuring with addons : \"${addons_list}\""
1.154 + CT_DoLog DEBUG "Extra config args passed: \"${extra_config}\""
1.155 + CT_DoLog DEBUG "Extra CC args passed: \"${extra_cc_args}\""
1.156 +
1.157 + # sh3 and sh4 really need to set configparms as of gcc-3.4/glibc-2.3.2
1.158 + # note: this is awkward, doesn't work well if you need more than one line in configparms
1.159 + echo ${CT_LIBC_GLIBC_CONFIGPARMS} > configparms
1.160 +
1.161 + echo "libc_cv_forced_unwind=yes" > config.cache
1.162 + echo "libc_cv_c_cleanup=yes" >> config.cache
1.163 +
1.164 + # Please see the comment for the configure step in do_libc().
1.165 +
1.166 + BUILD_CC=${CT_CC_NATIVE} \
1.167 + CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O" \
1.168 + CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
1.169 + AR=${CT_TARGET}-ar \
1.170 + RANLIB=${CT_TARGET}-ranlib \
1.171 + "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure" \
1.172 + --prefix=/usr \
1.173 + --build="${CT_UNIQ_BUILD}" \
1.174 + --host=${CT_TARGET} \
1.175 + --without-cvs \
1.176 + --disable-profile \
1.177 + --disable-debug \
1.178 + --without-gd \
1.179 + --with-headers="${CT_HEADERS_DIR}" \
1.180 + --cache-file=config.cache \
1.181 + ${extra_config} \
1.182 + ${CT_LIBC_GLIBC_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
1.183 +
1.184 +
1.185 + #TODO: should check whether slibdir has been set in configparms to */lib64
1.186 + # and copy the startfiles into the appropriate libdir.
1.187 + make csu/subdir_lib 2>&1 |CT_DoLog ALL
1.188 +
1.189 + if [ "${CT_USE_SYSROOT}" = "y" ]; then
1.190 + cp -fp csu/crt[1in].o "${CT_SYSROOT_DIR}/usr/lib/"
1.191 + else
1.192 + cp -fp csu/crt[1in].o "${CT_SYSROOT_DIR}/lib/"
1.193 + fi
1.194 +
1.195 CT_EndStep
1.196 }
1.197
1.198 @@ -146,51 +283,59 @@
1.199 CT_DoLog EXTRA "Configuring C library"
1.200
1.201 # Add some default glibc config options if not given by user.
1.202 - extra_config=""
1.203 - case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.204 - *enable-kernel*) ;;
1.205 - *) extra_config="${extra_config} --enable-kernel=`echo ${CT_KERNEL_VERSION} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;'`"
1.206 + # We don't need to be conditional on wether the user did set different
1.207 + # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG is passed after extra_config
1.208 +
1.209 + extra_config="--enable-kernel=`echo ${CT_KERNEL_VERSION} |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;'`"
1.210 +
1.211 + case "${CT_THREADS}" in
1.212 + nptl) extra_config="${extra_config} --with-__thread --with-tls";;
1.213 + linuxthreads) extra_config="${extra_config} --with-__thread --without-tls --without-nptl";;
1.214 + none) extra_config="${extra_config} --without-__thread --without-nptl"
1.215 + case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.216 + *-tls*) ;;
1.217 + *) extra_config="${extra_config} --without-tls";;
1.218 + esac
1.219 + ;;
1.220 esac
1.221 - case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.222 - *-tls*) ;;
1.223 - *) extra_config="${extra_config} --without-tls"
1.224 - esac
1.225 - case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.226 - *-__thread*) ;;
1.227 - *) extra_config="${extra_config} --without-__thread"
1.228 - esac
1.229 +
1.230 case "${CT_SHARED_LIBS}" in
1.231 y) extra_config="${extra_config} --enable-shared";;
1.232 *) extra_config="${extra_config} --disable-shared";;
1.233 esac
1.234 - case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
1.235 - *--with-fp*) ;;
1.236 - *--without-fp*) ;;
1.237 - *) case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
1.238 - y,) extra_config="${extra_config} --with-fp";;
1.239 - ,y) extra_config="${extra_config} --without-fp";;
1.240 - esac;;
1.241 +
1.242 + case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
1.243 + y,) extra_config="${extra_config} --with-fp";;
1.244 + ,y) extra_config="${extra_config} --without-fp";;
1.245 esac
1.246
1.247 + addons_list=
1.248 case "${CT_LIBC_ADDONS},${CT_LIBC_GLIBC_USE_PORTS}" in
1.249 - y,y) addons_config="--enable-add-ons=${CT_LIBC_ADDONS_LIST},${CT_LIBC}-ports-${CT_LIBC_VERSION}";;
1.250 - y,) addons_config="--enable-add-ons=${CT_LIBC_ADDONS_LIST}";;
1.251 - ,y) addons_config="--enable-add-ons=${CT_LIBC}-ports-${CT_LIBC_VERSION}";;
1.252 - *) addons_config="";;
1.253 + y,y) addons_list="${CT_LIBC_ADDONS_LIST},ports";;
1.254 + y,) addons_list="${CT_LIBC_ADDONS_LIST}";;
1.255 + ,y) addons_list="ports";;
1.256 + *) addons_list="";;
1.257 + esac
1.258 + case "${CT_THREADS}" in
1.259 + none) ;;
1.260 + *) addons_list="${addons_list},${CT_THREADS}";;
1.261 + esac
1.262 + case "${addons_list}" in
1.263 + "") ;;
1.264 + *) addons_config="--enable-add-ons=`echo ${addons_list} |sed -r -e 's/,+/,/g; s/^,+//g; s/,+$//;'`";;
1.265 + esac
1.266 + extra_config="${extra_config} ${addons_config}"
1.267 +
1.268 + # Add some default CC args
1.269 + if [ "${CT_USE_PIPES}" = "y" ]; then
1.270 + extra_cc_args="-pipe"
1.271 + fi
1.272 + case "${CT_ARCH_BE},${CT_ARCH_LE}" in
1.273 + y,) extra_cc_args="${extra_cc_args} -mbig-endian";;
1.274 + ,y) extra_cc_args="${extra_cc_args} -mlittle-endian";;
1.275 esac
1.276
1.277 - # Add some default CC args
1.278 - extra_cc_args="${CT_CFLAGS_FOR_HOST}"
1.279 - case "${CT_LIBC_EXTRA_CC_ARGS}" in
1.280 - *-mbig-endian*) ;;
1.281 - *-mlittle-endian*) ;;
1.282 - *) case "${CT_ARCH_BE},${CT_ARCH_LE}" in
1.283 - y,) extra_cc_args="${extra_cc_args} -mbig-endian";;
1.284 - ,y) extra_cc_args="${extra_cc_args} -mlittle-endian";;
1.285 - esac;;
1.286 - esac
1.287 -
1.288 - CT_DoLog DEBUG "Configuring with addons : \"${addons_config}\""
1.289 + CT_DoLog DEBUG "Configuring with addons : \"${addons_list}\""
1.290 CT_DoLog DEBUG "Extra config args passed: \"${extra_config}\""
1.291 CT_DoLog DEBUG "Extra CC args passed: \"${extra_cc_args}\""
1.292
1.293 @@ -201,11 +346,10 @@
1.294 # For glibc 2.3.4 and later we need to set some autoconf cache
1.295 # variables, because nptl/sysdeps/pthread/configure.in does not
1.296 # work when cross-compiling.
1.297 - if test -d ${GLIBC_DIR}/nptl; then
1.298 - libc_cv_forced_unwind=yes
1.299 - libc_cv_c_cleanup=yes
1.300 - export libc_cv_forced_unwind libc_cv_c_cleanup
1.301 - fi
1.302 + if [ "${CT_THREADS}" = "nptl" ]; then
1.303 + echo libc_cv_forced_unwind=yes
1.304 + echo libc_cv_c_cleanup=yes
1.305 + fi >config.cache
1.306
1.307 # Configure with --prefix the way we want it on the target...
1.308 # There are a whole lot of settings here. You'll probably want
1.309 @@ -216,19 +360,26 @@
1.310 # Set BUILD_CC, or you won't be able to build datafiles
1.311 # Set --build, else glibc-2.3.2 will think you're not cross-compiling, and try to run the test programs
1.312
1.313 + # OK. I'm fed up with those folks telling me what I should do.
1.314 + # I don't configure nptl? Well, maybe that's purposedly because
1.315 + # I don't want nptl! --disable-sanity-checks will shut up those
1.316 + # silly messages. GNU folks again, he?
1.317 +
1.318 BUILD_CC=${CT_CC_NATIVE} \
1.319 CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O" \
1.320 - CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
1.321 + CC="${CT_TARGET}-gcc ${extra_cc_args} ${CT_LIBC_EXTRA_CC_ARGS}" \
1.322 AR=${CT_TARGET}-ar \
1.323 RANLIB=${CT_TARGET}-ranlib \
1.324 "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure" \
1.325 --prefix=/usr \
1.326 - --build=${CT_BUILD} --host=${CT_TARGET} \
1.327 + --build=${CT_UNIQ_BUILD} \
1.328 + --host=${CT_TARGET} \
1.329 --without-cvs \
1.330 - --without-nptl \
1.331 --disable-profile \
1.332 --disable-debug \
1.333 --without-gd \
1.334 + --disable-sanity-checks \
1.335 + --cache-file=config.cache \
1.336 --with-headers="${CT_HEADERS_DIR}" \
1.337 ${addons_config} \
1.338 ${extra_config} \