diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/addToolVersion.sh | 17 | ||||
-rw-r--r-- | scripts/build/cc.sh | 58 | ||||
-rw-r--r-- | scripts/build/cc/100-gcc.sh (renamed from scripts/build/cc/gcc.sh) | 148 | ||||
-rw-r--r-- | scripts/build/companion_libs/130-cloog.sh | 3 | ||||
-rw-r--r-- | scripts/build/companion_libs/140-mpc.sh | 3 | ||||
-rw-r--r-- | scripts/build/debug/300-gdb.sh | 8 | ||||
-rw-r--r-- | scripts/build/internals.sh | 54 | ||||
-rw-r--r-- | scripts/build/kernel/linux.sh | 9 | ||||
-rw-r--r-- | scripts/build/libc/eglibc.sh | 189 | ||||
-rw-r--r-- | scripts/build/libc/glibc-eglibc.sh-common | 540 | ||||
-rw-r--r-- | scripts/build/libc/glibc.sh | 544 | ||||
-rw-r--r-- | scripts/build/libc/mingw.sh | 63 | ||||
-rw-r--r-- | scripts/build/test_suite/gcc.sh | 8 | ||||
-rw-r--r-- | scripts/crosstool-NG.sh.in | 12 | ||||
-rw-r--r-- | scripts/functions | 37 | ||||
-rwxr-xr-x | scripts/gen_in_frags.sh | 3 | ||||
-rw-r--r-- | scripts/populate.in | 4 | ||||
-rw-r--r-- | scripts/saveSample.sh.in | 6 | ||||
-rwxr-xr-x | scripts/showSamples.sh | 26 |
19 files changed, 832 insertions, 900 deletions
diff --git a/scripts/addToolVersion.sh b/scripts/addToolVersion.sh index 34f42eb..1ae47e8 100755 --- a/scripts/addToolVersion.sh +++ b/scripts/addToolVersion.sh @@ -16,7 +16,7 @@ doHelp() { cat <<-EOF Usage: ${myname} <--tool> <[options] version [...]> ... 'tool' in one of: - gcc, binutils, glibc, eglibc, uClibc, newlib, linux, gdb, dmalloc, + gcc, binutils, glibc, uClibc, newlib, linux, gdb, dmalloc, duma, strace, ltrace, libelf, gmp, mpfr, ppl, cloog, mpc Valid options for all tools: @@ -80,9 +80,9 @@ addToolVersion() { # to try adding a new version if the one he/she wants is not listed. # But it can be the case where the version is hidden behind either one # of EXPERIMENTAL or OBSOLETE, so warn if the version is already listed. - if grep -E "^config ${config_ver_option}$" "${file}" >/dev/null 2>&1; then + if ${grep} -E "^config ${config_ver_option}$" "${file}" >/dev/null 2>&1; then echo "'${tool}': version '${version}' already present:" - grep -A1 -B0 -n \ + ${grep} -A1 -B0 -n \ -E "^(config ${config_ver_option}| {4}prompt \"${version}\")$" \ "${file}" /dev/null return 0 @@ -131,14 +131,6 @@ addToolVersion() { SedExpr1="${SedExpr1}\n select BINUTILS_2_18_or_later" fi ;; - eglibc) - # Extract 'M'ajor and 'm'inor from version string - ver_M=$(getVersionField "${version}" _ 1) - ver_m=$(getVersionField "${version}" _ 2) - if [ \( ${ver_M} -eq 2 -a ${ver_m} -ge 16 \) ]; then - SedExpr1="${SedExpr1}\n select LIBC_EGLIBC_2_16_or_later" - fi - ;; uClibc) # uClibc-0.9.30 and above need some love ver_M=$(getVersionField "${version}" . 1) @@ -183,10 +175,9 @@ fi while [ $# -gt 0 ]; do case "$1" in # Tools: - --gcc) EXP=; OBS=; cat=CC; tool=gcc; tool_prefix=cc; dot2suffix=;; + --gcc) EXP=; OBS=; cat=CC_GCC; tool=gcc; tool_prefix=cc; dot2suffix=;; --binutils) EXP=; OBS=; cat=BINUTILS; tool=binutils; tool_prefix=binutils; dot2suffix=;; --glibc) EXP=; OBS=; cat=LIBC_GLIBC; tool=glibc; tool_prefix=libc; dot2suffix=;; - --eglibc) EXP=; OBS=; cat=LIBC_EGLIBC; tool=eglibc; tool_prefix=libc; dot2suffix=;; --uClibc) EXP=; OBS=; cat=LIBC_UCLIBC; tool=uClibc; tool_prefix=libc; dot2suffix=;; --newlib) EXP=; OBS=; cat=LIBC_NEWLIB; tool=newlib; tool_prefix=libc; dot2suffix=;; --linux) EXP=; OBS=; cat=KERNEL; tool=linux; tool_prefix=kernel; dot2suffix=;; diff --git a/scripts/build/cc.sh b/scripts/build/cc.sh new file mode 100644 index 0000000..3c8aaef --- /dev/null +++ b/scripts/build/cc.sh @@ -0,0 +1,58 @@ +# Wrapper to build the companion tools facilities + +# List all companion tools facilities, and parse their scripts +CT_CC_FACILITY_LIST= +for f in "${CT_LIB_DIR}/scripts/build/cc/"*.sh; do + _f="$(basename "${f}" .sh)" + _f="${_f#???-}" + __f="CT_CC_${_f}" + if [ "${!__f}" = "y" ]; then + CT_DoLog DEBUG "Enabling cc '${_f}'" + . "${f}" + CT_CC_FACILITY_LIST="${CT_CC_FACILITY_LIST} ${_f}" + else + CT_DoLog DEBUG "Disabling cc '${_f}'" + fi +done + +# Download the cc facilities +do_cc_get() { + for f in ${CT_CC_FACILITY_LIST}; do + do_${f}_get + done +} + +# Extract and patch the cc facilities +do_cc_extract() { + for f in ${CT_CC_FACILITY_LIST}; do + do_${f}_extract + done +} + +# Core pass 1 the cc facilities +do_cc_core_pass_1() { + for f in ${CT_CC_FACILITY_LIST}; do + do_${f}_core_pass_1 + done +} + +# Core pass 2 the cc facilities +do_cc_core_pass_2() { + for f in ${CT_CC_FACILITY_LIST}; do + do_${f}_core_pass_2 + done +} + +# Build for build the cc facilities +do_cc_for_build() { + for f in ${CT_CC_FACILITY_LIST}; do + do_${f}_for_build + done +} + +# Build for host the cc facilities +do_cc_for_host() { + for f in ${CT_CC_FACILITY_LIST}; do + do_${f}_for_host + done +} diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/100-gcc.sh index 500c9e7..f6ea34e 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/100-gcc.sh @@ -3,15 +3,15 @@ # Licensed under the GPL v2. See COPYING in the root of this package # Download gcc -do_cc_get() { +do_gcc_get() { local linaro_version="" local linaro_series="" - if [ "${CT_CC_CUSTOM}" = "y" ]; then - CT_GetCustom "gcc" "${CT_CC_VERSION}" "${CT_CC_CUSTOM_LOCATION}" + if [ "${CT_CC_GCC_CUSTOM}" = "y" ]; then + CT_GetCustom "gcc" "${CT_CC_GCC_VERSION}" "${CT_CC_GCC_CUSTOM_LOCATION}" else # Account for the Linaro versioning - linaro_version="$( echo "${CT_CC_VERSION}" \ + linaro_version="$( echo "${CT_CC_GCC_VERSION}" \ |${sed} -r -e 's/^linaro-//;' \ )" linaro_series="$( echo "${linaro_version}" \ @@ -21,13 +21,13 @@ do_cc_get() { # The official gcc hosts put gcc under a gcc/release/ directory, # whereas the mirrors put it in the gcc/ directory. # Also, Split out linaro mirrors, so that downloads happen faster. - if [ x"${linaro_version}" = x"${CT_CC_VERSION}" ]; then - CT_GetFile "gcc-${CT_CC_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/gcc/gcc-${CT_CC_VERSION} \ - ftp://{gcc.gnu.org,sourceware.org}/pub/gcc/releases/gcc-${CT_CC_VERSION} + if [ x"${linaro_version}" = x"${CT_CC_GCC_VERSION}" ]; then + CT_GetFile "gcc-${CT_CC_GCC_VERSION}" \ + {http,ftp,https}://ftp.gnu.org/gnu/gcc/gcc-${CT_CC_GCC_VERSION} \ + ftp://{gcc.gnu.org,sourceware.org}/pub/gcc/releases/gcc-${CT_CC_GCC_VERSION} else - YYMM=`echo ${CT_CC_VERSION} |cut -d- -f3 |${sed} -e 's,^..,,'` - CT_GetFile "gcc-${CT_CC_VERSION}" \ + YYMM=`echo ${CT_CC_GCC_VERSION} |cut -d- -f3 |${sed} -e 's,^..,,'` + CT_GetFile "gcc-${CT_CC_GCC_VERSION}" \ "http://launchpad.net/gcc-linaro/${linaro_series}/${linaro_version}/+download" \ https://releases.linaro.org/${YYMM}/components/toolchain/gcc-linaro/${linaro_series} \ http://cbuild.validation.linaro.org/snapshots @@ -47,21 +47,21 @@ do_cc_get() { } # Extract gcc -do_cc_extract() { +do_gcc_extract() { # If using custom directory location, nothing to do - if [ "${CT_CC_CUSTOM}" = "y" \ - -a -d "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}" ]; then + if [ "${CT_CC_GCC_CUSTOM}" = "y" \ + -a -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}" ]; then return 0 fi - CT_Extract "gcc-${CT_CC_VERSION}" - CT_Patch "gcc" "${CT_CC_VERSION}" + CT_Extract "gcc-${CT_CC_GCC_VERSION}" + CT_Patch "gcc" "${CT_CC_GCC_VERSION}" # Copy ecj-latest.jar to ecj.jar at the top of the GCC source tree if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" \ - -a ! -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/ecj.jar" \ + -a ! -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar" \ ]; then - CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/ecj.jar" + CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar" fi } @@ -86,7 +86,7 @@ cc_gcc_lang_list() { #------------------------------------------------------------------------------ # Core gcc pass 1 -do_cc_core_pass_1() { +do_gcc_core_pass_1() { local -a core_opts if [ "${CT_CC_CORE_PASS_1_NEEDED}" != "y" ]; then @@ -101,17 +101,17 @@ do_cc_core_pass_1() { core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) core_opts+=( "lang_list=c" ) - CT_DoStep INFO "Installing pass-1 core C compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-core-pass-1" + CT_DoStep INFO "Installing pass-1 core C gcc compiler" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-1" - do_cc_core_backend "${core_opts[@]}" + do_gcc_core_backend "${core_opts[@]}" CT_Popd CT_EndStep } # Core gcc pass 2 -do_cc_core_pass_2() { +do_gcc_core_pass_2() { local -a core_opts if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then @@ -148,10 +148,10 @@ do_cc_core_pass_2() { ;; esac - CT_DoStep INFO "Installing pass-2 core C compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-core-pass-2" + CT_DoStep INFO "Installing pass-2 core C gcc compiler" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-2" - do_cc_core_backend "${core_opts[@]}" + do_gcc_core_backend "${core_opts[@]}" CT_Popd CT_EndStep @@ -160,7 +160,7 @@ do_cc_core_pass_2() { #------------------------------------------------------------------------------ # Build core gcc # This function is used to build the core C compiler. -# Usage: do_cc_core_backend param=value [...] +# Usage: do_gcc_core_backend param=value [...] # Parameter : Definition : Type : Default # mode : build a 'static', 'shared' or 'baremetal' : string : (none) # host : the machine the core will run on : tuple : (none) @@ -174,8 +174,8 @@ do_cc_core_pass_2() { # build_manuals : whether to build manuals or not : bool : no # cflags : cflags to use : string : (empty) # ldflags : ldflags to use : string : (empty) -# Usage: do_cc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no] -do_cc_core_backend() { +# Usage: do_gcc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no] +do_gcc_core_backend() { local mode local build_libgcc=no local build_libstdcxx=no @@ -200,7 +200,7 @@ do_cc_core_backend() { eval "${arg// /\\ }" done - CT_DoLog EXTRA "Configuring gcc" + CT_DoLog EXTRA "Configuring core C gcc compiler" case "${mode}" in static) @@ -249,7 +249,7 @@ do_cc_core_backend() { # *** WARNING ! *** # Keep this full if-else-if-elif-fi-fi block in sync - # with the same block in do_cc, below. + # with the same block in do_gcc, below. if [ "${build_staticlinked}" = "yes" ]; then core_LDFLAGS+=("-static") host_libstdcxx_flags+=("-static-libgcc") @@ -262,7 +262,7 @@ do_cc_core_backend() { core_LDFLAGS+=("-lstdc++") core_LDFLAGS+=("-lm") else - if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then + if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2 # build script # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++, @@ -379,21 +379,21 @@ do_cc_core_backend() { CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532) - CT_DoExecLog CFG \ - CC_FOR_BUILD="${CT_BUILD}-gcc" \ - CFLAGS="${cflags}" \ - CXXFLAGS="${cflags}" \ - LDFLAGS="${core_LDFLAGS[*]}" \ - "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/configure" \ - --build=${CT_BUILD} \ - --host=${host} \ - --target=${CT_TARGET} \ - --prefix="${prefix}" \ - --with-local-prefix="${CT_SYSROOT_DIR}" \ - --disable-libmudflap \ - ${CC_CORE_SYSROOT_ARG} \ - "${extra_config[@]}" \ - --enable-languages="${lang_list}" \ + CT_DoExecLog CFG \ + CC_FOR_BUILD="${CT_BUILD}-gcc" \ + CFLAGS="${cflags}" \ + CXXFLAGS="${cflags}" \ + LDFLAGS="${core_LDFLAGS[*]}" \ + "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \ + --build=${CT_BUILD} \ + --host=${host} \ + --target=${CT_TARGET} \ + --prefix="${prefix}" \ + --with-local-prefix="${CT_SYSROOT_DIR}" \ + --disable-libmudflap \ + ${CC_CORE_SYSROOT_ARG} \ + "${extra_config[@]}" \ + --enable-languages="${lang_list}" \ "${extra_user_config[@]}" if [ "${build_libgcc}" = "yes" ]; then @@ -413,7 +413,7 @@ do_cc_core_backend() { # so we configure then build it. # Next we have to configure gcc, create libgcc.mk then edit it... # So much easier if we just edit the source tree, but hey... - if [ ! -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then + if [ ! -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then CT_DoExecLog CFG make ${JOBSFLAGS} configure-libiberty CT_DoExecLog ALL make ${JOBSFLAGS} -C libiberty libiberty.a CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp @@ -423,12 +423,12 @@ do_cc_core_backend() { CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp all-build-libiberty fi # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here. - if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/libdecnumber" ]; then + if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libdecnumber" ]; then CT_DoExecLog CFG make ${JOBSFLAGS} configure-libdecnumber CT_DoExecLog ALL make ${JOBSFLAGS} -C libdecnumber libdecnumber.a fi # HACK: gcc-4.8 uses libbacktrace to make libgcc.mvars, so make it here. - if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/libbacktrace" ]; then + if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libbacktrace" ]; then CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace fi @@ -492,7 +492,9 @@ do_cc_core_backend() { # check whether compiler has an extension file="$( ls -1 "${prefix}/bin/${CT_TARGET}-gcc."* 2>/dev/null || true )" [ -z "${file}" ] || ext=".${file##*.}" - CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}" + if [ -f "${prefix}/bin/${CT_TARGET}-gcc${ext}" ]; then + CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}" + fi if [ "${CT_MULTILIB}" = "y" ]; then if [ "${CT_CANADIAN}" = "y" -a "${mode}" = "baremetal" \ @@ -517,7 +519,7 @@ do_cc_core_backend() { #------------------------------------------------------------------------------ # Build complete gcc to run on build -do_cc_for_build() { +do_gcc_for_build() { local -a build_final_opts local build_final_backend @@ -542,13 +544,13 @@ do_cc_for_build() { if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then build_final_opts+=( "build_staticlinked=yes" ) fi - build_final_backend=do_cc_core_backend + build_final_backend=do_gcc_core_backend else - build_final_backend=do_cc_backend + build_final_backend=do_gcc_backend fi - CT_DoStep INFO "Installing final compiler for build" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-final-build-${CT_BUILD}" + CT_DoStep INFO "Installing final gcc compiler for build" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final-build-${CT_BUILD}" "${build_final_backend}" "${build_final_opts[@]}" @@ -558,7 +560,7 @@ do_cc_for_build() { #------------------------------------------------------------------------------ # Build final gcc to run on host -do_cc_for_host() { +do_gcc_for_host() { local -a final_opts local final_backend @@ -579,13 +581,13 @@ do_cc_for_host() { if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then final_opts+=( "build_staticlinked=yes" ) fi - final_backend=do_cc_core_backend + final_backend=do_gcc_core_backend else - final_backend=do_cc_backend + final_backend=do_gcc_backend fi - CT_DoStep INFO "Installing final compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-final" + CT_DoStep INFO "Installing final gcc compiler" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final" "${final_backend}" "${final_opts[@]}" @@ -595,7 +597,7 @@ do_cc_for_host() { #------------------------------------------------------------------------------ # Build the final gcc -# Usage: do_cc_backend param=value [...] +# Usage: do_gcc_backend param=value [...] # Parameter : Definition : Type : Default # host : the host we run onto : tuple : (none) # prefix : the runtime prefix : dir : (none) @@ -604,7 +606,7 @@ do_cc_for_host() { # ldflags : ldflags to use : string : (empty) # lang_list : the list of languages to build : string : (empty) # build_manuals : whether to build manuals or not : bool : no -do_cc_backend() { +do_gcc_backend() { local host local prefix local complibs @@ -622,7 +624,7 @@ do_cc_backend() { eval "${arg// /\\ }" done - CT_DoLog EXTRA "Configuring gcc" + CT_DoLog EXTRA "Configuring final gcc compiler" # Enable selected languages extra_config+=("--enable-languages=${lang_list}") @@ -649,8 +651,8 @@ do_cc_backend() { else extra_config+=("--disable-__cxa_atexit") fi - if [ -n "${CT_CC_ENABLE_CXX_FLAGS}" ]; then - extra_config+=("--enable-cxx-flags=${CT_CC_ENABLE_CXX_FLAGS}") + if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" ]; then + extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}") fi if [ "${CT_CC_GCC_4_8_or_later}" = "y" ]; then if [ "${CT_THREADS}" = "none" ]; then @@ -693,7 +695,7 @@ do_cc_backend() { # *** WARNING ! *** # Keep this full if-else-if-elif-fi-fi block in sync - # with the same block in do_cc_core, above. + # with the same block in do_gcc_core, above. if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then final_LDFLAGS+=("-static") host_libstdcxx_flags+=("-static-libgcc") @@ -706,7 +708,7 @@ do_cc_backend() { final_LDFLAGS+=("-lstdc++") final_LDFLAGS+=("-lm") else - if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then + if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2 # build script # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++, @@ -849,7 +851,7 @@ do_cc_backend() { CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ - "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/configure" \ + "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \ --build=${CT_BUILD} \ --host=${host} \ --target=${CT_TARGET} \ @@ -859,17 +861,17 @@ do_cc_backend() { --with-local-prefix="${CT_SYSROOT_DIR}" \ --enable-c99 \ --enable-long-long \ - "${CT_CC_EXTRA_CONFIG_ARRAY[@]}" + "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" if [ "${CT_CANADIAN}" = "y" ]; then CT_DoLog EXTRA "Building libiberty" CT_DoExecLog ALL make ${JOBSFLAGS} all-build-libiberty fi - CT_DoLog EXTRA "Building gcc" + CT_DoLog EXTRA "Building final gcc compiler" CT_DoExecLog ALL make ${JOBSFLAGS} all - CT_DoLog EXTRA "Installing gcc" + CT_DoLog EXTRA "Installing final gcc compiler" CT_DoExecLog ALL make ${JOBSFLAGS} install if [ "${build_manuals}" = "yes" ]; then @@ -884,7 +886,9 @@ do_cc_backend() { # check whether compiler has an extension file="$( ls -1 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-gcc."* 2>/dev/null || true )" [ -z "${file}" ] || ext=".${file##*.}" - CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-cc${ext}" + if [ -f "${CT_PREFIX_DIR}/bin/${CT_TARGET}-gcc${ext}" ]; then + CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-cc${ext}" + fi if [ "${CT_MULTILIB}" = "y" ]; then if [ "${CT_CANADIAN}" = "y" ]; then diff --git a/scripts/build/companion_libs/130-cloog.sh b/scripts/build/companion_libs/130-cloog.sh index 1a3b91a..fe5ba13 100644 --- a/scripts/build/companion_libs/130-cloog.sh +++ b/scripts/build/companion_libs/130-cloog.sh @@ -24,7 +24,8 @@ if [ "${CT_CLOOG}" = "y" ]; then # Download CLooG do_cloog_get() { CT_GetFile "$(cloog_basename_version)" \ - http://www.bastoul.net/cloog/pages/download + http://www.bastoul.net/cloog/pages/download \ + ftp://gcc.gnu.org/pub/gcc/infrastructure } # Extract CLooG diff --git a/scripts/build/companion_libs/140-mpc.sh b/scripts/build/companion_libs/140-mpc.sh index 03071d3..b15eea6 100644 --- a/scripts/build/companion_libs/140-mpc.sh +++ b/scripts/build/companion_libs/140-mpc.sh @@ -13,7 +13,8 @@ if [ "${CT_MPC}" = "y" ]; then # Download MPC do_mpc_get() { CT_GetFile "mpc-${CT_MPC_VERSION}" .tar.gz \ - {http,ftp,https}://ftp.gnu.org/gnu/mpc + {http,ftp,https}://ftp.gnu.org/gnu/mpc \ + http://www.multiprecision.org/mpc/download } # Extract MPC diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index 4eee214..93086b9 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -188,11 +188,11 @@ do_debug_gdb_build() { if [ "${CT_GDB_INSTALL_GDBINIT}" = "y" ]; then CT_DoLog EXTRA "Installing '.gdbinit' template" # See in scripts/build/internals.sh for why we do this - if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then - gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ) + if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then + gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ) else - gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \ - "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/version.c" \ + gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \ + "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/version.c" \ ) fi ${sed} -r \ diff --git a/scripts/build/internals.sh b/scripts/build/internals.sh index c7eb4c8..21f6472 100644 --- a/scripts/build/internals.sh +++ b/scripts/build/internals.sh @@ -28,33 +28,35 @@ do_finish() { CT_DoExecLog ALL "${CT_TARGET}-strip" ${strip_args} \ "${CT_TARGET}/debug-root/usr/bin/gdbserver" fi - # We can not use the version in CT_CC_VERSION because - # of the Linaro stuff. So, harvest the version string - # directly from the gcc sources... - # All gcc 4.x seem to have the version in gcc/BASE-VER - # while version prior to 4.x have the version in gcc/version.c - # Of course, here is not the better place to do that... - if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then - gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ) - else - gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \ - "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/version.c" \ - ) + if [ "${CT_CC_gcc}" = "y" ]; then + # We can not use the version in CT_CC_GCC_VERSION because + # of the Linaro stuff. So, harvest the version string + # directly from the gcc sources... + # All gcc 4.x seem to have the version in gcc/BASE-VER + # while version prior to 4.x have the version in gcc/version.c + # Of course, here is not the better place to do that... + if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then + gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ) + else + gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \ + "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/version.c" \ + ) + fi + for _t in "bin/${CT_TARGET}-"* \ + "${CT_TARGET}/bin/"* \ + "libexec/gcc/${CT_TARGET}/${gcc_version}/"* \ + "libexec/gcc/${CT_TARGET}/${gcc_version}/install-tools/"* \ + ; do + _type="$( file "${_t}" |cut -d ' ' -f 2- )" + case "${_type}" in + *script*executable*) + ;; + *executable*) + CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}" + ;; + esac + done fi - for _t in "bin/${CT_TARGET}-"* \ - "${CT_TARGET}/bin/"* \ - "libexec/gcc/${CT_TARGET}/${gcc_version}/"* \ - "libexec/gcc/${CT_TARGET}/${gcc_version}/install-tools/"* \ - ; do - _type="$( file "${_t}" |cut -d ' ' -f 2- )" - case "${_type}" in - *script*executable*) - ;; - *executable*) - CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}" - ;; - esac - done CT_Popd fi diff --git a/scripts/build/kernel/linux.sh b/scripts/build/kernel/linux.sh index 864562e..5f32680 100644 --- a/scripts/build/kernel/linux.sh +++ b/scripts/build/kernel/linux.sh @@ -33,21 +33,22 @@ do_kernel_get() { "${CT_KERNEL_LINUX_CUSTOM_LOCATION}" else # Not a custom tarball case "${CT_KERNEL_VERSION}" in - 2.6.*.*|3.*.*) + 2.6.*.*|3.*.*|4.*.*) # 4-part versions (for 2.6 stables and long-terms), and - # 3-part versions (for 3.x.y stables and long-terms), + # 3-part versions (for 3.x.y and 4.x.y stables and long-terms), # we need to trash the last digit k_ver="${CT_KERNEL_VERSION%.*}" ;; - 2.6.*|3.*) + 2.6.*|3.*|4.*) # 3-part version (for 2.6.x initial releases), and 2-part - # versions (for 3.x initial releases), use all of it + # versions (for 3.x and 4.x initial releases), use all of it k_ver="${CT_KERNEL_VERSION}" ;; esac case "${CT_KERNEL_VERSION}" in 2.6.*) rel_dir=v2.6;; 3.*) rel_dir=v3.x;; + 4.*) rel_dir=v4.x;; esac korg_base="http://www.kernel.org/pub/linux/kernel/${rel_dir}" CT_GetFile "linux-${CT_KERNEL_VERSION}" \ diff --git a/scripts/build/libc/eglibc.sh b/scripts/build/libc/eglibc.sh deleted file mode 100644 index 704ef7c..0000000 --- a/scripts/build/libc/eglibc.sh +++ /dev/null @@ -1,189 +0,0 @@ -# eglibc build functions (initially by Thomas JOURDAN). - -# Add the definitions common to glibc and eglibc -# do_libc_extract -# do_libc_start_files -# do_libc -# do_libc_add_ons_list -# do_libc_min_kernel_config -. "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common" - -# Download glibc -# eglibc is only available through subversion, there are no -# snapshots available. -do_libc_get() { - local addon - local -a extra_addons - local svn_base - - if echo ${CT_LIBC_VERSION} |grep -q linaro; then - # Linaro eglibc releases come from regular downloads... - YYMM=`echo ${CT_LIBC_VERSION} |cut -d- -f3 |${sed} -e 's,^..,,'` - CT_GetFile "eglibc-${CT_LIBC_VERSION}" \ - https://releases.linaro.org/${YYMM}/components/toolchain/eglibc-linaro \ - http://cbuild.validation.linaro.org/snapshots - return - fi - - if [ "${CT_EGLIBC_HTTP}" = "y" ]; then - svn_base="http://www.eglibc.org/svn" - else - svn_base="svn://svn.eglibc.org" - fi - - case "${CT_LIBC_VERSION}" in - trunk) svn_base+="/trunk";; - *) svn_base+="/branches/eglibc-${CT_LIBC_VERSION}";; - esac - - if [ "${CT_LIBC_CUSTOM}" = "y" ]; then - CT_GetCustom "eglibc" "${CT_LIBC_VERSION}" "${CT_LIBC_EGLIBC_CUSTOM_LOCATION}" - CT_LIBC_CUSTOM_LOCATION="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}" - else - CT_GetSVN "eglibc-${CT_LIBC_VERSION}" \ - "${svn_base}/libc" \ - "${CT_EGLIBC_REVISION:-HEAD}" - fi - - if [ "${CT_LIBC_LOCALES}" = "y" ]; then - extra_addons+=("localedef") - fi - - for addon in $(do_libc_add_ons_list " ") "${extra_addons[@]}"; do - # Never ever try to download these add-ons, - # they've always been internal - case "${addon}" in - nptl) continue;; - esac - - case "${addon}:${CT_LIBC_GLIBC_PORTS_EXTERNAL}" in - ports:y) ;; - ports:*) continue;; - esac - - if ! CT_GetSVN "eglibc-${addon}-${CT_LIBC_VERSION}" \ - "${svn_base}/${addon}" \ - "${CT_EGLIBC_REVISION:-HEAD}" - then - # Some add-ons are bundled with the main sources - # so failure to download them is expected - CT_DoLog DEBUG "Addon '${addon}' could not be downloaded." - CT_DoLog DEBUG "We'll see later if we can find it in the source tree" - fi - done -} - -# Copy user provided eglibc configuration file if provided -do_libc_check_config() { - if [ "${CT_EGLIBC_CUSTOM_CONFIG}" != "y" ]; then - return 0 - fi - - CT_DoStep INFO "Checking C library configuration" - - CT_TestOrAbort "You did not provide an eglibc config file!" \ - -n "${CT_EGLIBC_OPTION_GROUPS_FILE}" -a \ - -f "${CT_EGLIBC_OPTION_GROUPS_FILE}" - - CT_DoExecLog ALL cp "${CT_EGLIBC_OPTION_GROUPS_FILE}" "${CT_CONFIG_DIR}/eglibc.config" - - # NSS configuration - if grep -E '^OPTION_EGLIBC_NSSWITCH[[:space:]]*=[[:space:]]*n' "${CT_EGLIBC_OPTION_GROUPS_FILE}" >/dev/null 2>&1; then - CT_DoLog DEBUG "Using fixed-configuration nsswitch facility" - - if [ "${CT_EGLIBC_BUNDLED_NSS_CONFIG}" = "y" ]; then - nss_config="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.conf" - else - nss_config="${CT_EGLIBC_NSS_CONFIG_FILE}" - fi - CT_TestOrAbort "NSS config file not found!" -n "${nss_config}" -a -f "${nss_config}" - - CT_DoExecLog ALL cp "${nss_config}" "${CT_CONFIG_DIR}/nsswitch.config" - echo "OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG = ${CT_CONFIG_DIR}/nsswitch.config" \ - >> "${CT_CONFIG_DIR}/eglibc.config" - - if [ "${CT_EGLIBC_BUNDLED_NSS_FUNCTIONS}" = "y" ]; then - nss_functions="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}/nss/fixed-nsswitch.functions" - else - nss_functions="${CT_EGLIBC_NSS_FUNCTIONS_FILE}" - fi - CT_TestOrAbort "NSS functions file not found!" -n "${nss_functions}" -a -f "${nss_functions}" - - CT_DoExecLog ALL cp "${nss_functions}" "${CT_CONFIG_DIR}/nsswitch.functions" - echo "OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS = ${CT_CONFIG_DIR}/nsswitch.functions" \ - >> "${CT_CONFIG_DIR}/eglibc.config" - else - CT_DoLog DEBUG "Using full-blown nsswitch facility" - fi - - CT_EndStep -} - -# Extract the files required for the libc locales -do_libc_locales_extract() { - CT_Extract "eglibc-localedef-${CT_LIBC_VERSION}" - CT_Patch "eglibc" "localedef-${CT_LIBC_VERSION}" -} - -# Build and install the libc locales -do_libc_locales() { - local libc_src_dir="${CT_SRC_DIR}/eglibc-${CT_LIBC_VERSION}" - local src_dir="${CT_SRC_DIR}/eglibc-localedef-${CT_LIBC_VERSION}" - local -a extra_config - local -a localedef_opts - - mkdir -p "${CT_BUILD_DIR}/build-localedef" - cd "${CT_BUILD_DIR}/build-localedef" - - CT_DoLog EXTRA "Configuring C library localedef" - - if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") - [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") - fi - - CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'" - - # ./configure is misled by our tools override wrapper for bash - # so just tell it where the real bash is _on_the_target_! - # Notes: - # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL - # - ${BASH_SHELL} is only used to set BASH - # - ${BASH} is only used to set the shebang - # in two scripts to run on the target - # So we can safely bypass bash detection at compile time. - # Should this change in a future eglibc release, we'd better - # directly mangle the generated scripts _after_ they get built, - # or even after they get installed... - echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache - - # Configure with --prefix the way we want it on the target... - - CT_DoExecLog CFG \ - CPPFLAGS="-DNOT_IN_libc" \ - "${src_dir}/configure" \ - --prefix=/usr \ - --cache-file="$(pwd)/config.cache" \ - --with-glibc="${libc_src_dir}" \ - "${extra_config[@]}" - - CT_DoLog EXTRA "Building C library localedef" - CT_DoExecLog ALL make ${JOBSFLAGS} - - # Set the localedef endianness option - case "${CT_ARCH_ENDIAN}" in - big) localedef_opts+=(--big-endian);; - little) localedef_opts+=(--little-endian);; - esac - - # Set the localedef option for the target's uint32_t alignment in bytes. - # This is target-specific, but for now, 32-bit alignment should work for all - # supported targets, even 64-bit ones. - localedef_opts+=(--uint32-align=4) - - CT_DoLog EXTRA "Installing C library locales" - CT_DoExecLog ALL make ${JOBSFLAGS} \ - "LOCALEDEF_OPTS=${localedef_opts[*]}" \ - install_root="${CT_SYSROOT_DIR}" \ - install-locales -} diff --git a/scripts/build/libc/glibc-eglibc.sh-common b/scripts/build/libc/glibc-eglibc.sh-common deleted file mode 100644 index 28a36bd..0000000 --- a/scripts/build/libc/glibc-eglibc.sh-common +++ /dev/null @@ -1,540 +0,0 @@ -# This file contains the functions common to glibc and eglibc - -# Extract the C library tarball(s) -do_libc_extract() { - local addon - - # Attempt CT_EXTRACT only if NOT custom, or CUSTOM_LOCATION is not a directory - if [ "${CT_LIBC_CUSTOM}" != "y" \ - -o ! -d "${CT_LIBC_CUSTOM_LOCATION}" ]; then - CT_Extract "${CT_LIBC}-${CT_LIBC_VERSION}" - fi - CT_Pushd "${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" - # Attempt CT_PATCH only if NOT custom - if [ "${CT_LIBC_CUSTOM}" != "y" ]; then - CT_Patch nochdir "${CT_LIBC}" "${CT_LIBC_VERSION}" - fi - - # Extract the add-opns - for addon in $(do_libc_add_ons_list " "); do - # If the addon was bundled with the main archive, we do not - # need to extract it. Worse, if we were to try to extract - # it, we'd get an error. - if [ -d "${addon}" ]; then - CT_DoLog DEBUG "Add-on '${addon}' already present, skipping extraction" - continue - fi - - CT_Extract nochdir "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" - - CT_TestAndAbort "Error in add-on '${addon}': both short and long names in tarball" \ - -d "${addon}" -a -d "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" - - # Some addons have the 'long' name, while others have the - # 'short' name, but patches are non-uniformly built with - # either the 'long' or 'short' name, whatever the addons name - # but we prefer the 'short' name and avoid duplicates. - if [ -d "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" ]; then - CT_DoExecLog FILE mv "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" "${addon}" - fi - - CT_DoExecLog FILE ln -s "${addon}" "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" - - CT_Patch nochdir "${CT_LIBC}" "${addon}-${CT_LIBC_VERSION}" - - # Remove the long name since it can confuse configure scripts to run - # the same source twice. - rm "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" - done - - # The configure files may be older than the configure.in files - # if using a snapshot (or even some tarballs). Fake them being - # up to date. - find . -type f -name configure -exec touch {} \; 2>&1 |CT_DoLog ALL - - CT_Popd - - if [ "${CT_LIBC_LOCALES}" = "y" ]; then - do_libc_locales_extract - fi -} - -# Build and install headers and start files -do_libc_start_files() { - # Start files and Headers should be configured the same way as the - # final libc, but built and installed differently. - do_libc_backend libc_mode=startfiles -} - -# This function builds and install the full C library -do_libc() { - do_libc_backend libc_mode=final -} - -# This backend builds the C library once for each multilib -# variant the compiler gives us -# Usage: do_libc_backend param=value [...] -# Parameter : Definition : Type : Default -# libc_mode : 'startfiles' or 'final' : string : (none) -do_libc_backend() { - local libc_mode - local -a multilibs - local multilib - local multi_dir - local multi_flags - local extra_dir - local libc_headers libc_startfiles libc_full - local hdr - local arg - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - case "${libc_mode}" in - startfiles) - CT_DoStep INFO "Installing C library headers & start files" - hdr=y - libc_startfiles=y - libc_full= - ;; - final) - CT_DoStep INFO "Installing C library" - hdr= - libc_startfiles= - libc_full=y - ;; - *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";; - esac - - # If gcc is not configured for multilib, it still prints - # a single line for the default settings - multilibs=( $("${CT_TARGET}-gcc" -print-multi-lib 2>/dev/null) ) - for multilib in "${multilibs[@]}"; do - multi_dir="${multilib%%;*}" - if [ "${multi_dir}" != "." ]; then - CT_DoStep INFO "Building for multilib subdir='${multi_dir}'" - - extra_flags="$( echo "${multilib#*;}" \ - |${sed} -r -e 's/@/ -/g;' \ - )" - extra_dir="/${multi_dir}" - - # glibc install its files in ${extra_dir}/{usr/,}lib - # while gcc expects them in {,usr/}lib/${extra_dir}. - # Prepare some symlinks so glibc installs in fact in - # the proper place - # We do it in the start-files step, so it is not needed - # to do it in the final step, as the symlinks will - # already exist - if [ "${libc_mode}" = "startfiles" ]; then - CT_Pushd "${CT_SYSROOT_DIR}" - CT_DoExecLog ALL mkdir -p "lib/${multi_dir}" \ - "usr/lib/${multi_dir}" \ - "${multi_dir}" \ - "${multi_dir}/usr" - CT_DoExecLog ALL ln -sf "../lib/${multi_dir}" "${multi_dir}/lib" - CT_DoExecLog ALL ln -sf "../../usr/lib/${multi_dir}" "${multi_dir}/usr/lib" - CT_Popd - fi - libc_headers= - else - extra_dir= - extra_flags= - libc_headers="${hdr}" - fi - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}${extra_dir//\//_}" - - do_libc_backend_once extra_dir="${extra_dir}" \ - extra_flags="${extra_flags}" \ - libc_headers="${libc_headers}" \ - libc_startfiles="${libc_startfiles}" \ - libc_full="${libc_full}" - - CT_Popd - - if [ "${multi_dir}" != "." ]; then - if [ "${libc_mode}" = "final" ]; then - CT_DoLog EXTRA "Fixing up multilib location" - - # rewrite the library multiplexers - for d in "lib/${multi_dir}" "usr/lib/${multi_dir}"; do - for l in libc libpthread libgcc_s; do - if [ -f "${CT_SYSROOT_DIR}/${d}/${l}.so" \ - -a ! -L ${CT_SYSROOT_DIR}/${d}/${l}.so ] - then - CT_DoExecLog DEBUG ${sed} -r -i \ - -e "s:/lib/:/lib/${multi_dir}/:g;" \ - "${CT_SYSROOT_DIR}/${d}/${l}.so" - fi - done - done - # Remove the multi_dir now it is no longer useful - CT_DoExecLog DEBUG rm -rf "${CT_SYSROOT_DIR}/${multi_dir}" - fi # libc_mode == final - - CT_EndStep - fi - done - - CT_EndStep -} - -# This backend builds the C library once -# Usage: do_libc_backend_once param=value [...] -# Parameter : Definition : Type : Default -# libc_headers : Build libc headers : bool : n -# libc_startfiles : Build libc start-files : bool : n -# libc_full : Build full libc : bool : n -# extra_flags : Extra CFLAGS to use (for multilib) : string : (empty) -# extra_dir : Extra subdir for multilib : string : (empty) -do_libc_backend_once() { - local libc_headers - local libc_startfiles - local libc_full - local extra_flags - local extra_dir - local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" - local extra_cc_args - local -a extra_config - local -a extra_make_args - local glibc_cflags - local float_extra - local endian_extra - local arg - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - CT_DoLog EXTRA "Configuring C library" - - case "${CT_LIBC}" in - eglibc) - if [ "${CT_EGLIBC_CUSTOM_CONFIG}" = "y" ]; then - CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/eglibc.config" option-groups.config - fi - if [ "${CT_EGLIBC_OPT_SIZE}" = "y" ]; then - OPTIMIZE=-Os - else - OPTIMIZE=-O2 - fi - ;; - glibc) - # glibc can't be built without -O2 (reference needed!) - OPTIMIZE=-O2 - # Also, if those two are missing, iconv build breaks - extra_config+=( --disable-debug --disable-sanity-checks ) - ;; - esac - - # always include rpc, the user can still override it with TI-RPC - extra_config+=( --enable-obsolete-rpc ) - - # Add some default glibc config options if not given by user. - # We don't need to be conditional on wether the user did set different - # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY is passed after - # extra_config - - extra_config+=("$(do_libc_min_kernel_config)") - - case "${CT_THREADS}" in - nptl) extra_config+=("--with-__thread" "--with-tls");; - linuxthreads) extra_config+=("--with-__thread" "--without-tls" "--without-nptl");; - none) extra_config+=("--without-__thread" "--without-nptl") - case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in - *-tls*) ;; - *) extra_config+=("--without-tls");; - esac - ;; - esac - - case "${CT_SHARED_LIBS}" in - y) extra_config+=("--enable-shared");; - *) extra_config+=("--disable-shared");; - esac - - float_extra="$( echo "${extra_flags}" \ - |${sed} -r -e '/^(.*[[:space:]])?-m(hard|soft)-float([[:space:]].*)?$/!d;' \ - -e 's//\2/;' \ - )" - case "${float_extra}" in - hard) extra_config+=("--with-fp");; - soft) extra_config+=("--without-fp");; - "") - case "${CT_ARCH_FLOAT}" in - hard|softfp) extra_config+=("--with-fp");; - soft) extra_config+=("--without-fp");; - esac - ;; - esac - - if [ "${CT_LIBC_DISABLE_VERSIONING}" = "y" ]; then - extra_config+=("--disable-versioning") - fi - - if [ "${CT_LIBC_OLDEST_ABI}" != "" ]; then - extra_config+=("--enable-oldest-abi=${CT_LIBC_OLDEST_ABI}") - fi - - case "$(do_libc_add_ons_list ,)" in - "") extra_config+=("--enable-add-ons=no");; - *) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");; - esac - - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") - [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") - - # Extract the endianness options if any - # This should cover all possible endianness options - # in gcc, but it is prone to bit-rot... :-( - endian_extra="$( echo "${extra_flags}" \ - |${sed} -r -e '/^(.*[[:space:]])?-(E[BL]|m((big|little)(-endian)?|e?[bl]))([[:space:]].*)?$/!d;' \ - -e 's//\2/;' \ - )" - case "${endian_extra}" in - EB|mbig-endian|mbig|meb|mb) - extra_cc_args="${extra_cc_args} ${endian_extra}" - ;; - EL|mlittle-endian|mlittle|mel|ml) - extra_cc_args="${extra_cc_args} ${endian_extra}" - ;; - "") extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}" - ;; - esac - - touch config.cache - if [ "${CT_LIBC_GLIBC_FORCE_UNWIND}" = "y" ]; then - echo "libc_cv_forced_unwind=yes" >>config.cache - echo "libc_cv_c_cleanup=yes" >>config.cache - fi - - # Pre-seed the configparms file with values from the config option - printf "%s\n" "${CT_LIBC_GLIBC_CONFIGPARMS}" > configparms - - cross_cc=$(CT_Which "${CT_TARGET}-gcc") - extra_cc_args+=" ${extra_flags}" - - case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in - y) ;; - *) glibc_cflags+=" -U_FORTIFY_SOURCE";; - esac - glibc_cflags+=" ${CT_TARGET_CFLAGS} ${OPTIMIZE} ${CT_LIBC_GLIBC_EXTRA_CFLAGS}" - - # ./configure is mislead by our tools override wrapper for bash - # so just tell it where the real bash is _on_the_target_! - # Notes: - # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL - # - ${BASH_SHELL} is only used to set BASH - # - ${BASH} is only used to set the shebang - # in two scripts to run on the target - # So we can safely bypass bash detection at compile time. - # Should this change in a future eglibc release, we'd better - # directly mangle the generated scripts _after_ they get built, - # or even after they get installed... - echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache - - # Configure with --prefix the way we want it on the target... - # There are a whole lot of settings here. You'll probably want - # to read up on what they all mean, and customize a bit, possibly by setting GLIBC_EXTRA_CONFIG_ARRAY - # Compare these options with the ones used when installing the glibc headers above - they're different. - # Adding "--without-gd" option to avoid error "memusagestat.c:36:16: gd.h: No such file or directory" - # See also http://sources.redhat.com/ml/libc-alpha/2000-07/msg00024.html. - # Set BUILD_CC, or we won't be able to build datafiles - # Run explicitly through CONFIG_SHELL, or the build breaks badly (loop-of-death) - # when the shell is not bash... Sigh... :-( - - CT_DoLog DEBUG "Using gcc for target : '${cross_cc}'" - CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'" - CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'" - CT_DoLog DEBUG "Extra CC args passed : '${glibc_cflags}'" - CT_DoLog DEBUG "Extra flags (multilib) : '${extra_flags}'" - - CT_DoExecLog CFG \ - BUILD_CC="${CT_BUILD}-gcc" \ - CFLAGS="${glibc_cflags}" \ - CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \ - AR=${CT_TARGET}-ar \ - RANLIB=${CT_TARGET}-ranlib \ - "${CONFIG_SHELL}" \ - "${src_dir}/configure" \ - --prefix=/usr \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - --cache-file="$(pwd)/config.cache" \ - --without-cvs \ - --disable-profile \ - --without-gd \ - --with-headers="${CT_HEADERS_DIR}" \ - "${extra_config[@]}" \ - "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[@]}" - - # build hacks - case "${CT_ARCH},${CT_ARCH_CPU}" in - powerpc,8??) - # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html - CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)" - extra_make_args+=( ASFLAGS="-DBROKEN_PPC_8xx_CPU15" ) - ;; - esac - - if [ "${libc_headers}" = "y" ]; then - CT_DoLog EXTRA "Installing C library headers" - - # use the 'install-headers' makefile target to install the - # headers - CT_DoExecLog ALL make ${JOBSFLAGS} \ - install_root=${CT_SYSROOT_DIR}${extra_dir} \ - install-bootstrap-headers=yes \ - "${extra_make_args[@]}" \ - install-headers - - # For glibc, a few headers need to be manually installed - if [ "${CT_LIBC}" = "glibc" ]; then - # Two headers -- stubs.h and features.h -- aren't installed by install-headers, - # so do them by hand. We can tolerate an empty stubs.h for the moment. - # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html - mkdir -p "${CT_HEADERS_DIR}/gnu" - CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h" - CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \ - "${CT_HEADERS_DIR}/features.h" - - # Building the bootstrap gcc requires either setting inhibit_libc, or - # having a copy of stdio_lim.h... see - # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html - CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h" - - # Following error building gcc-4.0.0's gcj: - # error: bits/syscall.h: No such file or directory - # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html - # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html - # Of course, only copy it if it does not already exist - case "${CT_ARCH}" in - arm) ;; - *) if [ -f "${CT_HEADERS_DIR}/bits/syscall.h" ]; then - CT_DoLog ALL "Not over-writing existing bits/syscall.h" - elif [ -f "misc/bits/syscall.h" ]; then - CT_DoExecLog ALL cp -v "misc/bits/syscall.h" \ - "${CT_HEADERS_DIR}/bits/syscall.h" - else - # "Old" glibces do not have the above file, - # but provide this one: - CT_DoExecLog ALL cp -v "misc/syscall-list.h" \ - "${CT_HEADERS_DIR}/bits/syscall.h" - fi - ;; - esac - fi - fi # libc_headers == y - - if [ "${libc_startfiles}" = "y" ]; then - if [ "${CT_THREADS}" = "nptl" ]; then - CT_DoLog EXTRA "Installing C library start files" - - # there are a few object files needed to link shared libraries, - # which we build and install by hand - CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}${extra_dir}/usr/lib" - CT_DoExecLog ALL make ${JOBSFLAGS} \ - "${extra_make_args[@]}" \ - csu/subdir_lib - CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \ - "${CT_SYSROOT_DIR}${extra_dir}/usr/lib" - - # Finally, 'libgcc_s.so' requires a 'libc.so' to link against. - # However, since we will never actually execute its code, - # it doesn't matter what it contains. So, treating '/dev/null' - # as a C source file, we produce a dummy 'libc.so' in one step - CT_DoExecLog ALL "${cross_cc}" -nostdlib \ - -nostartfiles \ - -shared \ - -x c /dev/null \ - -o "${CT_SYSROOT_DIR}${extra_dir}/usr/lib/libc.so" - fi # threads == nptl - fi # libc_headers == y - - if [ "${libc_full}" = "y" ]; then - CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make ${JOBSFLAGS} \ - "${extra_make_args[@]}" \ - all - - CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL make ${JOBSFLAGS} \ - "${extra_make_args[@]}" \ - install_root="${CT_SYSROOT_DIR}${extra_dir}" \ - install - - if [ "${CT_BUILD_MANUALS}" = "y" ]; then - CT_DoLog EXTRA "Building and installing the C library manual" - # Omit JOBSFLAGS as GLIBC has problems building the - # manuals in parallel - CT_DoExecLog ALL make pdf html - # EGLIBC doesn't have a install-{pdf.html}, and older - # versions leave the manuals in the source directory - CT_DoExecLog ALL mkdir -p ${CT_PREFIX_DIR}/share/doc - if [ "${CT_LIBC_EGLIBC_2_16_or_later}" = "y" ]; then - CT_DoExecLog ALL cp -av manual/*.pdf manual/libc \ - ${CT_PREFIX_DIR}/share/doc - else - CT_DoExecLog ALL cp -av ${src_dir}/manual/*.pdf ${src_dir}/manual/libc \ - ${CT_PREFIX_DIR}/share/doc - fi - fi - - if [ "${CT_LIBC_LOCALES}" = "y" ]; then - do_libc_locales - fi - fi # libc_full == y -} - -# Build up the addons list, separated with $1 -do_libc_add_ons_list() { - local sep="$1" - local addons_list="$( echo "${CT_LIBC_ADDONS_LIST}" \ - |sed -r -e "s/[[:space:],]/${sep}/g;" \ - )" - if [ "${CT_LIBC_GLIBC_2_20_or_later}" != "y" ]; then - case "${CT_THREADS}" in - none) ;; - *) addons_list="${addons_list}${sep}${CT_THREADS}";; - esac - fi - [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list}${sep}ports" - # Remove duplicate, leading and trailing separators - echo "${addons_list}" |sed -r -e "s/${sep}+/${sep}/g; s/^${sep}//; s/${sep}\$//;" -} - -# Compute up the minimum supported Linux kernel version -do_libc_min_kernel_config() { - local min_kernel_config - - case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in - *--enable-kernel*) ;; - *) if [ "${CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then - # We can't rely on the kernel version from the configuration, - # because it might not be available if the user uses pre-installed - # headers. On the other hand, both method will have the kernel - # version installed in "usr/include/linux/version.h" in the sysroot. - # Parse that instead of having two code-paths. - version_code_file="${CT_SYSROOT_DIR}/usr/include/linux/version.h" - if [ ! -f "${version_code_file}" -o ! -r "${version_code_file}" ]; then - CT_Abort "Linux version is unavailable in installed headers files" - fi - version_code="$( grep -E LINUX_VERSION_CODE "${version_code_file}" \ - |cut -d ' ' -f 3 \ - )" - version=$(((version_code>>16)&0xFF)) - patchlevel=$(((version_code>>8)&0xFF)) - sublevel=$((version_code&0xFF)) - min_kernel_config="${version}.${patchlevel}.${sublevel}" - elif [ "${CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then - # Trim the fourth part of the linux version, keeping only the first three numbers - min_kernel_config="$( echo "${CT_LIBC_GLIBC_MIN_KERNEL_VERSION}" \ - |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;' \ - )" - fi - echo "--enable-kernel=${min_kernel_config}" - ;; - esac -} diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index a064c49..672e672 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -2,13 +2,532 @@ # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -# Add the definitions common to glibc and eglibc -# do_libc_extract -# do_libc_start_files -# do_libc -# do_libc_add_ons_list -# do_libc_min_kernel_config -. "${CT_LIB_DIR}/scripts/build/libc/glibc-eglibc.sh-common" +# Extract the C library tarball(s) +do_libc_extract() { + local addon + + # Attempt CT_EXTRACT only if NOT custom, or CUSTOM_LOCATION is not a directory + if [ "${CT_LIBC_CUSTOM}" != "y" \ + -o ! -d "${CT_LIBC_CUSTOM_LOCATION}" ]; then + CT_Extract "${CT_LIBC}-${CT_LIBC_VERSION}" + fi + CT_Pushd "${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" + # Attempt CT_PATCH only if NOT custom + if [ "${CT_LIBC_CUSTOM}" != "y" ]; then + CT_Patch nochdir "${CT_LIBC}" "${CT_LIBC_VERSION}" + fi + + # Extract the add-opns + for addon in $(do_libc_add_ons_list " "); do + # If the addon was bundled with the main archive, we do not + # need to extract it. Worse, if we were to try to extract + # it, we'd get an error. + if [ -d "${addon}" ]; then + CT_DoLog DEBUG "Add-on '${addon}' already present, skipping extraction" + continue + fi + + CT_Extract nochdir "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" + + CT_TestAndAbort "Error in add-on '${addon}': both short and long names in tarball" \ + -d "${addon}" -a -d "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" + + # Some addons have the 'long' name, while others have the + # 'short' name, but patches are non-uniformly built with + # either the 'long' or 'short' name, whatever the addons name + # but we prefer the 'short' name and avoid duplicates. + if [ -d "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" ]; then + CT_DoExecLog FILE mv "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" "${addon}" + fi + + CT_DoExecLog FILE ln -s "${addon}" "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" + + CT_Patch nochdir "${CT_LIBC}" "${addon}-${CT_LIBC_VERSION}" + + # Remove the long name since it can confuse configure scripts to run + # the same source twice. + rm "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" + done + + # The configure files may be older than the configure.in files + # if using a snapshot (or even some tarballs). Fake them being + # up to date. + find . -type f -name configure -exec touch {} \; 2>&1 |CT_DoLog ALL + + CT_Popd + + if [ "${CT_LIBC_LOCALES}" = "y" ]; then + do_libc_locales_extract + fi +} + +# Build and install headers and start files +do_libc_start_files() { + # Start files and Headers should be configured the same way as the + # final libc, but built and installed differently. + do_libc_backend libc_mode=startfiles +} + +# This function builds and install the full C library +do_libc() { + do_libc_backend libc_mode=final +} + +# This backend builds the C library once for each multilib +# variant the compiler gives us +# Usage: do_libc_backend param=value [...] +# Parameter : Definition : Type : Default +# libc_mode : 'startfiles' or 'final' : string : (none) +do_libc_backend() { + local libc_mode + local -a multilibs + local multilib + local multi_dir + local multi_flags + local extra_dir + local libc_headers libc_startfiles libc_full + local hdr + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + case "${libc_mode}" in + startfiles) + CT_DoStep INFO "Installing C library headers & start files" + hdr=y + libc_startfiles=y + libc_full= + ;; + final) + CT_DoStep INFO "Installing C library" + hdr= + libc_startfiles= + libc_full=y + ;; + *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";; + esac + + # If gcc is not configured for multilib, it still prints + # a single line for the default settings + multilibs=( $("${CT_TARGET}-gcc" -print-multi-lib 2>/dev/null) ) + for multilib in "${multilibs[@]}"; do + multi_dir="${multilib%%;*}" + if [ "${multi_dir}" != "." ]; then + CT_DoStep INFO "Building for multilib subdir='${multi_dir}'" + + extra_flags="$( echo "${multilib#*;}" \ + |${sed} -r -e 's/@/ -/g;' \ + )" + extra_dir="/${multi_dir}" + + # glibc install its files in ${extra_dir}/{usr/,}lib + # while gcc expects them in {,usr/}lib/${extra_dir}. + # Prepare some symlinks so glibc installs in fact in + # the proper place + # We do it in the start-files step, so it is not needed + # to do it in the final step, as the symlinks will + # already exist + if [ "${libc_mode}" = "startfiles" ]; then + CT_Pushd "${CT_SYSROOT_DIR}" + CT_DoExecLog ALL mkdir -p "lib/${multi_dir}" \ + "usr/lib/${multi_dir}" \ + "${multi_dir}" \ + "${multi_dir}/usr" + CT_DoExecLog ALL ln -sf "../lib/${multi_dir}" "${multi_dir}/lib" + CT_DoExecLog ALL ln -sf "../../usr/lib/${multi_dir}" "${multi_dir}/usr/lib" + CT_Popd + fi + libc_headers= + else + extra_dir= + extra_flags= + libc_headers="${hdr}" + fi + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}${extra_dir//\//_}" + + do_libc_backend_once extra_dir="${extra_dir}" \ + extra_flags="${extra_flags}" \ + libc_headers="${libc_headers}" \ + libc_startfiles="${libc_startfiles}" \ + libc_full="${libc_full}" + + CT_Popd + + if [ "${multi_dir}" != "." ]; then + if [ "${libc_mode}" = "final" ]; then + CT_DoLog EXTRA "Fixing up multilib location" + + # rewrite the library multiplexers + for d in "lib/${multi_dir}" "usr/lib/${multi_dir}"; do + for l in libc libpthread libgcc_s; do + if [ -f "${CT_SYSROOT_DIR}/${d}/${l}.so" \ + -a ! -L ${CT_SYSROOT_DIR}/${d}/${l}.so ] + then + CT_DoExecLog DEBUG ${sed} -r -i \ + -e "s:/lib/:/lib/${multi_dir}/:g;" \ + "${CT_SYSROOT_DIR}/${d}/${l}.so" + fi + done + done + # Remove the multi_dir now it is no longer useful + CT_DoExecLog DEBUG rm -rf "${CT_SYSROOT_DIR}/${multi_dir}" + fi # libc_mode == final + + CT_EndStep + fi + done + + CT_EndStep +} + +# This backend builds the C library once +# Usage: do_libc_backend_once param=value [...] +# Parameter : Definition : Type : Default +# libc_headers : Build libc headers : bool : n +# libc_startfiles : Build libc start-files : bool : n +# libc_full : Build full libc : bool : n +# extra_flags : Extra CFLAGS to use (for multilib) : string : (empty) +# extra_dir : Extra subdir for multilib : string : (empty) +do_libc_backend_once() { + local libc_headers + local libc_startfiles + local libc_full + local extra_flags + local extra_dir + local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" + local extra_cc_args + local -a extra_config + local -a extra_make_args + local glibc_cflags + local float_extra + local endian_extra + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Configuring C library" + + case "${CT_LIBC}" in + glibc) + # glibc can't be built without -O2 (reference needed!) + OPTIMIZE=-O2 + # Also, if those two are missing, iconv build breaks + extra_config+=( --disable-debug --disable-sanity-checks ) + ;; + esac + + # always include rpc, the user can still override it with TI-RPC + extra_config+=( --enable-obsolete-rpc ) + + # Add some default glibc config options if not given by user. + # We don't need to be conditional on wether the user did set different + # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY is passed after + # extra_config + + extra_config+=("$(do_libc_min_kernel_config)") + + case "${CT_THREADS}" in + nptl) extra_config+=("--with-__thread" "--with-tls");; + linuxthreads) extra_config+=("--with-__thread" "--without-tls" "--without-nptl");; + none) extra_config+=("--without-__thread" "--without-nptl") + case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in + *-tls*) ;; + *) extra_config+=("--without-tls");; + esac + ;; + esac + + case "${CT_SHARED_LIBS}" in + y) extra_config+=("--enable-shared");; + *) extra_config+=("--disable-shared");; + esac + + float_extra="$( echo "${extra_flags}" \ + |${sed} -r -e '/^(.*[[:space:]])?-m(hard|soft)-float([[:space:]].*)?$/!d;' \ + -e 's//\2/;' \ + )" + case "${float_extra}" in + hard) extra_config+=("--with-fp");; + soft) extra_config+=("--without-fp");; + "") + case "${CT_ARCH_FLOAT}" in + hard|softfp) extra_config+=("--with-fp");; + soft) extra_config+=("--without-fp");; + esac + ;; + esac + + if [ "${CT_LIBC_DISABLE_VERSIONING}" = "y" ]; then + extra_config+=("--disable-versioning") + fi + + if [ "${CT_LIBC_OLDEST_ABI}" != "" ]; then + extra_config+=("--enable-oldest-abi=${CT_LIBC_OLDEST_ABI}") + fi + + case "$(do_libc_add_ons_list ,)" in + "") extra_config+=("--enable-add-ons=no");; + *) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");; + esac + + extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") + + # Extract the endianness options if any + # This should cover all possible endianness options + # in gcc, but it is prone to bit-rot... :-( + endian_extra="$( echo "${extra_flags}" \ + |${sed} -r -e '/^(.*[[:space:]])?-(E[BL]|m((big|little)(-endian)?|e?[bl]))([[:space:]].*)?$/!d;' \ + -e 's//\2/;' \ + )" + case "${endian_extra}" in + EB|mbig-endian|mbig|meb|mb) + extra_cc_args="${extra_cc_args} ${endian_extra}" + ;; + EL|mlittle-endian|mlittle|mel|ml) + extra_cc_args="${extra_cc_args} ${endian_extra}" + ;; + "") extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}" + ;; + esac + + touch config.cache + if [ "${CT_LIBC_GLIBC_FORCE_UNWIND}" = "y" ]; then + echo "libc_cv_forced_unwind=yes" >>config.cache + echo "libc_cv_c_cleanup=yes" >>config.cache + fi + + # Pre-seed the configparms file with values from the config option + printf "%s\n" "${CT_LIBC_GLIBC_CONFIGPARMS}" > configparms + + cross_cc=$(CT_Which "${CT_TARGET}-gcc") + extra_cc_args+=" ${extra_flags}" + + case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in + y) ;; + *) glibc_cflags+=" -U_FORTIFY_SOURCE";; + esac + glibc_cflags+=" ${CT_TARGET_CFLAGS} ${OPTIMIZE} ${CT_LIBC_GLIBC_EXTRA_CFLAGS}" + + # ./configure is mislead by our tools override wrapper for bash + # so just tell it where the real bash is _on_the_target_! + # Notes: + # - ${ac_cv_path_BASH_SHELL} is only used to set BASH_SHELL + # - ${BASH_SHELL} is only used to set BASH + # - ${BASH} is only used to set the shebang + # in two scripts to run on the target + # So we can safely bypass bash detection at compile time. + # Should this change in a future glibc release, we'd better + # directly mangle the generated scripts _after_ they get built, + # or even after they get installed... + echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache + + # Configure with --prefix the way we want it on the target... + # There are a whole lot of settings here. You'll probably want + # to read up on what they all mean, and customize a bit, possibly by setting GLIBC_EXTRA_CONFIG_ARRAY + # Compare these options with the ones used when installing the glibc headers above - they're different. + # Adding "--without-gd" option to avoid error "memusagestat.c:36:16: gd.h: No such file or directory" + # See also http://sources.redhat.com/ml/libc-alpha/2000-07/msg00024.html. + # Set BUILD_CC, or we won't be able to build datafiles + # Run explicitly through CONFIG_SHELL, or the build breaks badly (loop-of-death) + # when the shell is not bash... Sigh... :-( + + CT_DoLog DEBUG "Using gcc for target : '${cross_cc}'" + CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'" + CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'" + CT_DoLog DEBUG "Extra CC args passed : '${glibc_cflags}'" + CT_DoLog DEBUG "Extra flags (multilib) : '${extra_flags}'" + + CT_DoExecLog CFG \ + BUILD_CC="${CT_BUILD}-gcc" \ + CFLAGS="${glibc_cflags}" \ + CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \ + AR=${CT_TARGET}-ar \ + RANLIB=${CT_TARGET}-ranlib \ + "${CONFIG_SHELL}" \ + "${src_dir}/configure" \ + --prefix=/usr \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --cache-file="$(pwd)/config.cache" \ + --without-cvs \ + --disable-profile \ + --without-gd \ + --with-headers="${CT_HEADERS_DIR}" \ + "${extra_config[@]}" \ + "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[@]}" + + # build hacks + case "${CT_ARCH},${CT_ARCH_CPU}" in + powerpc,8??) + # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html + CT_DoLog DEBUG "Activating support for memset on broken ppc-8xx (CPU15 erratum)" + extra_make_args+=( ASFLAGS="-DBROKEN_PPC_8xx_CPU15" ) + ;; + esac + + CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}" + CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}" + extra_make_args+=( "BUILD_CFLAGS=${CT_CFLAGS_FOR_BUILD}" "BUILD_LDFLAGS=${CT_LDFLAGS_FOR_BUILD}" ) + + if [ "${libc_headers}" = "y" ]; then + CT_DoLog EXTRA "Installing C library headers" + + # use the 'install-headers' makefile target to install the + # headers + CT_DoExecLog ALL make ${JOBSFLAGS} \ + install_root=${CT_SYSROOT_DIR}${extra_dir} \ + install-bootstrap-headers=yes \ + "${extra_make_args[@]}" \ + install-headers + + # For glibc, a few headers need to be manually installed + if [ "${CT_LIBC}" = "glibc" ]; then + # Two headers -- stubs.h and features.h -- aren't installed by install-headers, + # so do them by hand. We can tolerate an empty stubs.h for the moment. + # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html + mkdir -p "${CT_HEADERS_DIR}/gnu" + CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h" + CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}/include/features.h" \ + "${CT_HEADERS_DIR}/features.h" + + # Building the bootstrap gcc requires either setting inhibit_libc, or + # having a copy of stdio_lim.h... see + # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html + CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h" + + # Following error building gcc-4.0.0's gcj: + # error: bits/syscall.h: No such file or directory + # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html + # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html + # Of course, only copy it if it does not already exist + case "${CT_ARCH}" in + arm) ;; + *) if [ -f "${CT_HEADERS_DIR}/bits/syscall.h" ]; then + CT_DoLog ALL "Not over-writing existing bits/syscall.h" + elif [ -f "misc/bits/syscall.h" ]; then + CT_DoExecLog ALL cp -v "misc/bits/syscall.h" \ + "${CT_HEADERS_DIR}/bits/syscall.h" + else + # "Old" glibces do not have the above file, + # but provide this one: + CT_DoExecLog ALL cp -v "misc/syscall-list.h" \ + "${CT_HEADERS_DIR}/bits/syscall.h" + fi + ;; + esac + fi + fi # libc_headers == y + + if [ "${libc_startfiles}" = "y" ]; then + if [ "${CT_THREADS}" = "nptl" ]; then + CT_DoLog EXTRA "Installing C library start files" + + # there are a few object files needed to link shared libraries, + # which we build and install by hand + CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}${extra_dir}/usr/lib" + CT_DoExecLog ALL make ${JOBSFLAGS} \ + "${extra_make_args[@]}" \ + csu/subdir_lib + CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \ + "${CT_SYSROOT_DIR}${extra_dir}/usr/lib" + + # Finally, 'libgcc_s.so' requires a 'libc.so' to link against. + # However, since we will never actually execute its code, + # it doesn't matter what it contains. So, treating '/dev/null' + # as a C source file, we produce a dummy 'libc.so' in one step + CT_DoExecLog ALL "${cross_cc}" -nostdlib \ + -nostartfiles \ + -shared \ + -x c /dev/null \ + -o "${CT_SYSROOT_DIR}${extra_dir}/usr/lib/libc.so" + fi # threads == nptl + fi # libc_headers == y + + if [ "${libc_full}" = "y" ]; then + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make ${JOBSFLAGS} \ + "${extra_make_args[@]}" \ + all + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make ${JOBSFLAGS} \ + "${extra_make_args[@]}" \ + install_root="${CT_SYSROOT_DIR}${extra_dir}" \ + install + + if [ "${CT_BUILD_MANUALS}" = "y" ]; then + CT_DoLog EXTRA "Building and installing the C library manual" + # Omit JOBSFLAGS as GLIBC has problems building the + # manuals in parallel + CT_DoExecLog ALL make pdf html + CT_DoExecLog ALL mkdir -p ${CT_PREFIX_DIR}/share/doc + CT_DoExecLog ALL cp -av ${src_dir}/manual/*.pdf \ + ${src_dir}/manual/libc \ + ${CT_PREFIX_DIR}/share/doc + fi + + if [ "${CT_LIBC_LOCALES}" = "y" ]; then + do_libc_locales + fi + fi # libc_full == y +} + +# Build up the addons list, separated with $1 +do_libc_add_ons_list() { + local sep="$1" + local addons_list="$( echo "${CT_LIBC_ADDONS_LIST}" \ + |sed -r -e "s/[[:space:],]/${sep}/g;" \ + )" + if [ "${CT_LIBC_GLIBC_2_20_or_later}" != "y" ]; then + case "${CT_THREADS}" in + none) ;; + *) addons_list="${addons_list}${sep}${CT_THREADS}";; + esac + fi + [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && addons_list="${addons_list}${sep}ports" + # Remove duplicate, leading and trailing separators + echo "${addons_list}" |sed -r -e "s/${sep}+/${sep}/g; s/^${sep}//; s/${sep}\$//;" +} + +# Compute up the minimum supported Linux kernel version +do_libc_min_kernel_config() { + local min_kernel_config + + case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in + *--enable-kernel*) ;; + *) if [ "${CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then + # We can't rely on the kernel version from the configuration, + # because it might not be available if the user uses pre-installed + # headers. On the other hand, both method will have the kernel + # version installed in "usr/include/linux/version.h" in the sysroot. + # Parse that instead of having two code-paths. + version_code_file="${CT_SYSROOT_DIR}/usr/include/linux/version.h" + if [ ! -f "${version_code_file}" -o ! -r "${version_code_file}" ]; then + CT_Abort "Linux version is unavailable in installed headers files" + fi + version_code="$( grep -E LINUX_VERSION_CODE "${version_code_file}" \ + |cut -d ' ' -f 3 \ + )" + version=$(((version_code>>16)&0xFF)) + patchlevel=$(((version_code>>8)&0xFF)) + sublevel=$((version_code&0xFF)) + min_kernel_config="${version}.${patchlevel}.${sublevel}" + elif [ "${CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then + # Trim the fourth part of the linux version, keeping only the first three numbers + min_kernel_config="$( echo "${CT_LIBC_GLIBC_MIN_KERNEL_VERSION}" \ + |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;' \ + )" + fi + echo "--enable-kernel=${min_kernel_config}" + ;; + esac +} # Download glibc do_libc_get() { @@ -24,7 +543,7 @@ do_libc_get() { CT_LIBC_CUSTOM_LOCATION="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}" else if echo ${CT_LIBC_VERSION} |grep -q linaro; then - # Linaro eglibc releases come from regular downloads... + # Linaro glibc releases come from regular downloads... YYMM=`echo ${CT_LIBC_VERSION} |cut -d- -f3 |${sed} -e 's,^..,,'` CT_GetFile "glibc-${CT_LIBC_VERSION}" \ https://releases.linaro.org/${YYMM}/components/toolchain/glibc-linaro \ @@ -89,8 +608,13 @@ do_libc_locales() { CT_DoLog EXTRA "Configuring C library localedef" - if [ "${CT_LIBC_EGLIBC_HAS_PKGVERSION_BUGURL}" = "y" ]; then + # Versions that don't support --with-pkgversion or --with-bugurl will cause + # a harmless: `configure: WARNING: unrecognized options: --with-bugurl...` + # If it's set, use it, if is a recognized option. + if [ ! "${CT_TOOLCHAIN_PKGVERSION}" = "" ]; then extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + fi + if [ ! "${CT_TOOLCHAIN_BUGURL}" = "" ]; then [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") fi @@ -110,7 +634,7 @@ do_libc_locales() { # - ${BASH} is only used to set the shebang # in two scripts to run on the target # So we can safely bypass bash detection at compile time. - # Should this change in a future eglibc release, we'd better + # Should this change in a future glibc release, we'd better # directly mangle the generated scripts _after_ they get built, # or even after they get installed... echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache diff --git a/scripts/build/libc/mingw.sh b/scripts/build/libc/mingw.sh index 9a89df7..23f31d1 100644 --- a/scripts/build/libc/mingw.sh +++ b/scripts/build/libc/mingw.sh @@ -1,15 +1,25 @@ # Copyright 2012 Yann Diorcet # Licensed under the GPL v2. See COPYING in the root of this package -do_libc_get() { - CT_GetFile "mingw-w64-v${CT_WINAPI_VERSION}" \ - http://downloads.sourceforge.net/sourceforge/mingw-w64 +CT_WINAPI_VERSION_DOWNLOADED= + +do_libc_get() { + CT_DoStep INFO "Fetching mingw-w64 source for ${CT_WINAPI_VERSION}" + if [ "${CT_WINAPI_VERSION}" = "devel" ]; then + CT_GetGit "mingw-w64" "ref=HEAD" "git://git.code.sf.net/p/mingw-w64/mingw-w64" CT_WINAPI_VERSION_DOWNLOADED + CT_DoLog EXTRA "Fetched as ${CT_WINAPI_VERSION_DOWNLOADED}" + else + CT_GetFile "mingw-w64-v${CT_WINAPI_VERSION}" \ + http://downloads.sourceforge.net/sourceforge/mingw-w64 + CT_WINAPI_VERSION_DOWNLOADED=v${CT_WINAPI_VERSION} + fi + CT_EndStep } do_libc_extract() { - CT_Extract "mingw-w64-v${CT_WINAPI_VERSION}" - CT_Pushd "${CT_SRC_DIR}/mingw-w64-v${CT_WINAPI_VERSION}/" - CT_Patch nochdir mingw-w64 "${CT_WINAPI_VERSION}" + CT_Extract "mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}" + CT_Pushd "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/" + CT_Patch nochdir mingw-w64 "${CT_WINAPI_VERSION_DOWNLOADED}" CT_Popd } @@ -17,6 +27,13 @@ do_libc_check_config() { : } +do_set_mingw_install_prefix(){ + MINGW_INSTALL_PREFIX=/usr/${CT_TARGET} + if [[ ${CT_WINAPI_VERSION} == 2* ]]; then + MINGW_INSTALL_PREFIX=/usr + fi +} + do_libc_start_files() { local -a sdk_opts @@ -33,11 +50,12 @@ do_libc_start_files() { CT_DoLog EXTRA "Configuring Headers" + do_set_mingw_install_prefix CT_DoExecLog CFG \ - "${CT_SRC_DIR}/mingw-w64-v${CT_WINAPI_VERSION}/mingw-w64-headers/configure" \ + "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-headers/configure" \ --build=${CT_BUILD} \ --host=${CT_TARGET} \ - --prefix=/usr \ + --prefix=${MINGW_INSTALL_PREFIX} \ "${sdk_opts[@]}" CT_DoLog EXTRA "Compile Headers" @@ -45,7 +63,7 @@ do_libc_start_files() { CT_DoLog EXTRA "Installing Headers" CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} - + CT_Popd # It seems mingw is strangely set up to look into /mingw instead of @@ -56,18 +74,35 @@ do_libc_start_files() { CT_EndStep } +do_check_mingw_vendor_tuple() +{ + if [[ ${CT_WINAPI_VERSION} == 4* ]]; then + CT_DoStep INFO "Checking vendor tuple configured in crosstool-ng .config" + if [[ ${CT_TARGET_VENDOR} == w64 ]]; then + CT_DoLog EXTRA "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 team." + else + CT_DoLog WARN "WARNING! The tuple '${CT_TARGET_VENDOR}', is not equal to w64 and might break the toolchain! WARNING!" + fi + CT_EndStep + fi +} + do_libc() { + do_check_mingw_vendor_tuple + CT_DoStep INFO "Building mingw-w64 files" CT_DoLog EXTRA "Configuring mingw-w64-crt" CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt" - CT_DoExecLog CFG \ - "${CT_SRC_DIR}/mingw-w64-v${CT_WINAPI_VERSION}/mingw-w64-crt/configure" \ - --prefix=/usr \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ + do_set_mingw_install_prefix + CT_DoExecLog CFG \ + "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-crt/configure" \ + --with-sysroot=${CT_SYSROOT_DIR} \ + --prefix=${MINGW_INSTALL_PREFIX} \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ CT_DoLog EXTRA "Building mingw-w64-crt" CT_DoExecLog ALL make ${JOBSFLAGS} diff --git a/scripts/build/test_suite/gcc.sh b/scripts/build/test_suite/gcc.sh index 178cffd..c829a43 100644 --- a/scripts/build/test_suite/gcc.sh +++ b/scripts/build/test_suite/gcc.sh @@ -15,10 +15,10 @@ do_test_suite_gcc_build() { CT_DoStep INFO "Installing GCC test suite" CT_DoExecLog ALL mkdir -p "${CT_TEST_SUITE_DIR}/gcc" - CT_DoExecLog ALL cp -av "${CT_LIB_DIR}/contrib/gcc-test-suite/default.cfg" \ - "${CT_LIB_DIR}/contrib/gcc-test-suite/Makefile" \ - "${CT_LIB_DIR}/contrib/gcc-test-suite/README" \ - "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/testsuite" \ + CT_DoExecLog ALL cp -av "${CT_LIB_DIR}/contrib/gcc-test-suite/default.cfg" \ + "${CT_LIB_DIR}/contrib/gcc-test-suite/Makefile" \ + "${CT_LIB_DIR}/contrib/gcc-test-suite/README" \ + "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/testsuite" \ "${CT_TEST_SUITE_DIR}/gcc" CT_DoExecLog ALL sed -i -r -e "s/@@DG_TARGET@@/${CT_TARGET}/g;" \ diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index 53ac552..ab654da 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -143,7 +143,7 @@ CT_DoLog INFO "Building environment variables" . "${CT_LIB_DIR}/scripts/build/companion_libs.sh" . "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh" . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" -. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" +. "${CT_LIB_DIR}/scripts/build/cc.sh" . "${CT_LIB_DIR}/scripts/build/debug.sh" . "${CT_LIB_DIR}/scripts/build/test_suite.sh" @@ -165,8 +165,8 @@ CT_PREFIX_DIR="$( "${sed}" -r -e 's:/+:/:g; s:/*$::;' <<<"${CT_PREFIX_DIR}" )" # Put user-supplied flags at the end, so that they take precedence. CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}" CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}" -CT_CC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_CORE_EXTRA_CONFIG_ARRAY[@]}" ) -CT_CC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_EXTRA_CONFIG_ARRAY[@]}" ) +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" ) +CT_CC_GCC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) # Compute the package version string CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOLCHAIN_PKGVERSION}}" @@ -548,8 +548,8 @@ if [ -z "${CT_RESTART}" ]; then CT_EndStep fi - if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then - CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_CC_STATIC_LIBSTDCXX)" + if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then + CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_CC_GCC_STATIC_LIBSTDCXX)" CT_DoLog DEBUG "You may need to ensure that libstdc++.a is installed on your system" CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST} "${testc}" -static -lstdc++ -o "${gccout}" rm -f "${gccout}" @@ -562,7 +562,7 @@ if [ -z "${CT_RESTART}" ]; then CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration" CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin" CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" - CT_DoExecLog DEBUG sed -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" + CT_DoExecLog DEBUG ${sed} -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" CT_DoStep EXTRA "Dumping internal crosstool-NG configuration" diff --git a/scripts/functions b/scripts/functions index adb9f69..3e3440a 100644 --- a/scripts/functions +++ b/scripts/functions @@ -737,7 +737,7 @@ CT_GetFile() { done # Just return error, someone may want to catch and handle the error - # (eg. glibc/eglibc add-ons can be missing). + # (eg. glibc add-ons can be missing). return 1 } @@ -832,18 +832,43 @@ CT_GetSVN() { # Prerequisites: either the server does not require password, # or the user has already taken any action to authenticate to the server. # The cloned tree will *not* be stored in the local tarballs dir! -# Usage: CT_GetGit <basename> <cset> <url> +# cset_or_ref can be a branch or tag, if specified as 'ref=name' +# In this case, 'git ls-remote' is used to get the sha1 and can also +# be used to get a list valid refs (e.g. HEAD, refs/heads/master, refs/tags/v3.3.0) +# Usage: CT_GetGit <basename> <cset_or_ref> <url> <out_cset> CT_GetGit() { local basename="${1}" - local cset="${2}" + local cset_or_ref="${2}" local url="${3}" - local file="${basename}-${cset}.tar.gz" + local _out_cset="${4}" + + local ref=$(echo "${cset_or_ref}" | sed -n 's/^ref=\(.*\)/\1/p') + if [ -n "$ref" ]; then + local matches=$(git ls-remote --exit-code "$url" --refs "${ref}") + local result=$? + CT_TestAndAbort "Failed to find git ref ${ref} at ${url}" "${result}" != "0" + if [ $( echo "$matches" | wc -l) -gt 1 ]; then + CT_DoLog WARN "Ambiguous ref ${ref} at ${url}, using first" + fi + local cset=$(echo "$matches" | head -n1 | cut -c1-6) + CT_DoLog INFO "ref ${ref} at ${url} has cset of ${cset}" + else + local cset=${cset_or_ref} + CT_DoLog INFO "cset ${cset}" + fi + + if [ -n "${_out_cset}" ]; then + eval ${_out_cset}=\${cset} + fi + local dir="${CT_TARBALLS_DIR}/${basename}-${cset}.git" + local file="${basename}-${cset}.tar.gz" local dest="${CT_TARBALLS_DIR}/${file}" local tmp="${CT_TARBALLS_DIR}/${file}.tmp-dl" - # Do we alreadyhave it? + # Do we already have it? if CT_GetLocal "${file}"; then + echo ${cset} return 0 fi # Nope... @@ -877,6 +902,8 @@ CT_GetGit() { CT_SaveLocal "${dest}" CT_DoExecLog ALL rm -rf "${tmp}.tar.gz" "${tmp}.tar" "${tmp}" "${dir}" CT_Popd + echo ${cset} + return 0 else # Woops... CT_DoExecLog ALL rm -rf "${dir}" diff --git a/scripts/gen_in_frags.sh b/scripts/gen_in_frags.sh index 2451495..9c656a8 100755 --- a/scripts/gen_in_frags.sh +++ b/scripts/gen_in_frags.sh @@ -138,6 +138,9 @@ gen_menu() { _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;') printf 'menuconfig %s_%s\n' "${cfg_prefix}" "${_entry}" printf ' bool\n' + if "${grep}" -E '^## default' ${file} >/dev/null 2>&1; then + "${sed}" -r -e '/^## default ?/!d; s/^## default ?/ default /;' ${file} 2>/dev/null + fi printf ' prompt "%s"\n' "${entry}" "${sed}" -r -e '/^## depends on /!d; s/^## / /;' ${file} 2>/dev/null "${sed}" -r -e '/^## select /!d; s/^## / /;' ${file} 2>/dev/null diff --git a/scripts/populate.in b/scripts/populate.in index 9aa3ee9..8f476e3 100644 --- a/scripts/populate.in +++ b/scripts/populate.in @@ -184,13 +184,13 @@ do_add_lib() { local dir local mode - for dir in lib usr/lib; do + for dir in lib usr/lib usr/lib/gconv; do if [ -e "${dir}/${libname}" ]; then ${CT_PRINTF} " already present\n" return 0 fi done - for dir in lib usr/lib; do + for dir in lib usr/lib usr/lib/gconv; do ${CT_PRINTF} " trying in '%s'" "${dir}" libfile="${CT_SYSROOT_DIR}/${dir}/${libname}" ${CT_PRINTF} ": '%s'\n" "${libfile}" diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh.in index 792f033..34e6594 100644 --- a/scripts/saveSample.sh.in +++ b/scripts/saveSample.sh.in @@ -89,8 +89,8 @@ cp .config .defconfig CT_DoAddFileToSample() { source="$1" dest="$2" - inode_s=$(ls -i "${source}" |awk '{ print $1; }') - inode_d=$(ls -i "${dest}" 2>/dev/null |awk '{ print $1; }' || true) + inode_s=$(ls -i "${source}" | ${awk} '{ print $1; }') + inode_d=$(ls -i "${dest}" 2>/dev/null | ${awk} '{ print $1; }' || true) if [ "${inode_s}" != "${inode_d}" ]; then cp "${source}" "${dest}" fi @@ -132,7 +132,7 @@ read -p "Reporter name [${reporter_name}]: " reporter_name read -p "Reporter URL [${reporter_url}]: " reporter_url if [ -n "${reporter_comment}" ]; then echo "Old comment:" - printf "${reporter_comment}\n" |sed -r -e 's/^/ > /;' + printf "${reporter_comment}\n" | ${sed} -r -e 's/^/ > /;' fi echo "Reporter comment (Ctrl-D to finish, '.' to use previous):" reporter_comment=$(cat) diff --git a/scripts/showSamples.sh b/scripts/showSamples.sh index ccb8382..684e118 100755 --- a/scripts/showSamples.sh +++ b/scripts/showSamples.sh @@ -76,7 +76,15 @@ dump_single_sample() { [ -z "${CT_LIBELF}" -a -z "${CT_LIBELF_TARGET}" ] || printf " libelf-%s" "${CT_LIBELF_VERSION}" [ -z "${complibs}" ] || printf "\n" printf " %-*s : %s\n" ${width} "binutils" "binutils-${CT_BINUTILS_VERSION}" - printf " %-*s : %s" ${width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C" + printf " %-*s :" ${width} "C compilers" + for cc in $(env | ${sed} -n 's/^CT_CC_\(.*\)_VERSION.*/\1/p'); do + cc_variable=CT_CC_${cc}_VERSION + version=${!cc_variable} + compiler=$(echo $cc | ${awk} '{print tolower($0)}') + printf " $compiler-$version" + done + printf "\n" + printf " %-*s : %s" ${width} "Languages" "C" [ "${CT_CC_LANG_CXX}" = "y" ] && printf ",C++" [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran" [ "${CT_CC_LANG_JAVA}" = "y" ] && printf ",Java" @@ -85,7 +93,7 @@ dump_single_sample() { [ "${CT_CC_LANG_OBJCXX}" = "y" ] && printf ",Objective-C++" [ "${CT_CC_LANG_GOLANG}" = "y" ] && printf ",Go" [ -n "${CT_CC_LANG_OTHERS}" ] && printf ",${CT_CC_LANG_OTHERS}" - printf ")\n" + printf "\n" printf " %-*s : %s (threads: %s)\n" ${width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}" "${CT_THREADS}" printf " %-*s :" ${width} "Tools" [ "${CT_TOOL_sstrip}" ] && printf " sstrip" @@ -103,7 +111,7 @@ dump_single_sample() { ;; canadian) printf "| ''" - printf "${sample}" |sed -r -e 's/.*,//' + printf "${sample}" |${sed} -r -e 's/.*,//' printf "'' | ${CT_HOST} " ;; *) ;; @@ -120,8 +128,14 @@ dump_single_sample() { fi fi printf "| ${CT_BINUTILS_VERSION} " - printf "| ''${CT_CC}'' " - printf "| ${CT_CC_VERSION} " + printf "| " + for cc in $(env | ${sed} -n 's/^CT_CC_\(.*\)_VERSION.*/\1/p'); do + cc_variable=CT_CC_${cc}_VERSION + version=${!cc_variable} + compiler=$(echo $cc | ${awk} '{print tolower($0)}') + printf " $compiler-$version" + done + printf " " printf "| ''${CT_LIBC}'' |" if [ "${CT_LIBC}" != "none" ]; then printf " ${CT_LIBC_VERSION} " @@ -149,7 +163,7 @@ dump_single_sample() { fi ) sample_updated="$( git log -n1 --pretty=format:'%ci' "${sample_top}/samples/${sample}" \ - |awk '{ print $1; }' )" + |${awk} '{ print $1; }' )" printf "| ${sample_updated} " echo "|" fi |