diff options
Diffstat (limited to 'scripts')
94 files changed, 9330 insertions, 6000 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore deleted file mode 100644 index 7abc2a7..0000000 --- a/scripts/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -crosstool-NG.sh -saveSample.sh -showConfig.sh -scripts.mk diff --git a/scripts/addToolVersion.sh b/scripts/addToolVersion.sh deleted file mode 100755 index dbd1243..0000000 --- a/scripts/addToolVersion.sh +++ /dev/null @@ -1,237 +0,0 @@ -#!/bin/sh -set -e - -# Adds a new version to one of the toolchain component -myname="$0" - -# Parse the tools' paths configuration -# It is expected that this script is only to be run from the -# source directory of crosstool-NG, so it is trivial to find -# paths.sh (we can't use ". paths.sh", as POSIX states that -# $PATH should be searched for, and $PATH most probably doe -# not include "."), hence the "./". -. "./paths.sh" - -doHelp() { - cat <<-EOF - Usage: ${myname} <--tool> <[options] version [...]> ... - 'tool' in one of: - gcc, binutils, glibc, uClibc, uClibc-ng, newlib, linux, gdb, - duma, strace, ltrace, libelf, gmp, mpfr, isl, cloog, mpc, - mingw-w64, expat, ncurses, musl, gettext, zlib - - Valid options for all tools: - --stable, -s, +x (default) - mark the version as being stable (as opposed to experimental, below) - - --experimental, -x, +s - mark the version as being experimental (as opposed to stable, above) - - --current, -c, +o (default) - mark the version as being cuurent (as opposed to obsolete, below) - - --obsolete, -o, +c - mark the version as being obsolete (as opposed to current, above) - - Note: setting a new tool resets to the defaults: 'stable' and 'current'. - - 'version' is a valid version for the specified tool. - - Examples: - add stable current version 2.6.19.2 to linux kernel: - ${myname} --linux 2.6.19.2 - - add experimental obsolete version 2.3.5 and stable current versions 2.6.1 - and 2.6.2 to glibc, add stable obsolete version 3.3.3 to gcc: - ${myname} --glibc -x -o 2.3.5 -s -c 2.6.1 2.6.2 --gcc -o 3.3.3 -EOF -} - -# Extract field $3 from version $1 with separator $2 -getVersionField() { - local version="$1" - local sep="$2" - local field="$3" - - echo "${version}${sep}${sep}${sep}${sep}" |cut -d ${sep} -f ${field} -} - -# Effectively add a version to the specified tool -# $cat : tool category -# $tool : tool name -# $tool_prefix : tool directory prefix -# $EXP : set to non empty if experimental, to empty otherwise -# OBS : set to non empty if obsolete, to empty otherwise -# $1 : version string to add -addToolVersion() { - local version="$1" - local file="$2" - local config_ver_option - local exp_obs_prompt - local deps v ver_M ver_m ver_p - local SedExpr1 SedExpr2 - - [ -f "${file}" ] || return 0 - - v=$(echo "${version}" |"${sed}" -r -e 's/-/_/g; s/\./_/g;') - - config_ver_option="${cat}_V_${v}" - - # Check for existing version: it can be legitimitate for an end-user - # 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 - echo "'${tool}': version '${version}' already present:" - ${grep} -A1 -B0 -n \ - -E "^(config ${config_ver_option}| {4}prompt \"${version}\")$" \ - "${file}" /dev/null - return 0 - fi - - SedExpr1="${SedExpr1}config ${config_ver_option}\n" - SedExpr1="${SedExpr1} bool\n" - SedExpr1="${SedExpr1} prompt \"${version}" - case "${EXP},${OBS}" in - ,) ;; - ,*) exp_obs_prompt=" (OBSOLETE)" - deps=" depends on OBSOLETE" - ;; - *,) exp_obs_prompt=" (EXPERIMENTAL)" - deps=" depends on EXPERIMENTAL" - ;; - *) exp_obs_prompt=" (EXPERIMENTAL, OBSOLETE)" - deps=" depends on EXPERIMENTAL \\&\\& OBSOLETE" - ;; - esac - [ -n "${exp_obs_prompt}" ] && SedExpr1="${SedExpr1}${exp_obs_prompt}" - SedExpr1="${SedExpr1}\"" - [ -n "${deps}" ] && SedExpr1="${SedExpr1}\n${deps}" - case "${tool}" in - gcc) - # Extract 'M'ajor and 'm'inor from version string - ver_M=$(getVersionField "${version}" . 1) - ver_m=$(getVersionField "${version}" . 2) - if [ ${ver_M} -ge 4 ] && [ ${ver_m} -ge 2 ]; then - SedExpr1="${SedExpr1}\n select CC_GCC_${ver_M}_${ver_m}" - fi - ;; - binutils) - # Extract 'M'ajor, 'm'inor, sometimes 'p'atch from version string - # TODO: Rework this - ver_M=$(getVersionField "${version}" . 1) - ver_m=$(getVersionField "${version}" . 2) - ver_p=$(getVersionField "${version}" . 3) - if [ ${ver_M} -eq 2 -a ${ver_m} -eq 27 ]; then - SedExpr1="${SedExpr1}\n select BINUTILS_2_27_or_later" - elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 26 ]; then - SedExpr1="${SedExpr1}\n select BINUTILS_2_26_or_later" - elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 25 -a ${ver_p} -eq 1 ]; then - SedExpr1="${SedExpr1}\n select BINUTILS_2_25_1_or_later" - elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 25 -a -z ${ver_p} ]; then - SedExpr1="${SedExpr1}\n select BINUTILS_2_25_or_later" - elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 24 ]; then - SedExpr1="${SedExpr1}\n select BINUTILS_2_24_or_later" - elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 23 -a ${ver_p} -eq 2 ]; then - SedExpr1="${SedExpr1}\n select BINUTILS_2_23_2_or_later" - fi - ;; - uClibc) - # uClibc-0.9.33.2 needs some love - ver_M=$(getVersionField "${version}" . 1) - ver_m=$(getVersionField "${version}" . 2) - ver_p=$(getVersionField "${version}" . 3) - if [ ${ver_M} -eq 0 -a ${ver_m} -eq 9 -a ${ver_p} -eq 33 ]; then - SedExpr1="${SedExpr1}\n select LIBC_UCLIBC_0_9_33_2_or_later" - fi - ;; - uClibc-ng) - # uClibc-ng-1.0.15 changed threading configuration, no longer compatible - # with the rest of uClibc gang. - ver_M=$(getVersionField "${version}" . 1) - ver_m=$(getVersionField "${version}" . 2) - ver_p=$(getVersionField "${version}" . 3) - if [ ${ver_M} -eq 1 -a ${ver_m} -eq 0 -a ${ver_p} -eq 15 ]; then - SedExpr1="${SedExpr1}\n select LIBC_UCLIBC_NG_1_0_15_or_later" - fi - ;; - gdb) - # gdb-7.0 and above have special handling - ver_M=$(getVersionField "${version}" . 1) - ver_m=$(getVersionField "${version}" . 2) - if [ ${ver_M} -ge 7 ]; then - if [ ${ver_m} -ge 2 ]; then - SedExpr1="${SedExpr1}\n select GDB_7_2_or_later" - else - SedExpr1="${SedExpr1}\n select GDB_7_0_or_later" - fi - fi - ;; - esac - SedExpr2=" default \"${version}\" if ${config_ver_option}" - "${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_BELOW)$/\1\n\n'"${SedExpr1}"'/;' "${file}" - "${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_STRING_BELOW)$/\1\n'"${SedExpr2}"'/;' "${file}" -} - -cat= -tool= -tool_prefix= -VERSION= -EXP= -OBS= - -if [ $# -eq 0 ]; then - doHelp - exit 1 -fi - -while [ $# -gt 0 ]; do - case "$1" in - # Tools: - --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=;; - --uClibc) EXP=; OBS=; cat=LIBC_UCLIBC; tool=uClibc; tool_prefix=libc; dot2suffix=;; - --uClibc-ng)EXP=; OBS=; cat=LIBC_UCLIBC_NG; tool=uClibc; tool_prefix=libc; dot2suffix=;; - --newlib) EXP=; OBS=; cat=LIBC_NEWLIB; tool=newlib; tool_prefix=libc; dot2suffix=;; - --mingw-w64)EXP=; OBS=; cat=WINAPI; tool=mingw; tool_prefix=libc; dot2suffix=;; - --musl) EXP=; OBS=; cat=LIBC_MUSL; tool=musl; tool_prefix=libc; dot2suffix=;; - --linux) EXP=; OBS=; cat=KERNEL; tool=linux; tool_prefix=kernel; dot2suffix=;; - --gdb) EXP=; OBS=; cat=GDB; tool=gdb; tool_prefix=debug; dot2suffix=;; - --duma) EXP=; OBS=; cat=DUMA; tool=duma; tool_prefix=debug; dot2suffix=;; - --strace) EXP=; OBS=; cat=STRACE; tool=strace; tool_prefix=debug; dot2suffix=;; - --ltrace) EXP=; OBS=; cat=LTRACE; tool=ltrace; tool_prefix=debug; dot2suffix=;; - --gmp) EXP=; OBS=; cat=GMP; tool=gmp; tool_prefix=companion_libs; dot2suffix=;; - --mpfr) EXP=; OBS=; cat=MPFR; tool=mpfr; tool_prefix=companion_libs; dot2suffix=;; - --isl) EXP=; OBS=; cat=ISL; tool=isl; tool_prefix=companion_libs; dot2suffix=;; - --cloog) EXP=; OBS=; cat=CLOOG; tool=cloog; tool_prefix=companion_libs; dot2suffix=;; - --mpc) EXP=; OBS=; cat=MPC; tool=mpc; tool_prefix=companion_libs; dot2suffix=;; - --libelf) EXP=; OBS=; cat=LIBELF; tool=libelf; tool_prefix=companion_libs; dot2suffix=;; - --expat) EXP=; OBS=; cat=EXPAT; tool=expat; tool_prefix=companion_libs; dot2suffix=;; - --ncurses) EXP=; OBS=; cat=NCURSES; tool=ncurses; tool_prefix=companion_libs; dot2suffix=;; - --gettext) EXP=; OBS=; cat=GETTEXT; tool=gettext; tool_prefix=companion_libs; dot2suffix=;; - --zlib) EXP=; OBS=; cat=ZLIB; tool=zlib; tool_prefix=companion_tools; dot2suffix=;; - --make) EXP=; OBS=; cat=MAKE; tool=make; tool_prefix=companion_tools; dot2suffix=;; - --m4) EXP=; OBS=; cat=M4; tool=m4; tool_prefix=companion_tools; dot2suffix=;; - --autoconf) EXP=; OBS=; cat=AUTOCONF; tool=autoconf; tool_prefix=companion_tools; dot2suffix=;; - --automake) EXP=; OBS=; cat=AUTOMAKE; tool=automake; tool_prefix=companion_tools; dot2suffix=;; - --libtool) EXP=; OBS=; cat=LIBTOOL; tool=libtool; tool_prefix=companion_tools; dot2suffix=;; - - # Tools options: - -x|--experimental|+s) EXP=1;; - -s|--stable|+x) EXP=;; - -o|--obsolete|+c) OBS=1;; - -c|--current|+o) OBS=;; - - # Misc: - -h|--help) doHelp; exit 0;; - -*) echo "Unknown option: '$1' (use -h/--help for help)."; exit 1;; - - # Version string: - *) [ -n "${tool}" ] || { doHelp; exit 1; } - file_base="config/${tool_prefix}/${tool}.in" - addToolVersion "$1" "${file_base}${dot2suffix}" - ;; - esac - shift -done diff --git a/scripts/build/arch.sh b/scripts/build/arch.sh index 75d3e21..e7a2efe 100644 --- a/scripts/build/arch.sh +++ b/scripts/build/arch.sh @@ -1,20 +1,36 @@ # This file provides the default implementations of arch-specific functions. # Set up the target tuple -CT_DoArchTupleValues() { - :; +CT_DoArchTupleValues() +{ + : +} + +# Adjust the list of multilibs for the target +CT_DoArchMultilibList() +{ + : } # Multilib: change the target triplet according to CFLAGS # Usage: CT_DoArchGlibcAdjustTuple <variable-name> <CFLAGS> -CT_DoArchMultilibTarget() { - :; +CT_DoArchMultilibTarget() +{ + : } # Multilib: Adjust target tuple for GLIBC # Usage: CT_DoArchGlibcAdjustTuple <variable-name> -CT_DoArchGlibcAdjustTuple() { - :; +CT_DoArchGlibcAdjustTuple() +{ + : +} + +# Multilib: Adjust configure arguments for GLIBC +# Usage: CT_DoArchGlibcAdjustConfigure <configure-args-array-name> <cflags> +CT_DoArchGlibcAdjustConfigure() +{ + : } # Helper for uClibc configurators: select the architecture @@ -30,20 +46,22 @@ CT_DoArchUClibcSelectArch() { # uClibc: Adjust configuration file according to the CT-NG configuration # Usage: CT_DoArchUClibcConfig <config-file> -CT_DoArchUClibcConfig() { +CT_DoArchUClibcConfig() +{ CT_DoLog WARN "Support for '${CT_ARCH}' is not implemented in uClibc config tweaker." CT_DoLog WARN "Exact configuration file must be provided." } # Multilib/uClibc: Adjust configuration file for given CFLAGS # Usage: CT_DoArchUClibcCflags <config-file> <cflags> -CT_DoArchUClibcCflags() { +CT_DoArchUClibcCflags() +{ local cfg="${1}" local cflags="${2}" # Likely, any non-default cflags need to be reflected into the config. # It may work if we just pass them into EXTRA_CFLAGS, but we have no - # idea as they might interact with the CFLAGS inferred by uClibc from + # idea how they might interact with the CFLAGS inferred by uClibc from # the configuration file. if [ "${cflags}" != "" ]; then CT_DoLog WARN "Multilib configuration not supported for uClibc/${CT_ARCH}" @@ -52,21 +70,24 @@ CT_DoArchUClibcCflags() { # Multilib/uClibc: Adjust header installation path for given CFLAGS # Usage: CT_DoArchUClibcHeaderDir <path-variable> <cflags> -CT_DoArchUClibcHeaderDir() { +CT_DoArchUClibcHeaderDir() +{ # Only needed if a given architecture may select different uClibc architectures. - :; + : } # Multilib/MUSL: Adjust header installation path for given CFLAGS # Usage: CT_DoArchMUSLHeaderDir <path-variable> <cflags> -CT_DoArchMUSLHeaderDir() { +CT_DoArchMUSLHeaderDir() +{ # Only needed if a given architecture may select different MUSL architectures. - :; + : } # MUSL: Perform any final adjustments on the installed libc/headers -CT_DoArchMUSLPostInstall() { - :; +CT_DoArchMUSLPostInstall() +{ + : } # Override from the actual arch implementation as needed. diff --git a/scripts/build/arch/arc.sh b/scripts/build/arch/arc.sh new file mode 100644 index 0000000..2312c77 --- /dev/null +++ b/scripts/build/arch/arc.sh @@ -0,0 +1,50 @@ +# Compute ARC-specific values + +CT_DoArchTupleValues() +{ + # The architecture part of the tuple: + CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX:-${target_endian_eb}}" +} + +CT_DoArchUClibcConfig() +{ + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "arc" +} + +# Multilib: Adjust configure arguments for GLIBC +# Usage: CT_DoArchGlibcAdjustConfigure <configure-args-array-name> <cflags> +# +# From GCC's standpoint ARC's multilib items are defined by "mcpu" values +# which we have quite a few and for all of them might be built optimized +# cross-toolchain. +# +# From Glibc's standpoint multilib is multi-ABI and so very limited +# versions are supposed to co-exist. +# +# Here we force Glibc to install libraries in per-multilib folder to create +# a universal cross-toolchain that has libs optimized for multiple CPU types. +CT_DoArchGlibcAdjustConfigure() { + local -a add_args + local array="${1}" + local cflags="${2}" + local opt + local mcpu + + # If building for multilib, set proper installation paths + if [ "${CT_MULTILIB}" = "y" ]; then + for opt in ${cflags}; do + case "${opt}" in + -mcpu=*) + mcpu="${opt#*=}" + add_args+=( "libc_cv_rtlddir=/lib/${mcpu}" ) + add_args+=( "libc_cv_slibdir=/lib/${mcpu}" ) + add_args+=( "--libdir=/usr/lib/${mcpu}" ) + ;; + esac + done + fi + + eval "${array}+=( \"\${add_args[@]}\" )" +} diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh index eeffc7d..01a40bd 100644 --- a/scripts/build/arch/arm.sh +++ b/scripts/build/arch/arm.sh @@ -15,9 +15,10 @@ CT_DoArchTupleValues() { # The system part of the tuple: case "${CT_LIBC},${CT_ARCH_ARM_EABI}" in - *glibc,y) CT_TARGET_SYS=gnueabi;; - uClibc,y) CT_TARGET_SYS=uclibc${CT_LIBC_UCLIBC_USE_GNU_SUFFIX:+gnu}eabi;; + glibc,y) CT_TARGET_SYS=gnueabi;; + uClibc-ng,y)CT_TARGET_SYS=uclibc${CT_LIBC_UCLIBC_USE_GNU_SUFFIX:+gnu}eabi;; musl,y) CT_TARGET_SYS=musleabi;; + bionic,y) CT_TARGET_SYS=androideabi;; *,y) CT_TARGET_SYS=eabi;; esac @@ -69,6 +70,7 @@ CT_DoArchUClibcConfig() { ;; thumb) CT_KconfigEnableOption "COMPILE_IN_THUMB_MODE" "${cfg}" + CT_KconfigDisableOption "UCLIBC_HAS_CONTEXT_FUNCS" "${cfg}" ;; esac # FIXME: CONFIG_ARM_OABI does not exist in neither uClibc/uClibc-ng @@ -95,6 +97,7 @@ CT_DoArchUClibcCflags() { case "${f}" in -mthumb) CT_KconfigEnableOption "COMPILE_IN_THUMB_MODE" "${cfg}" + CT_KconfigDisableOption "UCLIBC_HAS_CONTEXT_FUNCS" "${cfg}" ;; -marm) CT_KconfigDisableOption "COMPILE_IN_THUMB_MODE" "${cfg}" diff --git a/scripts/build/arch/c6x.sh b/scripts/build/arch/c6x.sh new file mode 100644 index 0000000..3eb40e4 --- /dev/null +++ b/scripts/build/arch/c6x.sh @@ -0,0 +1,79 @@ +# Compute c6x-specific values + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "c6x" +} + +CT_DoArchTupleValues() { + CT_TARGET_ARCH="tic6x" + #binutils does not like uclibc in the tuple + if [ "${CT_TARGET_SYS}" = "uclibc" ]; then + CT_TARGET_SYS= + fi +} + +CT_DoArchUClibcHeaderDir() { + local dir_var="${1}" + local cflags="${2}" + + # If it is non-default multilib, add a suffix with architecture (reported by gcc) + # to the headers installation path. + if [ -n "${cflags}" ]; then + eval "${dir_var}="$( ${CT_TARGET}-${CT_CC} -print-multiarch ${cflags} ) + fi +} + +CT_DoArchUClibcCflags() { + local cfg="${1}" + local cflags="${2}" + local f + + # Set default little endian options + CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${cfg}" + CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${cfg}" + CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${cfg}" + CT_KconfigEnableOption "ARCH_WANTS_LITTLE_ENDIAN" "${cfg}" + + # Set arch options based on march switch + CT_KconfigDisableOption "CONFIG_TMS320C674X" "${cfg}" + CT_KconfigDisableOption "CONFIG_TMS320C64XPLUS" "${cfg}" + CT_KconfigDisableOption "CONFIG_TMS320C64X" "${cfg}" + CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}" + CT_KconfigEnableOption "CONFIG_GENERIC_C6X" "${cfg}" + + for f in ${cflags}; do + case "${f}" in + -march=*) + case "${f#-march=}" in + c674x) + CT_KconfigEnableOption "CONFIG_TMS320C674X" "${cfg}" + CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}" + CT_KconfigDisableOption "CONFIG_GENERIC_C6X" "${cfg}" + ;; + c64x+) + CT_KconfigEnableOption "CONFIG_TMS320C64XPLUS" "${cfg}" + CT_KconfigDisableOption "CONFIG_GENERIC_C6X" "${cfg}" + ;; + c64x) + CT_KconfigEnableOption "CONFIG_TMS320C64X" "${cfg}" + CT_KconfigDisableOption "CONFIG_GENERIC_C6X" "${cfg}" + ;; + c67x) + CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}" + ;; + c62x) + ;; + *) CT_Abort "Unsupported architecture: ${f#-march=}";; + esac + ;; + -mbig-endian) + CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${cfg}" + CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${cfg}" + CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${cfg}" + CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${cfg}" + ;; + esac + done +} diff --git a/scripts/build/arch/microblaze.sh b/scripts/build/arch/microblaze.sh index e9d9811..5b85012 100644 --- a/scripts/build/arch/microblaze.sh +++ b/scripts/build/arch/microblaze.sh @@ -3,21 +3,6 @@ CT_DoArchTupleValues () { # The architecture part of the tuple: CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX:-${target_endian_el}}" - - # gcc ./configure flags - CT_ARCH_WITH_ARCH= - CT_ARCH_WITH_ABI= - CT_ARCH_WITH_CPU= - CT_ARCH_WITH_TUNE= - CT_ARCH_WITH_FPU= - CT_ARCH_WITH_FLOAT= - - # CFLAGS - case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in - y,) CT_ARCH_FLOAT_CFLAG="-mhard-float" ;; - ,y) CT_ARCH_FLOAT_CFLAG="-msoft-float" ;; - esac - } CT_DoArchUClibcConfig() { diff --git a/scripts/build/arch/mips.sh b/scripts/build/arch/mips.sh index f91a80a..acb8851 100644 --- a/scripts/build/arch/mips.sh +++ b/scripts/build/arch/mips.sh @@ -48,6 +48,17 @@ CT_DoArchUClibcConfig() { CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64R2" "${cfg}" } +CT_DoArchUClibcHeaderDir() { + local dir_var="${1}" + local cflags="${2}" + + # If it is non-default multilib, add a suffix with architecture (reported by gcc) + # to the headers installation path. + if [ -n "${cflags}" ]; then + eval "${dir_var}="$( ${CT_TARGET}-${CT_CC} -print-multiarch ${cflags} ) + fi +} + CT_DoArchUClibcCflags() { local cfg="${1}" local cflags="${2}" diff --git a/scripts/build/arch/moxie.sh b/scripts/build/arch/moxie.sh new file mode 100644 index 0000000..9545d19 --- /dev/null +++ b/scripts/build/arch/moxie.sh @@ -0,0 +1,16 @@ +# Moxie-specific arch callbacks + +# No arch-specific overrides yet +CT_DoArchTupleValues() +{ + case "${CT_ARCH_ENDIAN}" in + big) CT_ARCH_ENDIAN_CFLAG=-meb;; + little) CT_ARCH_ENDIAN_CFLAG=-mel;; + esac + + case "${CT_LIBC}" in + moxiebox) + CT_TARGET_SYS=moxiebox + ;; + esac +} diff --git a/scripts/build/arch/msp430.sh b/scripts/build/arch/msp430.sh new file mode 100644 index 0000000..8edb72a --- /dev/null +++ b/scripts/build/arch/msp430.sh @@ -0,0 +1,5 @@ +# Compute MSP430-specific values + +CT_DoArchTupleValues() { + CT_TARGET_ARCH="${CT_ARCH}" +} diff --git a/scripts/build/arch/nios2.sh b/scripts/build/arch/nios2.sh index 24c556b..afd73ec 100644 --- a/scripts/build/arch/nios2.sh +++ b/scripts/build/arch/nios2.sh @@ -1,12 +1,6 @@ # Compute NIOS2-specific values CT_DoArchTupleValues() { - # gcc ./configure flags - CT_ARCH_WITH_ARCH= - CT_ARCH_WITH_ABI= - CT_ARCH_WITH_CPU= - CT_ARCH_WITH_TUNE= - CT_ARCH_WITH_FPU= - CT_ARCH_WITH_FLOAT= - CT_TARGET_SYS=elf + # Do nothing here. Default values are sane. + :; } diff --git a/scripts/build/arch/powerpc.sh b/scripts/build/arch/powerpc.sh index 52f3f8b..245adbe 100644 --- a/scripts/build/arch/powerpc.sh +++ b/scripts/build/arch/powerpc.sh @@ -7,23 +7,23 @@ CT_DoArchTupleValues () { # Only override values when ABI is not the default case "${CT_ARCH_powerpc_ABI}" in eabi) - # EABI is only for bare-metal, so libc ∈ [none,newlib] + # EABI is only for bare-metal, so libc ∈ [none,newlib,picolibc] CT_TARGET_SYS="eabi" ;; spe) case "${CT_LIBC}" in - none|newlib) CT_TARGET_SYS="spe";; + none|newlib|picolibc) CT_TARGET_SYS="elfspe";; *glibc) CT_TARGET_SYS="gnuspe";; - uClibc) CT_TARGET_SYS="uclibcgnuspe";; + uClibc-ng) CT_TARGET_SYS="uclibcgnuspe";; esac ;; esac - # Add extra flags for SPE if needed + # Add extra flags for SPE if needed. SPE is obsolete in GCC8. if [ "${CT_ARCH_powerpc_ABI_SPE}" = "y" ]; then CT_ARCH_TARGET_CFLAGS="-mabi=spe -mspe" - CT_ARCH_CC_CORE_EXTRA_CONFIG="--enable-e500_double" - CT_ARCH_CC_EXTRA_CONFIG="--enable-e500_double" + CT_ARCH_CC_CORE_EXTRA_CONFIG="--enable-e500_double --enable-obsolete" + CT_ARCH_CC_EXTRA_CONFIG="--enable-e500_double --enable-obsolete" fi } diff --git a/scripts/build/arch/pru.sh b/scripts/build/arch/pru.sh new file mode 100644 index 0000000..c4d61ce --- /dev/null +++ b/scripts/build/arch/pru.sh @@ -0,0 +1,5 @@ +# Compute PRU-specific values + +CT_DoArchTupleValues() { + CT_TARGET_ARCH="${CT_ARCH}" +} diff --git a/scripts/build/arch/riscv.sh b/scripts/build/arch/riscv.sh new file mode 100644 index 0000000..a0a5ba4 --- /dev/null +++ b/scripts/build/arch/riscv.sh @@ -0,0 +1,5 @@ +# Compute RISC-V-specific values + +CT_DoArchTupleValues() { + CT_TARGET_ARCH="riscv${CT_ARCH_BITNESS}" +} diff --git a/scripts/build/arch/sh.sh b/scripts/build/arch/sh.sh index 6761435..8339b94 100644 --- a/scripts/build/arch/sh.sh +++ b/scripts/build/arch/sh.sh @@ -1,50 +1,171 @@ # Compute sh-specific values CT_DoArchTupleValues () { - # The architecture part of the tuple: - CT_TARGET_ARCH="${CT_ARCH_SH_VARIANT}${CT_ARCH_SUFFIX:-${target_endian_eb}}" - - # gcc ./configure flags - CT_ARCH_WITH_ARCH= - CT_ARCH_WITH_ABI= - CT_ARCH_WITH_CPU= - CT_ARCH_WITH_TUNE= - CT_ARCH_WITH_FPU= - CT_ARCH_WITH_FLOAT= - - # Endianness stuff + # The architecture part of the tuple. Binutils do not accept specifications + # like 'sheb-unknown-elf' even though GCC does. So keep the tuple just sh-*-elf + # unless user wants something specific (either CPU or explicit suffix). + if [ "${CT_ARCH_SH_VARIANT}" != "sh" -o -n "${CT_ARCH_SUFFIX}" ]; then + CT_TARGET_ARCH="${CT_ARCH_SH_VARIANT}${CT_ARCH_SUFFIX:-${target_endian_eb}}" + fi + + # Endianness stuff (uses non-standard CFLAGS). If both are compiled, let the + # compiler's default or multilib iterator be used. case "${CT_ARCH_ENDIAN}" in big) CT_ARCH_ENDIAN_CFLAG=-mb;; little) CT_ARCH_ENDIAN_CFLAG=-ml;; esac - # CFLAGS + # Instead of -m{soft,hard}-float, uses CPU type + CT_ARCH_FLOAT_CFLAG= case "${CT_ARCH_SH_VARIANT}" in sh3) CT_ARCH_ARCH_CFLAG=-m3;; - sh4*) + sh4*|sh2*) # softfp is not possible for SuperH, no need to test for it. case "${CT_ARCH_FLOAT}" in hard) - CT_ARCH_ARCH_CFLAG="-m4${CT_ARCH_SH_VARIANT##sh?}" + CT_ARCH_ARCH_CFLAG="-m${CT_ARCH_SH_VARIANT##sh}" ;; soft) - CT_ARCH_ARCH_CFLAG="-m4${CT_ARCH_SH_VARIANT##sh?}-nofpu" + CT_ARCH_ARCH_CFLAG="-m${CT_ARCH_SH_VARIANT##sh}-nofpu" ;; esac ;; esac - CT_ARCH_FLOAT_CFLAG= +} + +CT_DoArchMultilibList() { + local save_ifs="${IFS}" + local new + local x + + # In a configuration for SuperH, GCC list of multilibs shall not include + # the default CPU. E.g. if configuring for sh4-*-*, we need to remove + # "sh4" or "m4" from the multilib list. Otherwise, the resulting compiler + # will fail when that CPU is selected explicitly "sh4-multilib-linux-gnu-gcc -m4 ..." + # as it will fail to find the sysroot with that suffix. This applies to both + # the CPU type inferred from the target tuple (CT_ARCH_SH_VARIANT) as well as + # the default CPU configured with --with-cpu (CT_ARCH_CPU). + IFS=, + for x in ${CT_CC_GCC_MULTILIB_LIST}; do + if [ "${x}" = "${CT_ARCH_SH_VARIANT}" -o "sh${x#m}" = "${CT_ARCH_SH_VARIANT}" ]; then + CT_DoLog WARN "Ignoring '${x}' in multilib list: it is the default multilib" + continue + fi + if [ "${x}" = "${CT_ARCH_CPU}" -o "sh${x#m}" = "${CT_ARCH_CPU}" ]; then + CT_DoLog WARN "Ignoring '${x}' in multilib list: it is the default multilib" + continue + fi + new="${new:+${new},}${x}" + done + IFS="${save_ifs}" + CT_CC_GCC_MULTILIB_LIST="${new}" + CT_DoLog DEBUG "Adjusted CT_CC_GCC_MULTILIB_LIST to '${CT_CC_GCC_MULTILIB_LIST}'" +} + +#------------------------------------------------------------------------------ +# Get multilib architecture-specific target +# Usage: CT_DoArchMultilibTarget "target variable" "multilib flags" +CT_DoArchMultilibTarget () +{ + local target_var="${1}"; shift + local -a multi_flags=( "$@" ) + local target_ + local newcpu + + for m in "${multi_flags[@]}"; do + case "${m}" in + -m4*) newcpu=sh4;; + -m3*) newcpu=sh3;; + -m2*) newcpu=sh2;; + -m1*) newcpu=sh1;; + esac + done + + eval target_=\"\${${target_var}}\" + + # Strip CPU name and append the new one if an option has been seen. + if [ -n "${newcpu}" ]; then + target_="${newcpu}-${target_#*-}" + fi + + # Set the target variable + eval ${target_var}=\"${target_}\" +} + +# Adjust target tuple for GLIBC +CT_DoArchGlibcAdjustTuple() { + local target_var="${1}" + local target_ + + eval target_=\"\${${target_var}}\" + + case "${target_}" in + sh-*) + # Glibc does not build unless configured with 'shX-*' tuple. + # Since we ended up here, no architecture variant has been + # specified, so the only source of default is CT_ARCH_CPU. + # GCC defaults to sh1, but this Glibc cannot compile for it. + if [ -n "${CT_ARCH_CPU}" ]; then + target_=${target_/#sh-/${CT_ARCH_CPU}-} + CT_DoLog DEBUG "Adjusted target tuple ${target_}" + else + CT_Abort "GNU C library cannot build for sh1 (GCC default). " \ + "Specify architecture variant or the default CPU type." + fi + ;; + esac + + # Set the target variable + eval ${target_var}=\"${target_}\" +} + +# Multilib: Adjust configure arguments for GLIBC +# Usage: CT_DoArchGlibcAdjustConfigure <configure-args-array-name> <cflags> +CT_DoArchGlibcAdjustConfigure() { + local -a add_args + local array="${1}" + local cflags="${2}" + local opt + + for opt in ${cflags}; do + case "${opt}" in + -m[1-5]*-nofpu) + add_args+=( "--without-fp" ) + ;; + -m[1-5]*) + add_args+=( "--with-fp" ) + ;; + esac + done + + # If architecture variant was specified, we'd have CT_ARCH_ARCH_CFLAG + # and it would've been handled above. Our last resort: CT_ARCH_CPU + if [ "${#add_args[@]}" = 0 ]; then + case "${CT_ARCH_CPU}" in + sh[34]*-nofpu) + add_args+=( "--without-fp" ) + ;; + sh[34]*) + add_args+=( "--with-fp" ) + ;; + esac + fi + + eval "${array}+=( \"\${add_args[@]}\" )" } CT_DoArchUClibcConfig() { local cfg="${1}" - # FIXME: uclibc (!ng) seems to support sh64 (sh5), too CT_DoArchUClibcSelectArch "${cfg}" "sh" + CT_KconfigDisableOption "CONFIG_SH2" "${cfg}" + CT_KconfigDisableOption "CONFIG_SH2A" "${cfg}" CT_KconfigDisableOption "CONFIG_SH3" "${cfg}" CT_KconfigDisableOption "CONFIG_SH4" "${cfg}" CT_KconfigDisableOption "CONFIG_SH4A" "${cfg}" case "${CT_ARCH_SH_VARIANT}" in + sh2) CT_KconfigEnableOption "CONFIG_SH2" "${cfg}";; + sh2a) CT_KconfigEnableOption "CONFIG_SH2A" "${cfg}";; sh3) CT_KconfigEnableOption "CONFIG_SH3" "${cfg}";; sh4) CT_KconfigEnableOption "CONFIG_SH4" "${cfg}";; sh4a) CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}";; @@ -58,6 +179,36 @@ CT_DoArchUClibcCflags() { for f in ${cflags}; do case "${f}" in + -ml) + CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${dst}" + CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}" + CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${dst}" + CT_KconfigEnableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}" + ;; + -mb) + CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${dst}" + CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}" + CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}" + CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}" + ;; + -m2|-m2a|-m2a-nofpu|-m3|-m4|-m4-nofpu|-m4a|-m4a-nofpu) + CT_KconfigDisableOption "CONFIG_SH2" "${cfg}" + CT_KconfigDisableOption "CONFIG_SH2A" "${cfg}" + CT_KconfigDisableOption "CONFIG_SH3" "${cfg}" + CT_KconfigDisableOption "CONFIG_SH4" "${cfg}" + CT_KconfigDisableOption "CONFIG_SH4A" "${cfg}" + CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}" + case "${f}" in + -m2) + CT_KconfigEnableOption "CONFIG_SH2" "${cfg}" + ;; + -m2a) + CT_KconfigEnableOption "CONFIG_SH2A" "${cfg}" + CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}" + ;; + -m2a-nofpu) + CT_KconfigEnableOption "CONFIG_SH2A" "${cfg}" + ;; -m3) CT_KconfigEnableOption "CONFIG_SH3" "${cfg}" ;; @@ -67,7 +218,6 @@ CT_DoArchUClibcCflags() { ;; -m4-nofpu) CT_KconfigEnableOption "CONFIG_SH4" "${cfg}" - CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}" ;; -m4a) CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}" @@ -75,8 +225,9 @@ CT_DoArchUClibcCflags() { ;; -m4a-nofpu) CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}" - CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}" ;; + esac + ;; esac done } diff --git a/scripts/build/arch/sparc.sh b/scripts/build/arch/sparc.sh index 74f6f78..22d98e4 100644 --- a/scripts/build/arch/sparc.sh +++ b/scripts/build/arch/sparc.sh @@ -3,17 +3,32 @@ CT_DoArchTupleValues() { # That's the only thing to override CT_TARGET_ARCH="sparc${target_bits_64}${CT_ARCH_SUFFIX}" - # By default, sparc64-*-linux is configured with -mcpu=v9. However, - # according to https://sourceware.org/ml/libc-alpha/2005-12/msg00027.html, - # "There is no Linux sparc64 port that runs on non-UltraSPARC-I+ ISA CPUs." - # There is a patch that would change the default to -mcpu=ultrasparc for - # sparc64-*-linux configuration: https://patchwork.ozlabs.org/patch/409424/ - # but that patch has not been integrated (yet). One concern raised about - # this patch was that -mcpu=ultrasparc can suboptimally schedule instructions - # for newer SPARC CPUs. So, override to -mcpu=ultrasparc and warn the user. - if [ "${CT_KERNEL}" = "linux" -a "${CT_ARCH_64}" = "y" -a -z "${CT_ARCH_CPU}" ]; then - CT_DoLog WARN "Setting CPU to UltraSPARC-I for sparc64-linux. Set CT_ARCH_CPU if a different CPU is desired." - CT_ARCH_WITH_CPU="--with-cpu=ultrasparc" + if [ "${CT_KERNEL}" = "linux" -a -z "${CT_ARCH_CPU}" ]; then + if [ "${CT_ARCH_64}" = "y" ]; then + # By default, sparc64-*-linux is configured with -mcpu=v9. However, + # according to https://sourceware.org/ml/libc-alpha/2005-12/msg00027.html, + # "There is no Linux sparc64 port that runs on non-UltraSPARC-I+ ISA CPUs." + # There is a patch that would change the default to -mcpu=ultrasparc for + # sparc64-*-linux configuration: https://patchwork.ozlabs.org/patch/409424/ + # but that patch has not been integrated (yet). One concern raised about + # this patch was that -mcpu=ultrasparc can suboptimally schedule instructions + # for newer SPARC CPUs. So, override to -mcpu=ultrasparc and warn the user. + CT_DoLog WARN "Setting CPU to UltraSPARC-I for sparc64-linux. Set CT_ARCH_CPU if a different CPU is desired." + CT_ARCH_WITH_CPU="--with-cpu=ultrasparc" + if [ -n "${CT_ARCH_SUPPORTS_WITH_32_64}" -a -n "${CT_MULTILIB}" ]; then + CT_ARCH_WITH_CPU_32="--with-cpu-32=ultrasparc" + CT_ARCH_WITH_CPU_64="--with-cpu-64=ultrasparc" + fi + else + # Similarly, sparc-*-linux defaults to v7. GLIBC 2.31 started to reject + # pre-v8 configurations with 2.31, and default v8 fails a subsequent test for + # using atomics (which are presumably, only available on some v8 CPUs). + # Therefore, default to v9. + if [ -z "${CT_GLIBC_SPARC_ALLOW_V7}" ]; then + CT_DoLog WARN "Setting CPU to V9 for sparc-linux. Set CT_ARCH_CPU if a different CPU is desired." + CT_ARCH_WITH_CPU="--with-cpu=v9" + fi + fi fi } @@ -60,8 +75,8 @@ CT_DoArchGlibcAdjustTuple() { # earlier (corresponding pthread barrier code is missing). Until this # support is reintroduced, configure as sparcv9. sparc-*) - if [ "${CT_LIBC_GLIBC_2_23_or_later}" = y ]; then - CT_DoLog WARN "GLIBC 2.23 only supports SPARCv9" + if [ "${CT_GLIBC_NO_SPARC_V8}" = y ]; then + CT_DoLog WARN "GLIBC 2.23 and newer only support SPARCv9" target_=${target_/#sparc-/sparcv9-} fi ;; diff --git a/scripts/build/arch/x86.sh b/scripts/build/arch/x86.sh index 3a7a2ce..0538d66 100644 --- a/scripts/build/arch/x86.sh +++ b/scripts/build/arch/x86.sh @@ -10,7 +10,11 @@ CT_DoArchTupleValues() { arch="${CT_ARCH_ARCH}" [ -z "${arch}" ] && arch="${CT_ARCH_TUNE}" case "${arch}" in - "") CT_TARGET_ARCH=i386;; + "") + CT_DoLog WARN "Architecture level is not specified for 32-bit x86; defaulting to i386." + CT_DoLog WARN "This may not be supported by the C library." + CT_TARGET_ARCH=i386 + ;; i386|i486|i586|i686) CT_TARGET_ARCH="${arch}";; winchip*) CT_TARGET_ARCH=i486;; pentium|pentium-mmx|c3*) CT_TARGET_ARCH=i586;; @@ -86,7 +90,7 @@ CT_DoArchGlibcAdjustTuple() { # x86 quirk: architecture name is i386, but glibc expects i[4567]86 - to # indicate the desired optimization. If it was a multilib variant of x86_64, # then it targets at least NetBurst a.k.a. i786, but we'll follow the model - # above # and set the optimization to i686. Otherwise, replace with the most + # above and set the optimization to i686. Otherwise, replace with the most # conservative choice, i486. i386-*) if [ "${CT_TARGET_ARCH}" = "x86_64" ]; then diff --git a/scripts/build/arch/xtensa.sh b/scripts/build/arch/xtensa.sh index bf94ddf..d0ba6f5 100644 --- a/scripts/build/arch/xtensa.sh +++ b/scripts/build/arch/xtensa.sh @@ -1,79 +1,15 @@ # Compute Xtensa-specific values -CT_DoArchTupleValues() { +CT_DoArchTupleValues() +{ # The architecture part of the tuple: CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX}" CT_ARCH_ENDIAN_CFLAG="" CT_ARCH_ENDIAN_LDFLAG="" - # The system part of the tuple: - case "${CT_LIBC}" in - *glibc) CT_TARGET_SYS=gnu;; - uClibc) CT_TARGET_SYS=uclibc;; - esac } -# This function updates the specified component (binutils, gcc, gdb, etc.) -# with the processor specific configuration. -CT_ConfigureXtensa() { - local component="${1}" - local version="${2}" - local custom_overlay="xtensa_${CT_ARCH_XTENSA_CUSTOM_NAME}.tar" - local custom_location="${CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION}" - - if [ -z "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then - custom_overlay="xtensa-overlay.tar" - fi - - CT_TestAndAbort "${custom_overlay}: CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION must be set." -z "${custom_location}" - - local full_file="${custom_location}/${custom_overlay}" - local basename="${component}-${version}" - local ext - - ext=${full_file/*./.} - - if [ -z "${ext}" ] ; then - CT_DoLog WARN "'${full_file}' not found" - return 1 - fi - - if [ -e "${CT_SRC_DIR}/.${basename}.configuring" ]; then - CT_DoLog ERROR "The '${basename}' source were partially configured." - CT_DoLog ERROR "Please remove first:" - CT_DoLog ERROR " - the source dir for '${basename}', in '${CT_SRC_DIR}'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.extracted'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.patch'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.configuring'" - CT_Abort - fi - - CT_DoLog EXTRA "Using '${custom_overlay}' from ${custom_location}" - CT_DoExecLog DEBUG ln -sf "${custom_location}/${custom_overlay}" \ - "${CT_TARBALLS_DIR}/${custom_overlay}" - - CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.configuring" - - CT_Pushd "${CT_SRC_DIR}/${basename}" - - tar_opts=( "--strip-components=1" ) - tar_opts+=( "-xv" ) - - case "${ext}" in - .tar) CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}" "${component}";; - .gz|.tgz) gzip -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f - "${component}";; - .bz2) bzip2 -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f - "${component}";; - *) CT_DoLog WARN "Don't know how to handle '${basename}${ext}': unknown extension" - return 1 - ;; - esac - - CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.configured" - CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/.${basename}.configuring" - - CT_Popd -} - -CT_DoArchUClibcConfig() { +CT_DoArchUClibcConfig() +{ local cfg="${1}" CT_DoArchUClibcSelectArch "${cfg}" "xtensa" diff --git a/scripts/build/binutils/binutils-ld.in b/scripts/build/binutils/binutils-ld.in deleted file mode 100644 index 30f4591..0000000 --- a/scripts/build/binutils/binutils-ld.in +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -call_to=@@DEFAULT_LD@@ - -case "${CTNG_LD_IS}" in - bfd) call_to=bfd;; - gold) call_to=gold;; -esac - -exec "${0}.${call_to}" "$@" -exit $? diff --git a/scripts/build/binutils/binutils.sh b/scripts/build/binutils/binutils.sh index f9c5fe7..b16be90 100644 --- a/scripts/build/binutils/binutils.sh +++ b/scripts/build/binutils/binutils.sh @@ -4,44 +4,17 @@ # Download binutils do_binutils_get() { - if [ "${CT_BINUTILS_CUSTOM}" = "y" ]; then - CT_GetCustom "binutils" "${CT_BINUTILS_CUSTOM_VERSION}" \ - "${CT_BINUTILS_CUSTOM_LOCATION}" - else - case "${CT_BINUTILS_VERSION}" in - linaro-*) - CT_GetLinaro "binutils" "${CT_BINUTILS_VERSION}" - ;; - *) - CT_GetFile "binutils-${CT_BINUTILS_VERSION}" \ - {http,ftp}://{ftp.gnu.org/gnu,ftp.kernel.org/pub/linux/devel}/binutils \ - ftp://{sourceware.org,gcc.gnu.org}/pub/binutils/{releases,snapshots} - ;; - esac - fi - + CT_Fetch BINUTILS if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then - if [ "${CT_ELF2FLT_CUSTOM}" = "y" ]; then - CT_GetCustom "elf2flt" "${CT_ELF2FLT_CUSTOM_VERSION}" \ - "${CT_ELF2FLT_CUSTOM_LOCATION}" - else - CT_GetGit elf2flt "${CT_ELF2FLT_GIT_CSET}" https://github.com/uclinux-dev/elf2flt.git - fi + CT_Fetch ELF2FLT fi } # Extract binutils do_binutils_extract() { - CT_Extract "binutils-${CT_BINUTILS_VERSION}" - CT_Patch "binutils" "${CT_BINUTILS_VERSION}" - + CT_ExtractPatch BINUTILS if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then - CT_Extract "elf2flt-${CT_ELF2FLT_GIT_CSET}" - CT_Patch "elf2flt" "${CT_ELF2FLT_GIT_CSET}" - fi - - if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then - CT_ConfigureXtensa "binutils" "${CT_BINUTILS_VERSION}" + CT_ExtractPatch ELF2FLT fi } @@ -67,7 +40,7 @@ do_binutils_for_build() { if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then # We re-use binutils' options, plus our owns - binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" ) + binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils" ) binutils_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-build-${CT_BUILD}" ) CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-build-${CT_BUILD}" @@ -82,7 +55,6 @@ do_binutils_for_build() { # Build binutils for host -> target do_binutils_for_host() { - local -a binutils_tools local -a binutils_opts CT_DoStep INFO "Installing binutils for host" @@ -101,7 +73,7 @@ do_binutils_for_host() { if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then # We re-use binutils' options, plus our owns - binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" ) + binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils" ) binutils_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}" ) CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}" @@ -118,26 +90,13 @@ do_binutils_for_host() { # are not executable on the build machine. case "${CT_TOOLCHAIN_TYPE}" in cross|native) - binutils_tools=( ar as ld ranlib strip ) - if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then - binutils_tools+=( elf2flt flthdr ) - fi - case "${CT_BINUTILS_LINKERS_LIST}" in - ld) binutils_tools+=( ld.bfd ) ;; - gold) binutils_tools+=( ld.gold ) ;; - ld,gold) binutils_tools+=( ld.bfd ld.gold ) ;; - gold,ld) binutils_tools+=( ld.bfd ld.gold ) ;; - esac - mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin" mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin" - for t in "${binutils_tools[@]}"; do - CT_DoExecLog ALL ln -sv \ - "${CT_PREFIX_DIR}/${CT_TARGET}/bin/${t}" \ - "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}" - CT_DoExecLog ALL ln -sv \ - "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" \ - "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}" - done + CT_SymlinkTools "${CT_BUILDTOOLS_PREFIX_DIR}/bin" \ + "${CT_PREFIX_DIR}/bin" \ + "${CT_TARGET}" + CT_DoExecLog ALL mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}" + CT_DoExecLog ALL ln -sv "${CT_PREFIX_DIR}/${CT_TARGET}/bin" \ + "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin" ;; *) ;; esac @@ -172,32 +131,36 @@ do_binutils_backend() { CT_DoLog EXTRA "Configuring binutils" - if [ "${CT_BINUTILS_HAS_GOLD}" = "y" ]; then - case "${CT_BINUTILS_LINKERS_LIST}" in - ld) - extra_config+=( --enable-ld=yes --enable-gold=no ) - ;; - gold) - extra_config+=( --enable-ld=no --enable-gold=yes ) - ;; - ld,gold) - extra_config+=( --enable-ld=default --enable-gold=yes ) - ;; - gold,ld) - extra_config+=( --enable-ld=yes --enable-gold=default ) - ;; - esac - if [ "${CT_BINUTILS_GOLD_THREADS}" = "y" ]; then - extra_config+=( --enable-threads ) - fi + case "${CT_BINUTILS_LINKERS_LIST}" in + ld) + extra_config+=( --enable-ld=yes --enable-gold=no ) + ;; + gold) + extra_config+=( --enable-ld=no --enable-gold=yes ) + ;; + ld,gold) + extra_config+=( --enable-ld=default --enable-gold=yes ) + ;; + gold,ld) + extra_config+=( --enable-ld=yes --enable-gold=default ) + ;; + esac + if [ "${CT_BINUTILS_GOLD_THREADS}" = "y" ]; then + extra_config+=( --enable-threads ) fi if [ "${CT_BINUTILS_PLUGINS}" = "y" ]; then extra_config+=( --enable-plugins ) fi - if [ "${CT_BINUTILS_HAS_PKGVERSION_BUGURL}" = "y" ]; then - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") - [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") + if [ "${CT_BINUTILS_RELRO}" = "y" ]; then + extra_config+=( --enable-relro ) + elif [ "${CT_BINUTILS_RELRO}" != "m" ]; then + extra_config+=( --disable-relro ) fi + if [ "${CT_BINUTILS_DETERMINISTIC_ARCHIVES}" = "y" ]; then + extra_config+=( --enable-deterministic-archives ) + fi + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") if [ "${CT_MULTILIB}" = "y" ]; then extra_config+=("--enable-multilib") else @@ -208,16 +171,27 @@ do_binutils_backend() { extra_config+=("--disable-sim") extra_config+=("--disable-gdb") + # libdebuginfod in incompatible with static linking + [ "${CT_STATIC_TOOLCHAIN}" = "y" ] && extra_config+=("--without-debuginfod") + [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls") + # Disable usage of glob for higher compatibility. + # Not strictly needed for anything but GDB anyways. + export ac_cv_func_glob=no + CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" CT_DoExecLog CFG \ + CC_FOR_BUILD="${CT_BUILD}-gcc" \ + CFLAGS_FOR_BUILD="${CT_CFLAGS_FOR_BUILD}" \ + CXXFLAGS_FOR_BUILD="${CT_CFLAGS_FOR_BUILD} ${CT_CXXFLAGS_FOR_BUILD}" \ + LDFLAGS_FOR_BUILD="${CT_LDFLAGS_FOR_BUILD}" \ CFLAGS="${cflags}" \ - CXXFLAGS="${cflags}" \ + CXXFLAGS="${cflags} ${CT_CXXFLAGS_FOR_BUILD}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \ + "${CT_SRC_DIR}/binutils/configure" \ --build=${CT_BUILD} \ --host=${host} \ --target=${CT_TARGET} \ @@ -225,21 +199,27 @@ do_binutils_backend() { --disable-werror \ "${extra_config[@]}" \ ${CT_ARCH_WITH_FLOAT} \ - ${BINUTILS_SYSROOT_ARG} \ + ${CT_BINUTILS_SYSROOT_ARG} \ "${CT_BINUTILS_EXTRA_CONFIG_ARRAY[@]}" if [ "${static_build}" = "y" ]; then extra_make_flags+=("LDFLAGS=${ldflags} -all-static") CT_DoLog EXTRA "Prepare binutils for static build" - CT_DoExecLog ALL make ${JOBSFLAGS} configure-host + CT_DoExecLog ALL make ${CT_JOBSFLAGS} configure-host fi CT_DoLog EXTRA "Building binutils" - CT_DoExecLog ALL make "${extra_make_flags[@]}" ${JOBSFLAGS} + CT_DoExecLog ALL make "${extra_make_flags[@]}" ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing binutils" CT_DoExecLog ALL make install + if [ "${CT_BINUTILS_PLUGINS}" = "y" ]; then + # Create a directory for plugins such as LTO (to be installed by + # their providers later) + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/lib/bfd-plugins" + fi + if [ "${build_manuals}" = "y" ]; then CT_DoLog EXTRA "Building and installing the binutils manuals" manuals_for=( gas binutils ld gprof ) @@ -248,7 +228,7 @@ do_binutils_backend() { fi manuals_install=( "${manuals_for[@]/#/install-pdf-}" ) manuals_install+=( "${manuals_for[@]/#/install-html-}" ) - CT_DoExecLog ALL make ${JOBSFLAGS} pdf html + CT_DoExecLog ALL make ${CT_JOBSFLAGS} pdf html CT_DoExecLog ALL make "${manuals_install[@]}" fi @@ -258,15 +238,16 @@ do_binutils_backend() { rm -f "${prefix}/bin/${CT_TARGET}-ld" rm -f "${prefix}/${CT_TARGET}/bin/ld" sed -r -e "s/@@DEFAULT_LD@@/${CT_BINUTILS_LINKER_DEFAULT}/" \ - "${CT_LIB_DIR}/scripts/build/binutils/binutils-ld.in" \ + "${CT_LIB_DIR}/packages/binutils/binutils-ld.in" \ >"${prefix}/bin/${CT_TARGET}-ld" - chmod +x "${prefix}/bin/${CT_TARGET}-ld" + chmod a+x "${prefix}/bin/${CT_TARGET}-ld" cp -a "${prefix}/bin/${CT_TARGET}-ld" \ "${prefix}/${CT_TARGET}/bin/ld" - # If needed, force using ld.bfd during the toolchain build - if [ "${CT_BINUTILS_FORCE_LD_BFD}" = "y" ]; then - export CTNG_LD_IS=bfd + # If needed, force using ld.bfd during the toolchain build. + # Note that + if [ "${CT_BINUTILS_FORCE_LD_BFD_DEFAULT}" = "y" ]; then + CT_EnvModify export CTNG_LD_IS bfd fi fi } @@ -301,7 +282,7 @@ do_elf2flt_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}/configure" \ + "${CT_SRC_DIR}/elf2flt/configure" \ --build=${CT_BUILD} \ --host=${host} \ --target=${CT_TARGET} \ @@ -315,7 +296,7 @@ do_elf2flt_backend() { "${CT_ELF2FLT_EXTRA_CONFIG_ARRAY[@]}" CT_DoLog EXTRA "Building elf2flt" - CT_DoExecLog ALL make ${JOBSFLAGS} CPU=${CT_ARCH} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} CPU=${CT_ARCH} CT_DoLog EXTRA "Installing elf2flt" CT_DoExecLog ALL make install @@ -343,10 +324,8 @@ do_binutils_for_target() { CT_DoLog EXTRA "Configuring binutils for target" - if [ "${CT_BINUTILS_HAS_PKGVERSION_BUGURL}" = "y" ]; then - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") - [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") - fi + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") if [ "${CT_MULTILIB}" = "y" ]; then extra_config+=("--enable-multilib") else @@ -361,7 +340,7 @@ do_binutils_for_target() { CT_DoExecLog CFG \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \ + "${CT_SRC_DIR}/binutils/configure" \ --build=${CT_BUILD} \ --host=${CT_TARGET} \ --target=${CT_TARGET} \ @@ -374,7 +353,7 @@ do_binutils_for_target() { "${CT_BINUTILS_EXTRA_CONFIG_ARRAY[@]}" CT_DoLog EXTRA "Building binutils' libraries (${targets[*]}) for target" - CT_DoExecLog ALL make ${JOBSFLAGS} "${build_targets[@]}" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} "${build_targets[@]}" CT_DoLog EXTRA "Installing binutils' libraries (${targets[*]}) for target" CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" "${install_targets[@]}" diff --git a/scripts/build/cc.sh b/scripts/build/cc.sh deleted file mode 100644 index 0db6b9c..0000000 --- a/scripts/build/cc.sh +++ /dev/null @@ -1,58 +0,0 @@ -# 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/100-gcc.sh b/scripts/build/cc/gcc.sh index 4dc7a69..0f369a4 100644 --- a/scripts/build/cc/100-gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -3,53 +3,33 @@ # Licensed under the GPL v2. See COPYING in the root of this package # Download gcc -do_gcc_get() { +do_cc_get() { local linaro_version="" local linaro_series="" - if [ "${CT_CC_GCC_CUSTOM}" = "y" ]; then - CT_GetCustom "gcc" "${CT_CC_GCC_CUSTOM_VERSION}" \ - "${CT_CC_GCC_CUSTOM_LOCATION}" - else - case "${CT_CC_GCC_VERSION}" in - linaro-*) - CT_GetLinaro "gcc" "${CT_CC_GCC_VERSION}" - ;; - *) - # The official gcc hosts put gcc under a gcc/release/ directory, - # whereas the mirrors put it in the gcc/ directory. - 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} - ;; - esac - fi # ! custom location + CT_Fetch GCC + # Starting with GCC 4.3, ecj is used for Java, and will only be # built if the configure script finds ecj.jar at the top of the # GCC source tree, which will not be there unless we get it and # put it there ourselves if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then - CT_GetFile ecj-latest .jar http://mirrors.kernel.org/sourceware/java/ \ - http://crosstool-ng.org/pub/java \ - ftp://gcc.gnu.org/pub/java \ - ftp://sourceware.org/pub/java + if ! CT_GetFile package=ecj basename=ecj-latest extensions=.jar dir_name=gcc \ + mirrors="$(CT_Mirrors sourceware java)"; then + # Should be a package, too - but with Java retirement in GCC, + # it may not make sense. + CT_Abort "Failed to download ecj-latest.jar" + fi fi } # Extract gcc -do_gcc_extract() { - CT_Extract "gcc-${CT_CC_GCC_VERSION}" - CT_Patch "gcc" "${CT_CC_GCC_VERSION}" +do_cc_extract() { + CT_ExtractPatch GCC # 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_GCC_VERSION}/ecj.jar" \ - ]; then - CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar" - fi - - if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then - CT_ConfigureXtensa "gcc" "${CT_CC_GCC_VERSION}" + if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" -a ! -f "${CT_SRC_DIR}/gcc/ecj.jar" ]; then + CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc/ecj.jar" fi } @@ -73,23 +53,6 @@ cc_gcc_lang_list() { } #------------------------------------------------------------------------------ -# Return a value of a requested GCC spec -cc_gcc_get_spec() { - local spec=$1 - local cc_and_cflags=$2 - - # GCC does not provide a facility to request a value of a spec string. - # The only way to do that I found was to augment the spec file with - # some dummy suffix handler that does nothing except printing it. - touch temp-input.spec_eval - { - echo ".spec_eval:" - echo "echo %(${spec})" - } > "tmp-specs-${spec}" - ${cc_and_cflags} -specs="tmp-specs-${spec}" -E temp-input.spec_eval -} - -#------------------------------------------------------------------------------ # Report the type of a GCC option cc_gcc_classify_opt() { # Options present in multiple architectures @@ -129,33 +92,55 @@ cc_gcc_classify_opt() { echo "unknown" } +evaluate_multilib_cflags() +{ + local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count + local mdir mdir_os dirtop + local f + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + mdir="lib/${multi_dir}" + mdir_os="lib/${multi_os_dir_gcc}" + CT_SanitizeVarDir mdir mdir_os + CT_DoLog EXTRA " '${multi_flags}' --> ${mdir} (gcc) ${mdir_os} (os)" + for f in ${multi_flags}; do + eval ml_`cc_gcc_classify_opt ${f}`=seen + done + if [ "${CT_DEMULTILIB}" = "y" -a "${CT_USE_SYSROOT}" = "y" ]; then + case "${mdir_os}" in + lib/*) + ;; + *) + dirtop="${mdir_os%%/*}" + if [ ! -e "${multi_root}/${mdir_os}" ]; then + CT_DoExecLog ALL ln -sfv lib "${multi_root}/${mdir_os}" + fi + if [ ! -e "${multi_root}/usr/${mdir_os}" ]; then + CT_DoExecLog ALL ln -sfv lib "${multi_root}/usr/${mdir_os}" + fi + ;; + esac + fi +} + #------------------------------------------------------------------------------ # This function lists the multilibs configured in the compiler (even if multilib # is disabled - so that it lists the default GCC/OS directory, which may differ # from the default 'lib'). It then performs a few multilib checks/quirks: # -# 1. On SuperH target, configuring with default CPU (e.g. by supplying the target -# name as 'sh4', which is what CT-NG does) results in the compiler being unable to -# run if that same switch is passed to the resulting gcc (e.g. 'gcc -m4'). The reason -# for this behavior is that the script that determines the sysroot suffix is not -# aware of the default multilib selection, so it generates <sysroot>/m4 as the -# suffixed sysroot. But the main driver, knowing that -m4 is the default, does not -# even attempt to fall back to the non-suffixed sysroot (as it does with non-default -# multilibs) - as a result, gcc fails to find any library if invoked with -m4. -# The right solution would be to drop the default CPU from the multilib list -# completely, or make the print-sysroot-suffix.sh script aware of the defaults -# (which is not easy, as the defaults are not in tmake_file, but rather in tm_file...) -# -# 2. On MIPS target, gcc (or rather, ld, which it invokes under the hood) chokes +# 1. On MIPS target, gcc (or rather, ld, which it invokes under the hood) chokes # if supplied with two -mabi=* options. I.e., 'gcc -mabi=n32' and 'gcc -mabi=32' both # work, but 'gcc -mabi=32 -mabi=n32' produces an internal error in ld. Thus we do -# not supply target's CFLAGS in multilib builds - and after compiling pass-1 gcc, +# not supply target's CFLAGS in multilib builds - and after compiling core gcc, # attempt to determine which CFLAGS need to be filtered out. +# +# 2. If "demultilibing" is in effect, create top-level directories for any +# multilibs not in lib/ as symlinks to lib. cc_gcc_multilib_housekeeping() { local cc host - local flags osdir dir multilibs i f - local multilib_defaults - local suffix sysroot base lnk local ml_arch ml_abi ml_cpu ml_tune ml_fpu ml_float ml_endian ml_mode ml_unknown ml local new_cflags @@ -171,76 +156,40 @@ cc_gcc_multilib_housekeeping() { cc="${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${CT_CC}" fi - # sed: prepend dashes or do nothing if default is empty string - multilib_defaults=( $( cc_gcc_get_spec multilib_defaults "${cc}" | \ - sed 's/\(^\|[[:space:]]\+\)\([^[:space:]]\)/ -\2/g' ) ) - CT_DoLog EXTRA "gcc default flags: '${multilib_defaults}'" - - multilibs=( $( "${cc}" -print-multi-lib ) ) - if [ ${#multilibs[@]} -ne 0 ]; then - CT_DoLog EXTRA "gcc configured with these multilibs (including the default):" - for i in "${multilibs[@]}"; do - dir="lib/${i%%;*}" - flags="${i#*;}" - flags=${flags//@/ -} - flags=$( echo ${flags} ) - osdir="lib/"$( "${cc}" -print-multi-os-directory ${flags} ) - CT_SanitizeVarDir dir osdir - CT_DoLog EXTRA " '${flags}' --> ${dir} (gcc) ${osdir} (os)" - for f in ${flags}; do - eval ml_`cc_gcc_classify_opt ${f}`=seen - done + CT_IterateMultilibs evaluate_multilib_cflags evaluate_cflags + + if [ -n "${CT_MULTILIB}" ]; then + # Filtering out some of the options provided in CT-NG config. Then *prepend* + # them to CT_TARGET_CFLAGS, like scripts/crosstool-NG.sh does. Zero out + # the stashed MULTILIB flags so that we don't process them again in the passes + # that follow. + CT_DoLog DEBUG "Configured target CFLAGS: '${CT_ARCH_TARGET_CFLAGS_MULTILIB}'" + ml_unknown= # Pass through anything we don't know about + for f in ${CT_ARCH_TARGET_CFLAGS_MULTILIB}; do + eval ml=\$ml_`cc_gcc_classify_opt ${f}` + if [ "${ml}" != "seen" ]; then + new_cflags="${new_cflags} ${f}" + fi done - else - CT_DoLog WARN "no multilib configuration: GCC unusable?" - fi - - # Filtering out some of the options provided in CT-NG config. Then *prepend* - # them to CT_TARGET_CFLAGS, like scripts/crosstool-NG.sh does. Zero out - # the stashed MULTILIB flags so that we don't process them again in the passes - # that follow. - CT_DoLog DEBUG "Configured target CFLAGS: '${CT_ARCH_TARGET_CFLAGS_MULTILIB}'" - ml_unknown= # Pass through anything we don't know about - for f in ${CT_ARCH_TARGET_CFLAGS_MULTILIB}; do - eval ml=\$ml_`cc_gcc_classify_opt ${f}` - if [ "${ml}" != "seen" ]; then - new_cflags="${new_cflags} ${f}" - fi - done - CT_DoLog DEBUG "Filtered target CFLAGS: '${new_cflags}'" - CT_EnvModify CT_TARGET_CFLAGS "${new_cflags} ${CT_TARGET_CFLAGS}" - CT_EnvModify CT_ARCH_TARGET_CFLAGS_MULTILIB "" - - # Currently, the only LDFLAGS are endianness-related - CT_DoLog DEBUG "Configured target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'" - if [ "${ml_endian}" != "seen" ]; then - CT_EnvModify CT_TARGET_LDFLAGS "${CT_ARCH_TARGET_LDFLAGS_MULTILIB} ${CT_TARGET_LDFLAGS}" - CT_EnvModify CT_ARCH_TARGET_LDFLAGS_MULTILIB "" - fi - CT_DoLog DEBUG "Filtered target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'" - - # Sysroot suffix fixup for the multilib default. - suffix=$( cc_gcc_get_spec sysroot_suffix_spec "${cc} ${multilib_defaults}" ) - if [ -n "${suffix}" ]; then - base=${suffix%/*} - sysroot=$( "${cc}" -print-sysroot ) - if [ -n "${base}" ]; then - CT_DoExecLog ALL mkdir -p "${sysroot}${base}" - lnk=$( echo "${base#/}" | sed -e 's,[^/]*,..,g' ) - else - lnk=. + CT_DoLog DEBUG "Filtered target CFLAGS: '${new_cflags}'" + CT_EnvModify CT_ALL_TARGET_CFLAGS "${new_cflags} ${CT_TARGET_CFLAGS}" + CT_EnvModify CT_ARCH_TARGET_CFLAGS_MULTILIB "" + + # Currently, the only LDFLAGS are endianness-related + CT_DoLog DEBUG "Configured target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'" + if [ "${ml_endian}" != "seen" ]; then + CT_EnvModify CT_ALL_TARGET_LDFLAGS "${CT_ARCH_TARGET_LDFLAGS_MULTILIB} ${CT_TARGET_LDFLAGS}" + CT_EnvModify CT_ARCH_TARGET_LDFLAGS_MULTILIB "" fi - CT_DoExecLog ALL rm -f "${sysroot}${suffix}" - CT_DoExecLog ALL ln -sfv "${lnk}" "${sysroot}${suffix}" + CT_DoLog DEBUG "Filtered target LDFLAGS: '${CT_ARCH_TARGET_LDFLAGS_MULTILIB}'" fi } #------------------------------------------------------------------------------ -# Core gcc pass 1 -do_gcc_core_pass_1() { +do_cc_core() { local -a core_opts - if [ "${CT_CC_CORE_PASS_1_NEEDED}" != "y" ]; then + if [ "${CT_CC_CORE_NEEDED}" != "y" ]; then return 0 fi @@ -251,56 +200,12 @@ do_gcc_core_pass_1() { core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) core_opts+=( "lang_list=c" ) - core_opts+=( "build_step=core1" ) - - CT_DoStep INFO "Installing pass-1 core C gcc compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-1" - - do_gcc_core_backend "${core_opts[@]}" - - CT_Popd - CT_EndStep -} - -# Core gcc pass 2 -do_gcc_core_pass_2() { - local -a core_opts - - if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then - return 0 - fi - - # Common options: - core_opts+=( "host=${CT_BUILD}" ) - core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) - core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" ) - core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) - core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) - core_opts+=( "lang_list=c" ) - core_opts+=( "build_step=core2" ) - - # Different conditions are at stake here: - # - In case the threading model is NPTL, we need a shared-capable core - # gcc; in all other cases, we need a static-only core gcc. - # - In case the threading model is NPTL or win32, or gcc is 4.3 or - # later, we need to build libgcc - case "${CT_THREADS}" in - nptl) - core_opts+=( "mode=shared" ) - core_opts+=( "build_libgcc=yes" ) - ;; - win32) - core_opts+=( "mode=static" ) - core_opts+=( "build_libgcc=yes" ) - ;; - *) - core_opts+=( "mode=static" ) - core_opts+=( "build_libgcc=yes" ) - ;; - esac + core_opts+=( "build_step=core" ) + core_opts+=( "mode=static" ) + core_opts+=( "build_libgcc=yes" ) - CT_DoStep INFO "Installing pass-2 core C gcc compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-2" + CT_DoStep INFO "Installing core C gcc compiler" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core" do_gcc_core_backend "${core_opts[@]}" @@ -325,8 +230,8 @@ do_gcc_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) -# build_step : build step 'core1', 'core2', 'gcc_build' -# or 'gcc_host' : string : (none) +# build_step : build step 'core', 'gcc_build', +# 'libstdcxx' or 'gcc_host' : string : (none) # Usage: do_gcc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no] do_gcc_core_backend() { local mode @@ -337,13 +242,18 @@ do_gcc_core_backend() { local build_manuals=no local host local prefix + local enable_optspace local complibs local lang_list - local cflags + local cflags cflags_for_build cxxflags_for_build cflags_for_target cxxflags_for_target + local extra_cxxflags_for_target local ldflags local build_step local log_txt local tmp + local exec_prefix + local header_dir + local libstdcxx_name local -a host_libstdcxx_flags local -a extra_config local -a core_LDFLAGS @@ -359,25 +269,44 @@ do_gcc_core_backend() { # This function gets called in case of a bare metal compiler for the final gcc, too. case "${build_step}" in - core1|core2) + core) CT_DoLog EXTRA "Configuring core C gcc compiler" log_txt="gcc" + extra_config+=( "${CT_CC_CORE_SYSROOT_ARG[@]}" ) extra_user_config=( "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" ) ;; gcc_build|gcc_host) CT_DoLog EXTRA "Configuring final gcc compiler" + extra_config+=( "${CT_CC_SYSROOT_ARG[@]}" ) extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) log_txt="final gcc compiler" - if [ "${CT_CC_GCC_TARGET_FINAL}" = "y" ]; then - # to inhibit the libiberty and libgcc tricks later on - build_libgcc=no + # to inhibit the libiberty and libgcc tricks later on + build_libgcc=no + ;; + libstdcxx) + CT_DoLog EXTRA "Configuring libstdc++ for ${libstdcxx_name}" + if [ "${header_dir}" = "" ]; then + header_dir="${CT_PREFIX_DIR}/${libstdcxx_name}/include" fi + if [ "${exec_prefix}" = "" ]; then + exec_prefix="${CT_PREFIX_DIR}/${libstdcxx_name}" + fi + extra_config+=( "${CT_CC_SYSROOT_ARG[@]}" ) + extra_config+=( "--with-headers=${header_dir}" ) + extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) + log_txt="libstdc++ ${libstdcxx_name} library" + # to inhibit the libiberty and libgcc tricks later on + build_libgcc=no ;; *) - CT_Abort "Internal Error: 'build_step' must be one of: 'core1', 'core2', 'gcc_build' or 'gcc_host', not '${build_step:-(empty)}'" + CT_Abort "Internal Error: 'build_step' must be one of: 'core', 'gcc_build', 'gcc_host' or 'libstdcxx', not '${build_step:-(empty)}'" ;; esac + if [ "${exec_prefix}" = "" ]; then + exec_prefix="${prefix}" + fi + case "${mode}" in static) extra_config+=("--with-newlib") @@ -397,29 +326,33 @@ do_gcc_core_backend() { ;; esac - # This is only needed when building libstdc++ in a canadian environment with - # this function being used for final step (i.e., when building for bare metal). - if [ "${build_step}" = "gcc_build" ]; then - CT_DoLog DEBUG "Copying headers to install area of core C compiler" - CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include" - fi - - for tmp in ARCH ABI CPU TUNE FPU FLOAT; do + for tmp in ARCH ABI CPU CPU_32 CPU_64 TUNE FPU FLOAT ENDIAN; do eval tmp="\${CT_ARCH_WITH_${tmp}}" if [ -n "${tmp}" ]; then extra_config+=("${tmp}") fi done - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") + # Hint GCC we'll use a bit special version of Newlib + if [ "${CT_LIBC_NEWLIB_NANO_FORMATTED_IO}" = "y" ]; then + extra_config+=("--enable-newlib-nano-formatted-io") + fi + if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then extra_config+=("--enable-__cxa_atexit") else extra_config+=("--disable-__cxa_atexit") fi + case "${CT_CC_GCC_TM_CLONE_REGISTRY}" in + y) extra_config+=("--enable-tm-clone-registry");; + m) ;; + "") extra_config+=("--disable-tm-clone-registry");; + esac + if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" \ -a "${mode}" = "baremetal" ]; then extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}") @@ -429,11 +362,11 @@ do_gcc_core_backend() { extra_config+=(--disable-libmudflap) extra_config+=(--disable-libmpx) - if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then - extra_config+=(--enable-libssp) - else - extra_config+=(--disable-libssp) - fi + case "${CT_CC_GCC_LIBSSP}" in + y) extra_config+=(--enable-libssp);; + m) ;; + "") extra_config+=(--disable-libssp);; + esac if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then extra_config+=(--enable-libquadmath) extra_config+=(--enable-libquadmath-support) @@ -442,6 +375,15 @@ do_gcc_core_backend() { extra_config+=(--disable-libquadmath-support) fi + case "${CT_CC_GCC_LIBSTDCXX_VERBOSE}" in + y) extra_config+=("--enable-libstdcxx-verbose");; + "") extra_config+=("--disable-libstdcxx-verbose");; + esac + + if [ "${build_libstdcxx}" = "no" ]; then + extra_config+=(--disable-libstdcxx) + fi + core_LDFLAGS+=("${ldflags}") # *** WARNING ! *** @@ -449,9 +391,11 @@ do_gcc_core_backend() { # with the same block in do_gcc_backend, below. if [ "${build_staticlinked}" = "yes" ]; then core_LDFLAGS+=("-static") - host_libstdcxx_flags+=("-static-libgcc") - host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++") - host_libstdcxx_flags+=("-lm") + if [ "${CT_GCC_older_than_6}" = "y" ]; then + host_libstdcxx_flags+=("-static-libgcc") + host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++") + host_libstdcxx_flags+=("-lm") + fi # Companion libraries are build static (eg !shared), so # the libstdc++ is not pulled automatically, although it # is needed. Shoe-horn it in our LDFLAGS @@ -459,7 +403,7 @@ do_gcc_core_backend() { core_LDFLAGS+=("-lstdc++") core_LDFLAGS+=("-lm") else - if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then + if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" -a "${CT_GCC_older_than_6}" = "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++, @@ -500,13 +444,28 @@ do_gcc_core_backend() { extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}") fi - if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then + if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ] || \ + [ "${enable_optspace}" = "yes" ]; then extra_config+=("--enable-target-optspace") fi if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then extra_config+=("--disable-libstdcxx-pch") fi + if [ "${CT_LIBC_GLIBC}" = "y" ]; then + # Report GLIBC's version to GCC, it affects the defaults on other options. + # GCC expects just two numbers separated by a dot. + local glibc_version + + CT_GetPkgVersion GLIBC glibc_version + case "${glibc_version}" in + new) glibc_version=99.99;; + old) glibc_version=1.0;; + *) glibc_version=`echo "${glibc_version}" | sed 's/\([1-9][0-9]*\.[1-9][0-9]*\).*/\1/'`;; + esac + extra_config+=("--with-glibc-version=${glibc_version}") + fi + case "${CT_CC_GCC_LDBL_128}" in y) extra_config+=("--with-long-double-128");; m) ;; @@ -563,11 +522,10 @@ do_gcc_core_backend() { # Some versions of gcc have a defective --enable-multilib. # Since that's the default, only pass --disable-multilib. For multilib, - # also enable multiarch. Without explicit --enable-multiarch, pass-1 - # compiler is configured as multilib/no-multiarch and pass-2/final - # are multilib/multiarch (because gcc autodetects multiarch based on - # multiple instances of crt*.o in the install directory - which do - # not exist in pass-1). + # also enable multiarch. Without explicit --enable-multiarch, core + # compiler is configured as multilib/no-multiarch (because gcc autodetects + # multiarch based on multiple instances of crt*.o in the install directory + # which do not exist in the core pass). if [ "${CT_MULTILIB}" != "y" ]; then extra_config+=("--disable-multilib") else @@ -579,29 +537,75 @@ do_gcc_core_backend() { CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" + # We may need to modify host/build/target CFLAGS separately below. Note + # that ${cflags} may refer either to build or host CFLAGS; they are provided + # by the caller. + cflags_for_build="${CT_CFLAGS_FOR_BUILD}" + cxxflags_for_build="${CT_CXXFLAGS_FOR_BUILD}" + cflags_for_target="${CT_TARGET_CFLAGS}" + # Clang's default bracket-depth is 256, and building GCC # requires somewhere between 257 and 512. - if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then - cflags="$cflags "-fbracket-depth=512 + if [ "${host}" = "${CT_BUILD}" ]; then + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + cflags="$cflags -fbracket-depth=512" + cflags_for_build="$cflags_for_build -fbracket-depth=512" + fi + else + # FIXME we currently don't support clang as host compiler, only as build + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + cflags_for_build="$cflags_for_build -fbracket-depth=512" + fi + fi + + # For non-sysrooted toolchain, GCC doesn't search except at the installation + # prefix; in core stage we use a temporary installation prefix - but + # we may have installed something into the final prefix. This is less than ideal: + # in the installation prefix GCC also handles subdirectories for multilibs + # (e.g. first trying ${prefix}/include/${arch-triplet}) but + # we can only pass the top level directory, so non-sysrooted build with libc + # selection that doesn't merge the headers (i.e. musl, uClibc-ng) may not + # work. Better suggestions welcome. + if [ "${CT_USE_SYSROOT}" != "y" ]; then + cflags_for_target="${cflags_for_target} -idirafter ${CT_HEADERS_DIR}" fi - # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532) + # Assume '-O2' by default for building target libraries. + cflags_for_target="-g -O2 ${cflags_for_target}" + + # Set target CXXFLAGS to CFLAGS if none is provided. + if [ -z "${cxxflags_for_target}" ]; then + cxxflags_for_target="${cflags_for_target}" + fi + + # Append extra CXXFLAGS if provided. + if [ -n "${extra_cxxflags_for_target}" ]; then + cxxflags_for_target="${cxxflags_for_target} ${extra_cxxflags_for_target}" + fi + + # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532). + # Pass only user-specified CFLAGS/LDFLAGS in CFLAGS_FOR_TARGET/LDFLAGS_FOR_TARGET: during + # the build of, for example, libatomic, GCC tried to compile multiple variants for runtime + # selection and passing architecture/CPU selectors, as detemined by crosstool-NG, may + # miscompile or outright fail. CT_DoExecLog CFG \ CC_FOR_BUILD="${CT_BUILD}-gcc" \ CFLAGS="${cflags}" \ - CXXFLAGS="${cflags}" \ + CFLAGS_FOR_BUILD="${cflags_for_build}" \ + CXXFLAGS="${cflags} ${cxxflags_for_build}" \ + CXXFLAGS_FOR_BUILD="${cflags_for_build} ${cxxflags_for_build}" \ LDFLAGS="${core_LDFLAGS[*]}" \ - CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ - CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ + CFLAGS_FOR_TARGET="${cflags_for_target}" \ + CXXFLAGS_FOR_TARGET="${cxxflags_for_target}" \ LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \ + "${CT_SRC_DIR}/gcc/configure" \ --build=${CT_BUILD} \ --host=${host} \ --target=${CT_TARGET} \ --prefix="${prefix}" \ + --exec_prefix="${exec_prefix}" \ --with-local-prefix="${CT_SYSROOT_DIR}" \ - ${CC_CORE_SYSROOT_ARG} \ "${extra_config[@]}" \ --enable-languages="${lang_list}" \ "${extra_user_config[@]}" @@ -623,43 +627,31 @@ do_gcc_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_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 - CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp + if [ ! -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then + CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-libiberty + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C libiberty libiberty.a + CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-gcc configure-libcpp + CT_DoExecLog ALL make ${CT_JOBSFLAGS} all-libcpp else - CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp configure-build-libiberty - CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp all-build-libiberty + CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-gcc configure-libcpp configure-build-libiberty + CT_DoExecLog ALL make ${CT_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_GCC_VERSION}/libdecnumber" ]; then - CT_DoExecLog CFG make ${JOBSFLAGS} configure-libdecnumber - CT_DoExecLog ALL make ${JOBSFLAGS} -C libdecnumber libdecnumber.a + if [ -d "${CT_SRC_DIR}/gcc/libdecnumber" ]; then + CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-libdecnumber + CT_DoExecLog ALL make ${CT_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_GCC_VERSION}/libbacktrace" ]; then - CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace - CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace + if [ -d "${CT_SRC_DIR}/gcc/libbacktrace" ]; then + CT_DoExecLog CFG make ${CT_JOBSFLAGS} configure-libbacktrace + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C libbacktrace fi libgcc_rule="libgcc.mvars" core_targets=( gcc target-libgcc ) - # On bare metal and canadian build the host-compiler is used when - # actually the build-system compiler is required. Choose the correct - # compilers for canadian build and use the defaults on other - # configurations. - if [ "${CT_BARE_METAL},${CT_CANADIAN}" = "y,y" ]; then - repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \ - CXX_FOR_BUILD=${CT_BUILD}-g++ \ - GCC_FOR_TARGET=${CT_TARGET}-${CT_CC}" - else - repair_cc="" - fi + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C gcc ${libgcc_rule} - CT_DoExecLog ALL make ${JOBSFLAGS} -C gcc ${libgcc_rule} \ - ${repair_cc} sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule} else # build_libgcc core_targets=( gcc ) @@ -681,17 +673,20 @@ do_gcc_core_backend() { case "${build_step}" in gcc_build|gcc_host) - if [ "${CT_CC_GCC_TARGET_FINAL}" = "y" ]; then - core_targets_all=all - core_targets_install=install - fi + core_targets_all=all + core_targets_install=install + ;; + libstdcxx) + core_targets=( target-libstdc++-v3 ) + core_targets_all="${core_targets[@]/#/all-}" + core_targets_install="${core_targets[@]/#/install-}" ;; esac CT_DoLog EXTRA "Building ${log_txt}" - CT_DoExecLog ALL make ${JOBSFLAGS} ${core_targets_all} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} ${core_targets_all} - # Do not pass ${JOBSFLAGS} here: recent GCC builds have been failing + # Do not pass ${CT_JOBSFLAGS} here: recent GCC builds have been failing # in parallel 'make install' at random locations: libitm, libcilk, # always for the files that are installed more than once to the same # location (such as libitm.info). @@ -729,11 +724,18 @@ do_gcc_core_backend() { cc_gcc_multilib_housekeeping cc="${prefix}/bin/${CT_TARGET}-${CT_CC}" \ host="${host}" + + # If binutils want the LTO plugin, point them to it + if [ -d "${CT_PREFIX_DIR}/lib/bfd-plugins" -a "${build_step}" = "gcc_host" ]; then + local gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ) + CT_DoExecLog ALL ln -sfv "../../libexec/gcc/${CT_TARGET}/${gcc_version}/liblto_plugin.so" \ + "${CT_PREFIX_DIR}/lib/bfd-plugins/liblto_plugin.so" + fi } #------------------------------------------------------------------------------ # Build complete gcc to run on build -do_gcc_for_build() { +do_cc_for_build() { local -a build_final_opts local build_final_backend @@ -755,7 +757,9 @@ do_gcc_for_build() { # lack of such a compiler, but better safe than sorry... build_final_opts+=( "mode=baremetal" ) build_final_opts+=( "build_libgcc=yes" ) - build_final_opts+=( "build_libstdcxx=yes" ) + if [ "${CT_LIBC_NONE}" != "y" ]; then + build_final_opts+=( "build_libstdcxx=yes" ) + fi build_final_opts+=( "build_libgfortran=yes" ) if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then build_final_opts+=( "build_staticlinked=yes" ) @@ -774,14 +778,24 @@ do_gcc_for_build() { CT_EndStep } -gcc_movelibs() { - local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count - local gcc_dir +gcc_movelibs() +{ + local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count + local gcc_dir dst_dir canon_root canon_prefix + local rel for arg in "$@"; do eval "${arg// /\\ }" done + # GCC prints the sysroot in canonicalized form, which may be different if there + # is a symlink in the path. Since we need textual match to obtain a relative + # subdirectory path, canonicalize the prefix directory. Since GCC's behavior + # is not documented and hence may change at any time, canonicalize it too just + # for the good measure. + canon_root=$( cd "${multi_root}" && pwd -P ) + canon_prefix=$( cd "${CT_PREFIX_DIR}" && pwd -P ) + # Move only files, directories are for other multilibs. We're looking inside # GCC's directory structure, thus use unmangled multi_os_dir that GCC reports. gcc_dir="${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_os_dir_gcc}" @@ -789,6 +803,16 @@ gcc_movelibs() { # GCC didn't install anything outside of sysroot return fi + # Depending on the selected libc, we may or may not have the ${multi_os_dir_gcc} + # created by libc installation. If we do, use it. If we don't, use ${multi_os_dir} + # to avoid creating an otherwise empty directory. + dst_dir="${canon_root}/lib/${multi_os_dir_gcc}" + if [ ! -d "${dst_dir}" ]; then + dst_dir="${canon_root}/lib/${multi_os_dir}" + fi + CT_SanitizeVarDir dst_dir gcc_dir + rel=$( echo "${gcc_dir#${CT_PREFIX_DIR}/}" | sed 's#[^/]\{1,\}#..#g' ) + ls "${gcc_dir}" | while read f; do case "${f}" in *.ld) @@ -798,15 +822,16 @@ gcc_movelibs() { ;; esac if [ -f "${gcc_dir}/${f}" ]; then - CT_DoExecLog ALL mkdir -p "${multi_root}/lib/${multi_os_dir}" - CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${multi_root}/lib/${multi_os_dir}/${f}" + CT_DoExecLog ALL mkdir -p "${dst_dir}" + CT_DoExecLog ALL mv "${gcc_dir}/${f}" "${dst_dir}/${f}" + CT_DoExecLog ALL ln -sf "${rel}/${dst_dir#${canon_prefix}/}/${f}" "${gcc_dir}/${f}" fi done } #------------------------------------------------------------------------------ # Build final gcc to run on host -do_gcc_for_host() { +do_cc_for_host() { local -a final_opts local final_backend @@ -823,7 +848,9 @@ do_gcc_for_host() { if [ "${CT_BARE_METAL}" = "y" ]; then final_opts+=( "mode=baremetal" ) final_opts+=( "build_libgcc=yes" ) - final_opts+=( "build_libstdcxx=yes" ) + if [ "${CT_LIBC_NONE}" != "y" ]; then + final_opts+=( "build_libstdcxx=yes" ) + fi final_opts+=( "build_libgfortran=yes" ) if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then final_opts+=( "build_staticlinked=yes" ) @@ -856,19 +883,31 @@ do_gcc_for_host() { # Parameter : Definition : Type : Default # host : the host we run onto : tuple : (none) # prefix : the runtime prefix : dir : (none) +# exec_prefix : prefix for executables : dir : (none) # complibs : the companion libraries prefix : dir : (none) # cflags : cflags to use : string : (empty) # 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 +# build_step : build step 'gcc_build', 'gcc_host' +# or 'libstdcxx' : string : (none) do_gcc_backend() { local host local prefix + local exec_prefix local complibs local lang_list local cflags + local cflags_for_build + local cxxflags_for_build + local cflags_for_target + local cxxflags_for_target + local extra_cxxflags_for_target local ldflags local build_manuals + local exec_prefix + local header_dir + local libstdcxx_name local -a host_libstdcxx_flags local -a extra_config local -a final_LDFLAGS @@ -879,22 +918,42 @@ do_gcc_backend() { eval "${arg// /\\ }" done - CT_DoLog EXTRA "Configuring final gcc compiler" + if [ "${exec_prefix}" = "" ]; then + exec_prefix="${prefix}" + fi + + # This function gets called for final gcc and libstdcxx. + case "${build_step}" in + gcc_build|gcc_host) + log_txt="final gcc compiler" + ;; + libstdcxx) + log_txt="libstdc++ library for ${libstdcxx_name}" + ;; + *) + CT_Abort "Internal Error: 'build_step' must be one of: 'gcc_build', 'gcc_host' or 'libstdcxx', not '${build_step:-(empty)}'" + ;; + esac + + CT_DoLog EXTRA "Configuring ${log_txt}" # Enable selected languages extra_config+=("--enable-languages=${lang_list}") - for tmp in ARCH ABI CPU TUNE FPU FLOAT; do + for tmp in ARCH ARCH_32 ARCH_64 ABI CPU CPU_32 CPU_64 TUNE TUNE_32 TUNE_64 FPU FLOAT; do eval tmp="\${CT_ARCH_WITH_${tmp}}" if [ -n "${tmp}" ]; then extra_config+=("${tmp}") fi done - [ "${CT_SHARED_LIBS}" = "y" ] || extra_config+=("--disable-shared") - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") + if [ "${CT_SHARED_LIBS}" != "y" ]; then + extra_config+=("--disable-shared") + fi + case "${CT_CC_GCC_SJLJ_EXCEPTIONS}" in y) extra_config+=("--enable-sjlj-exceptions");; m) ;; @@ -906,6 +965,12 @@ do_gcc_backend() { extra_config+=("--disable-__cxa_atexit") fi + case "${CT_CC_GCC_TM_CLONE_REGISTRY}" in + y) extra_config+=("--enable-tm-clone-registry");; + m) ;; + "") extra_config+=("--disable-tm-clone-registry");; + esac + if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" ]; then extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}") fi @@ -923,11 +988,11 @@ do_gcc_backend() { else extra_config+=(--disable-libgomp) fi - if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then - extra_config+=(--enable-libssp) - else - extra_config+=(--disable-libssp) - fi + case "${CT_CC_GCC_LIBSSP}" in + y) extra_config+=(--enable-libssp);; + m) ;; + "") extra_config+=(--disable-libssp);; + esac if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then extra_config+=(--enable-libquadmath) extra_config+=(--enable-libquadmath-support) @@ -950,6 +1015,15 @@ do_gcc_backend() { fi fi + case "${CT_CC_GCC_LIBSTDCXX_VERBOSE}" in + y) extra_config+=("--enable-libstdcxx-verbose");; + "") extra_config+=("--disable-libstdcxx-verbose");; + esac + + if [ "${build_libstdcxx}" = "no" ]; then + extra_config+=(--disable-libstdcxx) + fi + final_LDFLAGS+=("${ldflags}") # *** WARNING ! *** @@ -957,9 +1031,11 @@ do_gcc_backend() { # with the same block in do_gcc_core_backend, above. if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then final_LDFLAGS+=("-static") - host_libstdcxx_flags+=("-static-libgcc") - host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++") - host_libstdcxx_flags+=("-lm") + if [ "${CT_GCC_older_than_6}" = "y" ]; then + host_libstdcxx_flags+=("-static-libgcc") + host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++") + host_libstdcxx_flags+=("-lm") + fi # Companion libraries are build static (eg !shared), so # the libstdc++ is not pulled automatically, although it # is needed. Shoe-horn it in our LDFLAGS @@ -967,7 +1043,7 @@ do_gcc_backend() { final_LDFLAGS+=("-lstdc++") final_LDFLAGS+=("-lm") else - if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then + if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" -a "${CT_GCC_older_than_6}" = "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++, @@ -1003,6 +1079,11 @@ do_gcc_backend() { else extra_config+=("--disable-lto") fi + case "${CT_CC_GCC_LTO_ZSTD}" in + y) extra_config+=("--with-zstd");; + m) ;; + *) extra_config+=("--without-zstd");; + esac if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}") @@ -1019,9 +1100,11 @@ do_gcc_backend() { fi fi - if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then + if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ] || \ + [ "${enable_optspace}" = "yes" ]; then extra_config+=("--enable-target-optspace") fi + if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then extra_config+=("--disable-libstdcxx-pch") fi @@ -1102,27 +1185,58 @@ do_gcc_backend() { CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" + # We may need to modify host/build/target CFLAGS separately below + cflags_for_build="${cflags}" + cxxflags_for_build="${CT_CXXFLAGS_FOR_BUILD}" + cflags_for_target="${CT_TARGET_CFLAGS}" + # Clang's default bracket-depth is 256, and building GCC # requires somewhere between 257 and 512. - if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then - cflags="$cflags "-fbracket-depth=512 + if [ "${host}" = "${CT_BUILD}" ]; then + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + cflags="$cflags "-fbracket-depth=512 + cflags_for_build="$cflags_for_build "-fbracket-depth=512 + fi + else + # FIXME we currently don't support clang as host compiler, only as build + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + cflags_for_build="$cflags_for_build "-fbracket-depth=512 + fi + fi + + # Assume '-O2' by default for building target libraries. + cflags_for_target="-g -O2 ${cflags_for_target}" + + # Set target CXXFLAGS to CFLAGS if none is provided. + if [ -z "${cxxflags_for_target}" ]; then + cxxflags_for_target="${cflags_for_target}" fi + # Append extra CXXFLAGS if provided. + if [ -n "${extra_cxxflags_for_target}" ]; then + cxxflags_for_target="${cxxflags_for_target} ${extra_cxxflags_for_target}" + fi + + # NB: not using CT_ALL_TARGET_CFLAGS/CT_ALL_TARGET_LDFLAGS here! + # See do_gcc_core_backend for explanation. CT_DoExecLog CFG \ CC_FOR_BUILD="${CT_BUILD}-gcc" \ CFLAGS="${cflags}" \ - CXXFLAGS="${cflags}" \ + CFLAGS_FOR_BUILD="${cflags_for_build}" \ + CXXFLAGS="${cflags} ${cxxflags_for_build}" \ + CXXFLAGS_FOR_BUILD="${cflags_for_build} ${cxxflags_for_build}" \ LDFLAGS="${final_LDFLAGS[*]}" \ - CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ - CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \ + CFLAGS_FOR_TARGET="${cflags_for_target}" \ + CXXFLAGS_FOR_TARGET="${cxxflags_for_target}" \ LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure" \ + "${CT_SRC_DIR}/gcc/configure" \ --build=${CT_BUILD} \ --host=${host} \ --target=${CT_TARGET} \ --prefix="${prefix}" \ - ${CC_SYSROOT_ARG} \ + --exec_prefix="${exec_prefix}" \ + ${CT_CC_SYSROOT_ARG} \ "${extra_config[@]}" \ --with-local-prefix="${CT_SYSROOT_DIR}" \ --enable-long-long \ @@ -1130,11 +1244,11 @@ do_gcc_backend() { if [ "${CT_CANADIAN}" = "y" ]; then CT_DoLog EXTRA "Building libiberty" - CT_DoExecLog ALL make ${JOBSFLAGS} all-build-libiberty + CT_DoExecLog ALL make ${CT_JOBSFLAGS} all-build-libiberty fi CT_DoLog EXTRA "Building final gcc compiler" - CT_DoExecLog ALL make ${JOBSFLAGS} all + CT_DoExecLog ALL make ${CT_JOBSFLAGS} all # See the note on issues with parallel 'make install' in GCC above. CT_DoLog EXTRA "Installing final gcc compiler" @@ -1171,4 +1285,11 @@ do_gcc_backend() { cc_gcc_multilib_housekeeping cc="${prefix}/bin/${CT_TARGET}-${CT_CC}" \ host="${host}" + + # If binutils want the LTO plugin, point them to it + if [ -d "${CT_PREFIX_DIR}/lib/bfd-plugins" -a "${build_step}" = "gcc_host" ]; then + local gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ) + CT_DoExecLog ALL ln -sfv "../../libexec/gcc/${CT_TARGET}/${gcc_version}/liblto_plugin.so" \ + "${CT_PREFIX_DIR}/lib/bfd-plugins/liblto_plugin.so" + fi } diff --git a/scripts/build/companion_libs/050-zlib.sh b/scripts/build/companion_libs/050-zlib.sh index 6e17819..8c6a0f6 100644 --- a/scripts/build/companion_libs/050-zlib.sh +++ b/scripts/build/companion_libs/050-zlib.sh @@ -13,14 +13,12 @@ if [ "${CT_ZLIB}" = "y" ]; then # Download zlib do_zlib_get() { - CT_GetFile "zlib-${CT_ZLIB_VERSION}" \ - "http://downloads.sourceforge.net/project/libpng/zlib/${CT_ZLIB_VERSION}" + CT_Fetch ZLIB } # Extract zlib do_zlib_extract() { - CT_Extract "zlib-${CT_ZLIB_VERSION}" - CT_Patch "zlib" "${CT_ZLIB_VERSION}" + CT_ExtractPatch ZLIB } # Build zlib for running on build @@ -76,30 +74,51 @@ do_zlib_backend() { local ldflags local arg local -a extra_config + local -a extra_make for arg in "$@"; do eval "${arg// /\\ }" done - CT_DoLog EXTRA "Configuring zlib" - - CT_DoExecLog CFG \ - CFLAGS="${cflags}" \ - LDFLAGS="${ldflags}" \ - CROSS_PREFIX="${host}-" \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/zlib-${CT_ZLIB_VERSION}/configure" \ - --prefix="${prefix}" \ - --static \ - "${extra_config[@]}" + case "${host}" in + *-mingw32) + # zlib treats mingw host differently and requires using a different + # makefile rather than configure+make. It also does not support + # out-of-tree building. + cp -av "${CT_SRC_DIR}/zlib/." . + extra_make=( -f win32/Makefile.gcc \ + PREFIX="${host}-" \ + SHAREDLIB= \ + IMPLIB= \ + LIBRARY_PATH="${prefix}/lib" \ + INCLUDE_PATH="${prefix}/include" \ + BINARY_PATH="${prefix}/bin" \ + prefix="${prefix}" \ + ) + ;; + + *) + CT_DoLog EXTRA "Configuring zlib" + + CT_DoExecLog CFG \ + CFLAGS="${cflags}" \ + LDFLAGS="${ldflags}" \ + CHOST="${host}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/zlib/configure" \ + --prefix="${prefix}" \ + --static \ + "${extra_config[@]}" + ;; + esac CT_DoLog EXTRA "Building zlib" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make "${extra_make[@]}" ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking zlib" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make "${extra_make[@]}" -s test else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for zlib on the host" @@ -107,7 +126,7 @@ do_zlib_backend() { fi CT_DoLog EXTRA "Installing zlib" - CT_DoExecLog ALL make install + CT_DoExecLog ALL make "${extra_make[@]}" install } fi # CT_ZLIB diff --git a/scripts/build/companion_libs/100-gmp.sh b/scripts/build/companion_libs/100-gmp.sh index c81874a..a17eda9 100644 --- a/scripts/build/companion_libs/100-gmp.sh +++ b/scripts/build/companion_libs/100-gmp.sh @@ -9,19 +9,16 @@ do_gmp_for_host() { :; } do_gmp_for_target() { :; } # Overide functions depending on configuration -if [ "${CT_GMP}" = "y" ]; then +if [ "${CT_GMP_TARGET}" = "y" -o "${CT_GMP}" = "y" ]; then # Download GMP do_gmp_get() { - CT_GetFile "gmp-${CT_GMP_VERSION}" \ - https://gmplib.org/download/gmp \ - {http,ftp,https}://ftp.gnu.org/gnu/gmp + CT_Fetch GMP } # Extract GMP do_gmp_extract() { - CT_Extract "gmp-${CT_GMP_VERSION}" - CT_Patch "gmp" "${CT_GMP_VERSION}" + CT_ExtractPatch GMP } # Build GMP for running on build @@ -64,12 +61,40 @@ do_gmp_for_host() { CT_EndStep } +if [ "${CT_GMP_TARGET}" = "y" ]; then +do_gmp_for_target() { + local -a gmp_opts + + CT_DoStep INFO "Installing GMP for target" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-target-${CT_HOST}" + + gmp_opts+=( "host=${CT_TARGET}" ) + case "${CT_TARGET}" in + *-*-mingw*) + prefix="/mingw" + ;; + *) + prefix="/usr" + ;; + esac + gmp_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) + gmp_opts+=( "prefix=${prefix}" ) + gmp_opts+=( "destdir=${CT_SYSROOT_DIR}" ) + gmp_opts+=( "shared=${CT_SHARED_LIBS}" ) + do_gmp_backend "${gmp_opts[@]}" + + CT_Popd + CT_EndStep +} +fi + # Build GMP # Parameter : description : type : default # host : machine to run on : tuple : (none) # prefix : prefix to install into : dir : (none) # cflags : cflags to use : string : (empty) # ldflags : ldflags to use : string : (empty) +# destdir : install destination : dir : (none) do_gmp_backend() { local host local prefix @@ -84,15 +109,23 @@ do_gmp_backend() { CT_DoLog EXTRA "Configuring GMP" - if [ ! "${CT_GMP_5_0_2_or_later}" = "y" ]; then - extra_config+=("--enable-mpbsd") - fi + # To avoind “illegal text-relocation” linking error against + # the static library, see: + # https://github.com/Homebrew/homebrew-core/pull/25470 + case "${host}" in + *darwin*) + extra_config+=("--with-pic") + ;; + esac + # FIXME: GMP's configure script doesn't respect the host parameter + # when not cross-compiling, ie when build == host. CT_DoExecLog CFG \ + CC="${host}-gcc" \ CFLAGS="${cflags} -fexceptions" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \ + "${CT_SRC_DIR}/gmp/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -103,12 +136,12 @@ do_gmp_backend() { "${extra_config[@]}" CT_DoLog EXTRA "Building GMP" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking GMP" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for GMP on the host" @@ -116,7 +149,7 @@ do_gmp_backend() { fi CT_DoLog EXTRA "Installing GMP" - CT_DoExecLog ALL make install + CT_DoExecLog ALL make install DESTDIR="${destdir}" } fi # CT_GMP diff --git a/scripts/build/companion_libs/110-mpfr.sh b/scripts/build/companion_libs/110-mpfr.sh index 5a89077..d2cb9f6 100644 --- a/scripts/build/companion_libs/110-mpfr.sh +++ b/scripts/build/companion_libs/110-mpfr.sh @@ -13,16 +13,14 @@ if [ "${CT_MPFR}" = "y" ]; then # Download MPFR do_mpfr_get() { - CT_GetFile "mpfr-${CT_MPFR_VERSION}" \ - {https,http,ftp}://ftp.gnu.org/gnu/mpfr \ - http://www.mpfr.org/mpfr-${CT_MPFR_VERSION} + CT_Fetch MPFR } # Extract MPFR do_mpfr_extract() { - CT_Extract "mpfr-${CT_MPFR_VERSION}" - CT_Patch "mpfr" "${CT_MPFR_VERSION}" + CT_ExtractPatch MPFR + # TBD is it a problem with 2.4.x? The comment says it is not, yet the code is run # OK, Gentoo have a sanity check that libtool.m4 and ltmain.sh have the # same version number. Unfortunately, some tarballs of MPFR are not # built sanely, and thus ./configure fails on Gentoo. @@ -115,7 +113,7 @@ do_mpfr_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure" \ + "${CT_SRC_DIR}/mpfr/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -124,12 +122,12 @@ do_mpfr_backend() { --enable-static CT_DoLog EXTRA "Building MPFR" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking MPFR" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for MPFR on the host" diff --git a/scripts/build/companion_libs/121-isl.sh b/scripts/build/companion_libs/121-isl.sh index ef93bbd..3577b75 100644 --- a/scripts/build/companion_libs/121-isl.sh +++ b/scripts/build/companion_libs/121-isl.sh @@ -13,14 +13,12 @@ if [ "${CT_ISL}" = "y" ]; then # Download ISL do_isl_get() { - CT_GetFile "isl-${CT_ISL_VERSION}" \ - http://isl.gforge.inria.fr + CT_Fetch ISL } # Extract ISL do_isl_extract() { - CT_Extract "isl-${CT_ISL_VERSION}" - CT_Patch "isl" "${CT_ISL_VERSION}" + CT_ExtractPatch ISL } # Build ISL for running on build @@ -86,21 +84,12 @@ do_isl_backend() { CT_DoLog EXTRA "Configuring ISL" - if [ "${CT_ISL_V_0_12_or_later}" != "y" ]; then - extra_config+=("--with-libgmp-prefix=${prefix}") - extra_config+=("--with-libgmpxx-prefix=${prefix}") - fi - - if [ "${CT_ISL_V_0_14_or_later}" != "y" ]; then - extra_config+=("--with-piplib=no") - fi - CT_DoExecLog CFG \ CFLAGS="${cflags}" \ CXXFLAGS="${cxxflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/isl-${CT_ISL_VERSION}/configure" \ + "${CT_SRC_DIR}/isl/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -112,12 +101,12 @@ do_isl_backend() { --with-clang=no CT_DoLog EXTRA "Building ISL" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking ISL" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for ISL on the host" diff --git a/scripts/build/companion_libs/130-cloog.sh b/scripts/build/companion_libs/130-cloog.sh index b21b028..9ee897a 100644 --- a/scripts/build/companion_libs/130-cloog.sh +++ b/scripts/build/companion_libs/130-cloog.sh @@ -13,18 +13,12 @@ if [ "${CT_CLOOG}" = "y" ]; then # Download CLooG do_cloog_get() { - CT_GetFile "cloog-${CT_CLOOG_VERSION}" \ - http://www.bastoul.net/cloog/pages/download \ - ftp://gcc.gnu.org/pub/gcc/infrastructure + CT_Fetch CLOOG } # Extract CLooG do_cloog_extract() { - CT_Extract "cloog-${CT_CLOOG_VERSION}" - CT_Patch "cloog" "${CT_CLOOG_VERSION}" - - # Help the autostuff in case it thinks there are things to regenerate... - CT_DoExecLog DEBUG mkdir -p "${CT_SRC_DIR}/cloog-${CT_CLOOG_VERSION}/m4" + CT_ExtractPatch CLOOG } # Build CLooG for running on build @@ -85,11 +79,9 @@ do_cloog_backend() { eval "${arg// /\\ }" done - if [ "${CT_CLOOG_0_18_or_later}" = y ]; then - cloog_opts+=( --with-gmp=system --with-gmp-prefix="${prefix}" ) - cloog_opts+=( --with-isl=system --with-isl-prefix="${prefix}" ) - cloog_opts+=( --without-osl ) - fi + cloog_opts+=( --with-gmp=system --with-gmp-prefix="${prefix}" ) + cloog_opts+=( --with-isl=system --with-isl-prefix="${prefix}" ) + cloog_opts+=( --without-osl ) CT_DoLog EXTRA "Configuring CLooG" @@ -98,7 +90,7 @@ do_cloog_backend() { LDFLAGS="${ldflags}" \ LIBS="-lm" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/cloog-${CT_CLOOG_VERSION}/configure" \ + "${CT_SRC_DIR}/cloog/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -109,12 +101,12 @@ do_cloog_backend() { "${cloog_opts[@]}" CT_DoLog EXTRA "Building CLooG" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking CLooG" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for CLooG on the host" diff --git a/scripts/build/companion_libs/140-mpc.sh b/scripts/build/companion_libs/140-mpc.sh index e6efb4f..2166ef1 100644 --- a/scripts/build/companion_libs/140-mpc.sh +++ b/scripts/build/companion_libs/140-mpc.sh @@ -13,15 +13,12 @@ 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://www.multiprecision.org/mpc/download + CT_Fetch MPC } # Extract MPC do_mpc_extract() { - CT_Extract "mpc-${CT_MPC_VERSION}" - CT_Patch "mpc" "${CT_MPC_VERSION}" + CT_ExtractPatch MPC } # Build MPC for running on build @@ -87,7 +84,7 @@ do_mpc_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \ + "${CT_SRC_DIR}/mpc/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -97,12 +94,12 @@ do_mpc_backend() { --enable-static CT_DoLog EXTRA "Building MPC" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then if [ "${host}" = "${CT_BUILD}" ]; then CT_DoLog EXTRA "Checking MPC" - CT_DoExecLog ALL make ${JOBSFLAGS} -s check + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check else # Cannot run host binaries on build in a canadian cross CT_DoLog EXTRA "Skipping check for MPC on the host" diff --git a/scripts/build/companion_libs/200-libelf.sh b/scripts/build/companion_libs/200-libelf.sh index 807ce7e..f0d8be4 100644 --- a/scripts/build/companion_libs/200-libelf.sh +++ b/scripts/build/companion_libs/200-libelf.sh @@ -9,15 +9,11 @@ do_libelf_for_target() { :; } if [ "${CT_LIBELF}" = "y" -o "${CT_LIBELF_TARGET}" = "y" ]; then do_libelf_get() { - # The server hosting libelf will return an "HTTP 300 : Multiple Choices" - # error code if we try to download a file that does not exists there. - # So we have to request the file with an explicit extension. - CT_GetFile "libelf-${CT_LIBELF_VERSION}" .tar.gz http://www.mr511.de/software/ + CT_Fetch LIBELF } do_libelf_extract() { - CT_Extract "libelf-${CT_LIBELF_VERSION}" - CT_Patch "libelf" "${CT_LIBELF_VERSION}" + CT_ExtractPatch LIBELF } if [ "${CT_LIBELF}" = "y" ]; then @@ -85,6 +81,7 @@ do_libelf_for_target() { libelf_opts+=( "destdir=${CT_SYSROOT_DIR}" ) libelf_opts+=( "host=${CT_TARGET}" ) + libelf_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) libelf_opts+=( "prefix=${prefix}" ) libelf_opts+=( "shared=${CT_SHARED_LIBS}" ) do_libelf_backend "${libelf_opts[@]}" @@ -131,7 +128,7 @@ do_libelf_backend() { CFLAGS="${cflags} -fPIC" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure" \ + "${CT_SRC_DIR}/libelf/configure" \ --build=${CT_BUILD} \ --host=${host} \ --target=${CT_TARGET} \ diff --git a/scripts/build/companion_libs/210-expat.sh b/scripts/build/companion_libs/210-expat.sh index 5aa8e31..68667f6 100755..100644 --- a/scripts/build/companion_libs/210-expat.sh +++ b/scripts/build/companion_libs/210-expat.sh @@ -9,13 +9,11 @@ do_expat_for_target() { :; } if [ "${CT_EXPAT_TARGET}" = "y" -o "${CT_EXPAT}" = "y" ]; then do_expat_get() { - CT_GetFile "expat-${CT_EXPAT_VERSION}" .tar.gz \ - http://downloads.sourceforge.net/project/expat/expat/${CT_EXPAT_VERSION} + CT_Fetch EXPAT } do_expat_extract() { - CT_Extract "expat-${CT_EXPAT_VERSION}" - CT_Patch "expat" "${CT_EXPAT_VERSION}" + CT_ExtractPatch EXPAT } if [ "${CT_EXPAT}" = "y" ]; then @@ -56,6 +54,7 @@ do_expat_for_target() { prefix="/usr" ;; esac + expat_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) expat_opts+=( "prefix=${prefix}" ) expat_opts+=( "destdir=${CT_SYSROOT_DIR}" ) expat_opts+=( "shared=${CT_SHARED_LIBS}" ) @@ -95,17 +94,18 @@ do_expat_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/expat-${CT_EXPAT_VERSION}/configure" \ + "${CT_SRC_DIR}/expat/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ --enable-static \ + --without-docbook \ "${extra_config[@]}" CT_DoLog EXTRA "Building expat" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing expat" - CT_DoExecLog ALL make install INSTALL_ROOT="${destdir}" + CT_DoExecLog ALL make install DESTDIR="${destdir}" } fi diff --git a/scripts/build/companion_libs/220-ncurses.sh b/scripts/build/companion_libs/220-ncurses.sh index 573523b..f1fcd1a 100644 --- a/scripts/build/companion_libs/220-ncurses.sh +++ b/scripts/build/companion_libs/220-ncurses.sh @@ -9,15 +9,11 @@ do_ncurses_for_target() { :; } if [ "${CT_NCURSES_TARGET}" = "y" -o "${CT_NCURSES}" = "y" ]; then do_ncurses_get() { - CT_GetFile "ncurses-${CT_NCURSES_VERSION}" .tar.gz \ - {http,ftp,https}://ftp.gnu.org/pub/gnu/ncurses \ - ftp://invisible-island.net/ncurses + CT_Fetch NCURSES } do_ncurses_extract() { - CT_Extract "ncurses-${CT_NCURSES_VERSION}" - CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}" - CT_Patch "ncurses" "${CT_NCURSES_VERSION}" + CT_ExtractPatch NCURSES } # We need tic that runs on the build when building ncurses for host/target @@ -31,26 +27,13 @@ do_ncurses_for_build() { "--without-tests" \ "--without-cxx" \ "--without-cxx-binding" \ - "--without-ada") - # If we are not canadian, this is also our host curses - # Unlike other companion libs, we skip host build if build==host - # (i.e. in simple cross or native): ncurses may not be needed for - # host, but we still need them on build to produce 'tic'. - case "${CT_TOOLCHAIN_TYPE}" in - native|cross) - if [ "${CT_NCURSES_HOST_DISABLE_DB}" = "y" ]; then - opts+=( "--disable-database" ) - fi - if [ -n "${CT_NCURSES_HOST_FALLBACKS}" ]; then - opts+=( "--with-fallbacks=${CT_NCURSES_HOST_FALLBACKS}" ) - fi - opts+=( "${CT_NCURSES_HOST_CONFIG_ARGS[@]}" ) - ;; - esac + "--without-ada" \ + "--without-fallbacks" ) do_ncurses_backend host="${CT_BUILD}" \ destdir="${CT_BUILDTOOLS_PREFIX_DIR}" \ cflags="${CT_CFLAGS_FOR_BUILD}" \ ldflags="${CT_LDFLAGS_FOR_BUILD}" \ + install_target=install.progs \ "${opts[@]}" CT_Popd CT_EndStep @@ -60,13 +43,6 @@ if [ "${CT_NCURSES}" = "y" ]; then do_ncurses_for_host() { local -a opts - # Unlike other companion libs, we skip host build if build==host - # (i.e. in simple cross or native): ncurses may not be needed for - # host, but we still need them on build to produce 'tic'. - case "${CT_TOOLCHAIN_TYPE}" in - native|cross) return 0;; - esac - CT_DoStep INFO "Installing ncurses for host" CT_mkdir_pushd "${CT_BUILD_DIR}/build-ncurses-host-${CT_HOST}" opts=("--enable-symlinks" \ @@ -76,7 +52,8 @@ do_ncurses_for_host() { "--without-cxx-binding" \ "--without-ada" ) if [ "${CT_NCURSES_HOST_DISABLE_DB}" = "y" ]; then - opts+=( "--disable-database" ) + opts+=( "--disable-database" \ + "--disable-db-install" ) fi if [ -n "${CT_NCURSES_HOST_FALLBACKS}" ]; then opts+=( "--with-fallbacks=${CT_NCURSES_HOST_FALLBACKS}" ) @@ -120,6 +97,7 @@ do_ncurses_for_target() { prefix="${prefix}" \ destdir="${CT_SYSROOT_DIR}" \ shared="${CT_SHARED_LIBS}" \ + cflags="${CT_ALL_TARGET_CFLAGS}" \ "${opts[@]}" CT_Popd CT_EndStep @@ -142,12 +120,12 @@ do_ncurses_backend() { local ldflags local shared local arg - local for_target + local install_target=install for arg in "$@"; do case "$arg" in --*) - ncurses_opts+=("$arg") + ncurses_opts+=("${arg}") ;; *) eval "${arg// /\\ }" @@ -177,7 +155,7 @@ do_ncurses_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/ncurses-${CT_NCURSES_VERSION}/configure" \ + "${CT_SRC_DIR}/ncurses/configure" \ --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ @@ -196,9 +174,13 @@ do_ncurses_backend() { # it also builds ncurses anyway, and dedicated targets (install.includes and # install.progs) do not do well with parallel make (-jX). CT_DoLog EXTRA "Building ncurses" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + # STRIPPROG is handled by our wrapper around install. CT_DoLog EXTRA "Installing ncurses" - CT_DoExecLog ALL make install + CT_DoExecLog ALL \ + STRIPPROG="${host}-strip" \ + make "${install_target}" } fi diff --git a/scripts/build/companion_libs/320-libiconv.sh b/scripts/build/companion_libs/320-libiconv.sh index f2f0bef..9748ba2 100644 --- a/scripts/build/companion_libs/320-libiconv.sh +++ b/scripts/build/companion_libs/320-libiconv.sh @@ -9,13 +9,11 @@ do_libiconv_for_target() { :; } if [ "${CT_LIBICONV}" = "y" ]; then do_libiconv_get() { - CT_GetFile "libiconv-${CT_LIBICONV_VERSION}" \ - http://ftp.gnu.org/pub/gnu/libiconv/ + CT_Fetch LIBICONV } do_libiconv_extract() { - CT_Extract "libiconv-${CT_LIBICONV_VERSION}" - CT_Patch "libiconv" "${CT_LIBICONV_VERSION}" + CT_ExtractPatch LIBICONV } # Build libiconv for running on build @@ -93,7 +91,7 @@ do_libiconv_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/libiconv-${CT_LIBICONV_VERSION}/configure" \ + "${CT_SRC_DIR}/libiconv/configure" \ --build=${CT_BUILD} \ --host="${host}" \ --prefix="${prefix}" \ @@ -102,7 +100,7 @@ do_libiconv_backend() { "${extra_config[@]}" \ CT_DoLog EXTRA "Building libiconv" - CT_DoExecLog ALL make CC="${host}-gcc ${cflags}" ${JOBSFLAGS} + CT_DoExecLog ALL make CC="${host}-gcc ${cflags}" ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing libiconv" CT_DoExecLog ALL make install CC="${host}-gcc ${cflags}" diff --git a/scripts/build/companion_libs/330-gettext.sh b/scripts/build/companion_libs/330-gettext.sh index 8828e5d..9fa3bdc 100644 --- a/scripts/build/companion_libs/330-gettext.sh +++ b/scripts/build/companion_libs/330-gettext.sh @@ -9,13 +9,11 @@ do_gettext_for_target() { :; } if [ "${CT_GETTEXT}" = "y" ]; then do_gettext_get() { - CT_GetFile "gettext-${CT_GETTEXT_VERSION}" \ - http://ftp.gnu.org/pub/gnu/gettext/ + CT_Fetch GETTEXT } do_gettext_extract() { - CT_Extract "gettext-${CT_GETTEXT_VERSION}" - CT_Patch "gettext" "${CT_GETTEXT_VERSION}" + CT_ExtractPatch GETTEXT } # Build gettext for running on build @@ -82,6 +80,28 @@ do_gettext_backend() { return ;; + # Starting with 0.21, gettext cannot build against uClibc-NG: gettext + # checks if it needs to use fopen wrapper (using gnulib) and newer versions + # of gnulib also check if fopen provided by the system supports 'e' and 'x' + # modes. In cross-compile environment, gnulib falls back to assuming fopen + # does not support these modes unless the target tuple is glibc or musl + # (rightly so, since these fopen modes are optional in uClibc-NG). + # Unfortunately, the fopen() wrapper does not compile against uClibc-NG's + # stdio.h then because it includes <stdio.h> after defining __need_FILE macro. + # It looks like two bugs, one in each of uClibc-ng and gnulib: + # - uClibc-ng does not include its internal headers with the definitions for the + # __BEGIN_NAMESPACE_STD/__END_NAMESPACE_STD macros, which therefore escape + # unsubstituted into the including code. + # - gnulib shouldn't expect the fopen() prototype if it only asked for FILE + # structure definition by defining the __need_FILE macro. + # Until the maintainers sort this out, disallow newer gettext versions if + # linking against uClibc-NG. + *-uclibc*) + if [ "${CT_GETTEXT_INCOMPATIBLE_WITH_UCLIBC_NG}" = "y" ]; then + CT_Abort "This version of gettext is incompatible with uClibc-NG" + fi + ;; + # A bit ugly. D__USE_MINGW_ANSI_STDIO=1 has its own {v}asprintf functions # but gettext configure doesn't see this flag when it checks for that. An # alternative may be to use CC="${host}-gcc ${cflags}" but that didn't @@ -112,7 +132,7 @@ do_gettext_backend() { CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/gettext-${CT_GETTEXT_VERSION}/configure" \ + "${CT_SRC_DIR}/gettext/configure" \ --build=${CT_BUILD} \ --host="${host}" \ --prefix="${prefix}" \ @@ -133,7 +153,7 @@ do_gettext_backend() { "${extra_config[@]}" CT_DoLog EXTRA "Building gettext" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing gettext" CT_DoExecLog ALL make install diff --git a/scripts/build/companion_libs/340-picolibc.sh b/scripts/build/companion_libs/340-picolibc.sh new file mode 100644 index 0000000..e879005 --- /dev/null +++ b/scripts/build/companion_libs/340-picolibc.sh @@ -0,0 +1,171 @@ +# This file adds functions to build the Picolibc library +# Copyright © 2020 Keith Packard +# Licensed under the GPL v2 or later. See COPYING in the root of this package +# +# Edited by Keith Packard <keithp@keithp.com> +# + +do_picolibc_get() { :; } +do_picolibc_extract() { :; } +do_picolibc_for_build() { :; } +do_picolibc_for_host() { :; } +do_picolibc_for_target() { :; } + +if [ "${CT_COMP_LIBS_PICOLIBC}" = "y" ]; then + +# Download picolibc +do_picolibc_get() { + CT_Fetch PICOLIBC +} + +do_picolibc_extract() { + CT_ExtractPatch PICOLIBC +} + +#------------------------------------------------------------------------------ +# Build an additional target libstdc++ with "-Os" (optimise for speed) option +# flag for libstdc++ "picolibc" variant. +do_cc_libstdcxx_picolibc() +{ + local -a final_opts + local final_backend + + if [ "${CT_LIBC_PICOLIBC_GCC_LIBSTDCXX}" = "y" ]; then + final_opts+=( "host=${CT_HOST}" ) + final_opts+=( "libstdcxx_name=picolibc" ) + final_opts+=( "prefix=${CT_PREFIX_DIR}" ) + final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" ) + final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" ) + final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) + final_opts+=( "lang_list=c,c++" ) + final_opts+=( "build_step=libstdcxx" ) + final_opts+=( "extra_config+=('--enable-stdio=stdio_pure')" ) + final_opts+=( "extra_config+=('--disable-wchar_t')" ) + if [ "${CT_LIBC_PICOLIBC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then + final_opts+=( "enable_optspace=yes" ) + fi + + if [ "${CT_BARE_METAL}" = "y" ]; then + final_opts+=( "mode=baremetal" ) + final_opts+=( "build_libgcc=yes" ) + final_opts+=( "build_libstdcxx=yes" ) + final_opts+=( "build_libgfortran=yes" ) + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then + final_opts+=( "build_staticlinked=yes" ) + fi + final_backend=do_gcc_core_backend + else + final_backend=do_gcc_backend + fi + + CT_DoStep INFO "Installing libstdc++ picolibc" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-libstdcxx-picolibc" + "${final_backend}" "${final_opts[@]}" + CT_Popd + + CT_EndStep + fi +} + +do_picolibc_for_target() { + local -a picolibc_opts + local cflags_for_target + + CT_DoStep INFO "Installing Picolibc library" + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-picolibc-build-${CT_BUILD}" + + CT_DoLog EXTRA "Configuring Picolibc library" + + # Multilib is the default, so if it is not enabled, disable it. + if [ "${CT_MULTILIB}" != "y" ]; then + picolibc_opts+=("-Dmultilib=false") + fi + + yn_args="IO_C99FMT:io-c99-formats +IO_LL:io-long-long +REGISTER_FINI:newlib-register-fini +NANO_MALLOC:newlib-nano-malloc +ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc +GLOBAL_ATEXIT:newlib-global-atexit +LITE_EXIT:lite-exit +MULTITHREAD:newlib-multithread +RETARGETABLE_LOCKING:newlib-retargetable-locking + " + + for ynarg in $yn_args; do + var="CT_LIBC_PICOLIBC_${ynarg%:*}" + eval var=\$${var} + argument=${ynarg#*:} + + + if [ "${var}" = "y" ]; then + picolibc_opts+=( "-D$argument=true" ) + else + picolibc_opts+=( "-D$argument=false" ) + fi + done + + [ "${CT_USE_SYSROOT}" = "y" ] && \ + picolibc_opts+=( "-Dsysroot-install=true" ) + + [ "${CT_LIBC_PICOLIBC_EXTRA_SECTIONS}" = "y" ] && \ + CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -ffunction-sections -fdata-sections" + + [ "${CT_LIBC_PICOLIBC_LTO}" = "y" ] && \ + CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -flto" + + cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_PICOLIBC_TARGET_CFLAGS}" + + # Note: picolibc handles the build/host/target a little bit differently + # than one would expect: + # build : not used + # host : the machine building picolibc + # target : the machine picolibc runs on + meson_cflags="" + for cflag in ${cflags_for_target}; do + meson_cflags="${meson_cflags} '${cflag}'," + done + cat << EOF > picolibc-cross.txt +[binaries] +c = '${CT_TARGET}-gcc' +ar = '${CT_TARGET}-ar' +as = '${CT_TARGET}-as' +strip = '${CT_TARGET}-strip' + +[host_machine] +system = '${CT_TARGET_VENDOR}' +cpu_family = '${CT_TARGET_ARCH}' +cpu = '${CT_TARGET_ARCH}' +endian = '${CT_ARCH_ENDIAN}' + +[properties] +c_args = [ ${meson_cflags} '-nostdlib', '-fno-common', '-ftls-model=local-exec' ] +needs_exe_wrapper = true +skip_sanity_check = true +EOF + + CT_DoExecLog CFG \ + meson \ + --cross-file picolibc-cross.txt \ + --prefix="${CT_PREFIX_DIR}" \ + -Dincludedir=picolibc/include \ + -Dlibdir=picolibc/${CT_TARGET}/lib \ + -Dspecsdir="${CT_SYSROOT_DIR}"/lib \ + "${CT_SRC_DIR}/picolibc" \ + "${picolibc_opts[@]}" \ + "${CT_LIBC_PICOLIBC_EXTRA_CONFIG_ARRAY[@]}" + + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL ninja + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL ninja install + + CT_Popd + CT_EndStep + + do_cc_libstdcxx_picolibc +} + +fi diff --git a/scripts/build/companion_libs/350-newlib_nano.sh b/scripts/build/companion_libs/350-newlib_nano.sh new file mode 100644 index 0000000..ad6ea9a --- /dev/null +++ b/scripts/build/companion_libs/350-newlib_nano.sh @@ -0,0 +1,276 @@ +# This file adds functions to build the Newlib library using the 'nano' configuration +# Copyright © 2021 Keith Packard +# Licensed under the GPL v2 or later. See COPYING in the root of this package +# +# Edited by Keith Packard <keithp@keithp.com> +# + +do_newlib_nano_get() { :; } +do_newlib_nano_extract() { :; } +do_newlib_nano_for_build() { :; } +do_newlib_nano_for_host() { :; } +do_newlib_nano_for_target() { :; } + +if [ "${CT_COMP_LIBS_NEWLIB_NANO}" = "y" ]; then + +# Download newlib_nano +do_newlib_nano_get() { + CT_Fetch NEWLIB_NANO +} + +do_newlib_nano_extract() { + CT_ExtractPatch NEWLIB_NANO +} + +# Some architectures assume "nano" libs co-exist with normal ones +# in the same folder, though being suffixed with "_nano". +do_nano_libc_symlinks() { + CT_Pushd "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib/${multi_dir}" + + CT_DoLog DEBUG "Installing nano libc symlinks in $PWD" + + ln -s libc.a libc_nano.a + ln -s libm.a libm_nano.a + ln -s libg.a libg_nano.a + + CT_Popd +} + +do_nano_libstdcxx_symlinks() { + CT_Pushd "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib/${multi_dir}" + + CT_DoLog DEBUG "Installing nano libstdc++ symlinks in $PWD" + + ln -s libstdc++.a libstdc++_nano.a + ln -s libsupc++.a libsupc++_nano.a + + CT_Popd +} + +#------------------------------------------------------------------------------ +# Build an additional target libstdc++ with "-Os" (optimise for speed) option +# flag for libstdc++ "newlib_nano" variant. +do_cc_libstdcxx_newlib_nano() +{ + local -a final_opts + local final_backend + + if [ "${CT_NEWLIB_NANO_GCC_LIBSTDCXX}" = "y" ]; then + final_opts+=( "host=${CT_HOST}" ) + final_opts+=( "libstdcxx_name=newlib-nano" ) + final_opts+=( "prefix=${CT_PREFIX_DIR}" ) + final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" ) + final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" ) + final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) + final_opts+=( "lang_list=c,c++" ) + final_opts+=( "build_step=libstdcxx" ) + if [ "${CT_LIBC_NEWLIB_NANO_ENABLE_TARGET_OPTSPACE}" = "y" ]; then + final_opts+=( "enable_optspace=yes" ) + fi + if [ -n "${CT_NEWLIB_NANO_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" ]; then + final_opts+=( "extra_cxxflags_for_target=${CT_NEWLIB_NANO_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" ) + fi + + if [ "${CT_BARE_METAL}" = "y" ]; then + final_opts+=( "mode=baremetal" ) + final_opts+=( "build_libgcc=yes" ) + final_opts+=( "build_libstdcxx=yes" ) + final_opts+=( "build_libgfortran=yes" ) + if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then + final_opts+=( "build_staticlinked=yes" ) + fi + final_backend=do_gcc_core_backend + else + final_backend=do_gcc_backend + fi + + CT_DoStep INFO "Installing libstdc++ newlib-nano" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-libstdcxx-newlib-nano" + "${final_backend}" "${final_opts[@]}" + + # Create "nano" symlinks for libstdc++.a & libsup++.a + CT_IterateMultilibs do_nano_libstdcxx_symlinks libstdcxx_symlinks + + CT_Popd + + CT_EndStep + fi +} + +do_newlib_nano_for_target() { + local -a newlib_nano_opts + local cflags_for_target + + CT_DoStep INFO "Installing Newlib Nano library" + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-newlib_nano-build-${CT_BUILD}" + + CT_DoLog EXTRA "Configuring Newlib Nano library" + + # Multilib is the default, so if it is not enabled, disable it. + if [ "${CT_MULTILIB}" != "y" ]; then + newlib_nano_opts+=("-Dmultilib=false") + fi + + if [ "${CT_LIBC_NEWLIB_NANO_IO_FLOAT}" = "y" ]; then + newlib_opts+=( "--enable-newlib-io-float" ) + if [ "${CT_LIBC_NEWLIB_NANO_IO_LDBL}" = "y" ]; then + newlib_opts+=( "--enable-newlib-io-long-double" ) + else + newlib_opts+=( "--disable-newlib-io-long-double" ) + fi + else + newlib_opts+=( "--disable-newlib-io-float" ) + newlib_opts+=( "--disable-newlib-io-long-double" ) + fi + + if [ "${CT_LIBC_NEWLIB_NANO_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then + newlib_opts+=( "--disable-newlib-supplied-syscalls" ) + else + newlib_opts+=( "--enable-newlib-supplied-syscalls" ) + fi + + yn_args="IO_POS_ARGS:newlib-io-pos-args +IO_C99FMT:newlib-io-c99-formats +IO_LL:newlib-io-long-long +REGISTER_FINI:newlib-register-fini +NANO_MALLOC:newlib-nano-malloc +NANO_FORMATTED_IO:newlib-nano-formatted-io +ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc +GLOBAL_ATEXIT:newlib-global-atexit +LITE_EXIT:lite-exit +REENT_SMALL:newlib-reent-small +MULTITHREAD:newlib-multithread +RETARGETABLE_LOCKING:newlib-retargetable-locking +WIDE_ORIENT:newlib-wide-orient +FSEEK_OPTIMIZATION:newlib-fseek-optimization +FVWRITE_IN_STREAMIO:newlib-fvwrite-in-streamio +UNBUF_STREAM_OPT:newlib-unbuf-stream-opt +ENABLE_TARGET_OPTSPACE:target-optspace + " + + for ynarg in $yn_args; do + var="CT_LIBC_NEWLIB_NANO_${ynarg%:*}" + eval var=\$${var} + argument=${ynarg#*:} + + + if [ "${var}" = "y" ]; then + newlib_opts+=( "--enable-$argument" ) + else + newlib_opts+=( "--disable-$argument" ) + fi + done + + [ "${CT_LIBC_NEWLIB_NANO_EXTRA_SECTIONS}" = "y" ] && \ + CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS="${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS} -ffunction-sections -fdata-sections" + + [ "${CT_LIBC_NEWLIB_NANO_LTO}" = "y" ] && \ + CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS="${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS} -flto" + + cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_NANO_TARGET_CFLAGS}" + + # Note: newlib handles the build/host/target a little bit differently + # than one would expect: + # build : not used + # host : the machine building newlib + # target : the machine newlib runs on + CT_DoExecLog CFG \ + CC_FOR_BUILD="${CT_BUILD}-gcc" \ + CFLAGS_FOR_TARGET="${cflags_for_target}" \ + AR_FOR_TARGET="`which ${CT_TARGET}-gcc-ar`" \ + RANLIB_FOR_TARGET="`which ${CT_TARGET}-gcc-ranlib`" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/newlib-nano/configure" \ + --host=${CT_BUILD} \ + --target=${CT_TARGET} \ + --prefix=${CT_PREFIX_DIR} \ + --exec-prefix=${CT_PREFIX_DIR}/newlib-nano \ + --libdir=${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib \ + "${newlib_opts[@]}" \ + "${CT_LIBC_NEWLIB_NANO_EXTRA_CONFIG_ARRAY[@]}" + + CT_DoLog EXTRA "Building Newlib Nano C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + CT_DoLog EXTRA "Installing Newlib Nano C library" + CT_DoExecLog ALL make install + + if [ "${CT_NEWLIB_NANO_INSTALL_IN_TARGET}" = "y" ]; then + cat > "${CT_SYSROOT_DIR}/lib/nano.specs" <<EOF +%rename link nano_link +%rename link_gcc_c_sequence nano_link_gcc_c_sequence +%rename cpp_unique_options nano_cpp_unique_options + +*cpp_unique_options: +-isystem =/include/newlib-nano %(nano_cpp_unique_options) + +*nano_libc: +-lc_nano + +*nano_libgloss: +%{specs=rdimon.specs:-lrdimon_nano} %{specs=nosys.specs:-lnosys} + +*link_gcc_c_sequence: +%(nano_link_gcc_c_sequence) --start-group %G %(nano_libc) %(nano_libgloss) --end-group + +*link: +%(nano_link) %:replace-outfile(-lc -lc_nano) %:replace-outfile(-lg -lg_nano) %:replace-outfile(-lm -lm_nano) %:replace-outfile(-lstdc++ -lstdc++_nano) %:replace-outfile(-lsupc++ -lsupc++_nano) %:replace-outfile(-lrdimon -lrdimon_nano) + +*lib: +%{!shared:%{g*:-lg_nano} %{!p:%{!pg:-lc_nano}}%{p:-lc_p}%{pg:-lc_p}} + +EOF + else + cat > "${CT_SYSROOT_DIR}/lib/nano.specs" <<EOF +%rename link newlib_nano_link +%rename cpp newlib_nano_cpp +%rename cc1plus newlib_nano_cc1plus + +*cpp: +-isystem %:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/include) %(newlib_nano_cpp) + +*cc1plus: +-idirafter %:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/include) %(newlib_nano_cc1plus) + +*link: +-L%:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/lib/%M) -L%:getenv(GCC_EXEC_PREFIX ../../newlib-nano/${CT_TARGET}/lib) + +EOF + fi + + # Create "nano" symlinks for libc.a, libg.a & libm.a + CT_IterateMultilibs do_nano_libc_symlinks libc_symlinks + + CT_Popd + CT_EndStep + + do_cc_libstdcxx_newlib_nano + + if [ "${CT_NEWLIB_NANO_INSTALL_IN_TARGET}" = "y" ]; then + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano" + CT_DoExecLog ALL cp -f "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/include/newlib.h" \ + "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano/newlib.h" + CT_IterateMultilibs newlib_nano_copy_multilibs copylibs + fi +} + +newlib_nano_copy_multilibs() +{ + local nano_lib_dir="${CT_PREFIX_DIR}/newlib-nano" + local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + for lib_a in "${nano_lib_dir}/${CT_TARGET}/lib/${multi_dir}/"*.a; do + if [ -f ${lib_a} ] && [ ! -L ${lib_a} ]; then + _f=$(basename "${lib_a}") + CT_DoExecLog ALL cp -f "${lib_a}" \ + "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/${_f%.*}_nano.a" + fi + done +} + +fi diff --git a/scripts/build/companion_libs/400-gnuprumcu.sh b/scripts/build/companion_libs/400-gnuprumcu.sh new file mode 100644 index 0000000..bba8574 --- /dev/null +++ b/scripts/build/companion_libs/400-gnuprumcu.sh @@ -0,0 +1,88 @@ +# Build script for gnuprumcu + +do_gnuprumcu_get() { :; } +do_gnuprumcu_extract() { :; } +do_gnuprumcu_for_build() { :; } +do_gnuprumcu_for_host() { :; } +do_gnuprumcu_for_target() { :; } + +if [ "${CT_COMP_LIBS_GNUPRUMCU}" = "y" ]; then + +do_gnuprumcu_get() { + CT_Fetch GNUPRUMCU +} + +do_gnuprumcu_extract() { + CT_ExtractPatch GNUPRUMCU +} + + +do_gnuprumcu_for_target() { + local -a gnuprumcu_opts + + CT_DoStep INFO "Installing gnuprumcu for the target" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gnuprumcu-target-${CT_TARGET}" + + gnuprumcu_opts+=( "destdir=${CT_SYSROOT_DIR}" ) + gnuprumcu_opts+=( "host=${CT_TARGET}" ) + + gnuprumcu_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) + gnuprumcu_opts+=( "prefix=${CT_PREFIX_DIR}" ) + do_gnuprumcu_backend "${gnuprumcu_opts[@]}" + + CT_Popd + CT_EndStep +} + + +# Build gnuprumcu +# Parameter : description : type : default +# destdir : out-of-tree install dir : string : / +# host : machine to run on : tuple : (none) +# prefix : prefix to install into : dir : (none) +# cflags : cflags to use : string : (empty) +# ldflags : ldflags to use : string : (empty) +# shared : also buils shared lib : bool : n +do_gnuprumcu_backend() { + local destdir="/" + local host + local prefix + local cflags + local ldflags + local shared + local -a extra_config + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Configuring gnuprumcu" + + CT_DoExecLog CFG \ + CC="${CT_TARGET}-${CT_CC}" \ + RANLIB="${CT_TARGET}-ranlib" \ + CFLAGS="${cflags}" \ + LDFLAGS="${ldflags}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/gnuprumcu/configure" \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --prefix="${prefix}" \ + "${extra_config[@]}" + + CT_DoLog EXTRA "Building gnuprumcu" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing gnuprumcu" + + # Guard against $destdir$prefix == // + # which is a UNC path on Cygwin/MSYS2 + if [[ ${destdir} == / ]] && [[ ${prefix} == /* ]]; then + destdir= + fi + + CT_DoExecLog ALL make instroot="${destdir}" install +} + +fi # CT_COMP_LIBS_GNUPRUMCU diff --git a/scripts/build/companion_tools.sh b/scripts/build/companion_tools.sh index b190ed7..7776f64 100644 --- a/scripts/build/companion_tools.sh +++ b/scripts/build/companion_tools.sh @@ -5,7 +5,7 @@ CT_COMP_TOOLS_FACILITY_LIST= for f in "${CT_LIB_DIR}/scripts/build/companion_tools/"*.sh; do _f="$(basename "${f}" .sh)" _f="${_f#???-}" - __f="CT_COMP_TOOLS_${_f}" + __f="CT_COMP_TOOLS_${_f^^}" if [ "${!__f}" = "y" ]; then CT_DoLog DEBUG "Enabling companion tool '${_f}'" . "${f}" diff --git a/scripts/build/companion_tools/050-make.sh b/scripts/build/companion_tools/050-make.sh index 44487c1..df77d5b 100644 --- a/scripts/build/companion_tools/050-make.sh +++ b/scripts/build/companion_tools/050-make.sh @@ -1,17 +1,17 @@ # Build script for make -do_companion_tools_make_get() { - CT_GetFile "make-${CT_MAKE_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/make +do_companion_tools_make_get() +{ + CT_Fetch MAKE } -do_companion_tools_make_extract() { - CT_Extract "make-${CT_MAKE_VERSION}" - CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/make-${CT_MAKE_VERSION}" - CT_Patch "make" "${CT_MAKE_VERSION}" +do_companion_tools_make_extract() +{ + CT_ExtractPatch MAKE } -do_companion_tools_make_for_build() { +do_companion_tools_make_for_build() +{ CT_DoStep INFO "Installing make for build" CT_mkdir_pushd "${CT_BUILD_DIR}/build-make-build" do_make_backend \ @@ -23,10 +23,14 @@ do_companion_tools_make_for_build() { if [ "${CT_MAKE_GMAKE_SYMLINK}" = "y" ]; then CT_DoExecLog ALL ln -sv make "${CT_BUILD_COMPTOOLS_DIR}/bin/gmake" fi + if [ "${CT_MAKE_GNUMAKE_SYMLINK}" = "y" ]; then + CT_DoExecLog ALL ln -sv make "${CT_BUILD_COMPTOOLS_DIR}/bin/gnumake" + fi CT_EndStep } -do_companion_tools_make_for_host() { +do_companion_tools_make_for_host() +{ CT_DoStep INFO "Installing make for host" CT_mkdir_pushd "${CT_BUILD_DIR}/build-make-host" do_make_backend \ @@ -38,27 +42,37 @@ do_companion_tools_make_for_host() { if [ "${CT_MAKE_GMAKE_SYMLINK}" = "y" ]; then CT_DoExecLog ALL ln -sv make "${CT_PREFIX_DIR}/bin/gmake" fi + if [ "${CT_MAKE_GNUMAKE_SYMLINK}" = "y" ]; then + CT_DoExecLog ALL ln -sv make "${CT_PREFIX_DIR}/bin/gnumake" + fi CT_EndStep } -do_make_backend() { +do_make_backend() +{ local host local prefix local cflags local ldflags + local -a extra_config for arg in "$@"; do eval "${arg// /\\ }" done + if [ "${host}" != "${CT_BUILD}" ]; then + extra_config+=( --without-guile ) + fi + CT_DoLog EXTRA "Configuring make" CT_DoExecLog CFG \ CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/make-${CT_MAKE_VERSION}/configure" \ + "${CT_SRC_DIR}/make/configure" \ --host="${host}" \ - --prefix="${prefix}" + --prefix="${prefix}" \ + "${extra_config[@]}" CT_DoLog EXTRA "Building make" CT_DoExecLog ALL make diff --git a/scripts/build/companion_tools/100-m4.sh b/scripts/build/companion_tools/100-m4.sh index e0fccd7..7d9044f 100644 --- a/scripts/build/companion_tools/100-m4.sh +++ b/scripts/build/companion_tools/100-m4.sh @@ -1,16 +1,17 @@ # Build script for m4 -do_companion_tools_m4_get() { - CT_GetFile "m4-${CT_M4_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/m4 +do_companion_tools_m4_get() +{ + CT_Fetch M4 } -do_companion_tools_m4_extract() { - CT_Extract "m4-${CT_M4_VERSION}" - CT_Patch "m4" "${CT_M4_VERSION}" +do_companion_tools_m4_extract() +{ + CT_ExtractPatch M4 } -do_companion_tools_m4_for_build() { +do_companion_tools_m4_for_build() +{ CT_DoStep INFO "Installing m4 for build" CT_mkdir_pushd "${CT_BUILD_DIR}/build-m4-build" do_m4_backend \ @@ -22,7 +23,8 @@ do_companion_tools_m4_for_build() { CT_EndStep } -do_companion_tools_m4_for_host() { +do_companion_tools_m4_for_host() +{ CT_DoStep INFO "Installing m4 for host" CT_mkdir_pushd "${CT_BUILD_DIR}/build-m4-host" do_m4_backend \ @@ -34,11 +36,13 @@ do_companion_tools_m4_for_host() { CT_EndStep } -do_m4_backend() { +do_m4_backend() +{ local host local prefix local cflags local ldflags + local libs for arg in "$@"; do eval "${arg// /\\ }" @@ -51,14 +55,21 @@ do_m4_backend() { # it includes system <spawn.h> but expects a locally-built # posix_spawn(). ldflags="${ldflags} -lrt" + ;; + *-mingw32) + # m4 is built with stack smashing protection enabled which + # is not part of mingw-w64 c library in v7.0.0 and later. + libs="${libs} -lssp" + ;; esac CT_DoLog EXTRA "Configuring m4" CT_DoExecLog CFG \ CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ + LIBS="${libs}" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/m4-${CT_M4_VERSION}/configure" \ + "${CT_SRC_DIR}/m4/configure" \ --host="${host}" \ --prefix="${prefix}" diff --git a/scripts/build/companion_tools/200-autoconf.sh b/scripts/build/companion_tools/200-autoconf.sh index bccef75..28ff651 100644 --- a/scripts/build/companion_tools/200-autoconf.sh +++ b/scripts/build/companion_tools/200-autoconf.sh @@ -1,17 +1,17 @@ # Build script for autoconf -do_companion_tools_autoconf_get() { - CT_GetFile "autoconf-${CT_AUTOCONF_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/autoconf +do_companion_tools_autoconf_get() +{ + CT_Fetch AUTOCONF } -do_companion_tools_autoconf_extract() { - CT_Extract "autoconf-${CT_AUTOCONF_VERSION}" - CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/autoconf-${CT_AUTOCONF_VERSION}" - CT_Patch "autoconf" "${CT_AUTOCONF_VERSION}" +do_companion_tools_autoconf_extract() +{ + CT_ExtractPatch AUTOCONF } -do_companion_tools_autoconf_for_build() { +do_companion_tools_autoconf_for_build() +{ CT_DoStep INFO "Installing autoconf for build" CT_mkdir_pushd "${CT_BUILD_DIR}/build-autoconf-build" do_autoconf_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}" @@ -19,7 +19,8 @@ do_companion_tools_autoconf_for_build() { CT_EndStep } -do_companion_tools_autoconf_for_host() { +do_companion_tools_autoconf_for_host() +{ CT_DoStep INFO "Installing autoconf for host" CT_mkdir_pushd "${CT_BUILD_DIR}/build-autoconf-host" do_autoconf_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}" @@ -27,7 +28,8 @@ do_companion_tools_autoconf_for_host() { CT_EndStep } -do_autoconf_backend() { +do_autoconf_backend() +{ local host local prefix @@ -42,7 +44,7 @@ do_autoconf_backend() { CT_DoLog EXTRA "Configuring autoconf" CT_DoExecLog CFG \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/autoconf-${CT_AUTOCONF_VERSION}/configure" \ + "${CT_SRC_DIR}/autoconf/configure" \ --host="${host}" \ --prefix="${prefix}" diff --git a/scripts/build/companion_tools/300-automake.sh b/scripts/build/companion_tools/300-automake.sh index ee76463..9f7dd49 100644 --- a/scripts/build/companion_tools/300-automake.sh +++ b/scripts/build/companion_tools/300-automake.sh @@ -1,17 +1,17 @@ # Build script for automake -do_companion_tools_automake_get() { - CT_GetFile "automake-${CT_AUTOMAKE_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/automake +do_companion_tools_automake_get() +{ + CT_Fetch AUTOMAKE } -do_companion_tools_automake_extract() { - CT_Extract "automake-${CT_AUTOMAKE_VERSION}" - CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/automake-${CT_AUTOMAKE_VERSION}" - CT_Patch "automake" "${CT_AUTOMAKE_VERSION}" +do_companion_tools_automake_extract() +{ + CT_ExtractPatch AUTOMAKE } -do_companion_tools_automake_for_build() { +do_companion_tools_automake_for_build() +{ CT_DoStep INFO "Installing automake for build" CT_mkdir_pushd "${CT_BUILD_DIR}/build-automake-build" do_automake_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}" @@ -19,7 +19,8 @@ do_companion_tools_automake_for_build() { CT_EndStep } -do_companion_tools_automake_for_host() { +do_companion_tools_automake_for_host() +{ CT_DoStep INFO "Installing automake for host" CT_mkdir_pushd "${CT_BUILD_DIR}/build-automake-host" do_automake_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}" @@ -27,7 +28,8 @@ do_companion_tools_automake_for_host() { CT_EndStep } -do_automake_backend() { +do_automake_backend() +{ local host local prefix @@ -38,7 +40,7 @@ do_automake_backend() { CT_DoLog EXTRA "Configuring automake" CT_DoExecLog CFG \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/automake-${CT_AUTOMAKE_VERSION}/configure" \ + "${CT_SRC_DIR}/automake/configure" \ --host="${host}" \ --prefix="${prefix}" diff --git a/scripts/build/companion_tools/400-libtool.sh b/scripts/build/companion_tools/400-libtool.sh index 4461207..f7aeb6c 100644 --- a/scripts/build/companion_tools/400-libtool.sh +++ b/scripts/build/companion_tools/400-libtool.sh @@ -1,17 +1,17 @@ # Build script for libtool -do_companion_tools_libtool_get() { - CT_GetFile "libtool-${CT_LIBTOOL_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/libtool +do_companion_tools_libtool_get() +{ + CT_Fetch LIBTOOL } -do_companion_tools_libtool_extract() { - CT_Extract "libtool-${CT_LIBTOOL_VERSION}" - CT_DoExecLog ALL chmod -R u+w "${CT_SRC_DIR}/libtool-${CT_LIBTOOL_VERSION}" - CT_Patch "libtool" "${CT_LIBTOOL_VERSION}" +do_companion_tools_libtool_extract() +{ + CT_ExtractPatch LIBTOOL } -do_companion_tools_libtool_for_build() { +do_companion_tools_libtool_for_build() +{ CT_DoStep INFO "Installing libtool for build" CT_mkdir_pushd "${CT_BUILD_DIR}/build-libtool-build" do_libtool_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}" @@ -19,7 +19,8 @@ do_companion_tools_libtool_for_build() { CT_EndStep } -do_companion_tools_libtool_for_host() { +do_companion_tools_libtool_for_host() +{ CT_DoStep INFO "Installing libtool for host" CT_mkdir_pushd "${CT_BUILD_DIR}/build-libtool-host" do_libtool_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}" @@ -27,7 +28,8 @@ do_companion_tools_libtool_for_host() { CT_EndStep } -do_libtool_backend() { +do_libtool_backend() +{ local host local prefix @@ -38,7 +40,7 @@ do_libtool_backend() { CT_DoLog EXTRA "Configuring libtool" CT_DoExecLog CFG \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/libtool-${CT_LIBTOOL_VERSION}/configure" \ + "${CT_SRC_DIR}/libtool/configure" \ --host="${host}" \ --prefix="${prefix}" diff --git a/scripts/build/companion_tools/500-dtc.sh b/scripts/build/companion_tools/500-dtc.sh new file mode 100644 index 0000000..a16ff62 --- /dev/null +++ b/scripts/build/companion_tools/500-dtc.sh @@ -0,0 +1,87 @@ +# Build script for DTC (device tree compiler) + +do_companion_tools_dtc_get() +{ + CT_Fetch DTC +} + +do_companion_tools_dtc_extract() +{ + CT_ExtractPatch DTC +} + +do_companion_tools_dtc_for_build() +{ + CT_DoStep INFO "Installing dtc for build" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-dtc-build" + do_dtc_backend \ + host=${CT_BUILD} \ + prefix="${CT_BUILD_COMPTOOLS_DIR}" \ + cflags="${CT_CFLAGS_FOR_BUILD}" \ + ldflags="${CT_LDFLAGS_FOR_BUILD}" + CT_Popd + CT_EndStep +} + +do_companion_tools_dtc_for_host() +{ + CT_DoStep INFO "Installing dtc for host" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-dtc-host" + do_dtc_backend \ + host=${CT_HOST} \ + prefix="${CT_PREFIX_DIR}" \ + cflags="${CT_CFLAGS_FOR_HOST}" \ + ldflags="${CT_LDFLAGS_FOR_HOST}" + CT_Popd + CT_EndStep +} + +do_dtc_backend() +{ + local host + local prefix + local cflags + local ldflags + local -a extra_opts + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + # Override PKG_CONFIG: if pkg-config is not installed, DTC's makefile + # misinterprets the error code and tries to enable YAML support while + # not linking against libyaml. NO_YAML=1 is sufficient to make the build + # pass; PKG_CONFIG=/bin/true just suppresses some scary error messages. + extra_opts=( \ + CC="${host}-gcc" \ + AR="${host}-ar" \ + PREFIX="${prefix}" \ + PKG_CONFIG=/bin/true \ + NO_PYTHON=1 \ + NO_YAML=1 \ + BIN=dtc \ + ) + if [ -n "${CT_DTC_VERBOSE}" ]; then + extra_opts+=( V=1 ) + fi + case "${host}" in + *-mingw32) + # Turn off warnings: mingw32 hosts complain about %zd formats even though + # they seem to be supported by mingw32. Only build 'dtc', again, because + # other binaries use syscalls not available under mingw32, but we also + # do not need them. Hijack WARNINGS to override lstat with stat (Windows + # does not have symlinks). + extra_opts+=( BIN=dtc WARNINGS=-Dlstat=stat ) + ;; + esac + + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/dtc/." . + + CT_DoLog EXTRA "Building dtc" + CT_DoExecLog ALL make all "${extra_opts[@]}" + + # Only install binaries, we don't support shared libraries in installation + # directory yet. + CT_DoLog EXTRA "Installing dtc" + CT_DoExecLog ALL make install-bin "${extra_opts[@]}" +} diff --git a/scripts/build/companion_tools/510-bison.sh b/scripts/build/companion_tools/510-bison.sh new file mode 100644 index 0000000..90bf9ec --- /dev/null +++ b/scripts/build/companion_tools/510-bison.sh @@ -0,0 +1,66 @@ +# Build script for bison + +do_companion_tools_bison_get() +{ + CT_Fetch BISON +} + +do_companion_tools_bison_extract() +{ + CT_ExtractPatch BISON +} + +do_companion_tools_bison_for_build() +{ + CT_DoStep INFO "Installing bison for build" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-bison-build" + do_bison_backend \ + host=${CT_BUILD} \ + prefix="${CT_BUILD_COMPTOOLS_DIR}" \ + cflags="${CT_CFLAGS_FOR_BUILD}" \ + ldflags="${CT_LDFLAGS_FOR_BUILD}" + CT_Popd + CT_EndStep +} + +do_companion_tools_bison_for_host() +{ + CT_DoStep INFO "Installing bison for host" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-bison-host" + do_bison_backend \ + host=${CT_HOST} \ + prefix="${CT_PREFIX_DIR}" \ + cflags="${CT_CFLAGS_FOR_HOST}" \ + ldflags="${CT_LDFLAGS_FOR_HOST}" + CT_Popd + CT_EndStep +} + +do_bison_backend() +{ + local host + local prefix + local cflags + local ldflags + local -a extra_config + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Configuring bison" + CT_DoExecLog CFG \ + CFLAGS="${cflags}" \ + LDFLAGS="${ldflags}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/bison/configure" \ + --host="${host}" \ + --prefix="${prefix}" \ + "${extra_config[@]}" + + CT_DoLog EXTRA "Building bison" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing bison" + CT_DoExecLog ALL make install +} diff --git a/scripts/build/debug.sh b/scripts/build/debug.sh index f07b295..f8178dd 100644 --- a/scripts/build/debug.sh +++ b/scripts/build/debug.sh @@ -5,7 +5,7 @@ CT_DEBUG_FACILITY_LIST= for f in "${CT_LIB_DIR}/scripts/build/debug/"*.sh; do _f="$(basename "${f}" .sh)" _f="${_f#???-}" - __f="CT_DEBUG_${_f}" + __f="CT_DEBUG_${_f^^}" if [ "${!__f}" = "y" ]; then CT_DoLog DEBUG "Enabling debug '${_f}'" . "${f}" diff --git a/scripts/build/debug/000-template.sh b/scripts/build/debug/000-template.sh deleted file mode 100644 index 47d2cae..0000000 --- a/scripts/build/debug/000-template.sh +++ /dev/null @@ -1,34 +0,0 @@ -# Template file for a debug utility - -# Put your download code here -do_debug_foobar_get() { - # For example: - # CT_GetFile "foobar-${CT_FOOBAR_VERSION}" http://foobar.com/releases/ - : -} - -# Put your extract code here -do_debug_foobar_extract() { - # For example: - # CT_Extract "foobar-${CT_FOOBAR_VERSION}" - # CT_Patch "foobar" "${CT_FOOBAR_VERSION}" - : -} - -# Put your build code here -do_debug_foobar_build() { - # For example: - # mkdir -p "${CT_BUILD_DIR}/build-foobar" - # CT_Pushd "${CT_BUILD_DIR}/build-foobar" - # CT_DoExecLog CFG \ - # "${CT_SRC_DIR}/foobar-${CT_FOOBAR_VERSION}/configure" \ - # --build=${CT_BUILD} \ - # --host=${CT_TARGET} \ - # --prefix=/usr \ - # --foobar-options - # CT_DoExecLog ALL make - # CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install - # CT_Popd - : -} - diff --git a/scripts/build/debug/200-duma.sh b/scripts/build/debug/200-duma.sh index 2a9b01f..9e2379e 100644 --- a/scripts/build/debug/200-duma.sh +++ b/scripts/build/debug/200-duma.sh @@ -1,24 +1,11 @@ # Build script for D.U.M.A. do_debug_duma_get() { - local dl_base - - dl_base="http://downloads.sourceforge.net/project/duma/duma" - dl_base+="/${CT_DUMA_VERSION//_/.}" - - # Downloading an non-existing file from sourceforge will give you an - # HTML file containing an error message, instead of returning a 404. - # Sigh... - CT_GetFile "duma_${CT_DUMA_VERSION}" .tar.gz "${dl_base}" - # Downloading from sourceforge may leave garbage, cleanup - CT_DoExecLog ALL rm -f "${CT_TARBALLS_DIR}/showfiles.php"* + CT_Fetch DUMA } do_debug_duma_extract() { - CT_Extract "duma_${CT_DUMA_VERSION}" - CT_Pushd "${CT_SRC_DIR}/duma_${CT_DUMA_VERSION}" - CT_Patch nochdir "duma" "${CT_DUMA_VERSION}" - CT_Popd + CT_ExtractPatch DUMA } do_debug_duma_build() { @@ -26,14 +13,14 @@ do_debug_duma_build() { CT_DoStep INFO "Installing D.U.M.A." CT_DoLog EXTRA "Copying sources" - cp -a "${CT_SRC_DIR}/duma_${CT_DUMA_VERSION}/." "${CT_BUILD_DIR}/build-duma" + cp -a "${CT_SRC_DIR}/duma/." "${CT_BUILD_DIR}/build-duma" CT_Pushd "${CT_BUILD_DIR}/build-duma" make_args=( prefix="${CT_DEBUGROOT_DIR}/usr" HOSTCC="${CT_BUILD}-gcc" - CC="${CT_TARGET}-${CT_CC}" - CXX="${CT_TARGET}-g++" + CC="${CT_TARGET}-${CT_CC} ${CT_ALL_TARGET_CFLAGS}" + CXX="${CT_TARGET}-g++ ${CT_ALL_TARGET_CFLAGS}" RANLIB="${CT_TARGET}-ranlib" OS="${CT_KERNEL}" ) diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index a5ac7f9..4afaba4 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -1,190 +1,150 @@ # Build script for the gdb debug facility -do_debug_gdb_get() { - local linaro_version="" - local linaro_series="" - - if [ "${CT_GDB_CUSTOM}" = "y" ]; then - CT_GetCustom "gdb" "${CT_GDB_CUSTOM_VERSION}" \ - "${CT_GDB_CUSTOM_LOCATION}" - else - case "${CT_GDB_VERSION}" in - linaro-*) - CT_GetLinaro "gdb" "${CT_GDB_VERSION}" - ;; - *) - CT_GetFile "gdb-${CT_GDB_VERSION}" \ - http://mirrors.kernel.org/sourceware/gdb \ - {http,ftp,https}://ftp.gnu.org/pub/gnu/gdb \ - ftp://{sourceware.org,gcc.gnu.org}/pub/gdb/releases - ;; - esac - fi +do_debug_gdb_get() +{ + CT_Fetch GDB } -do_debug_gdb_extract() { - CT_Extract "gdb-${CT_GDB_VERSION}" - CT_Patch "gdb" "${CT_GDB_VERSION}" - - if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then - CT_ConfigureXtensa "gdb" "${CT_GDB_VERSION}" - fi +do_debug_gdb_extract() +{ + CT_ExtractPatch GDB } -do_debug_gdb_build() { - local -a extra_config - - gdb_src_dir="${CT_SRC_DIR}/gdb-${CT_GDB_VERSION}" - - # Version 6.3 and below behave badly with gdbmi - case "${CT_GDB_VERSION}" in - 6.2*|6.3) extra_config+=("--disable-gdbmi");; - esac - - if [ "${CT_GDB_HAS_PKGVERSION_BUGURL}" = "y" ]; then - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") - [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") - fi - +do_debug_gdb_build() +{ if [ "${CT_GDB_CROSS}" = "y" ]; then + local gcc_version p _p local -a cross_extra_config - local gcc_version CT_DoStep INFO "Installing cross-gdb" - CT_DoLog EXTRA "Configuring cross-gdb" - - mkdir -p "${CT_BUILD_DIR}/build-gdb-cross" - cd "${CT_BUILD_DIR}/build-gdb-cross" - - cross_extra_config=("${extra_config[@]}") - - # For gdb-cross this combination of flags forces - # gdb configure to fall back to default '-lexpat' flag - # which is acceptable. - # - # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!! - # It conflicts with a static build: GDB's configure script will find the shared - # version of expat and will attempt to link that, despite the -static flag. - # The link will fail, and configure will abort with "expat missing or unusable" - # message. - cross_extra_config+=("--with-expat") - cross_extra_config+=("--without-libexpat-prefix") + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-cross" - case "${CT_THREADS}" in - none) cross_extra_config+=("--disable-threads");; - *) cross_extra_config+=("--enable-threads");; - esac + cross_extra_config=( "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}" ) if [ "${CT_GDB_CROSS_PYTHON}" = "y" ]; then - cross_extra_config+=( "--with-python=yes" ) + if [ -z "${CT_GDB_CROSS_PYTHON_BINARY}" ]; then + if [ "${CT_CANADIAN}" = "y" -o "${CT_CROSS_NATIVE}" = "y" ]; then + CT_Abort "For canadian build, Python wrapper runnable on the build machine must be provided. Set CT_GDB_CROSS_PYTHON_BINARY." + elif [ "${CT_CONFIGURE_has_python}" = "y" ]; then + cross_extra_config+=("--with-python=${python}") + else + CT_Abort "Python support requested in GDB, but Python not found. Set CT_GDB_CROSS_PYTHON_BINARY." + fi + else + cross_extra_config+=("--with-python=${CT_GDB_CROSS_PYTHON_BINARY}") + fi else - cross_extra_config+=( "--with-python=no" ) + cross_extra_config+=("--with-python=no") fi + if [ "${CT_GDB_CROSS_SIM}" = "y" ]; then - cross_extra_config+=( "--enable-sim" ) + cross_extra_config+=("--enable-sim") else - cross_extra_config+=( "--disable-sim" ) - fi - if [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ]; then - cross_extra_config+=("--disable-nls") + cross_extra_config+=("--disable-sim") fi - CPP_for_gdb="${CT_HOST}-cpp ${CT_CFLAGS_FOR_HOST}" - CC_for_gdb="${CT_HOST}-gcc ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST}" - CXX_for_gdb="${CT_HOST}-g++ ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST}" - LD_for_gdb="${CT_HOST}-ld ${CT_LDFLAGS_FOR_HOST}" - if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then - CC_for_gdb+=" -static" - CXX_for_gdb+=" -static" - LD_for_gdb+=" -static" + if ${CT_HOST}-gcc --version 2>&1 | grep clang; then + # clang detects the line from gettext's _ macro as format string + # not being a string literal and produces a lot of warnings - which + # ct-ng's logger faithfully relays to user if this happens in the + # error() function. Suppress them. + cross_extra_config+=("--enable-build-warnings=,-Wno-format-nonliteral,-Wno-format-security") fi - case "${CT_HOST}" in - *darwin*) - # FIXME: Really, we should be testing for host compiler being clang. - CC_for_gdb+=" -Qunused-arguments" - CXX_for_gdb+=" -Qunused-arguments" - ;; - esac - # Fix up whitespace. Some older GDB releases (e.g. 6.8a) get confused if there - # are multiple consecutive spaces: sub-configure scripts replace them with a - # single space and then complain that $CC value changed from that in - # the master directory. - CPP_for_gdb=`echo $CPP_for_gdb` - CC_for_gdb=`echo $CC_for_gdb` - CXX_for_gdb=`echo $CXX_for_gdb` - LD_for_gdb=`echo $LD_for_gdb` - - # Disable binutils options when building from the binutils-gdb repo. - cross_extra_config+=("--disable-binutils") - cross_extra_config+=("--disable-ld") - cross_extra_config+=("--disable-gas") - - CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'" - - CT_DoExecLog CFG \ - CPP="${CPP_for_gdb}" \ - CC="${CC_for_gdb}" \ - CXX="${CXX_for_gdb}" \ - LD="${LD_for_gdb}" \ - ${CONFIG_SHELL} \ - "${gdb_src_dir}/configure" \ - --build=${CT_BUILD} \ - --host=${CT_HOST} \ - --target=${CT_TARGET} \ - --prefix="${CT_PREFIX_DIR}" \ - --with-build-sysroot="${CT_SYSROOT_DIR}" \ + # Target libexpat resides in sysroot and does not have + # any dependencies, so just passing '-lexpat' to gcc is enough. + # + # By default gdb configure looks for expat in '$prefix/lib' + # directory. In our case '$prefix/lib' resolves to '/usr/lib' + # where libexpat for build platform lives, which is + # unacceptable for cross-compiling. + # + # To prevent this '--without-libexpat-prefix' flag must be passed. + # Thus configure falls back to '-lexpat', which is exactly what we want. + # + # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!! + # It conflicts with a static build: GDB's configure script will find the shared + # version of expat and will attempt to link that, despite the -static flag. + # The link will fail, and configure will abort with "expat missing or unusable" + # message. + extra_config+=("--with-expat") + extra_config+=("--without-libexpat-prefix") + + do_gdb_backend \ + buildtype=cross \ + host="${CT_HOST}" \ + cflags="${CT_CFLAGS_FOR_HOST}" \ + ldflags="${CT_LDFLAGS_FOR_HOST}" \ + prefix="${CT_PREFIX_DIR}" \ + static="${CT_GDB_CROSS_STATIC}" \ --with-sysroot="${CT_SYSROOT_DIR}" \ - --disable-werror \ - "${cross_extra_config[@]}" \ - "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}" - - CT_DoLog EXTRA "Building cross-gdb" - CT_DoExecLog ALL make ${JOBSFLAGS} - - CT_DoLog EXTRA "Installing cross-gdb" - CT_DoExecLog ALL make install + "${cross_extra_config[@]}" if [ "${CT_BUILD_MANUALS}" = "y" ]; then CT_DoLog EXTRA "Building and installing the cross-GDB manuals" - CT_DoExecLog ALL make ${JOBSFLAGS} pdf html + CT_DoExecLog ALL make ${CT_JOBSFLAGS} pdf html CT_DoExecLog ALL make install-{pdf,html}-gdb fi - 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_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 - sed -r \ - -e "s:@@PREFIX@@:${CT_PREFIX_DIR}:;" \ - -e "s:@@VERSION@@:${gcc_version}:;" \ - "${CT_LIB_DIR}/scripts/build/debug/gdbinit.in" \ - >"${CT_PREFIX_DIR}/share/gdb/gdbinit" - fi # Install gdbinit sample + CT_DoLog EXTRA "Installing '.gdbinit' template" + # See in scripts/build/internals.sh for why we do this + # TBD GCC 3.x and older not supported + if [ -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then + gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER") + else + gcc_version=$(sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \ + "${CT_SRC_DIR}/gcc/gcc/version.c" \ + ) + fi + sed -r \ + -e "s:@@PREFIX@@:${CT_PREFIX_DIR}:;" \ + -e "s:@@VERSION@@:${gcc_version}:;" \ + "${CT_LIB_DIR}/scripts/build/debug/gdbinit.in" \ + >"${CT_PREFIX_DIR}/share/gdb/gdbinit" + CT_Popd CT_EndStep fi if [ "${CT_GDB_NATIVE}" = "y" ]; then local -a native_extra_config + local subdir CT_DoStep INFO "Installing native gdb" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-native" - native_extra_config=("${extra_config[@]}") + native_extra_config+=("--program-prefix=") - # We may not have C++ language configured for target - native_extra_config+=("--disable-build-with-cxx") + # gdbserver gets enabled by default with gdb + # since gdbserver was promoted to top-level + if [ "${CT_GDB_GDBSERVER_TOPLEVEL}" = "y" ]; then + native_extra_config+=("--disable-gdbserver") + fi # GDB on Mingw depends on PDcurses, not ncurses if [ "${CT_MINGW32}" != "y" ]; then native_extra_config+=("--with-curses") fi + if [ "${CT_GDB_NATIVE_BUILD_IPA_LIB}" = "y" ]; then + native_extra_config+=("--enable-inprocess-agent") + else + native_extra_config+=("--disable-inprocess-agent") + fi + + export ac_cv_func_strncmp_works=yes + + # TBD do we need all these? + native_extra_config+=( + --without-uiout + --disable-gdbtk + --without-x + --disable-sim + --without-included-gettext + --without-develop + --sysconfdir=/etc + --localstatedir=/var + ) + # Target libexpat resides in sysroot and does not have # any dependencies, so just passing '-lexpat' to gcc is enough. # @@ -201,146 +161,194 @@ do_debug_gdb_build() { # version of expat and will attempt to link that, despite the -static flag. # The link will fail, and configure will abort with "expat missing or unusable" # message. - native_extra_config+=("--with-expat") - native_extra_config+=("--without-libexpat-prefix") + extra_config+=("--with-expat") + extra_config+=("--without-libexpat-prefix") + + do_gdb_backend \ + buildtype=native \ + subdir=${subdir} \ + host="${CT_TARGET}" \ + cflags="${CT_ALL_TARGET_CFLAGS}" \ + ldflags="${CT_ALL_TARGET_LDFLAGS}" \ + static="${CT_GDB_NATIVE_STATIC}" \ + static_libstdc="${CT_GDB_NATIVE_STATIC_LIBSTDC}" \ + prefix=/usr \ + destdir="${CT_DEBUGROOT_DIR}" \ + "${native_extra_config[@]}" - CT_DoLog EXTRA "Configuring native gdb" + unset ac_cv_func_strncmp_works - mkdir -p "${CT_BUILD_DIR}/build-gdb-native" - cd "${CT_BUILD_DIR}/build-gdb-native" + CT_Popd + CT_EndStep # native gdb build + fi - case "${CT_THREADS}" in - none) native_extra_config+=("--disable-threads");; - *) native_extra_config+=("--enable-threads");; - esac + if [ "${CT_GDB_GDBSERVER}" = "y" ]; then + local -a native_extra_config + local subdir - [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && \ - native_extra_config+=("--disable-nls") - - CPP_for_gdb="${CT_TARGET}-cpp" - CC_for_gdb="${CT_TARGET}-${CT_CC}" - CXX_for_gdb="${CT_TARGET}-g++" - LD_for_gdb="${CT_TARGET}-ld" - if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then - CC_for_gdb+=" -static" - CXX_for_gdb+=" -static" - LD_for_gdb+=" -static" + if [ "${CT_GDB_GDBSERVER_TOPLEVEL}" != "y" ]; then + subdir=gdb/gdbserver/ + else + native_extra_config+=("--disable-gdb") fi - export ac_cv_func_strncmp_works=yes + CT_DoStep INFO "Installing gdb server" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-server" - # Disable binutils options when building from the binutils-gdb repo. - native_extra_config+=("--disable-binutils") - native_extra_config+=("--disable-ld") - native_extra_config+=("--disable-gas") - - CT_DoLog DEBUG "Extra config passed: '${native_extra_config[*]}'" - - CT_DoExecLog CFG \ - CPP="${CPP_for_gdb}" \ - CC="${CC_for_gdb}" \ - CXX="${CXX_for_gdb}" \ - LD="${LD_for_gdb}" \ - ${CONFIG_SHELL} \ - "${gdb_src_dir}/configure" \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - --target=${CT_TARGET} \ - --prefix=/usr \ - --with-build-sysroot="${CT_SYSROOT_DIR}" \ - --without-uiout \ - --disable-tui \ - --disable-gdbtk \ - --without-x \ - --disable-sim \ - --disable-werror \ - --without-included-gettext \ - --without-develop \ - "${native_extra_config[@]}" + native_extra_config+=("--program-prefix=") + native_extra_config+=("--enable-gdbserver") - CT_DoLog EXTRA "Building native gdb" - CT_DoExecLog ALL make ${JOBSFLAGS} + if [ "${CT_GDB_NATIVE_BUILD_IPA_LIB}" = "y" ]; then + native_extra_config+=("--enable-inprocess-agent") + else + native_extra_config+=("--disable-inprocess-agent") + fi - CT_DoLog EXTRA "Installing native gdb" - CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install + export ac_cv_func_strncmp_works=yes - # Building a native gdb also builds a gdbserver - find "${CT_DEBUGROOT_DIR}" -type f -name gdbserver -exec rm -fv {} \; 2>&1 |CT_DoLog ALL + # TBD do we need all these? + native_extra_config+=( + --without-uiout + --disable-gdbtk + --without-x + --disable-sim + --without-included-gettext + --without-develop + --sysconfdir=/etc + --localstatedir=/var + ) + + do_gdb_backend \ + buildtype=native \ + subdir=${subdir} \ + host="${CT_TARGET}" \ + cflags="${CT_ALL_TARGET_CFLAGS}" \ + ldflags="${CT_ALL_TARGET_LDFLAGS}" \ + static="${CT_GDB_NATIVE_STATIC}" \ + static_libstdcxx="${CT_GDB_NATIVE_STATIC_LIBSTDCXX}" \ + prefix=/usr \ + destdir="${CT_DEBUGROOT_DIR}" \ + "${native_extra_config[@]}" unset ac_cv_func_strncmp_works - CT_EndStep # native gdb build + CT_Popd + CT_EndStep # gdb server build fi +} - if [ "${CT_GDB_GDBSERVER}" = "y" ]; then - local -a gdbserver_extra_config - local gdbserver_LDFLAGS +do_gdb_backend() +{ + local host prefix destdir cflags ldflags static buildtype subdir + local -a extra_config - CT_DoStep INFO "Installing gdbserver" - CT_DoLog EXTRA "Configuring gdbserver" + for arg in "$@"; do + case "$arg" in + --*) + extra_config+=("${arg}") + ;; + *) + eval "${arg// /\\ }" + ;; + esac + done + + # Starting with glibc 2.25, it now provides a <proc_service.h> header. The + # problem is that GDB releases prior to 7.12 used to implement one of the + # interfaces, ps_get_thread_are with a const qualifier on one of the arguments. + # Therefore, such older versions cannot be compiled against a newer glibc. + # If we detect such a combination, mitigate by creating a local proc_service.h + # with a prototype adjusted for GDB requirements. + if [ -r "${CT_HEADERS_DIR}/proc_service.h" -a "${CT_GDB_CONST_GET_THREAD_AREA}" = "y" ]; then + CT_DoLog DEBUG "Fixing up the prototype in <proc_service.h>" + CT_DoExecLog ALL mkdir -p gdb/gdbserver + CT_DoExecLog ALL cp "${CT_HEADERS_DIR}/proc_service.h" gdb/proc_service.h + CT_DoExecLog ALL sed -i \ + "s/\(ps_get_thread_area *(\).*\(struct ps_prochandle\)/\1const \2/" \ + gdb/proc_service.h + CT_DoExecLog ALL cp gdb/proc_service.h gdb/gdbserver/proc_service.h + fi - mkdir -p "${CT_BUILD_DIR}/build-gdb-gdbserver" - cd "${CT_BUILD_DIR}/build-gdb-gdbserver" + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") - # Workaround for bad versions, where the configure - # script for gdbserver is not executable... - # Bah, GNU folks strike again... :-( - chmod +x "${gdb_src_dir}/gdb/gdbserver/configure" + # Disable binutils options when building from the binutils-gdb repo. + extra_config+=("--disable-binutils") + extra_config+=("--disable-ld") + extra_config+=("--disable-gas") - gdbserver_LDFLAGS= - if [ "${CT_GDB_GDBSERVER_STATIC}" = "y" ]; then - gdbserver_LDFLAGS=-static - fi + if [ "${CT_GDB_HAS_DISABLE_CXX_BUILD}" = "y" ]; then + extra_config+=("--disable-build-with-cxx") + fi - gdbserver_extra_config=("${extra_config[@]}") + case "${CT_THREADS}" in + none) extra_config+=("--disable-threads");; + *) extra_config+=("--enable-threads");; + esac - # We may not have C++ language configured for target - gdbserver_extra_config+=("--disable-build-with-cxx") + if [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ]; then + extra_config+=("--disable-nls") + fi - if [ "${CT_GDB_GDBSERVER_HAS_IPA_LIB}" = "y" ]; then - if [ "${CT_GDB_GDBSERVER_BUILD_IPA_LIB}" = "y" ]; then - gdbserver_extra_config+=( --enable-inprocess-agent ) - else - gdbserver_extra_config+=( --disable-inprocess-agent ) - fi - fi + if [ "${static}" = "y" ]; then + cflags+=" -static" + ldflags+=" -static" + # There is no static libsource-highlight + extra_config+=("--disable-source-highlight") + fi + if [ "${static_libstdcxx}" = "y" ]; then + ldflags+=" -static-libgcc" + ldflags+=" -static-libstdc++" + # libsource-highlight is a dynamic library that uses exception + # exceptions are handled by libstdc++ + # this combination is very buggy, so configure don't use it and abort + extra_config+=("--disable-source-highlight") + fi - # Disable binutils options when building from the binutils-gdb repo. - gdbserver_extra_config+=("--disable-binutils") - gdbserver_extra_config+=("--disable-ld") - gdbserver_extra_config+=("--disable-gas") - - CT_DoExecLog CFG \ - CC="${CT_TARGET}-${CT_CC}" \ - CPP="${CT_TARGET}-cpp" \ - LD="${CT_TARGET}-ld" \ - LDFLAGS="${gdbserver_LDFLAGS}" \ - ${CONFIG_SHELL} \ - "${gdb_src_dir}/gdb/gdbserver/configure" \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - --target=${CT_TARGET} \ - --prefix=/usr \ - --sysconfdir=/etc \ - --localstatedir=/var \ - --includedir="${CT_HEADERS_DIR}" \ - --with-build-sysroot="${CT_SYSROOT_DIR}" \ - --program-prefix= \ - --without-uiout \ - --disable-tui \ - --disable-gdbtk \ - --without-x \ - --without-included-gettext \ - --without-develop \ - --disable-werror \ - "${gdbserver_extra_config[@]}" - - CT_DoLog EXTRA "Building gdbserver" - CT_DoExecLog ALL make ${JOBSFLAGS} CC=${CT_TARGET}-${CT_CC} - - CT_DoLog EXTRA "Installing gdbserver" - CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install - CT_EndStep + # Fix up whitespace. Some older GDB releases (e.g. 6.8a) get confused if there + # are multiple consecutive spaces: sub-configure scripts replace them with a + # single space and then complain that $CC value changed from that in + # the master directory. + cflags=`echo ${cflags}` + ldflags=`echo ${ldflags}` + + CT_DoLog EXTRA "Configuring ${buildtype} gdb" + CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" + + # Run configure/make in the matching subdirectory so that any fixups + # prepared in a given subdirectory apply. + if [ -n "${subdir}" ]; then + CT_mkdir_pushd "${subdir}" + fi + + # TBD: is passing CPP/CC/CXX/LD needed? GCC should be determining this automatically from the triplets + CT_DoExecLog CFG \ + CPP="${host}-cpp" \ + CC="${host}-gcc" \ + CXX="${host}-g++" \ + LD="${host}-ld" \ + CFLAGS="${cflags}" \ + CXXFLAGS="${cflags}" \ + LDFLAGS="${ldflags}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/gdb/${subdir}configure" \ + --build=${CT_BUILD} \ + --host=${host} \ + --target=${CT_TARGET} \ + --prefix="${prefix}" \ + --with-build-sysroot="${CT_SYSROOT_DIR}" \ + --includedir="${CT_HEADERS_DIR}" \ + --disable-werror \ + "${extra_config[@]}" \ + + CT_DoLog EXTRA "Building ${buildtype} gdb" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + CT_DoLog EXTRA "Installing ${buildtype} gdb" + CT_DoExecLog ALL make install ${destdir:+DESTDIR="${destdir}"} + + if [ -n "${subdir}" ]; then + CT_Popd fi } diff --git a/scripts/build/debug/400-ltrace.sh b/scripts/build/debug/400-ltrace.sh index 6b860e9..9c9052a 100644 --- a/scripts/build/debug/400-ltrace.sh +++ b/scripts/build/debug/400-ltrace.sh @@ -1,19 +1,11 @@ # Build script for ltrace do_debug_ltrace_get() { - CT_GetFile "ltrace_${CT_LTRACE_VERSION}.orig" .tar.gz \ - {http,ftp}://ftp.debian.org/debian/pool/main/l/ltrace/ - # Create a link so that the following steps are easier to do: - CT_Pushd "${CT_TARBALLS_DIR}" - ltrace_ext=$(CT_GetFileExtension "ltrace_${CT_LTRACE_VERSION}.orig") - ln -sf "ltrace_${CT_LTRACE_VERSION}.orig${ltrace_ext}" \ - "ltrace-${CT_LTRACE_VERSION}${ltrace_ext}" - CT_Popd + CT_Fetch LTRACE } do_debug_ltrace_extract() { - CT_Extract "ltrace-${CT_LTRACE_VERSION}" - CT_Patch "ltrace" "${CT_LTRACE_VERSION}" + CT_ExtractPatch LTRACE } do_debug_ltrace_build() { @@ -22,37 +14,17 @@ do_debug_ltrace_build() { CT_DoStep INFO "Installing ltrace" CT_DoLog EXTRA "Copying sources to build dir" - CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/ltrace-${CT_LTRACE_VERSION}/." \ + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/ltrace/." \ "${CT_BUILD_DIR}/build-ltrace" CT_Pushd "${CT_BUILD_DIR}/build-ltrace" CT_DoLog EXTRA "Configuring ltrace" - # ltrace-0.5.3 has a unique hand-crafted configure script. Releases - # 0.5.2 and earlier as well as 0.6.0 and later use GNU autotools. - if [ "${LTRACE_0_5_3_CONFIGURE}" = "y" ]; then - case "${CT_ARCH}:${CT_ARCH_BITNESS}" in - x86:32) ltrace_host="i386";; - x86:64) ltrace_host="x86_64";; - powerpc:*) ltrace_host="ppc";; - mips:*) ltrace_host="mipsel";; - *) ltrace_host="${CT_ARCH}";; - esac - CT_DoExecLog CFG \ - CC="${CT_TARGET}-${CT_CC}" \ - AR="${CT_TARGET}-ar" \ - HOST="${ltrace_host}" \ - HOST_OS="${CT_TARGET_KERNEL}" \ - CFLAGS="${CT_TARGET_CFLAGS}" \ - ${CONFIG_SHELL} \ - ./configure --prefix=/usr - else - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - ./configure \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - --prefix=/usr - fi + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + ./configure \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --prefix=/usr CT_DoLog EXTRA "Building ltrace" CT_DoExecLog ALL make @@ -63,4 +35,3 @@ do_debug_ltrace_build() { CT_Popd CT_EndStep } - diff --git a/scripts/build/debug/500-strace.sh b/scripts/build/debug/500-strace.sh index 6eb2357..c28af35 100644 --- a/scripts/build/debug/500-strace.sh +++ b/scripts/build/debug/500-strace.sh @@ -1,32 +1,44 @@ # Build script for strace -do_debug_strace_get() { - local base_url="http://downloads.sourceforge.net/project/strace/strace" - CT_GetFile "strace-${CT_STRACE_VERSION}" "${base_url}/${CT_STRACE_VERSION}" - # Downloading from sourceforge leaves garbage, cleanup - CT_DoExecLog ALL rm -f "${CT_TARBALLS_DIR}/showfiles.php"* +do_debug_strace_get() +{ + CT_Fetch STRACE } -do_debug_strace_extract() { - CT_Extract "strace-${CT_STRACE_VERSION}" - CT_Patch "strace" "${CT_STRACE_VERSION}" +do_debug_strace_extract() +{ + CT_ExtractPatch STRACE } -do_debug_strace_build() { +do_debug_strace_build() +{ + local cflags="${CT_ALL_TARGET_CFLAGS}" + CT_DoStep INFO "Installing strace" + if [ "${CT_LIBC_MUSL}" = "y" ]; then + # Otherwise kernel headers cause errors when included, e.g. + # <netinet/in.h> and <linux/in6.h>. Kernel's libc-compat.h + # only cares about GLIBC. uClibc-ng does the same + # internally, pretending it's GLIBC for kernel headers inclusion. + cflags+=" -D__GLIBC__ -D__USE_MISC" + fi + CT_mkdir_pushd "${CT_BUILD_DIR}/build-strace" CT_DoLog EXTRA "Configuring strace" CT_DoExecLog CFG \ CC="${CT_TARGET}-${CT_CC}" \ + CFLAGS="${cflags}" \ + LDFLAGS="${CT_ALL_TARGET_LDFLAGS}" \ CPP="${CT_TARGET}-cpp" \ LD="${CT_TARGET}-ld" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/strace-${CT_STRACE_VERSION}/configure" \ + "${CT_SRC_DIR}/strace/configure" \ --build=${CT_BUILD} \ --host=${CT_TARGET} \ - --prefix=/usr + --prefix=/usr \ + --enable-mpers=check CT_DoLog EXTRA "Building strace" CT_DoExecLog ALL make diff --git a/scripts/build/internals.sh b/scripts/build/internals.sh index 18ada66..821761c 100644 --- a/scripts/build/internals.sh +++ b/scripts/build/internals.sh @@ -1,5 +1,27 @@ # This file contains crosstool-NG internal steps +create_ldso_conf() +{ + local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_count multi_target + local b d + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoExecLog ALL mkdir -p "${multi_root}/etc" + for b in /lib /usr/lib "${CT_LDSO_CONF_EXTRA_DIRS_ARRAY[@]}"; do + d="${b}/${multi_os_dir}" + CT_SanitizeVarDir d + echo "${d}" >> "${multi_root}/etc/ld.so.conf" + if [ "${multi_os_dir}" != "${multi_os_dir_gcc}" ]; then + d="${b}/${multi_os_dir_gcc}" + CT_SanitizeVarDir d + echo "${d}" >> "${multi_root}/etc/ld.so.conf" + fi + done +} + # This step is called once all components were built, to remove # un-wanted files, to add tuple aliases, and to add the final # crosstool-NG-provided files. @@ -10,13 +32,23 @@ do_finish() { local gcc_version local exe_suffix - CT_DoStep INFO "Cleaning-up the toolchain's directory" + CT_DoStep INFO "Finalizing the toolchain's directory" + + if [ "${CT_CREATE_LDSO_CONF}" = "y" ]; then + # Create /etc/ld.so.conf + CT_mkdir_pushd "${CT_BUILD_DIR}/build-create-ldso" + CT_IterateMultilibs create_ldso_conf create-ldso + CT_Popd + fi if [ "${CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES}" = "y" ]; then case "$CT_HOST" in *darwin*) strip_args="" ;; + *freebsd*) + strip_args="--strip-all" + ;; *) strip_args="--strip-all -v" ;; @@ -37,20 +69,11 @@ do_finish() { CT_DoExecLog ALL "${CT_TARGET}-strip" ${strip_args} \ "${CT_TARGET}/debug-root/usr/bin/gdbserver${exe_suffix}" fi - if [ "${CT_CC_gcc}" = "y" ]; then - # We can not use the version in CT_CC_GCC_VERSION because + if [ "${CT_CC_GCC}" = "y" ]; then + # We can not use the version in CT_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 + gcc_version=$( cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ) for _t in "bin/${CT_TARGET}-"* \ "${CT_TARGET}/bin/"* \ "libexec/gcc/${CT_TARGET}/${gcc_version}/"* \ @@ -60,7 +83,7 @@ do_finish() { case "${_type}" in *script*executable*) ;; - *executable*) + *executable*|*shared*object*) CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}" ;; esac @@ -100,25 +123,8 @@ do_finish() { # Create the aliases to the target tools CT_DoLog EXTRA "Creating toolchain aliases" - CT_Pushd "${CT_PREFIX_DIR}/bin" - for t in "${CT_TARGET}-"*; do - if [ -n "${CT_TARGET_ALIAS}" ]; then - _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;') - CT_DoExecLog ALL ln -sfv "${t}" "${_t}" - fi - if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then - _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}") - if [ "${_t}" = "${t}" ]; then - CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'" - else - CT_DoExecLog ALL ln -sfv "${t}" "${_t}" - fi - fi - done - CT_Popd - - CT_DoLog EXTRA "Removing access to the build system tools" - CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools" + CT_SymlinkTools "${CT_PREFIX_DIR}/bin" "${CT_PREFIX_DIR}/bin" \ + "${CT_TARGET_ALIAS}" "${CT_TARGET_ALIAS_SED_EXPR}" # Remove the generated documentation files if [ "${CT_REMOVE_DOCS}" = "y" ]; then @@ -128,5 +134,9 @@ do_finish() { CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{,share/}{man,info} fi + if [ "${CT_INSTALL_LICENSES}" = y ]; then + CT_InstallCopyingInformation + fi + CT_EndStep } diff --git a/scripts/build/kernel/bare-metal.sh b/scripts/build/kernel/bare-metal.sh index 629f63f..79c4345 100644 --- a/scripts/build/kernel/bare-metal.sh +++ b/scripts/build/kernel/bare-metal.sh @@ -2,19 +2,23 @@ # Copyright 2008 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -CT_DoKernelTupleValues() { +CT_DoKernelTupleValues() +{ # For bare-metal, there is no kernel part in the tuple CT_TARGET_KERNEL= } -do_kernel_get() { +do_kernel_get() +{ : } -do_kernel_extract() { +do_kernel_extract() +{ : } -do_kernel_headers() { +do_kernel_headers() +{ : } diff --git a/scripts/build/kernel/linux.sh b/scripts/build/kernel/linux.sh index 9cfc433..ad3c2ca 100644 --- a/scripts/build/kernel/linux.sh +++ b/scripts/build/kernel/linux.sh @@ -2,90 +2,48 @@ # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -CT_DoKernelTupleValues() { - if [ "${CT_ARCH_USE_MMU}" = "y" ]; then - CT_TARGET_KERNEL="linux" - else +CT_DoKernelTupleValues() +{ + if [ -z "${CT_ARCH_USE_MMU}" ]; then # Some no-mmu linux targets requires a -uclinux tuple (like m68k/cf), # while others must have a -linux tuple. Other targets # should be added here when someone starts to care about them. case "${CT_ARCH}" in - arm*) CT_TARGET_KERNEL="linux" ;; - m68k) CT_TARGET_KERNEL="uclinux" ;; - *) CT_Abort "Unsupported no-mmu arch '${CT_ARCH}'" + arm*|microblaze*) CT_TARGET_KERNEL="linux" ;; + c6x|m68k|xtensa*) CT_TARGET_KERNEL="uclinux" ;; + *) CT_Abort "Unsupported no-mmu arch '${CT_ARCH}'" esac fi } # Download the kernel -do_kernel_get() { - local k_ver - local custom_name - local rel_dir - local korg_base mirror_base +do_kernel_get() +{ + CT_Fetch LINUX +} - if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then - CT_GetCustom "linux" "${CT_KERNEL_LINUX_CUSTOM_VERSION}" \ - "${CT_KERNEL_LINUX_CUSTOM_LOCATION}" - else # Not a custom tarball - case "${CT_KERNEL_VERSION}" in - 2.6.*.*|3.*.*|4.*.*) - # 4-part versions (for 2.6 stables and long-terms), and - # 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.*|4.*) - # 3-part version (for 2.6.x initial releases), and 2-part - # 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}" \ - "${korg_base}" \ - "${korg_base}/longterm/v${k_ver}" \ - "${korg_base}/longterm" - fi +# Disable building relocs application - it needs <linux/types.h> +# on the host, which may not be present on Cygwin or MacOS; it +# needs <elf.h>, which again is not present on MacOS; and most +# important, we don't need it to install the headers. +# This is not done as a patch, since it varies from Linux version +# to version - patching each particular Linux version would be +# too cumbersome. +linux_disable_build_relocs() +{ + sed -i -r 's/(\$\(MAKE\) .* relocs)$/:/' arch/*/Makefile } # Extract kernel -do_kernel_extract() { - # If using a custom directory location, nothing to do - if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" \ - -a -d "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}" ]; then - return 0 - fi - - # Otherwise, we're using either a mainstream tarball, or a custom - # tarball; in either case, we need to extract - CT_Extract "linux-${CT_KERNEL_VERSION}" - - # If using a custom tarball, no need to patch - if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then - return 0 - fi - CT_Patch "linux" "${CT_KERNEL_VERSION}" - - # Disable building relocs application - it needs <linux/types.h> - # on the host, which may not be present on Cygwin or MacOS; it - # needs <elf.h>, which again is not present on MacOS; and most - # important, we don't need it to install the headers. - # This is not done as a patch, since it varies from Linux version - # to version - patching each particular Linux version would be - # too cumbersome. - CT_Pushd "${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}" - sed -i -r 's/(\$\(MAKE\) .* relocs)$/:/' arch/*/Makefile - CT_Popd +do_kernel_extract() +{ + # TBD verify linux_disable_build_relocs is run + CT_ExtractPatch LINUX linux_disable_build_relocs } # Install kernel headers using headers_install from kernel sources. -do_kernel_headers() { +do_kernel_headers() +{ local kernel_path local kernel_arch @@ -93,7 +51,7 @@ do_kernel_headers() { mkdir -p "${CT_BUILD_DIR}/build-kernel-headers" - kernel_path="${CT_SRC_DIR}/linux-${CT_KERNEL_VERSION}" + kernel_path="${CT_SRC_DIR}/linux" V_OPT="V=${CT_KERNEL_LINUX_VERBOSE_LEVEL}" kernel_arch="${CT_ARCH}" @@ -103,24 +61,28 @@ do_kernel_headers() { esac CT_DoLog EXTRA "Installing kernel headers" - CT_DoExecLog ALL \ - make -C "${kernel_path}" \ - CROSS_COMPILE="${CT_TARGET}-" \ - O="${CT_BUILD_DIR}/build-kernel-headers" \ - ARCH=${kernel_arch} \ - INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \ - ${V_OPT} \ + CT_DoExecLog ALL \ + make -C "${kernel_path}" \ + BASH="$(which bash)" \ + HOSTCC="${CT_BUILD}-gcc" \ + CROSS_COMPILE="${CT_TARGET}-" \ + O="${CT_BUILD_DIR}/build-kernel-headers" \ + ARCH=${kernel_arch} \ + INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \ + ${V_OPT} \ headers_install if [ "${CT_KERNEL_LINUX_INSTALL_CHECK}" = "y" ]; then CT_DoLog EXTRA "Checking installed headers" - CT_DoExecLog ALL \ - make -C "${kernel_path}" \ - CROSS_COMPILE="${CT_TARGET}-" \ - O="${CT_BUILD_DIR}/build-kernel-headers" \ - ARCH=${kernel_arch} \ - INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \ - ${V_OPT} \ + CT_DoExecLog ALL \ + make -C "${kernel_path}" \ + BASH="$(which bash)" \ + HOSTCC="${CT_BUILD}-gcc" \ + CROSS_COMPILE="${CT_TARGET}-" \ + O="${CT_BUILD_DIR}/build-kernel-headers" \ + ARCH=${kernel_arch} \ + INSTALL_HDR_PATH="${CT_SYSROOT_DIR}/usr" \ + ${V_OPT} \ headers_check fi diff --git a/scripts/build/kernel/windows.sh b/scripts/build/kernel/windows.sh index 5e34420..37bc1d7 100644 --- a/scripts/build/kernel/windows.sh +++ b/scripts/build/kernel/windows.sh @@ -2,21 +2,24 @@ # Copyright 2012 Yann Diorcet # Licensed under the GPL v2. See COPYING in the root of this package -CT_DoKernelTupleValues() { +CT_DoKernelTupleValues() +{ # Even we compile for x86_64 target architecture, the target OS have to # bet mingw32 (require by gcc and mingw-w64) CT_TARGET_KERNEL="mingw32" - CT_TARGET_SYS= } -do_kernel_get() { +do_kernel_get() +{ : } -do_kernel_extract() { +do_kernel_extract() +{ : } -do_kernel_headers() { +do_kernel_headers() +{ : } diff --git a/scripts/build/libc.sh b/scripts/build/libc.sh new file mode 100644 index 0000000..5f5aa6f --- /dev/null +++ b/scripts/build/libc.sh @@ -0,0 +1,39 @@ +# C library build routines. We don't invoke the corresponding functions directly +# because some of them build on top of another. E.g. moxiebox runtime requires +# newlib as a prerequisite. + +# Define default hooks - download/unpack just the main package; no-op build hooks. +# The actual implementation can override just what it needs then. +eval "${CT_LIBC//[^A-Za-z0-9]/_}_get() { CT_Fetch \"\${CT_LIBC_${CT_LIBC_CHOICE_KSYM}_PKG_KSYM}\"; }" +eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract() { CT_ExtractPatch \"\${CT_LIBC_${CT_LIBC_CHOICE_KSYM}_PKG_KSYM}\"; }" +for _m in headers main post_cc; do + eval "${CT_LIBC//[^A-Za-z0-9]/_}_${_m}() { :; }" +done + +# Source the selected libc. +. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" + +do_libc_get() +{ + eval "${CT_LIBC//[^A-Za-z0-9]/_}_get" +} + +do_libc_extract() +{ + eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract" +} + +do_libc_headers() +{ + eval "${CT_LIBC//[^A-Za-z0-9]/_}_headers" +} + +do_libc_main() +{ + eval "${CT_LIBC//[^A-Za-z0-9]/_}_main" +} + +do_libc_post_cc() +{ + eval "${CT_LIBC//[^A-Za-z0-9]/_}_post_cc" +} diff --git a/scripts/build/libc/avr-libc.sh b/scripts/build/libc/avr-libc.sh index f94b601..34eb0f5 100644 --- a/scripts/build/libc/avr-libc.sh +++ b/scripts/build/libc/avr-libc.sh @@ -1,24 +1,14 @@ # This file adds functions to build the avr-libc C library -do_libc_get() { - local libc_src - - libc_src="http://download.savannah.gnu.org/releases/avr-libc" - - if [ "${CT_LIBC_AVR_LIBC_CUSTOM}" = "y" ]; then - CT_GetCustom "avr-libc" "${CT_LIBC_AVR_LIBC_CUSTOM_VERSION}" \ - "${CT_LIBC_AVR_LIBC_CUSTOM_LOCATION}" - else # ! custom location - CT_GetFile "avr-libc-${CT_LIBC_VERSION}" "${libc_src}" - fi # ! custom location -} +avr_libc_post_cc() +{ + CT_DoStep INFO "Installing C library" -do_libc_extract() { - CT_Extract "avr-libc-${CT_LIBC_VERSION}" - CT_Patch "avr-libc" "${CT_LIBC_VERSION}" -} + CT_DoLog EXTRA "Copying sources to build directory" + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/avr-libc/." \ + "${CT_BUILD_DIR}/build-libc-post-cc" + cd "${CT_BUILD_DIR}/build-libc-post-cc" -do_libc_configure() { CT_DoLog EXTRA "Configuring C library" CT_DoExecLog CFG \ @@ -28,28 +18,9 @@ do_libc_configure() { --host=${CT_TARGET} \ --prefix=${CT_PREFIX_DIR} \ "${CT_LIBC_AVR_LIBC_EXTRA_CONFIG_ARRAY[@]}" -} - -do_libc_start_files() { - : -} - -do_libc() { - : -} - -do_libc_post_cc() { - CT_DoStep INFO "Installing C library" - - CT_DoLog EXTRA "Copying sources to build directory" - CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/avr-libc-${CT_LIBC_VERSION}/." \ - "${CT_BUILD_DIR}/build-libc-post-cc" - cd "${CT_BUILD_DIR}/build-libc-post-cc" - - do_libc_configure CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing C library" CT_DoExecLog ALL make install diff --git a/scripts/build/libc/bionic.sh b/scripts/build/libc/bionic.sh new file mode 100644 index 0000000..0ffd4d8 --- /dev/null +++ b/scripts/build/libc/bionic.sh @@ -0,0 +1,34 @@ +# This file adds functions to extract the bionic C library from the Android NDK +# Copyright 2017 Howard Chu +# Licensed under the GPL v2. See COPYING in the root of this package + +# Install Unified headers +bionic_headers() +{ + CT_DoStep INFO "Installing C library headers" + CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/sysroot/usr" "${CT_SYSROOT_DIR}" +} + +bionic_main() +{ + local arch="${CT_ARCH}" + if [ "${CT_ARCH_64}" = "y" ]; then + if [ "${CT_ARCH}" = "x86" ]; then + arch="${arch}_" + fi + arch="${arch}64" + fi + CT_DoStep INFO "Installing C library binaries" + CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/platforms/android-${CT_ANDROID_API}/arch-${arch}/usr" "${CT_SYSROOT_DIR}" + + # NB: Modifying both CT_TARGET_CFLAGS and CT_ALL_TARGET_CFLAGS: the __ANDROID_API__ + # definition needs to be passed into GCC build, or the resulting libstdc++ gets + # miscompiled (attempt to link against it results in unresolved symbols to stdout/...). + # And since __ANDROID_API__ is a user config option, placing it with other user-supplied + # options isn't completely out of character. + # On the other hand, CT_ALL_TARGET_CFLAGS in non-multilib builds is already set and does + # not get recalculated after GCC build, so setting CT_TARGET_CFLAGS is not reflected + # on other libraries/apps, such as gdbserver. + CT_EnvModify CT_TARGET_CFLAGS "${CT_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}" + CT_EnvModify CT_ALL_TARGET_CFLAGS "${CT_ALL_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}" +} diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 348c35a..c78f069 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -2,166 +2,58 @@ # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -do_libc_get() { +glibc_get() +{ local date local version - local -a addons_list - - addons_list=($(do_libc_add_ons_list " ")) - - # Main source - if [ "${CT_LIBC_GLIBC_CUSTOM}" = "y" ]; then - CT_GetCustom "glibc" "${CT_LIBC_GLIBC_CUSTOM_VERSION}" \ - "${CT_LIBC_GLIBC_CUSTOM_LOCATION}" - else - case "${CT_LIBC_VERSION}" in - linaro-*) - CT_GetLinaro "glibc" "${CT_LIBC_VERSION}" - ;; - *) - CT_GetFile "glibc-${CT_LIBC_VERSION}" \ - {http,ftp,https}://ftp.gnu.org/gnu/glibc \ - ftp://{sourceware.org,gcc.gnu.org}/pub/glibc/{releases,snapshots} - ;; - esac - fi - - # C library addons - for addon in "${addons_list[@]}"; 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_GetFile "glibc-${addon}-${CT_LIBC_VERSION}" \ - http://mirrors.kernel.org/sourceware/glibc \ - {http,ftp,https}://ftp.gnu.org/gnu/glibc \ - ftp://{sourceware.org,gcc.gnu.org}/pub/glibc/{releases,snapshots} - then - # Some add-ons are bundled with glibc, others are - # bundled in their own tarball. Eg. NPTL is internal, - # while LinuxThreads was external. Also, for old - # versions of glibc, the libidn add-on was external, - # but with version >=2.10, it is internal. - 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 + CT_Fetch GLIBC + if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then + CT_Fetch GLIBC_PORTS + fi return 0 } -do_libc_extract() { - local addon - - CT_Extract "${CT_LIBC}-${CT_LIBC_VERSION}" - CT_Pushd "${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" - # Custom glibc won't get patched, because CT_GetCustom - # marks custom glibc as patched. - CT_Patch nochdir "${CT_LIBC}" "${CT_LIBC_VERSION}" - - 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 -} - -# 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 +glibc_extract() +{ + CT_ExtractPatch GLIBC + if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then + CT_ExtractPatch GLIBC_PORTS + + # This may create a bogus symlink if glibc-ports is using custom + # sources or has an overlay (and glibc is shared). However, + # we do not support concurrent use of the source directory + # and next run, if using different glibc-ports source, will override + # this symlink anyway. + CT_DoExecLog ALL ln -sf "${CT_SRC_DIR}/${CT_GLIBC_PORTS_DIR_NAME}" \ + "${CT_SRC_DIR}/${CT_GLIBC_DIR_NAME}/ports" + fi } # This function builds and install the full C library -do_libc() { - do_libc_backend libc_mode=final -} - -do_libc_post_cc() { - : -} - -# 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 +glibc_main() +{ local arg - for arg in "$@"; do - eval "${arg// /\\ }" - done - - case "${libc_mode}" in - startfiles) - CT_DoStep INFO "Installing C library headers & start files" - ;; - final) - CT_DoStep INFO "Installing C library" - ;; - *) - CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'" - ;; - esac - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}" + CT_DoStep INFO "Installing C library" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc" + CT_IterateMultilibs glibc_backend_once multilib CT_Popd CT_EndStep } # This backend builds the C library once -# Usage: do_libc_backend_once param=value [...] +# Usage: glibc_backend_once param=value [...] # Parameter : Definition : Type -# libc_mode : 'startfiles' or 'final' : string : (empty) # multi_* : as defined in CT_IterateMultilibs : (varies) : -do_libc_backend_once() { - local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count +glibc_backend_once() +{ + # Glibc seems to be smart enough to know about the cases that can coexist + # in the same root and installs them into proper multilib-os directory; all + # we need is to point to the right root. + local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target local build_cflags build_cppflags build_ldflags - local startfiles_dir - local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" + local src_dir="${CT_SRC_DIR}/glibc" local -a extra_config local -a extra_make_args local glibc_cflags @@ -179,93 +71,95 @@ do_libc_backend_once() { # Adjust target tuple according GLIBC quirks CT_DoArchGlibcAdjustTuple multi_target - # Glibc seems to be smart enough to know about the cases that can coexist - # in the same root and installs them into proper multilib-os directory; all - # we need is to point to the right root. We do need to handle multilib-os - # here, though, for the first pass where we install crt*.o and a dummy - # libc.so; we therefore install it to the most specific location of - # <sysroot>/<suffix>/usr/lib/<multilib-os> where it is least likely to clash - # with other multilib variants. We then remove these temporary files at - # the beginning of the libc-final step and allow glibc to install them - # where it thinks is proper. - startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}" - CT_SanitizeVarDir startfiles_dir - - if [ "${libc_mode}" = "final" ]; then - CT_DoLog EXTRA "Cleaning up start files" - CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \ - "${startfiles_dir}/crti.o" \ - "${startfiles_dir}/crtn.o" \ - "${startfiles_dir}/libc.so" - fi - CT_DoLog EXTRA "Configuring C library" - # Also, if those two are missing, iconv build breaks + # If those two are missing, iconv build breaks extra_config+=( --disable-debug --disable-sanity-checks ) - # always include rpc, the user can still override it with TI-RPC - extra_config+=( --enable-obsolete-rpc ) + if [ "${CT_GLIBC_ENABLE_OBSOLETE_RPC}" = "y" ]; then + extra_config+=( --enable-obsolete-rpc ) + fi # Add some default glibc config options if not given by user. # We don't need to be conditional on whether the user did set different - # values, as they CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY is passed after + # values, as they CT_GLIBC_EXTRA_CONFIG_ARRAY is passed after # extra_config - extra_config+=("$(do_libc_min_kernel_config)") + extra_config+=("$(glibc_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 + case "${CT_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in *-tls*) ;; *) extra_config+=("--without-tls");; esac ;; esac + # FIXME static version of glibc seems to be broken: + # build tries to use libc-modules.h which is generated from + # soversions.i, which is only created for builds with shared libs. case "${CT_SHARED_LIBS}" in y) extra_config+=("--enable-shared");; *) extra_config+=("--disable-shared");; esac - if [ "${CT_LIBC_DISABLE_VERSIONING}" = "y" ]; then + if [ "${CT_GLIBC_DISABLE_VERSIONING}" = "y" ]; then extra_config+=("--disable-versioning") fi - if [ "${CT_LIBC_OLDEST_ABI}" != "" ]; then - extra_config+=("--enable-oldest-abi=${CT_LIBC_OLDEST_ABI}") + if [ "${CT_GLIBC_OLDEST_ABI}" != "" ]; then + extra_config+=("--enable-oldest-abi=${CT_GLIBC_OLDEST_ABI}") fi - case "$(do_libc_add_ons_list ,)" in + case "$(glibc_add_ons_list ,)" in "") extra_config+=("--enable-add-ons=no");; - *) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");; + *) extra_config+=("--enable-add-ons=$(glibc_add_ons_list ,)");; esac - extra_config+=("--with-pkgversion=${CT_PKGVERSION}") + [ "${CT_GLIBC_ENABLE_WERROR}" != "y" ] && extra_config+=("--disable-werror") + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") + if [ -n "${CT_GLIBC_SSP}" ]; then + extra_config+=("--enable-stack-protector=${CT_GLIBC_SSP}") + fi + touch config.cache - if [ "${CT_LIBC_GLIBC_FORCE_UNWIND}" = "y" ]; then + + # Until it became explicitly controllable with --enable-stack-protector=..., + # configure detected GCC support for -fstack-protector{,-strong} and + # tried to enable it in some parts of glibc - which then failed to build. + if [ -z "${CT_GLIBC_BUILD_SSP}" ]; then + echo "libc_cv_ssp=no" >>config.cache + echo "libc_cv_ssp_strong=no" >>config.cache + fi + + if [ "${CT_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 + printf "%s\n" "${CT_GLIBC_CONFIGPARMS}" > configparms # glibc can't be built without -O2 (reference needed!) - glibc_cflags+=" -O2" + glibc_cflags+=" -g -O2" + + if [ "${CT_GLIBC_ENABLE_COMMON_FLAG}" = "y" ]; then + glibc_cflags+=" -fcommon" + fi - case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in + case "${CT_GLIBC_ENABLE_FORTIFIED_BUILD}" in y) ;; *) glibc_cflags+=" -U_FORTIFY_SOURCE";; esac # In the order of increasing precedence. Flags common to compiler and linker. - glibc_cflags+=" ${CT_TARGET_CFLAGS}" - glibc_cflags+=" ${CT_LIBC_GLIBC_EXTRA_CFLAGS}" + glibc_cflags+=" ${CT_ALL_TARGET_CFLAGS}" + glibc_cflags+=" ${CT_GLIBC_EXTRA_CFLAGS}" glibc_cflags+=" ${multi_flags}" # Analyze the resulting options for any extra configure switches to throw in. @@ -279,6 +173,7 @@ do_libc_backend_once() { ;; esac done + CT_DoArchGlibcAdjustConfigure extra_config "${glibc_cflags}" # ./configure is mislead by our tools override wrapper for bash # so just tell it where the real bash is _on_the_target_! @@ -293,6 +188,8 @@ do_libc_backend_once() { # or even after they get installed... echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache + CT_SymlinkToolsMultilib + # 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 @@ -306,17 +203,19 @@ do_libc_backend_once() { # Run explicitly through CONFIG_SHELL, or the build breaks badly (loop-of-death) # when the shell is not bash... Sigh... :-( - CT_DoLog DEBUG "Configuring with addons : '$(do_libc_add_ons_list ,)'" + CT_DoLog DEBUG "Configuring with addons : '$(glibc_add_ons_list ,)'" CT_DoLog DEBUG "Extra config args passed : '${extra_config[*]}'" CT_DoLog DEBUG "Extra CFLAGS passed : '${glibc_cflags}'" - CT_DoLog DEBUG "Placing startfiles into : '${startfiles_dir}'" CT_DoLog DEBUG "Configuring with --host : '${multi_target}'" # CFLAGS are only applied when compiling .c files. .S files are compiled with ASFLAGS, # but they are not passed by configure. Thus, pass everything in CC instead. + # The CFLAGS variable needs to be cleared, else the default "-g -O2" + # would override previous flags. CT_DoExecLog CFG \ BUILD_CC=${CT_BUILD}-gcc \ CC="${CT_TARGET}-${CT_CC} ${glibc_cflags}" \ + CFLAGS="" \ AR=${CT_TARGET}-ar \ RANLIB=${CT_TARGET}-ranlib \ "${CONFIG_SHELL}" \ @@ -330,9 +229,13 @@ do_libc_backend_once() { --without-gd \ --with-headers="${CT_HEADERS_DIR}" \ "${extra_config[@]}" \ - "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[@]}" + "${CT_GLIBC_EXTRA_CONFIG_ARRAY[@]}" # build hacks + + # Mask C++ compiler. Glibc 2.29+ attempts to build some tests using gcc++, but + # we haven't built libstdc++ yet. Should really implement #808 after 1.24.0... + extra_make_args+=( CXX= ) case "${CT_ARCH},${CT_ARCH_CPU}" in powerpc,8??) # http://sourceware.org/ml/crossgcc/2008-10/msg00068.html @@ -346,153 +249,86 @@ do_libc_backend_once() { build_ldflags="${CT_LDFLAGS_FOR_BUILD}" case "$CT_BUILD" in - *mingw*|*cygwin*|*msys*|*darwin*) + *mingw*|*cygwin*|*msys*|*darwin*|*freebsd*) # When installing headers on Cygwin, Darwin, MSYS2 and MinGW-w64 sunrpc needs # gettext for building cross-rpcgen. build_cppflags="${build_cppflags} -I${CT_BUILDTOOLS_PREFIX_DIR}/include/" build_ldflags="${build_ldflags} -lintl -liconv" + case "$CT_BUILD" in + *cygwin*|*freebsd*) + # Additionally, stat in FreeBSD, Cygwin, and possibly others + # is always 64bit, so replace struct stat64 with stat. + build_cppflags="${build_cppflags} -Dstat64=stat" + ;; + esac ;; esac + + # Make sure glibc build system respects our provided CFLAGS. + extra_make_args+=( default_cflags= ) extra_make_args+=( "BUILD_CFLAGS=${build_cflags}" ) extra_make_args+=( "BUILD_CPPFLAGS=${build_cppflags}" ) extra_make_args+=( "BUILD_LDFLAGS=${build_ldflags}" ) - if [ "${libc_mode}" = "startfiles" -a ! -r "${multi_root}/.libc_headers_installed" ]; then - CT_DoLog EXTRA "Installing C library headers" - CT_DoExecLog ALL touch "${multi_root}/.libc_headers_installed" - - # use the 'install-headers' makefile target to install the - # headers - CT_DoExecLog ALL make ${JOBSFLAGS} \ - install_root=${multi_root} \ - 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 - elif [ "${libc_mode}" = "final" -a -r "${multi_root}/.libc_headers_installed" ]; then - CT_DoExecLog ALL rm -f "${multi_root}/.libc_headers_installed" - fi # installing headers - - if [ "${libc_mode}" = "startfiles" ]; 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 "${startfiles_dir}" - CT_DoExecLog ALL make ${JOBSFLAGS} \ - "${extra_make_args[@]}" \ - csu/subdir_lib - CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \ - "${startfiles_dir}" - - # 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 "${CT_TARGET}-${CT_CC}" ${multi_flags} \ - -nostdlib \ - -nostartfiles \ - -shared \ - -x c /dev/null \ - -o "${startfiles_dir}/libc.so" - fi # threads == nptl - fi # libc_mode = startfiles - - if [ "${libc_mode}" = "final" ]; 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="${multi_root}" \ - install - - if [ "${CT_BUILD_MANUALS}" = "y" -a "${multi_index}" = "${multi_count}" ]; then - # We only need to build the manuals once. Only build them on the - # last multilib target. If it's not multilib, it will happen on the - # only target. - 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 manual/*.pdf \ - manual/libc \ - ${CT_PREFIX_DIR}/share/doc - fi - - if [ "${CT_LIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then - do_libc_locales - fi - fi # libc_mode = final + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ + "${extra_make_args[@]}" \ + all + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ + "${extra_make_args[@]}" \ + install_root="${multi_root}" \ + install + + if [ "${CT_BUILD_MANUALS}" = "y" -a "${multi_index}" = "${multi_count}" ]; then + # We only need to build the manuals once. Only build them on the + # last multilib target. If it's not multilib, it will happen on the + # only target. + CT_DoLog EXTRA "Building and installing the C library manual" + # Omit CT_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 manual/*.pdf \ + manual/libc \ + ${CT_PREFIX_DIR}/share/doc + fi + + if [ "${CT_GLIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then + glibc_locales + fi CT_EndStep } # Build up the addons list, separated with $1 -do_libc_add_ons_list() { +glibc_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 + local addons_list + + if [ "${CT_GLIBC_USE_PORTS_ADDON}" = "y" ]; then + addons_list="${addons_list}${sep}ports" + fi + if [ "${CT_GLIBC_USE_NPTL_ADDON}" = "y" ]; then + addons_list="${addons_list}${sep}nptl" 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}\$//;" + if [ "${CT_GLIBC_USE_LIBIDN_ADDON}" = "y" ]; then + addons_list="${addons_list}${sep}libidn" + fi + echo "${addons_list#${sep}}" # Remove leading separator if any } # Compute up the minimum supported Linux kernel version -do_libc_min_kernel_config() { +glibc_min_kernel_config() +{ local min_kernel_config - case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in + case "${CT_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in *--enable-kernel*) ;; - *) if [ "${CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then + *) if [ "${CT_GLIBC_KERNEL_VERSION_AS_HEADERS}" = "y" ]; then + # TBD do we support that currently? We always seem to install kernel headers # 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 @@ -509,9 +345,9 @@ do_libc_min_kernel_config() { patchlevel=$(((version_code>>8)&0xFF)) sublevel=$((version_code&0xFF)) min_kernel_config="${version}.${patchlevel}.${sublevel}" - elif [ "${CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN}" = "y" ]; then + elif [ "${CT_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}" \ + min_kernel_config="$( echo "${CT_GLIBC_MIN_KERNEL_VERSION}" \ |sed -r -e 's/^([^.]+\.[^.]+\.[^.]+)(|\.[^.]+)$/\1/;' \ )" fi @@ -521,11 +357,21 @@ do_libc_min_kernel_config() { } # Build and install the libc locales -do_libc_locales() { - local src_dir="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}" +glibc_locales() +{ + local src_dir="${CT_SRC_DIR}/glibc" local -a extra_config local glibc_cflags + # To build locales, we'd need to build glibc for the build machine. + # Bail out if the host is not supported. + case "${CT_BUILD}" in + *-cygwin|*-darwin*) + CT_DoLog EXTRA "Skipping GNU libc locales: incompatible build machine" + return + ;; + esac + mkdir -p "${CT_BUILD_DIR}/build-localedef" cd "${CT_BUILD_DIR}/build-localedef" @@ -535,7 +381,7 @@ do_libc_locales() { # 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}") + [ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}") fi if [ ! "${CT_TOOLCHAIN_BUGURL}" = "" ]; then [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") @@ -544,7 +390,7 @@ do_libc_locales() { CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'" glibc_cflags="-O2 -fno-stack-protector" - case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in + case "${CT_GLIBC_ENABLE_FORTIFIED_BUILD}" in y) ;; *) glibc_cflags+=" -U_FORTIFY_SOURCE";; esac @@ -578,7 +424,7 @@ do_libc_locales() { "${extra_config[@]}" CT_DoLog EXTRA "Building C library localedef" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} # The target's endianness and uint32_t alignment should be passed as options # to localedef, but glibc's localedef does not support these options, which @@ -586,7 +432,7 @@ do_libc_locales() { # only if it has the same endianness and uint32_t alignment as the host's. CT_DoLog EXTRA "Installing C library locales" - CT_DoExecLog ALL make ${JOBSFLAGS} \ + CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ install_root="${CT_SYSROOT_DIR}" \ localedata/install-locales } diff --git a/scripts/build/libc/mingw-w64.sh b/scripts/build/libc/mingw-w64.sh new file mode 100644 index 0000000..54e8d07 --- /dev/null +++ b/scripts/build/libc/mingw-w64.sh @@ -0,0 +1,220 @@ +# Copyright 2012 Yann Diorcet +# Licensed under the GPL v2. See COPYING in the root of this package + +mingw_w64_set_install_prefix() +{ + MINGW_INSTALL_PREFIX=/usr/${CT_TARGET} + if [[ ${CT_MINGW_W64_VERSION} == 2* ]]; then + MINGW_INSTALL_PREFIX=/usr + fi +} + +mingw_w64_headers() { + local -a sdk_opts + + CT_DoStep INFO "Installing C library headers" + + case "${CT_MINGW_DIRECTX}:${CT_MINGW_DDK}" in + y:y) sdk_opts+=( "--enable-sdk=all" );; + y:) sdk_opts+=( "--enable-sdk=directx" );; + :y) sdk_opts+=( "--enable-sdk=ddk" );; + :) ;; + esac + + if [ "${CT_MINGW_SECURE_API}" = "y" ]; then + sdk_opts+=( "--enable-secure-api" ) + fi + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-headers" + + CT_DoLog EXTRA "Configuring Headers" + + mingw_w64_set_install_prefix + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/mingw-w64/mingw-w64-headers/configure" \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --prefix=${MINGW_INSTALL_PREFIX} \ + "${sdk_opts[@]}" + + CT_DoLog EXTRA "Compile Headers" + CT_DoExecLog ALL make + + 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 + # /usr (notably when looking for the headers). This symlink is + # here to workaround this, and seems to be here to last... :-/ + CT_DoExecLog ALL ln -sv "usr/${CT_TARGET}" "${CT_SYSROOT_DIR}/mingw" + + CT_EndStep +} + +do_check_mingw_vendor_tuple() +{ + CT_DoStep INFO "Checking configured vendor tuple" + if [ ${CT_TARGET_VENDOR} = "w64" ]; then + CT_DoLog DEBUG "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 developers." + else + CT_DoLog WARN "The tuple vendor is '${CT_TARGET_VENDOR}', not equal to 'w64' and might break the toolchain!" + fi + CT_EndStep +} + +do_mingw_tools() +{ + local f + + for f in "${CT_MINGW_TOOL_LIST_ARRAY[@]}"; do + CT_mkdir_pushd "${f}" + if [ ! -d "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}" ]; then + CT_DoLog WARN "Skipping ${f}: not found" + CT_Popd + continue + fi + + CT_DoLog EXTRA "Configuring ${f}" + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}/configure" \ + --build=${CT_BUILD} \ + --host=${CT_HOST} \ + --target=${CT_TARGET} \ + --program-prefix=${CT_TARGET}- \ + --prefix="${CT_PREFIX_DIR}" + + # mingw-w64 has issues with parallel builds, see mingw_w64_main + CT_DoLog EXTRA "Building ${f}" + CT_DoExecLog ALL make + CT_DoLog EXTRA "Installing ${f}" + CT_DoExecLog ALL make install + CT_Popd + done +} + +do_mingw_pthreads() +{ + local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target + local libprefix + local rcflags dlltoolflags + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'" + + libprefix="${MINGW_INSTALL_PREFIX}/lib/${multi_os_dir}" + CT_SanitizeVarDir libprefix + + CT_SymlinkToolsMultilib + + # DLLTOOLFLAGS does not appear to be currently used by winpthread package, but + # the master package uses this variable and describes this as one of the changes + # needed for i686 in mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt + case "${multi_target}" in + i[3456]86-*) + rcflags="-F pe-i386" + dlltoolflags="-m i386" + ;; + x86_64-*) + rcflags="-F pe-x86-64" + dlltoolflags="-m i386:x86_64" + ;; + *) + CT_Abort "Tuple ${multi_target} is not supported by mingw-w64" + ;; + esac + + CT_DoLog EXTRA "Configuring mingw-w64-winpthreads" + + CT_DoExecLog CFG \ + CFLAGS="${multi_flags}" \ + CXXFLAGS="${multi_flags}" \ + RCFLAGS="${rcflags}" \ + DLLTOOLFLAGS="${dlltoolflags}" \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/mingw-w64/mingw-w64-libraries/winpthreads/configure" \ + --with-sysroot=${CT_SYSROOT_DIR} \ + --prefix=${MINGW_INSTALL_PREFIX} \ + --libdir=${libprefix} \ + --build=${CT_BUILD} \ + --host=${multi_target} + + # mingw-w64 has issues with parallel builds, see mingw_w64_main + CT_DoLog EXTRA "Building mingw-w64-winpthreads" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing mingw-w64-winpthreads" + CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} + + # Post-install hackery: all libwinpthread-1.dll end up being installed + # into /bin, which is broken on multilib install. Hence, stash it back + # into /lib - and after iterating over multilibs, copy the default one + # back into /bin. + if [ "${multi_index}" != 1 -o "${multi_count}" != 1 ]; then + CT_DoExecLog ALL mv "${CT_SYSROOT_DIR}${MINGW_INSTALL_PREFIX}/bin/libwinpthread-1.dll" \ + "${CT_SYSROOT_DIR}${libprefix}/libwinpthread-1.dll" + if [ "${multi_index}" = 1 ]; then + default_libprefix="${libprefix}" + elif [ "${multi_index}" = "${multi_count}" ]; then + CT_DoExecLog ALL cp "${CT_SYSROOT_DIR}${default_libprefix}/libwinpthread-1.dll" \ + "${CT_SYSROOT_DIR}${MINGW_INSTALL_PREFIX}/bin/libwinpthread-1.dll" + fi + fi + + CT_EndStep +} + +mingw_w64_main() +{ + # Used when iterating over libwinpthread + local default_libprefix + + do_check_mingw_vendor_tuple + + CT_DoStep INFO "Building mingw-w64" + + CT_DoLog EXTRA "Configuring mingw-w64-crt" + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-crt" + + mingw_w64_set_install_prefix + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + "${CT_SRC_DIR}/mingw-w64/mingw-w64-crt/configure" \ + --with-sysroot=${CT_SYSROOT_DIR} \ + --prefix=${MINGW_INSTALL_PREFIX} \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} + + # mingw-w64-crt has a missing dependency occasionally breaking the + # parallel build. See https://github.com/crosstool-ng/crosstool-ng/issues/246 + # Do not pass ${CT_JOBSFLAGS} - build serially. + CT_DoLog EXTRA "Building mingw-w64-crt" + CT_DoExecLog ALL make + + CT_DoLog EXTRA "Installing mingw-w64-crt" + CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} + CT_EndStep + + if [ "${CT_THREADS}" = "posix" ]; then + CT_DoStep INFO "Building mingw-w64-winpthreads" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-winpthreads" + CT_IterateMultilibs do_mingw_pthreads pthreads-multilib + CT_Popd + CT_EndStep + fi + + if [ "${CT_MINGW_TOOLS}" = "y" ]; then + CT_DoStep INFO "Installing mingw-w64 companion tools" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-tools" + do_mingw_tools + CT_Popd + CT_EndStep + fi +} diff --git a/scripts/build/libc/mingw.sh b/scripts/build/libc/mingw.sh deleted file mode 100644 index eb04cb6..0000000 --- a/scripts/build/libc/mingw.sh +++ /dev/null @@ -1,178 +0,0 @@ -# Copyright 2012 Yann Diorcet -# Licensed under the GPL v2. See COPYING in the root of this package - -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-${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 -} - -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 - - CT_DoStep INFO "Installing C library headers" - - case "${CT_MINGW_DIRECTX}:${CT_MINGW_DDK}" in - y:y) sdk_opts+=( "--enable-sdk=all" );; - y:) sdk_opts+=( "--enable-sdk=directx" );; - :y) sdk_opts+=( "--enable-sdk=ddk" );; - :) ;; - esac - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-headers" - - CT_DoLog EXTRA "Configuring Headers" - - do_set_mingw_install_prefix - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-headers/configure" \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - --prefix=${MINGW_INSTALL_PREFIX} \ - "${sdk_opts[@]}" - - CT_DoLog EXTRA "Compile Headers" - CT_DoExecLog ALL make - - 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 - # /usr (notably when looking for the headers). This symlink is - # here to workaround this, and seems to be here to last... :-/ - CT_DoExecLog ALL ln -sv "usr/${CT_TARGET}" "${CT_SYSROOT_DIR}/mingw" - - 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_mingw_tools() { - for f in gendef genidl genlib genpeimg widl - do - if [[ ! -d "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-tools/${f}" ]]; then - continue; - fi - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-tools/${f}" - - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-tools/${f}/configure" \ - --build=${CT_BUILD} \ - --host=${CT_HOST} \ - --target=${CT_TARGET} \ - --program-prefix=${CT_TARGET}- \ - --prefix="${CT_PREFIX_DIR}" - - CT_DoExecLog ALL ${make} ${JOBSFLAGS} - - CT_DoExecLog ALL ${make} install - - CT_Popd - done -} - -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" - - do_set_mingw_install_prefix - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - "${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} \ - - # mingw-w64-crt has a missing dependency occasionally breaking the - # parallel build. See https://github.com/crosstool-ng/crosstool-ng/issues/246 - # Do not pass ${JOBSFLAGS} - build serially. - CT_DoLog EXTRA "Building mingw-w64-crt" - CT_DoExecLog ALL make - - CT_DoLog EXTRA "Installing mingw-w64-crt" - CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} - - if [[ ${CT_MINGW_TOOLS} == "y" ]]; then - CT_DoLog EXTRA "Installing mingw-w64 companion tools" - do_mingw_tools - fi - - CT_EndStep - - if [ "${CT_THREADS}" = "posix" ]; then - do_pthreads - fi -} - -do_libc_post_cc() { - : -} - -do_pthreads() { - CT_DoStep INFO "Building mingw-w64-winpthreads files" - - CT_DoLog EXTRA "Configuring mingw-w64-winpthreads" - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-mingw-w64-winpthreads" - - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-libraries/winpthreads/configure" \ - --with-sysroot=${CT_SYSROOT_DIR} \ - --prefix=${MINGW_INSTALL_PREFIX} \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - - CT_DoLog EXTRA "Building mingw-w64-winpthreads" - CT_DoExecLog ALL make ${JOBSFLAGS} - - CT_DoLog EXTRA "Installing mingw-w64-winpthreads" - CT_DoExecLog ALL make install DESTDIR=${CT_SYSROOT_DIR} - - CT_EndStep -} diff --git a/scripts/build/libc/moxiebox.sh b/scripts/build/libc/moxiebox.sh new file mode 100644 index 0000000..35e2ea4 --- /dev/null +++ b/scripts/build/libc/moxiebox.sh @@ -0,0 +1,79 @@ +# Functions to build the moxiebox runtime. + +. "${CT_LIB_DIR}/scripts/build/libc/newlib.sh" + +moxiebox_get() +{ + CT_Fetch NEWLIB + CT_Fetch MOXIEBOX +} + +moxiebox_extract() +{ + CT_ExtractPatch NEWLIB + CT_ExtractPatch MOXIEBOX +} + +moxiebox_headers() +{ + newlib_headers +} + +moxiebox_main() +{ + newlib_main +} + +moxiebox_post_cc() +{ + CT_DoStep INFO "Installing moxiebox runtime and VM" + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-moxiebox" + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/moxiebox/." . + + CT_DoLog EXTRA "Building SHA256-only libcrypto" + # Moxiebox needs libcrypto on the host, but it only uses SHA256 digest functions + # from it. We don't want to pull the whole OpenSSL for the host; fortunately, + # moxiebox comes with a standalone SHA256 implementation - which it only uses + # for the target library. Help it use the same implementation for the host. + CT_mkdir_pushd openssl + CT_DoExecLog ALL cp -v "${CT_LIB_DIR}/packages/moxiebox/"sha*.[ch] ./ + CT_DoExecLog ALL "${CT_HOST}-gcc" -c sha256_wrap.c -O2 -Wall + CT_DoExecLog ALL "${CT_HOST}-ar" cru libcrypto.a sha256_wrap.o + CT_Popd + + # Moxiebox includes a VM which we're building for the + # host machine. + CT_DoLog EXTRA "Configuring moxiebox" + + CT_DoExecLog CFG ./autogen.sh + + # moxiebox build script creates symlinks from the installation location to the build + # directory for the moxiebox library. This seems backwards. Instead, pass the search + # as part of the MOX_GCC definition. + # moxiebox also depends on the tools being named moxiebox-{gcc,as,ar}. However, failure + # to detect such tools is non-fatal in the configure and we need to override it in + # make's command line anyway. + CT_DoExecLog CFG \ + LDFLAGS="${CT_LDFLAGS_FOR_HOST} -L${CT_BUILD_DIR}/build-libc-moxiebox/openssl" \ + CFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \ + CXXFLAGS="${CT_CFLAGS_FOR_HOST} -I${CT_BUILD_DIR}/build-libc-moxiebox" \ + ./configure \ + --host="${CT_HOST}" + CT_DoLog EXTRA "Building moxiebox" + CT_DoExecLog CFG make all \ + MOX_GCC="${CT_TARGET}-gcc -B ${CT_BUILD_DIR}/build-libc-moxiebox/runtime -B ${CT_SYSROOT_DIR}/lib" \ + MOX_AS="${CT_TARGET}-as" \ + MOX_AR="${CT_TARGET}-ar" + + CT_DoLog EXTRA "Installing moxiebox" + + # moxiebox does not have install target. Copy the interesting stuff manually. + CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/runtime/libsandboxrt.a" \ + "${CT_BUILD_DIR}/build-libc-moxiebox/runtime/crt0.o" \ + "${CT_SYSROOT_DIR}/lib/" + CT_DoExecLog ALL cp -v "${CT_BUILD_DIR}/build-libc-moxiebox/src/sandbox" \ + "${CT_PREFIX_DIR}/bin" + CT_Popd + CT_EndStep +} diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh index 4ccb84c..bc2a2e6 100644 --- a/scripts/build/libc/musl.sh +++ b/scripts/build/libc/musl.sh @@ -2,65 +2,31 @@ # Copyright 2013 Timo Teräs # Licensed under the GPL v2. See COPYING in the root of this package -do_libc_get() { - if [ "${CT_LIBC_MUSL_CUSTOM}" = "y" ]; then - CT_GetCustom "musl" "${CT_LIBC_MUSL_CUSTOM_VERSION}" \ - "${CT_LIBC_MUSL_CUSTOM_LOCATION}" - else # ! custom location - CT_GetFile "musl-${CT_LIBC_VERSION}" http://www.musl-libc.org/releases - fi # ! custom location +musl_post_cc() +{ + # MUSL creates dynamic linker symlink with absolute path - which works on the + # target but not on the host. We want our cross-ldd tool to work. + CT_MultilibFixupLDSO } -do_libc_extract() { - CT_Extract "musl-${CT_LIBC_VERSION}" - CT_Patch "musl" "${CT_LIBC_VERSION}" -} - -# 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 -} - -do_libc_post_cc() { - : -} - -do_libc_backend() { - local libc_mode - local arg - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - case "${libc_mode}" in - startfiles) CT_DoStep INFO "Installing C library headers & start files";; - final) CT_DoStep INFO "Installing C library";; - *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";; - esac - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}" +musl_main() +{ + CT_DoStep INFO "Installing C library" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc" + CT_IterateMultilibs musl_backend_once multilib CT_Popd CT_EndStep } # This backend builds the C library -# Usage: do_libc_backend param=value [...] +# Usage: musl_backend param=value [...] # Parameter : Definition : Type : Default -# libc_mode : 'startfiles' or 'final' : string : (none) -do_libc_backend_once() { - local libc_mode +# multi_* : as defined in CT_IterateMultilibs : (varies) : +musl_backend_once() +{ local -a extra_cflags local -a extra_config - local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" + local src_dir="${CT_SRC_DIR}/musl" local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count local multilib_dir local hdr_install_subdir @@ -78,13 +44,6 @@ do_libc_backend_once() { extra_cflags=( ${multi_flags} ) - # From buildroot: - # gcc constant folding bug with weak aliases workaround - # See http://www.openwall.com/lists/musl/2014/05/15/1 - if [ "${CT_CC_GCC_4_9_or_later}" = "y" ]; then - extra_cflags+=("-fno-toplevel-reorder") - fi - if [ "${CT_LIBC_MUSL_DEBUG}" = "y" ]; then extra_config+=("--enable-debug") fi @@ -93,6 +52,11 @@ do_libc_backend_once() { extra_config+=("--enable-warnings") fi + case "${CT_SHARED_LIBS}" in + y) extra_config+=("--enable-shared");; + *) extra_config+=("--disable-shared");; + esac + extra_config+=( "--enable-optimize=${CT_LIBC_MUSL_OPTIMIZE}" ) # Same problem as with uClibc: different variants sometimes have @@ -102,13 +66,16 @@ do_libc_backend_once() { extra_config+=( "--includedir=/usr/include/${hdr_install_subdir}" ) fi + CT_SymlinkToolsMultilib + # NOTE: musl handles the build/host/target a little bit differently # then one would expect: # build : not used # host : same as --target # target : the machine musl runs on CT_DoExecLog CFG \ - CFLAGS="${extra_cflags[*]}" \ + CFLAGS="${CT_TARGET_CFLAGS} ${extra_cflags[*]}" \ + LDFLAGS="${CT_TARGET_LDFLAGS}" \ CROSS_COMPILE="${CT_TARGET}-" \ ${CONFIG_SHELL} \ ${src_dir}/configure \ @@ -119,45 +86,26 @@ do_libc_backend_once() { --disable-gcc-wrapper \ "${extra_config[@]}" - if [ "${libc_mode}" = "startfiles" ]; then - CT_DoLog EXTRA "Installing C library headers" - CT_DoExecLog ALL make DESTDIR="${multi_root}" install-headers - CT_DoLog EXTRA "Building C library start files" - CT_DoExecLog ALL make DESTDIR="${multi_root}" \ - obj/crt/crt1.o obj/crt/crti.o obj/crt/crtn.o - CT_DoLog EXTRA "Installing C library start files" - CT_DoExecLog ALL cp -av obj/crt/crt*.o "${multi_root}${multilib_dir}" - CT_DoExecLog ALL ${CT_TARGET}-${CT_CC} -nostdlib \ - -nostartfiles -shared -x c /dev/null -o "${multi_root}${multilib_dir}/libc.so" - fi - if [ "${libc_mode}" = "final" ]; then - CT_DoLog EXTRA "Cleaning up start files" - CT_DoExecLog ALL rm -f "${multi_root}${multilib_dir}/crt1.o" \ - "${multi_root}${multilib_dir}/crti.o" \ - "${multi_root}${multilib_dir}/crtn.o" \ - "${multi_root}${multilib_dir}/libc.so" - - CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make ${JOBSFLAGS} - - CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL make DESTDIR="${multi_root}" install - - # Convert /lib/ld-* symlinks to relative paths so that they are valid - # both on the host and on the target. - for f in ${multi_root}/ld-musl-*; do - [ -L "${f}" ] || continue - l=$( readlink ${f} ) - case "${l}" in - ${multilib_dir}/*) - CT_DoExecLog ALL ln -sf "../${l}" "${f}" - ;; - esac - done - - # Any additional actions for this architecture - CT_DoArchMUSLPostInstall - fi + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make DESTDIR="${multi_root}" install + + # Convert /lib/ld-* symlinks to relative paths so that they are valid + # both on the host and on the target. + for f in ${multi_root}/ld-musl-*; do + [ -L "${f}" ] || continue + l=$( readlink ${f} ) + case "${l}" in + ${multilib_dir}/*) + CT_DoExecLog ALL ln -sf "../${l}" "${f}" + ;; + esac + done + + # Any additional actions for this architecture + CT_DoArchMUSLPostInstall CT_EndStep } diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh index 3b48507..72111a9 100644 --- a/scripts/build/libc/newlib.sh +++ b/scripts/build/libc/newlib.sh @@ -5,64 +5,32 @@ # Edited by Martin Lund <mgl@doredevelopment.dk> # -do_libc_get() { - local libc_src="{http://mirrors.kernel.org/sourceware/newlib, - ftp://sourceware.org/pub/newlib}" - - if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" ]; then - CT_GetCustom "newlib" "${CT_LIBC_NEWLIB_CUSTOM_VERSION}" \ - "${CT_LIBC_NEWLIB_CUSTOM_LOCATION}" - else # ! custom location - case "${CT_LIBC_VERSION}" in - linaro-*) - CT_GetLinaro "newlib" "${CT_LIBC_VERSION}" - ;; - *) - # kernel.org mirror is outdated, keep last as a fallback - CT_GetFile "newlib-${CT_LIBC_VERSION}" \ - ftp://sourceware.org/pub/newlib \ - http://mirrors.kernel.org/sourceware/newlib \ - http://mirrors.kernel.org/sources.redhat.com/newlib - ;; - esac - fi # ! custom location -} - -do_libc_extract() { - CT_Extract "newlib-${CT_LIBC_VERSION}" - CT_Patch "newlib" "${CT_LIBC_VERSION}" - - if [ -n "${CT_ARCH_XTENSA_CUSTOM_NAME}" ]; then - CT_ConfigureXtensa "newlib" "${CT_LIBC_VERSION}" - fi -} - -do_libc_start_files() { - CT_DoStep INFO "Installing C library headers & start files" - CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/newlib/libc/include/." \ - "${CT_HEADERS_DIR}" - if [ "${CT_ARCH_xtensa}" = "y" ]; then +newlib_headers() +{ + CT_DoStep INFO "Installing C library headers" + CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." "${CT_HEADERS_DIR}" + if [ "${CT_ARCH_XTENSA}" = "y" ]; then CT_DoLog EXTRA "Installing Xtensa headers" - CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/newlib/libc/sys/xtensa/include/." \ + CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/newlib/newlib/libc/sys/xtensa/include/." \ "${CT_HEADERS_DIR}" fi CT_EndStep } -do_libc() { +newlib_main() +{ local -a newlib_opts local cflags_for_target CT_DoStep INFO "Installing C library" - mkdir -p "${CT_BUILD_DIR}/build-libc" - cd "${CT_BUILD_DIR}/build-libc" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc" CT_DoLog EXTRA "Configuring C library" # Multilib is the default, so if it is not enabled, disable it. if [ "${CT_MULTILIB}" != "y" ]; then - extra_config+=("--disable-multilib") + newlib_opts+=("--disable-multilib") fi if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then @@ -86,16 +54,19 @@ do_libc() { yn_args="IO_POS_ARGS:newlib-io-pos-args IO_C99FMT:newlib-io-c99-formats IO_LL:newlib-io-long-long -NEWLIB_REGISTER_FINI:newlib-register-fini +REGISTER_FINI:newlib-register-fini NANO_MALLOC:newlib-nano-malloc NANO_FORMATTED_IO:newlib-nano-formatted-io -ATEXIT_DYNAMIC_ALLOC:atexit-dynamic-alloc +ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc GLOBAL_ATEXIT:newlib-global-atexit LITE_EXIT:lite-exit -REENT_SMALL:reent-small -MULTITHREAD:multithread +REENT_SMALL:newlib-reent-small +MULTITHREAD:newlib-multithread +RETARGETABLE_LOCKING:newlib-retargetable-locking WIDE_ORIENT:newlib-wide-orient -UNBUF_STREAM_OPT:unbuf-stream-opt +FSEEK_OPTIMIZATION:newlib-fseek-optimization +FVWRITE_IN_STREAMIO:newlib-fvwrite-in-streamio +UNBUF_STREAM_OPT:newlib-unbuf-stream-opt ENABLE_TARGET_OPTSPACE:target-optspace " @@ -118,7 +89,7 @@ ENABLE_TARGET_OPTSPACE:target-optspace [ "${CT_LIBC_NEWLIB_LTO}" = "y" ] && \ CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -flto" - cflags_for_target="${CT_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_TARGET_CFLAGS}" + cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_TARGET_CFLAGS}" # Note: newlib handles the build/host/target a little bit differently # than one would expect: @@ -131,7 +102,7 @@ ENABLE_TARGET_OPTSPACE:target-optspace AR_FOR_TARGET="`which ${CT_TARGET}-gcc-ar`" \ RANLIB_FOR_TARGET="`which ${CT_TARGET}-gcc-ranlib`" \ ${CONFIG_SHELL} \ - "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \ + "${CT_SRC_DIR}/newlib/configure" \ --host=${CT_BUILD} \ --target=${CT_TARGET} \ --prefix=${CT_PREFIX_DIR} \ @@ -139,7 +110,7 @@ ENABLE_TARGET_OPTSPACE:target-optspace "${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}" CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make ${JOBSFLAGS} + CT_DoExecLog ALL make ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing C library" CT_DoExecLog ALL make install @@ -159,9 +130,6 @@ ENABLE_TARGET_OPTSPACE:target-optspace "${CT_PREFIX_DIR}/share/doc/newlib" fi + CT_Popd CT_EndStep } - -do_libc_post_cc() { - : -} diff --git a/scripts/build/libc/none.sh b/scripts/build/libc/none.sh index 8537a8e..5173afb 100644 --- a/scripts/build/libc/none.sh +++ b/scripts/build/libc/none.sh @@ -2,22 +2,12 @@ # Copyright 2008 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -do_libc_get() { +none_get() +{ : } -do_libc_extract() { - : -} - -do_libc_start_files() { - : -} - -do_libc() { - : -} - -do_libc_post_cc() { +none_extract() +{ : } diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc-ng.sh index e87abaf..7b81d92 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc-ng.sh @@ -2,96 +2,22 @@ # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -# This is a constant because it does not change very often. -# We're in 2010, and are still using data from 7 years ago. -uclibc_locales_version=030818 -uclibc_locale_tarball="uClibc-locale-${uclibc_locales_version}" - -if [ "${CT_LIBC_UCLIBC_NG}" = "y" ]; then - uclibc_name="uClibc-ng" - libc_src="http://downloads.uclibc-ng.org/releases/${CT_LIBC_VERSION}" -else - uclibc_name="uClibc" - libc_src="http://www.uclibc.org/downloads - http://www.uclibc.org/downloads/old-releases" -fi - -# Download uClibc -do_libc_get() { - if [ "${CT_LIBC_UCLIBC_CUSTOM}" = "y" ]; then - CT_GetCustom "${uclibc_name}" "${CT_LIBC_UCLIBC_CUSTOM_VERSION}" \ - "${CT_LIBC_UCLIBC_CUSTOM_LOCATION}" - else - CT_GetFile "${uclibc_name}-${CT_LIBC_VERSION}" ${libc_src} - fi - # uClibc locales - if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" ]; then - CT_GetFile "${uclibc_locale_tarball}" ${libc_src} - fi - - return 0 -} - -# Extract uClibc -do_libc_extract() { - CT_Extract "${uclibc_name}-${CT_LIBC_VERSION}" - CT_Patch "${uclibc_name}" "${CT_LIBC_VERSION}" - - # uClibc locales - # Extracting pregen locales ourselves is kinda - # broken, so just link it in place... - if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" \ - -a ! -f "${CT_SRC_DIR}/.${uclibc_locale_tarball}.extracted" ]; then - CT_Pushd "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}/extra/locale" - CT_DoExecLog ALL ln -s "${CT_TARBALLS_DIR}/${uclibc_locale_tarball}.tgz" . - CT_Popd - touch "${CT_SRC_DIR}/.${uclibc_locale_tarball}.extracted" - fi - - return 0 -} - -# 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 -} - -# Common backend for 1st and 2nd passes. -do_libc_backend() { - local libc_mode - local arg - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - case "${libc_mode}" in - startfiles) CT_DoStep INFO "Installing C library headers & start files";; - final) CT_DoStep INFO "Installing C library";; - *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";; - esac - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}" - - +uClibc_ng_main() +{ + CT_DoStep INFO "Installing C library" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc" + CT_IterateMultilibs uClibc_ng_backend_once multilib CT_Popd CT_EndStep } # Common backend for 1st and 2nd passes, once per multilib. -do_libc_backend_once() { - local libc_mode +uClibc_ng_backend_once() +{ local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count local multilib_dir startfiles_dir - local jflag=${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} + local jflag=${CT_JOBSFLAGS} local -a make_args local extra_cflags f cfg_cflags cf local hdr_install_subdir @@ -102,17 +28,13 @@ do_libc_backend_once() { CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'" - # Simply copy files until uClibc has the ability to build out-of-tree - CT_DoLog EXTRA "Copying sources to build dir" - CT_DoExecLog ALL cp -aT "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}/." . - multilib_dir="lib/${multi_os_dir}" startfiles_dir="${multi_root}/usr/${multilib_dir}" CT_SanitizeVarDir multilib_dir startfiles_dir # Construct make arguments: # - uClibc uses the CROSS environment variable as a prefix to the compiler - # tools to use. Since it requires core pass-1, thusly named compiler is + # tools to use. Since it requires core compiler, thusly named compiler is # already available. # - Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak, # depending on the configuration of the library. That is, they are tailored @@ -121,20 +43,24 @@ do_libc_backend_once() { # - We do _not_ want to strip anything for now, in case we specifically # asked for a debug toolchain, thus the STRIPTOOL= assignment. make_args=( CROSS_COMPILE="${CT_TARGET}-" \ + HOSTCC="${CT_BUILD}-gcc" \ PREFIX="${multi_root}/" \ MULTILIB_DIR="${multilib_dir}" \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ ) + # Simply copy files until uClibc has the ability to build out-of-tree + CT_DoLog EXTRA "Copying sources to build dir" + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/uClibc-ng/." . + # Force the date of the pregen locale data, as the # newer ones that are referenced are not available CT_DoLog EXTRA "Applying configuration" # Use the default config if the user did not provide one. if [ -z "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then - CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/contrib/uClibc-defconfigs/${uclibc_name}.config" + CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/packages/uClibc-ng/config" fi manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" .config "${multi_flags}" @@ -176,63 +102,11 @@ do_libc_backend_once() { CT_DoExecLog ALL cp -a "${multi_root}/usr/include" "${multi_root}/usr/include.saved" fi - if [ "${libc_mode}" = "startfiles" ]; then - CT_DoLog EXTRA "Building headers" - CT_DoExecLog ALL make "${make_args[@]}" headers - - # Ensure the directory for installing multilib-specific binaries exists. - CT_DoExecLog ALL mkdir -p "${startfiles_dir}" - - CT_DoLog EXTRA "Installing headers" - CT_DoExecLog ALL make "${make_args[@]}" install_headers - - # The check might look bogus, but it is the same condition as is used - # by GCC build script to enable/disable shared library support. - if [ "${CT_THREADS}" = "nptl" ]; then - CT_DoLog EXTRA "Building start files" - CT_DoExecLog ALL make ${jflag} "${make_args[@]}" \ - lib/crt1.o lib/crti.o lib/crtn.o - - # From: http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b - # libm.so is needed for ppc, as libgcc is linked against libm.so - # No problem to create it for other archs. - CT_DoLog EXTRA "Building dummy shared libs" - CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -nostdlib -nostartfiles \ - -shared ${multi_flags} -x c /dev/null -o libdummy.so - - CT_DoLog EXTRA "Installing start files" - CT_DoExecLog ALL install -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \ - "${startfiles_dir}" - - CT_DoLog EXTRA "Installing dummy shared libs" - CT_DoExecLog ALL install -m 0755 libdummy.so "${startfiles_dir}/libc.so" - CT_DoExecLog ALL install -m 0755 libdummy.so "${startfiles_dir}/libm.so" - fi # CT_THREADS == nptl - fi # libc_mode == startfiles - - if [ "${libc_mode}" = "final" ]; then - CT_DoLog EXTRA "Cleaning up startfiles" - CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \ - "${startfiles_dir}/crti.o" \ - "${startfiles_dir}/crtn.o" \ - "${startfiles_dir}/libc.so" \ - "${startfiles_dir}/libm.so" - - CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make "${make_args[@]}" pregen - CT_DoExecLog ALL make ${jflag} "${make_args[@]}" all - - # YEM-FIXME: - # - we want to install 'runtime' files, eg. lib*.{a,so*}, crti.o and - # such files, except the headers as they already are installed - # - "make install_dev" installs the headers, the crti.o... and the - # static libs, but not the dynamic libs - # - "make install_runtime" installs the dynamic libs only - # - "make install" calls install_runtime and install_dev - # - so we're left with re-installing the headers... Sigh... - CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL make "${make_args[@]}" install install_utils - fi # libc_mode == final + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make "${make_args[@]}" pregen + CT_DoExecLog ALL make ${jflag} "${make_args[@]}" all + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make "${make_args[@]}" install install_utils # Now, if installing headers into a subdirectory, put everything in its place. # Remove the header subdirectory if it existed already. @@ -249,7 +123,8 @@ do_libc_backend_once() { # Initialises the .config file to sensible values # $1: original file # $2: modified file -manage_uClibc_config() { +manage_uClibc_config() +{ src="$1" dst="$2" flags="$3" @@ -258,13 +133,13 @@ manage_uClibc_config() { CT_DoExecLog ALL cp "${src}" "${dst}" case "${CT_ARCH_ENDIAN}" in - big) + big|big,little) CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}" CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}" CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${dst}" CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}" ;; - little) + little|little,big) CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${dst}" CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}" CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${dst}" @@ -276,6 +151,15 @@ manage_uClibc_config() { CT_KconfigEnableOption "ARCH_USE_MMU" "${dst}" else CT_KconfigDisableOption "ARCH_USE_MMU" "${dst}" + CT_KconfigDisableOption "UCLIBC_FORMAT_FDPIC" "${dst}" + CT_KconfigDisableOption "UCLIBC_FORMAT_FLAT" "${dst}" + CT_KconfigDisableOption "UCLIBC_FORMAT_SHARED_FLAT" "${dst}" + case "${CT_ARCH_BINFMT_FLAT},${CT_ARCH_BINFMT_FDPIC},${CT_SHARED_LIBS}" in + y,,y) CT_KconfigEnableOption "UCLIBC_FORMAT_SHARED_FLAT" "${dst}";; + y,,) CT_KconfigEnableOption "UCLIBC_FORMAT_FLAT" "${dst}";; + ,y,*) CT_KconfigEnableOption "UCLIBC_FORMAT_FDPIC" "${dst}";; + *) CT_Abort "Unsupported binary format";; + esac fi if [ "${CT_SHARED_LIBS}" = "y" ]; then @@ -324,27 +208,14 @@ manage_uClibc_config() { # entirely if LOCALE is not set. If LOCALE was already set, we'll # assume the user has already made all the appropriate generation # arrangements. Note that having the uClibc Makefile download the - # pregenerated locales is not compatible with crosstool; besides, - # crosstool downloads them as part of getandpatch.sh. - CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE" "${dst}" - case "${CT_LIBC_UCLIBC_LOCALES}:${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" in - :*) - ;; - y:) + # pregenerated locales is not compatible with crosstool. + if [ -z "${CT_LIBC_UCLIBC_LOCALES}" ]; then + CT_KconfigDisableOption "UCLIBC_HAS_LOCALE" "${dst}" + else CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}" CT_KconfigDeleteOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}" - CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" \ - "${dst}" - CT_KconfigDeleteOption "UCLIBC_HAS_XLOCALE" "${dst}" - ;; - y:y) - CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}" - CT_KconfigEnableOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}" - CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" \ - "${dst}" - CT_KconfigDeleteOption "UCLIBC_HAS_XLOCALE" "${dst}" - ;; - esac + CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" "${dst}" + fi # WCHAR support if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ]; then @@ -360,6 +231,13 @@ manage_uClibc_config() { CT_KconfigDisableOption "UCLIBC_HAS_IPV6" "${dst}" fi + # Iconv support + if [ "${CT_LIBC_UCLIBC_LIBICONV}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_HAS_LIBICONV" "${dst}" + else + CT_KconfigDisableOption "UCLIBC_HAS_LIBICONV" "${dst}" + fi + # Force on options needed for C++ if we'll be making a C++ compiler. # I'm not sure locales are a requirement for doing C++... Are they? if [ "${CT_CC_LANG_CXX}" = "y" ]; then @@ -368,11 +246,14 @@ manage_uClibc_config() { fi # Stack Smash Protection (SSP) - if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then + if [ "${CT_LIBC_UCLIBC_HAS_SSP}" = "y" ]; then CT_KconfigEnableOption "UCLIBC_HAS_SSP" "${dst}" - CT_KconfigEnableOption "UCLIBC_BUILD_SSP" "${dst}" else CT_KconfigDisableOption "UCLIBC_HAS_SSP" "${dst}" + fi + if [ "${CT_LIBC_UCLIBC_BUILD_SSP}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_BUILD_SSP" "${dst}" + else CT_KconfigDisableOption "UCLIBC_BUILD_SSP" "${dst}" fi @@ -381,28 +262,19 @@ manage_uClibc_config() { CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}" CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}" CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" - case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in - none:) + case "${CT_THREADS}" in + none) ;; - linuxthreads:) - # Newer version of uClibc-ng, no old/new dichotomy + linuxthreads) CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" CT_KconfigEnableOption "UCLIBC_HAS_LINUXTHREADS" "${dst}" ;; - linuxthreads:old) - CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigEnableOption "LINUXTHREADS_OLD" "${dst}" - ;; - linuxthreads:new) - CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigEnableOption "LINUXTHREADS_NEW" "${dst}" - ;; - nptl:) + nptl) CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" CT_KconfigEnableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" ;; *) - CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREAD}' CT_LIBC_UCLIBC_LNXTHRD='${CT_LIBC_UCLIBC_LNXTHRD}'" + CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREADS}'" ;; esac @@ -445,9 +317,14 @@ manage_uClibc_config() { # Now allow architecture to tweak as it wants CT_DoArchUClibcConfig "${dst}" CT_DoArchUClibcCflags "${dst}" "${flags}" + + # Preserve the config we created (before uclibc's `make olddefconfig` + # overrides anything). + CT_DoExecLog ALL cp "${dst}" "${dst}.created-by-ct-ng" } -do_libc_post_cc() { +uClibc_ng_post_cc() +{ # uClibc and GCC disagree where the dynamic linker lives. uClibc always # places it in the MULTILIB_DIR, while gcc does that for *some* variants # and expects it in /lib for the other. So, create a symlink from lib @@ -455,51 +332,9 @@ do_libc_post_cc() { # file in /lib. Thus, need to do this after all the variants are built. # Moreover, need to do this after the final compiler is built: on targets # that use elf2flt, the core compilers cannot find ld when running elf2flt. - CT_DoStep INFO "Checking dynamic linker symlinks" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-post_cc" - echo "int main(void) { return 0; }" > test-ldso.c - CT_IterateMultilibs do_libc_ldso_fixup ldso_fixup - CT_Popd - CT_EndStep -} + CT_MultilibFixupLDSO -do_libc_ldso_fixup() { - local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count - local binary - local ldso ldso_f ldso_d multilib_dir - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'" - - multilib_dir="/lib/${multi_os_dir}" - CT_SanitizeVarDir multilib_dir - - CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags} - if [ -r "test-ldso.gdb" ]; then - binary="test-ldso.gdb" - else - binary="test-ldso" - fi - if ${CT_TARGET}-readelf -Wl "${binary}" | grep -q 'Requesting program interpreter: '; then - ldso=$( ${CT_TARGET}-readelf -Wl "${binary}" | \ - grep 'Requesting program interpreter: ' | \ - sed -e 's,.*: ,,' -e 's,\].*,,' ) - fi - CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'" - - ldso_d="${ldso%/ld*.so.*}" - ldso_f="${ldso##*/}" - # Create symlink if GCC produced an executable, dynamically linked, it was requesting - # a linker not in the current directory, and there is no such file in the expected - # ldso dir. - if [ -n "${ldso}" -a "${ldso_d}" != "${multilib_dir}" -a ! -r "${multi_root}${ldso}" ]; then - # Convert ldso_d to "how many levels we need to go up" and remove - # leading slash. - ldso_d=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' ) - CT_DoExecLog ALL ln -sf "${ldso_d}${multilib_dir}/${ldso_f}" \ - "${multi_root}${ldso}" + if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then + CT_InstallConfigurationFile "${CT_LIBC_UCLIBC_CONFIG_FILE}" libc fi } diff --git a/scripts/build/test_suite.sh b/scripts/build/test_suite.sh index 8fabf42..e963a99 100644 --- a/scripts/build/test_suite.sh +++ b/scripts/build/test_suite.sh @@ -7,8 +7,7 @@ CT_TEST_SUITE_FACILITY_LIST= for f in "${CT_LIB_DIR}/scripts/build/test_suite/"*.sh; do _f="$(basename "${f}" .sh)" - __f="CT_TEST_SUITE_${_f}" - __f=`echo ${__f} | tr "[:lower:]" "[:upper:]"` + __f="CT_TEST_SUITE_${_f^^}" if [ "${!__f}" = "y" ]; then CT_DoLog DEBUG "Enabling test suite '${_f}'" . "${f}" diff --git a/scripts/build/test_suite/gcc.sh b/scripts/build/test_suite/gcc.sh index c829a43..6c6e5a7 100644 --- a/scripts/build/test_suite/gcc.sh +++ b/scripts/build/test_suite/gcc.sh @@ -18,7 +18,7 @@ do_test_suite_gcc_build() { 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_SRC_DIR}/gcc/gcc/testsuite" \ "${CT_TEST_SUITE_DIR}/gcc" CT_DoExecLog ALL sed -i -r -e "s/@@DG_TARGET@@/${CT_TARGET}/g;" \ diff --git a/scripts/compile b/scripts/compile new file mode 100755 index 0000000..a85b723 --- /dev/null +++ b/scripts/compile @@ -0,0 +1,347 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2012-10-14.11; # UTC + +# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Written by Tom Tromey <tromey@cygnus.com>. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to <bug-automake@gnu.org> or send patches to +# <automake-patches@gnu.org>. + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to <bug-automake@gnu.org>. +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/scripts/config.guess b/scripts/config.guess index 1000e2b..e81d3ae 100755 --- a/scripts/config.guess +++ b/scripts/config.guess @@ -1,8 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2017-02-07' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2021-06-03' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +17,7 @@ timestamp='2017-02-07' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. +# along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,11 +29,19 @@ timestamp='2017-02-07' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to <config-patches@gnu.org>. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -39,7 +49,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +60,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,7 +94,8 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 +# Just in case it came from the environment. +GUESS= # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires @@ -96,66 +107,90 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD=$driver + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case $UNAME_SYSTEM in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include <features.h> #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #else + #include <stdarg.h> + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -167,32 +202,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -208,10 +243,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -219,47 +254,68 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case $UNAME_VERSION in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" - exit ;; + GUESS=$machine-${os}${release}${abi-} + ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; + *:MidnightBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; + *:OS108:*:*) + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix - exit ;; + GUESS=$UNAME_MACHINE-unknown-sortix + ;; + *:Twizzler:*:*) + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; + *:Redox:*:*) + GUESS=$UNAME_MACHINE-unknown-redox + ;; + mips:OSF1:*.*) + GUESS=mips-dec-osf1 + ;; alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` @@ -273,7 +329,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in + case $ALPHA_CPU_TYPE in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") @@ -310,84 +366,76 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; + GUESS=m68k-unknown-sysv4 + ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; + GUESS=$UNAME_MACHINE-unknown-morphos + ;; *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; + GUESS=i370-ibm-openedition + ;; *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; + GUESS=s390-ibm-zvmoe + ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; + GUESS=powerpc-ibm-os400 + ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; + GUESS=arm-unknown-riscos + ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; + GUESS=hppa1.1-hitachi-hiuxmpp + ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; + GUESS=pyramid-pyramid-svr4 + ;; DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; + GUESS=sparc-icl-nx6 + ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build + set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null @@ -395,41 +443,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in + case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 - case "`/bin/arch`" in + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case `/bin/arch` in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac - exit ;; + ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -439,44 +490,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; + GUESS=mips-dec-mach_bsd4.3 + ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include <stdio.h> /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -485,95 +536,96 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; + GUESS=powerpc-motorola-powermax + ;; Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; + GUESS=powerpc-harris-powerunix + ;; m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; + GUESS=m88k-harris-cxux7 + ;; m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; + GUESS=m88k-motorola-sysv4 + ;; m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux${UNAME_RELEASE} + GUESS=m88k-dg-dgux$UNAME_RELEASE else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else - echo i586-dg-dgux${UNAME_RELEASE} + GUESS=i586-dg-dgux$UNAME_RELEASE fi - exit ;; + ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; + GUESS=m88k-dolphin-sysv3 + ;; M88*:*:R3*:*) # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; + GUESS=m88k-tektronix-sysv3 + ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; + GUESS=m68k-tektronix-bsd + ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; + GUESS=i386-ibm-aix + ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then + if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> main() @@ -584,77 +636,77 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then - echo "$SYSTEM_NAME" + GUESS=$SYSTEM_NAME else - echo rs6000-ibm-aix3.2.5 + GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 + GUESS=rs6000-ibm-aix3.2.4 else - echo rs6000-ibm-aix3.2 + GUESS=rs6000-ibm-aix3.2 fi - exit ;; + ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; + GUESS=rs6000-ibm-aix + ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + GUESS=romp-ibm-bsd4.4 + ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; + GUESS=rs6000-bull-bosx + ;; DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; + GUESS=m68k-bull-sysv3 + ;; 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; + GUESS=m68k-hp-bsd + ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; + GUESS=m68k-hp-bsd4.4 + ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then + if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in + case $sc_cpu_version in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in + case $sc_kernel_bits in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include <stdlib.h> @@ -687,13 +739,13 @@ EOF exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = hppa2.0w ] + if test "$HP_ARCH" = hppa2.0w then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -712,15 +764,15 @@ EOF HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include <unistd.h> int main () @@ -745,38 +797,38 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; + GUESS=unknown-hitachi-hiuxwe2 + ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + GUESS=hppa1.1-hp-bsd + ;; 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; + GUESS=hppa1.0-hp-bsd + ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; + GUESS=hppa1.0-hp-mpeix + ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + GUESS=hppa1.1-hp-osf + ;; hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; + GUESS=hppa1.0-hp-osf + ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + GUESS=$UNAME_MACHINE-unknown-osf1 fi - exit ;; + ;; parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; + GUESS=hppa1.1-hp-lites + ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; + GUESS=c1-convex-bsd + ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd @@ -784,139 +836,145 @@ EOF fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; + GUESS=c34-convex-bsd + ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; + GUESS=c38-convex-bsd + ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; + GUESS=c4-convex-bsd + ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi + else + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf + fi + ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case $UNAME_PROCESSOR in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac - exit ;; + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; + GUESS=$UNAME_MACHINE-pc-cygwin + ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-msys + ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-pw32 + ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case $UNAME_MACHINE in x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; + GUESS=i586-pc-interix$UNAME_RELEASE + ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; + GUESS=$UNAME_MACHINE-pc-uwin + ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; + GUESS=x86_64-pc-cygwin + ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; + *:Minix:*:*) + GUESS=$UNAME_MACHINE-unknown-minix + ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -927,183 +985,225 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi - exit ;; + ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} - exit ;; + GUESS=or1k-unknown-linux-$LIBC + ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; + GUESS=sparc-unknown-linux-$LIBC + ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; + GUESS=hppa64-unknown-linux-$LIBC + ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; esac - exit ;; + ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc64-unknown-linux-$LIBC + ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc-unknown-linux-$LIBC + ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc64le-unknown-linux-$LIBC + ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=powerpcle-unknown-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; + set_cc_for_build + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI=${LIBC}x32 + fi + fi + GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI + ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; + GUESS=i386-sequent-sysv4 + ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; + GUESS=$UNAME_MACHINE-unknown-stop + ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; + GUESS=$UNAME_MACHINE-unknown-atheos + ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; + GUESS=$UNAME_MACHINE-pc-syllable + ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi - exit ;; + ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in @@ -1111,12 +1211,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL elif /bin/uname -X 2>/dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1126,11 +1226,11 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else - echo ${UNAME_MACHINE}-pc-sysv32 + GUESS=$UNAME_MACHINE-pc-sysv32 fi - exit ;; + ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -1138,31 +1238,31 @@ EOF # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; + GUESS=i586-pc-msdosdjgpp + ;; Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; + GUESS=i386-pc-mach3 + ;; paragon:*:*:*) - echo i860-intel-osf1 - exit ;; + GUESS=i860-intel-osf1 + ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi - exit ;; + ;; mini*:CTIX:SYS*5:*) # "miniframe" - echo m68010-convergent-sysv - exit ;; + GUESS=m68010-convergent-sysv + ;; mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; + GUESS=m68k-convergent-sysv + ;; M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; + GUESS=m68k-diab-dnix + ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) @@ -1170,9 +1270,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1181,252 +1281,434 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; + GUESS=m68k-atari-sysv4 + ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + GUESS=$UNAME_MACHINE-sni-sysv4 else - echo ns32k-sni-sysv + GUESS=ns32k-sni-sysv fi - exit ;; + ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit ;; + GUESS=i586-unisys-sysv4 + ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; + GUESS=hppa1.1-stratus-sysv4 + ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; + GUESS=i860-stratus-sysv4 + ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; + GUESS=$UNAME_MACHINE-stratus-vos + ;; *:VOS:*:*) # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; + GUESS=hppa1.1-stratus-vos + ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; + GUESS=mips-sony-newsos6 + ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE else - echo mips-unknown-sysv${UNAME_RELEASE} + GUESS=mips-unknown-sysv$UNAME_RELEASE fi - exit ;; + ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; + GUESS=powerpc-be-beos + ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; + GUESS=powerpc-apple-beos + ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; + GUESS=i586-pc-beos + ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; + GUESS=i586-pc-haiku + ;; x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; + GUESS=x86_64-unknown-haiku + ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=i386-pc-qnx + ;; + NEO-*:NONSTOP_KERNEL:*:*) + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - NSX-?:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; + NSR-*:NONSTOP_KERNEL:*:*) + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; + NSV-*:NONSTOP_KERNEL:*:*) + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; + NSX-*:NONSTOP_KERNEL:*:*) + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; + GUESS=mips-compaq-nonstopux + ;; BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; + GUESS=bs2000-siemens-sysv + ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = 386; then + if test "${cputype-}" = 386; then UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; + GUESS=pdp10-unknown-tops10 + ;; *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; + GUESS=pdp10-unknown-tenex + ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; + GUESS=pdp10-dec-tops20 + ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; + GUESS=pdp10-xkl-tops20 + ;; *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; + GUESS=pdp10-unknown-tops20 + ;; *:ITS:*:*) - echo pdp10-unknown-its - exit ;; + GUESS=pdp10-unknown-its + ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; + GUESS=i386-pc-xenix + ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` - exit ;; + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; + GUESS=$UNAME_MACHINE-pc-rdos + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-unknown-aros + ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; + GUESS=$UNAME_MACHINE-unknown-esx + ;; amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs - exit ;; + GUESS=x86_64-unknown-onefs + ;; + *:Unleashed:*:*) + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; +esac + +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" <<EOF +#ifdef _SEQUENT_ +#include <sys/types.h> +#include <sys/utsname.h> +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include <signal.h> +#if defined(_SIZE_T_) || defined(SIGLOST) +#include <sys/utsname.h> +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include <sys/param.h> +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case $UNAME_MACHINE:$UNAME_SYSTEM in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <<EOF + +NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize +the system type. Please install a C compiler and try again. +EOF + ;; esac cat >&2 <<EOF -$0: unable to guess system type This script (version $timestamp), has failed to recognize the -operating system you are using. If your script is old, overwrite -config.guess and config.sub with the latest versions from: +operating system you are using. If your script is old, overwrite *all* +copies of config.guess and config.sub with the latest versions from: - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess + https://git.savannah.gnu.org/cgit/config.git/plain/config.guess and - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + https://git.savannah.gnu.org/cgit/config.git/plain/config.sub +EOF + +our_year=`echo $timestamp | sed 's,-.*,,'` +thisyear=`date +%Y` +# shellcheck disable=SC2003 +script_age=`expr "$thisyear" - "$our_year"` +if test "$script_age" -lt 3 ; then + cat >&2 <<EOF If $0 has already been updated, send the following data and any information you think might be pertinent to config-patches@gnu.org to @@ -1449,16 +1731,17 @@ hostinfo = `(hostinfo) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/scripts/config.rpath b/scripts/config.rpath new file mode 100644 index 0000000..1b83ae0 --- /dev/null +++ b/scripts/config.rpath @@ -0,0 +1,2 @@ +# Dummy file for gettext dependencies +: diff --git a/scripts/config.sub b/scripts/config.sub index 87abeab..d74fb6d 100755 --- a/scripts/config.sub +++ b/scripts/config.sub @@ -1,8 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2017-02-07' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2021-08-14' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +17,7 @@ timestamp='2017-02-07' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. +# along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +35,7 @@ timestamp='2017-02-07' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -50,6 +52,13 @@ timestamp='2017-02-07' # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -57,7 +66,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +76,7 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -89,12 +98,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -110,1247 +119,1181 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +saved_IFS=$IFS +IFS="-" read field1 field2 field3 field4 <<EOF +$1 +EOF +IFS=$saved_IFS -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos +# Separate into logical components for further validation +case $1 in + *-*-*-*-*) + echo Invalid configuration \`"$1"\': more than four components >&2 + exit 1 ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac ;; - -psos*) - os=-psos + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec + cpu=powerpc + vendor=ibm + basic_os=cnk ;; decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 + cpu=pdp10 + vendor=dec + basic_os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 + cpu=pdp10 + vendor=dec + basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp + cpu=m68k + vendor=motorola ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - os=$os"spe" - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) + cpu=mips + vendor=sgi + case $basic_os in + irix*) ;; *) - os=-irix4 + basic_os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) - basic_machine=m68000-convergent + cpu=m68000 + vendor=convergent ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint ;; news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) ;; - -ns2*) - os=-nextstep2 + ns2*) + basic_os=nextstep2 ;; *) - os=-nextstep3 + basic_os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem + cpu=np1 + vendor=gould ;; op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k + cpu=hppa1.1 + vendor=oki + basic_os=proelf ;; pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; pbd) - basic_machine=sparc-tti + cpu=sparc + vendor=tti ;; pbb) - basic_machine=m68k-tti + cpu=m68k + vendor=tti ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + pc532) + cpu=ns32k + vendor=pc532 ;; pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm + cpu=pn + vendor=gould ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + power) + cpu=power + vendor=ibm ;; ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff + cpu=i386 + vendor=ibm ;; rm[46]00) - basic_machine=mips-siemens + cpu=mips + vendor=siemens ;; rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm + cpu=romp + vendor=ibm ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks ;; - sde) - basic_machine=mipsisa32-sde - os=-elf + tower | tower-32) + cpu=m68k + vendor=ncr ;; - sei) - basic_machine=mips-sei - os=-seiux + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu ;; - sequent) - basic_machine=i386-sequent + w65) + cpu=w65 + vendor=wdc ;; - sh) - basic_machine=sh-hitachi - os=-hms + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf ;; - sh5el) - basic_machine=sh5le-unknown + none) + cpu=none + vendor=none ;; - sh64) - basic_machine=sh64-unknown + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 + + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read cpu vendor <<EOF +$basic_machine +EOF + IFS=$saved_IFS ;; - spur) - basic_machine=spur-unknown + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + cpu=$basic_machine + vendor=pc ;; - st2000) - basic_machine=m68k-tandem + # These rules are duplicated from below for sake of the special case above; + # i.e. things that normalized to x86 arches should also default to "pc" + pc98) + cpu=i386 + vendor=pc ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 + x64 | amd64) + cpu=x86_64 + vendor=pc ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + # Recognize the basic CPU types without company name. + *) + cpu=$basic_machine + vendor=unknown ;; - sun2) - basic_machine=m68000-sun +esac + +unset -v basic_machine + +# Decode basic machines in the full and proper CPU-Company form. +case $cpu-$vendor in + # Here we handle the default manufacturer of certain CPU types in canonical form. It is in + # some cases the only manufacturer, in others, it is the most popular. + craynv-unknown) + vendor=cray + basic_os=${basic_os:-unicosmp} ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 + c90-unknown | c90-cray) + vendor=cray + basic_os=${Basic_os:-unicos} ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 + fx80-unknown) + vendor=alliant ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 + romp-unknown) + vendor=ibm ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 + mmix-unknown) + vendor=knuth ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 + microblaze-unknown | microblazeel-unknown) + vendor=xilinx ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 + rs6000-unknown) + vendor=ibm ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 + vax-unknown) + vendor=dec ;; - sun3 | sun3-*) - basic_machine=m68k-sun + pdp11-unknown) + vendor=dec ;; - sun4) - basic_machine=sparc-sun + we32k-unknown) + vendor=att ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun + cydra-unknown) + vendor=cydrome ;; - sv1) - basic_machine=sv1-cray - os=-unicos + i370-ibm*) + vendor=ibm ;; - symmetry) - basic_machine=i386-sequent - os=-dynix + orion-unknown) + vendor=highlevel ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos + xps-unknown | xps100-unknown) + cpu=xps100 + vendor=honeywell ;; - t90) - basic_machine=t90-cray - os=-unicos + + # Here we normalize CPU types with a missing or matching vendor + dpx20-unknown | dpx20-bull) + cpu=rs6000 + vendor=bull + basic_os=${basic_os:-bosx} ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu + + # Here we normalize CPU types irrespective of the vendor + amd64-*) + cpu=x86_64 ;; - tx39) - basic_machine=mipstx39-unknown + blackfin-*) + cpu=bfin + basic_os=linux ;; - tx39el) - basic_machine=mipstx39el-unknown + c54x-*) + cpu=tic54x ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 + c55x-*) + cpu=tic55x ;; - tower | tower-32) - basic_machine=m68k-ncr + c6x-*) + cpu=tic6x ;; - tpf) - basic_machine=s390x-ibm - os=-tpf + e500v[12]-*) + cpu=powerpc + basic_os=${basic_os}"spe" ;; - udi29k) - basic_machine=a29k-amd - os=-udi + mips3*-*) + cpu=mips64 ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 + ms1-*) + cpu=mt ;; - v810 | necv810) - basic_machine=v810-nec - os=-none + m68knommu-*) + cpu=m68k + basic_os=linux ;; - vaxv) - basic_machine=vax-dec - os=-sysv + m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) + cpu=s12z ;; - vms) - basic_machine=vax-dec - os=-vms + openrisc-*) + cpu=or32 ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu + parisc-*) + cpu=hppa + basic_os=linux ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + cpu=i586 ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks + pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + cpu=i686 ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + cpu=i686 ;; - w65*) - basic_machine=w65-wdc - os=-none + pentium4-*) + cpu=i786 ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf + pc98-*) + cpu=i386 ;; - xbox) - basic_machine=i686-pc - os=-mingw32 + ppc-* | ppcbe-*) + cpu=powerpc ;; - xps | xps100) - basic_machine=xps100-honeywell + ppcle-* | powerpclittle-*) + cpu=powerpcle ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ppc64-*) + cpu=powerpc64 ;; - ymp) - basic_machine=ymp-cray - os=-unicos + ppc64le-* | powerpc64little-*) + cpu=powerpc64le ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim + sb1-*) + cpu=mipsisa64sb1 ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim + sb1el-*) + cpu=mipsisa64sb1el ;; - none) - basic_machine=none-none - os=-none + sh5e[lb]-*) + cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'` ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond + spur-*) + cpu=spur ;; - op50n) - basic_machine=hppa1.1-oki + strongarm-* | thumb-*) + cpu=arm ;; - op60c) - basic_machine=hppa1.1-oki + tx39-*) + cpu=mipstx39 ;; - romp) - basic_machine=romp-ibm + tx39el-*) + cpu=mipstx39el ;; - mmix) - basic_machine=mmix-knuth + x64-*) + cpu=x86_64 ;; - rs6000) - basic_machine=rs6000-ibm + xscale-* | xscalee[bl]-*) + cpu=`echo "$cpu" | sed 's/^xscale/arm/'` ;; - vax) - basic_machine=vax-dec + arm64-*) + cpu=aarch64 ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. + cr16-*) + basic_os=${basic_os:-elf} ;; - pdp11) - basic_machine=pdp11-dec + crisv32-* | etraxfs*-*) + cpu=crisv32 + vendor=axis ;; - we32k) - basic_machine=we32k-att + cris-* | etrax*-*) + cpu=cris + vendor=axis ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown + crx-*) + basic_os=${basic_os:-elf} ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun + neo-tandem) + cpu=neo + vendor=tandem ;; - cydra) - basic_machine=cydra-cydrome + nse-tandem) + cpu=nse + vendor=tandem ;; - orion) - basic_machine=orion-highlevel + nsr-tandem) + cpu=nsr + vendor=tandem ;; - orion105) - basic_machine=clipper-highlevel + nsv-tandem) + cpu=nsv + vendor=tandem ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple + nsx-tandem) + cpu=nsx + vendor=tandem ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple + mipsallegrexel-sony) + cpu=mipsallegrexel + vendor=sony ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. + tile*-*) + basic_os=${basic_os:-linux-gnu} ;; + *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb | arc32 | arc64 \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | loongarch32 | loongarch64 | loongarchx32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r3 | mipsisa32r3el \ + | mipsisa32r5 | mipsisa32r5el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r3 | mipsisa64r3el \ + | mipsisa64r5 | mipsisa64r5el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1358,203 +1301,215 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if test x$basic_os != x then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + +# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read kernel os <<EOF +$basic_os +EOF + IFS=$saved_IFS + ;; + # Default OS when just kernel was specified + nto*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto|qnx|'` + ;; + linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|linux|gnu|'` ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` + *) + kernel= + os=$basic_os ;; - -solaris) - os=-solaris2 +esac + +# Now, normalize the OS (knowing we just have one component, it's not a kernel, +# etc.) +case $os in + # First match some system type aliases that might get confused + # with valid system types. + # solaris* is a basic system type, with this one exception. + auroraux) + os=auroraux ;; - -svr4*) - os=-sysv4 + bluegene*) + os=cnk ;; - -unixware*) - os=-sysv4.2uw + solaris1 | solaris1.*) + os=`echo "$os" | sed -e 's|solaris1|sunos4|'` ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + solaris) + os=solaris2 ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* | -sortix* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac + unixware*) + os=sysv4.2uw ;; - -nto-qnx*) + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` + # Some version numbers need modification + chorusos*) + os=chorusos ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + isc) + os=isc2.2 ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + sco6) + os=sco5v6 ;; - -linux-dietlibc) - os=-linux-dietlibc + sco5) + os=sco3.2v5 ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` + sco4) + os=sco3.2v4 ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + sco3.2.[4-9]*) + os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'` ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + sco*v* | scout) + # Don't match below ;; - -opened*) - os=-openedition + sco*) + os=sco3.2v2 ;; - -os400*) - os=-os400 + psos*) + os=psos ;; - -wince*) - os=-wince + qnx*) + os=qnx ;; - -osfrose*) - os=-osfrose + hiux*) + os=hiuxwe2 ;; - -osf*) - os=-osf + lynx*178) + os=lynxos178 ;; - -utek*) - os=-bsd + lynx*5) + os=lynxos5 ;; - -dynix*) - os=-bsd + lynxos*) + # don't get caught up in next wildcard ;; - -acis*) - os=-aos + lynx*) + os=lynxos ;; - -atheos*) - os=-atheos + mac[0-9]*) + os=`echo "$os" | sed -e 's|mac|macos|'` ;; - -syllable*) - os=-syllable + opened*) + os=openedition ;; - -386bsd) - os=-bsd + os400*) + os=os400 ;; - -ctix* | -uts*) - os=-sysv + sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; - -nova*) - os=-rtmk-nova + sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; - -ns2 ) - os=-nextstep2 + wince*) + os=wince ;; - -nsk*) - os=-nsk + utek*) + os=bsd ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` + dynix*) + os=bsd ;; - -sinix*) - os=-sysv4 + acis*) + os=aos ;; - -tpf*) - os=-tpf + atheos*) + os=atheos ;; - -triton*) - os=-sysv3 + syllable*) + os=syllable ;; - -oss*) - os=-sysv3 + 386bsd) + os=bsd ;; - -svr4) - os=-sysv4 + ctix* | uts*) + os=sysv ;; - -svr3) - os=-sysv3 + nova*) + os=rtmk-nova ;; - -sysvr4) - os=-sysv4 + ns2) + os=nextstep2 ;; - # This must come after -sysvr4. - -sysv*) + # Preserve the version number of sinix5. + sinix5.*) + os=`echo "$os" | sed -e 's|sinix|sysv|'` ;; - -ose*) - os=-ose + sinix*) + os=sysv4 ;; - -es1800*) - os=-ose + tpf*) + os=tpf ;; - -xenix) - os=-xenix + triton*) + os=sysv3 ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + oss*) + os=sysv3 ;; - -aros*) - os=-aros + svr4*) + os=sysv4 ;; - -zvmoe) - os=-zvmoe + svr3) + os=sysv3 ;; - -dicos*) - os=-dicos + sysvr4) + os=sysv4 ;; - -nacl*) + ose*) + os=ose ;; - -ios) + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint ;; - -none) + dicos*) + os=dicos + ;; + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $cpu in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac ;; *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1567,264 +1522,362 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + kernel=linux + os=gnu ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; pru-*) - os=-elf + os=elf ;; *-be) - os=-beos - ;; - *-haiku) - os=-haiku + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + musl* | newlib* | relibc* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* | serenity* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ + | linux-musl* | linux-relibc* | linux-uclibc* ) + ;; + uclinux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - -sunos*) + *-sunos*) vendor=sun ;; - -cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - -beos*) + *-beos*) vendor=be ;; - -hpux*) + *-hpux*) vendor=hp ;; - -mpeix*) + *-mpeix*) vendor=hp ;; - -hiux*) + *-hiux*) vendor=hitachi ;; - -unos*) + *-unos*) vendor=crds ;; - -dgux*) + *-dgux*) vendor=dg ;; - -luna*) + *-luna*) vendor=omron ;; - -genix*) + *-genix*) vendor=ns ;; - -mvs* | -opened*) + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - -os400*) + s390-* | s390x-*) vendor=ibm ;; - -ptx*) + *-ptx*) vendor=sequent ;; - -tpf*) + *-tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - -aux*) + *-aux*) vendor=apple ;; - -hms*) + *-hms*) vendor=hitachi ;; - -mpw* | -macos*) + *-mpw* | *-macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - -vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh index 902c15d..ea3bd68 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh @@ -32,6 +32,8 @@ if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then fi fi +CT_TestAndAbort "Invalid configuration. Run 'ct-ng menuconfig' and check which options select INVALID_CONFIGURATION." -n "${CT_INVALID_CONFIGURATION}" + # If we want an interactive debug-shell, we must ensure these FDs # are indeed connected to a terminal (and not redirected in any way). if [ "${CT_DEBUG_INTERACTIVE}" = "y" -a ! \( -t 0 -a -t 6 -a -t 2 \) ]; then @@ -40,6 +42,8 @@ if [ "${CT_DEBUG_INTERACTIVE}" = "y" -a ! \( -t 0 -a -t 6 -a -t 2 \) ]; then exit 1 fi +CT_TrapEnvExport + # Override the locale early, in case we ever translate crosstool-NG messages if [ -z "${CT_NO_OVERRIDE_LC_MESSAGES}" ]; then export LC_ALL=C @@ -51,17 +55,19 @@ CT_SanitizePath # Some sanity checks in the environment and needed tools CT_DoLog INFO "Performing some trivial sanity checks" -CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}" -CT_TestAndAbort "Don't set LIBRARY_PATH. It screws up the build." -n "${LIBRARY_PATH}" -CT_TestAndAbort "Don't set LPATH. It screws up the build." -n "${LPATH}" -CT_TestAndAbort "Don't set CPATH. It screws up the build." -n "${CPATH}" -CT_TestAndAbort "Don't set C_INCLUDE_PATH. It screws up the build." -n "${C_INCLUDE_PATH}" -CT_TestAndAbort "Don't set CPLUS_INCLUDE_PATH. It screws up the build." -n "${CPLUS_INCLUDE_PATH}" -CT_TestAndAbort "Don't set OBJC_INCLUDE_PATH. It screws up the build." -n "${OBJC_INCLUDE_PATH}" -CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}" -CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}" -CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}" -export GREP_OPTIONS= +CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH+set}" +CT_TestAndAbort "Don't set LIBRARY_PATH. It screws up the build." -n "${LIBRARY_PATH+set}" +CT_TestAndAbort "Don't set LPATH. It screws up the build." -n "${LPATH+set}" +CT_TestAndAbort "Don't set CPATH. It screws up the build." -n "${CPATH+set}" +CT_TestAndAbort "Don't set C_INCLUDE_PATH. It screws up the build." -n "${C_INCLUDE_PATH+set}" +CT_TestAndAbort "Don't set CPLUS_INCLUDE_PATH. It screws up the build." -n "${CPLUS_INCLUDE_PATH+set}" +CT_TestAndAbort "Don't set OBJC_INCLUDE_PATH. It screws up the build." -n "${OBJC_INCLUDE_PATH+set}" +CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS+set}" +CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS+set}" +CT_TestAndAbort "Don't set CC. It screws up the build." -n "${CC+set}" +CT_TestAndAbort "Don't set CXX. It screws up the build." -n "${CXX+set}" +CT_Test "GREP_OPTIONS screws up the build. Unsetting." -n "${GREP_OPTIONS+set}" +unset GREP_OPTIONS # Workaround against openSUSE 12.1 that breaks ./configure for cross-compilation: export CONFIG_SITE= @@ -70,6 +76,7 @@ for d in \ LOCAL_TARBALLS \ WORK \ PREFIX \ + BUILD_TOP \ INSTALL \ ; do eval dir="\${CT_${d}_DIR}" @@ -84,8 +91,27 @@ for d in \ CT_Abort "'CT_${d}_DIR'='${dir}' contains a comma in it.\nDon't use commas in paths, it breaks things." ;; esac + case "${dir}" in + /*) + # Absolute path, okay + ;; + *) + # Relative path from CT_TOP_DIR, make absolute + eval CT_${d}_DIR="${CT_TOP_DIR}/${dir}" + # Having .. inside CT_PREFIX breaks relocatability. + CT_SanitizeVarDir CT_${d}_DIR + ;; + esac done +n_open_files=$(ulimit -n) +if [ "${n_open_files}" -lt 2048 ]; then + # Newer ld seems to keep a lot of open file descriptors, hitting the default limit + # (1024) for example during uClibc-ng link. + CT_DoLog WARN "Number of open files ${n_open_files} may not be sufficient to build the toolchain; increasing to 2048" + ulimit -n 2048 +fi + # Where will we work? CT_WORK_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/.build}" CT_DoExecLog ALL mkdir -p "${CT_WORK_DIR}" @@ -106,18 +132,22 @@ CT_TestOrAbort "The CONFIG_SHELL '${CT_CONFIG_SHELL}' is not valid" -f "${CT_CON CT_TOOLS_OVERRIDE_DIR="${CT_WORK_DIR}/tools" CT_DoLog DEBUG "Creating bin-override for tools in '${CT_TOOLS_OVERRIDE_DIR}'" CT_DoExecLog DEBUG mkdir -p "${CT_TOOLS_OVERRIDE_DIR}/bin" -cat "${CT_LIB_DIR}/paths.sh" |while read trash line; do +cat "${paths_sh_location}" |while read trash line; do tool="${line%%=*}" # Suppress extra quoting eval path=${line#*=} - if [ -r "${CT_LIB_DIR}/scripts/override/$tool" ]; then - tmpl="${CT_LIB_DIR}/scripts/override/$tool" - else - tmpl="${CT_LIB_DIR}/scripts/override/__default" + if [ ! -r "${CT_LIB_DIR}/scripts/override/$tool" ]; then + if [ -n "${path}" ]; then + CT_DoExecLog ALL rm -f "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" + CT_DoExecLog ALL ln -s "${path}" "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" + fi + continue fi + tmpl="${CT_LIB_DIR}/scripts/override/$tool" CT_DoLog DEBUG "Creating script-override for '${tool}' -> '${path}' using '${tmpl}' template" CT_DoExecLog ALL cp "${tmpl}" "${CT_TOOLS_OVERRIDE_DIR}/bin/${tool}" CT_DoExecLog ALL ${sed} -i -r \ + -e "s#@INSTALL_WITH_STRIP_PROGRAM@#${CT_CONFIGURE_has_install_with_strip_program}#g" \ -e "s#@CONFIG_SHELL@#${CT_CONFIG_SHELL}#g" \ -e "s#@TOOL_PATH@#${path}#g" \ -e "s#@TOOLS_OVERRIDE_DIR@#${CT_TOOLS_OVERRIDE_DIR}#g" \ @@ -138,9 +168,13 @@ CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration" CT_DoExecLog DEBUG ${grep} -E '^(# )?CT_' .config CT_EndStep -CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS" +CT_DoLog DEBUG "Unsetting MAKEFLAGS" unset MAKEFLAGS -export MAKEFLAGS + +# Set the shell to be used by ./configure scripts and by Makefiles (those +# that support it!). +export CONFIG_SHELL="${CT_CONFIG_SHELL}" # for ./configure +export SHELL="${CT_CONFIG_SHELL}" # for Makefiles CT_DoLog INFO "Building environment variables" @@ -153,20 +187,37 @@ CT_PREFIX_DIR="$( ${sed} -r -e 's:/+:/:g; s:/*$::;' <<<"${CT_PREFIX_DIR}" )" # Second kludge: merge user-supplied target CFLAGS with architecture-provided # target CFLAGS. Do the same for LDFLAGS in case it happens in the future. # 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_ALL_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}" +CT_ALL_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}" + +# FIXME move to gcc.sh 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[@]}" ) +# Starting with 1.0.20, applications using uClibc-ng do not link with +# the default libgcc_c_spec used by GCC if only static libc.a exists - unless +# -static is thrown in. The difference is that with -static, gcc passes +# "--start-group -lgcc -lc --end-group" and without -static, it passes +# "-lgcc -lc -lgcc" instead. The latter leaves a symbol from 2nd libgcc +# (dl_iterate_phdr) unresolved because -lc is already done at this point. +# Force static link on the target. +if [ "${CT_SHARED_LIBS}" != "y" ]; then + CT_TARGET_LDFLAGS+=" -static" +fi + # Compute the package version string -CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOLCHAIN_PKGVERSION}}" +if [ "${CT_SHOW_CT_VERSION}" = "y" ]; then + CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOLCHAIN_PKGVERSION}}" +else + CT_PKGVERSION="${CT_TOOLCHAIN_PKGVERSION}" +fi # Compute the working directories names CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs" -CT_SRC_DIR="${CT_WORK_DIR}/src" -CT_BUILD_DIR="${CT_BUILD_TOP_DIR}/build" +CT_COMMON_SRC_DIR="${CT_WORK_DIR}/src" +CT_SRC_DIR="${CT_BUILD_TOP_DIR}/src" CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools" -CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state" +CT_STATE_DIR="${CT_BUILD_TOP_DIR}/state" # Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a # sub-dir. So we won't have to save/restore it, not even create it. # In case of cross or native, host-complibs are used for build-complibs; @@ -211,11 +262,6 @@ if [ "${CT_SAVE_TARBALLS}" = "y" \ CT_SAVE_TARBALLS= fi -# Check now if we can write to the destination directory: -if [ -d "${CT_PREFIX_DIR}" ]; then - CT_TestAndAbort "Destination directory '${CT_PREFIX_DIR}' is not removable" ! -w $(dirname "${CT_PREFIX_DIR}") -fi - # Good, now grab a bit of informations on the system we're being run on, # just in case something goes awok, and it's not our fault: CT_SYS_USER=$(id -un) @@ -227,10 +273,13 @@ CT_SYS_REVISION=$(uname -r) CT_SYS_OS=$(uname -s) CT_SYS_MACHINE=$(uname -m) CT_SYS_PROCESSOR=$(uname -p) -CT_SYS_GCC=$(gcc -dumpversion) +CT_SYS_GCC=$(${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX} -dumpversion) CT_SYS_TARGET=$(CT_DoConfigGuess) CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}" +# Adjust the list of multilibs, if needed +CT_DoArchMultilibList + CT_DoLog EXTRA "Preparing working directories" # Ah! The build directory shall be eradicated, even if we restart! @@ -239,12 +288,14 @@ CT_DoForceRmdir "${CT_BUILD_DIR}" "${CT_BUILDTOOLS_PREFIX_DIR}" # Don't eradicate directories if we need to restart if [ -z "${CT_RESTART}" ]; then + # Per-target sources: eliminate + CT_DoForceRmdir "${CT_SRC_DIR}" # Get rid of pre-existing installed toolchain and previous build directories. if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then CT_DoForceRmdir "${CT_TARBALLS_DIR}" fi - if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then - CT_DoForceRmdir "${CT_SRC_DIR}" + if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_COMMON_SRC_DIR}" ]; then + CT_DoForceRmdir "${CT_COMMON_SRC_DIR}" fi if [ -d "${CT_PREFIX_DIR}" -a "${CT_RM_RF_PREFIX_DIR}" = "y" ]; then CT_DoForceRmdir "${CT_PREFIX_DIR}" @@ -259,6 +310,7 @@ fi # create already existent directories, and CT_BUILD_DIR needs to be created # anyway CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}" +CT_DoExecLog ALL mkdir -p "${CT_COMMON_SRC_DIR}" CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}" CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}" CT_DoExecLog ALL mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin" @@ -268,15 +320,15 @@ CT_DoExecLog ALL mkdir -p "${CT_HOST_COMPLIBS_DIR}" # Only create the state dir if asked for a restartable build [ -n "${CT_DEBUG_CT_SAVE_STEPS}" ] && CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}" +# Kludge: CT_PREFIX_DIR might have grown read-only if +# the previous build was successful. +CT_DoExecLog ALL chmod -R u+w "${CT_PREFIX_DIR}" + # Check install file system case-sensitiveness CT_DoExecLog DEBUG touch "${CT_PREFIX_DIR}/foo" CT_TestAndAbort "Your file system in '${CT_PREFIX_DIR}' is *not* case-sensitive!" -f "${CT_PREFIX_DIR}/FOO" CT_DoExecLog DEBUG rm -f "${CT_PREFIX_DIR}/foo" -# Kludge: CT_PREFIX_DIR might have grown read-only if -# the previous build was successful. -CT_DoExecLog ALL chmod -R u+w "${CT_PREFIX_DIR}" - # Setting up the rest of the environment only if not restarting if [ -z "${CT_RESTART}" ]; then case "${CT_SYSROOT_NAME}" in @@ -288,14 +340,13 @@ if [ -z "${CT_RESTART}" ]; then # Arrange paths depending on whether we use sysroot or not. if [ "${CT_USE_SYSROOT}" = "y" ]; then - CT_SYSROOT_REL_DIR="${CT_SYSROOT_DIR_PREFIX:+${CT_SYSROOT_DIR_PREFIX}/}${CT_SYSROOT_NAME}" - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_REL_DIR}" + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}" CT_DEBUGROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/debug-root" CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include" - CT_SanitizeVarDir CT_SYSROOT_REL_DIR CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR - BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" + CT_SanitizeVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR + CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" + CT_CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" + CT_CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get # confused when $sysroot/usr/include is not present. # Note: --prefix=/usr is magic! @@ -309,11 +360,11 @@ if [ -z "${CT_RESTART}" ]; then # hack! Always use --with-sysroot for binutils. # binutils 2.14 and later obey it, older binutils ignore it. # Lets you build a working 32->64 bit cross gcc - BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" + CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" # Use --with-headers, else final gcc will define disable_glibc while # building libgcc, and you'll have no profiling - CC_CORE_SYSROOT_ARG="--without-headers" - CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}" + CT_CC_CORE_SYSROOT_ARG="--without-headers" + CT_CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}" fi CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}" CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}" @@ -386,7 +437,7 @@ if [ -z "${CT_RESTART}" ]; then t="${!r}-" fi - for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do + for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld libtool nm objcopy objdump ranlib strip windres; do # First try with prefix + suffix # Then try with prefix only # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST @@ -408,6 +459,7 @@ if [ -z "${CT_RESTART}" ]; then fi # Not all tools are available for all platforms, but some are required. + # TBD do we need these as shell wrappers? exec is slow on Cygwin, and this makes exec twice for each compiler/linker run if [ -n "${where}" ]; then CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'" printf "#${BANG}${CT_CONFIG_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}" @@ -418,7 +470,7 @@ if [ -z "${CT_RESTART}" ]; then ar|as|gcc|ld|nm|objcopy|objdump|ranlib) CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" ;; - # Some are conditionnally required + # Some are conditionally required # Add them in alphabetical (C locale) ordering g++) # g++ (needed for companion lib), only needed for HOST @@ -478,9 +530,13 @@ if [ -z "${CT_RESTART}" ]; then # package's default optimisation flags CT_CFLAGS_FOR_BUILD="-O2 -g -I${CT_BUILDTOOLS_PREFIX_DIR}/include" CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}" + CT_CXXFLAGS_FOR_BUILD="${CT_EXTRA_CXXFLAGS_FOR_BUILD}" CT_LDFLAGS_FOR_BUILD="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib" CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}" + if ${CT_BUILD}-gcc --version 2>&1 | grep clang; then + CT_CFLAGS_FOR_BUILD+=" -Qunused-arguments" + fi case "${CT_BUILD}" in *darwin*) # Two issues while building on MacOS. Really, we should be checking for @@ -497,6 +553,7 @@ if [ -z "${CT_RESTART}" ]; then esac CT_DoLog DEBUG "CFLAGS for build compiler: '${CT_CFLAGS_FOR_BUILD}'" + CT_DoLog DEBUG "CXXFLAGS for build compiler: '${CT_CXXFLAGS_FOR_BUILD}'" CT_DoLog DEBUG "LDFLAGS for build compiler: '${CT_LDFLAGS_FOR_BUILD}'" # Help host gcc @@ -508,6 +565,9 @@ if [ -z "${CT_RESTART}" ]; then CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}" CT_LDFLAGS_FOR_HOST="-L${CT_HOST_COMPLIBS_DIR}/lib" CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}" + if ${CT_HOST}-gcc --version 2>&1 | grep clang; then + CT_CFLAGS_FOR_HOST+=" -Qunused-arguments" + fi case "${CT_HOST}" in *darwin*) # Same as above, for host @@ -518,13 +578,8 @@ if [ -z "${CT_RESTART}" ]; then CT_DoLog DEBUG "CFLAGS for host compiler: '${CT_CFLAGS_FOR_HOST}'" CT_DoLog DEBUG "LDFLAGS for host compiler: '${CT_LDFLAGS_FOR_HOST}'" - # Set the shell to be used by ./configure scripts and by Makefiles (those - # that support it!). - export CONFIG_SHELL="${CT_CONFIG_SHELL}" # for ./configure - export SHELL="${CT_CONFIG_SHELL}" # for Makefiles - # And help make go faster - JOBSFLAGS= + CT_JOBSFLAGS= # Override the configured jobs with what's been given on the command line if [ -n "${CT_JOBS}" ]; then if [ ! -z "`echo "${CT_JOBS}" | ${sed} 's/[0-9]//g'`" ]; then @@ -533,11 +588,11 @@ if [ -z "${CT_RESTART}" ]; then CT_PARALLEL_JOBS="${CT_JOBS}" fi # Use the number of processors+1 when automatically setting the number of - # parallel jobs. Fall back to 1 if the host doesn't use GLIBC. - AUTO_JOBS=$((`getconf _NPROCESSORS_ONLN 2> /dev/null || echo 0` + 1)) - [ ${CT_PARALLEL_JOBS} -eq 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${AUTO_JOBS}" - [ ${CT_PARALLEL_JOBS} -gt 0 ] && JOBSFLAGS="${JOBSFLAGS} -j${CT_PARALLEL_JOBS}" - JOBSFLAGS="${JOBSFLAGS} -l${CT_LOAD}" + # parallel jobs. + AUTO_JOBS=$[ BUILD_NCPUS + 1 ] + [ ${CT_PARALLEL_JOBS} -eq 0 ] && CT_JOBSFLAGS="${CT_JOBSFLAGS} -j${AUTO_JOBS}" + [ ${CT_PARALLEL_JOBS} -gt 0 ] && CT_JOBSFLAGS="${CT_JOBSFLAGS} -j${CT_PARALLEL_JOBS}" + CT_JOBSFLAGS="${CT_JOBSFLAGS} -l${CT_LOAD}" # Override 'download only' option [ -n "${CT_SOURCE}" ] && CT_ONLY_DOWNLOAD=y @@ -558,28 +613,25 @@ if [ -z "${CT_RESTART}" ]; then rm -f "${gccout}" CT_EndStep + # These tests are only enabled if we need static linking on the *build* if [ "${CT_WANTS_STATIC_LINK}" = "y" ]; then CT_DoStep DEBUG "Checking that gcc can compile a trivial statically linked program (CT_WANTS_STATIC_LINK)" CT_DoLog DEBUG "You may need to ensure that static libraries such as libc.a are installed on your system" - CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST} "${testc}" -static -o "${gccout}" + CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_BUILD} ${CT_LDFLAGS_FOR_BUILD} "${testc}" -static -o "${gccout}" rm -f "${gccout}" CT_EndStep fi - - if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then - CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_CC_GCC_STATIC_LIBSTDCXX)" + if [ "${CT_WANTS_STATIC_LINK_CXX}" = "y" ]; then + CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_WANTS_STATIC_LINK_CXX)" 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}" + CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_BUILD} ${CT_LDFLAGS_FOR_BUILD} "${testc}" -static -lstdc++ -o "${gccout}" rm -f "${gccout}" CT_EndStep fi rm -f "${testc}" 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" - bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config" + CT_InstallConfigurationFile .config ct-ng CT_DoStep EXTRA "Dumping internal crosstool-NG configuration" CT_DoLog EXTRA "Building a toolchain for:" @@ -590,9 +642,7 @@ if [ -z "${CT_RESTART}" ]; then CT_DoLog DEBUG "Other environment:" printenv |${grep} -v -E '^CT_.+=' |CT_DoLog DEBUG CT_EndStep -fi -if [ -z "${CT_RESTART}" ]; then CT_DoStep INFO "Retrieving needed toolchain components' tarballs" do_companion_tools_get do_kernel_get @@ -629,7 +679,6 @@ if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then do_stop=0 prev_step= [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1 - # Aha! CT_STEPS comes from steps.mk! for step in ${CT_STEPS}; do if [ ${do_it} -eq 0 ]; then if [ "${CT_RESTART}" = "${step}" ]; then @@ -640,7 +689,7 @@ if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then else CT_DoSaveState ${step} if [ ${do_stop} -eq 1 ]; then - CT_DoLog ERROR "Stopping just after step '${prev_step}', as requested." + CT_DoLog INFO "Stopping just after step '${prev_step}', as requested." exit 0 fi fi diff --git a/scripts/depcomp b/scripts/depcomp new file mode 100755 index 0000000..fc98710 --- /dev/null +++ b/scripts/depcomp @@ -0,0 +1,791 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2013-05-30.07; # UTC + +# Copyright (C) 1999-2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputting dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to <bug-automake@gnu.org>. +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +# Get the directory component of the given path, and save it in the +# global variables '$dir'. Note that this directory component will +# be either empty or ending with a '/' character. This is deliberate. +set_dir_from () +{ + case $1 in + */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; + *) dir=;; + esac +} + +# Get the suffix-stripped basename of the given path, and save it the +# global variable '$base'. +set_base_from () +{ + base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` +} + +# If no dependency file was actually created by the compiler invocation, +# we still have to create a dummy depfile, to avoid errors with the +# Makefile "include basename.Plo" scheme. +make_dummy_depfile () +{ + echo "#dummy" > "$depfile" +} + +# Factor out some common post-processing of the generated depfile. +# Requires the auxiliary global variable '$tmpdepfile' to be set. +aix_post_process_depfile () +{ + # If the compiler actually managed to produce a dependency file, + # post-process it. + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependency.h'. + # Do two passes, one to just change these to + # $object: dependency.h + # and one to simply output + # dependency.h: + # which is needed to avoid the deleted-header problem. + { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" + sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" + } > "$depfile" + rm -f "$tmpdepfile" + else + make_dummy_depfile + fi +} + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' +# Character ranges might be problematic outside the C locale. +# These definitions help. +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ +lower=abcdefghijklmnopqrstuvwxyz +digits=0123456789 +alpha=${upper}${lower} + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Avoid interferences from the environment. +gccflag= dashmflag= + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvisualcpp +fi + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The second -e expression handles DOS-style file names with drive + # letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the "deleted header file" problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. +## Some versions of gcc put a space before the ':'. On the theory +## that the space means something, we add a space to the output as +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like '#:fec' to the end of the + # dependency line. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ + | tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" + # The second pass generates a dummy entry for each header file. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" + ;; + +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts '$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + aix_post_process_depfile + ;; + +tcc) + # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 + # FIXME: That version still under development at the moment of writing. + # Make that this statement remains true also for stable, released + # versions. + # It will wrap lines (doesn't matter whether long or short) with a + # trailing '\', as in: + # + # foo.o : \ + # foo.c \ + # foo.h \ + # + # It will put a trailing '\' even on the last line, and will use leading + # spaces rather than leading tabs (at least since its commit 0394caf7 + # "Emit spaces for -MD"). + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. + # We have to change lines of the first kind to '$object: \'. + sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" + # And for each line of the second kind, we have to emit a 'dep.h:' + # dummy dependency, to avoid the deleted-header problem. + sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\' : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + set_dir_from "$object" + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + set_base_from "$source" + tmpdepfile=$base.d + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir=$base.d-lock + trap " + echo '$0: caught signal, cleaning up...' >&2 + rmdir '$lockdir' + exit 1 + " 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0; do + # mkdir is a portable test-and-set. + if mkdir "$lockdir" 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rmdir "$lockdir" + break + else + # If the lock is being held by a different process, wait + # until the winning process is done or we timeout. + while test -d "$lockdir" && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in 'foo.d' instead, so we check for that too. + # Subdirectories are respected. + set_dir_from "$object" + set_base_from "$object" + + if test "$libtool" = yes; then + # Libtool generates 2 separate objects for the 2 libraries. These + # two compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir$base.o.d # libtool 1.5 + tmpdepfile2=$dir.libs/$base.o.d # Likewise. + tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + # Same post-processing that is required for AIX mode. + aix_post_process_depfile + ;; + +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + echo >> "$depfile" # make sure the fragment doesn't end with a backslash + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for ':' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. + "$@" $dashmflag | + sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this sed invocation + # correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no eat=no + for arg + do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + if test $eat = yes; then + eat=no + continue + fi + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix=`echo "$object" | sed 's/^.*\././'` + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process the last invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed '1,2d' "$tmpdepfile" \ + | tr ' ' "$nl" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E \ + | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + | sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + IFS=" " + for arg + do + case "$arg" in + -o) + shift + ;; + $object) + shift + ;; + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/scripts/functions b/scripts/functions index 723064c..2446342 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1,18 +1,19 @@ # -*- mode: sh; tab-width: 4 -*- # vi: ts=4:sw=4:sts=4:et +# vim: filetype=sh : # This file contains some useful common functions # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package CT_LoadConfig() { - local o + local o oldvals vals # Parse the configuration file # It has some info about the logging facility, so include it early # It also sets KERNEL/ARCH/... for file inclusion below. Does not handle # recursive definitions yet. We don't need arrays at this point. CT_TestOrAbort "Configuration file not found. Please create one." -r .config - . .config + . ./.config # Prefixing with ./ prevents Bash from searching $PATH # Include sub-scripts instead of calling them: that way, we do not have to # export any variable, nor re-parse the configuration and functions files. @@ -22,8 +23,8 @@ CT_LoadConfig() { . "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" . "${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.sh" + . "${CT_LIB_DIR}/scripts/build/libc.sh" + . "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" . "${CT_LIB_DIR}/scripts/build/debug.sh" . "${CT_LIB_DIR}/scripts/build/test_suite.sh" @@ -36,7 +37,7 @@ CT_LoadConfig() { oldvals="" try=0 while [ "$try" -le 10 ]; do - . .config + . ./.config # Prefixing with ./ prevents Bash from searching $PATH vals=`set | ${grep} -E '^CT_'` if [ "$oldvals" = "$vals" ]; then break @@ -155,7 +156,34 @@ CT_OnError() { CT_DoLog ERROR ">> For more info on this error, look at the file: '${CT_BUILD_LOG#${CT_TOP_DIR}/}'" fi CT_DoLog ERROR ">> There is a list of known issues, some with workarounds, in:" - CT_DoLog ERROR ">> '${CT_DOC_DIR#${CT_TOP_DIR}/}/B - Known issues.txt'" + if [ -r "${CT_DOC_DIR}/manual/B_Known_issues.md" ]; then + CT_DoLog ERROR ">> '${CT_DOC_DIR#${CT_TOP_DIR}/}/manual/B_Known_issues.md'" + else + CT_DoLog ERROR ">> https://crosstool-ng.github.io/docs/known-issues/" + fi + CT_DoLog ERROR ">>" + if [ -n "${CT_EXPERIMENTAL}" ]; then + CT_DoLog ERROR ">> NOTE: Your configuration includes features marked EXPERIMENTAL." + CT_DoLog ERROR ">> Before submitting a bug report, try to reproduce it without enabling" + CT_DoLog ERROR ">> any experimental features. Otherwise, you'll need to debug it" + CT_DoLog ERROR ">> and present an explanation why it is a bug in crosstool-NG - or" + CT_DoLog ERROR ">> preferably, a fix." + CT_DoLog ERROR ">>" + fi + if [ "${CT_PATCH_ORDER}" != "bundled" ]; then + CT_DoLog ERROR ">> NOTE: You configuration uses non-default patch sets. Please" + CT_DoLog ERROR ">> select 'bundled' as the set of patches applied and attempt" + CT_DoLog ERROR ">> to reproduce this issue. Issues reported with other patch" + CT_DoLog ERROR ">> set selections (none, local, bundled+local) are going to be" + CT_DoLog ERROR ">> closed without explanation." + CT_DoLog ERROR ">>" + fi + CT_DoLog ERROR ">> If you feel this is a bug in crosstool-NG, report it at:" + CT_DoLog ERROR ">> https://github.com/crosstool-ng/crosstool-ng/issues/" + CT_DoLog ERROR ">>" + CT_DoLog ERROR ">> Make sure your report includes all the information pertinent to this issue." + CT_DoLog ERROR ">> Read the bug reporting guidelines here:" + CT_DoLog ERROR ">> http://crosstool-ng.github.io/support/" CT_DoLog ERROR "" CT_DoEnd ERROR @@ -171,7 +199,7 @@ trap CT_OnError ERR set -E # Make pipes fail on the _first_ failed command -# Not supported on bash < 3.x, but we need it, so drop the obsoleting bash-2.x +# Not supported on bash < 3.x, but we need it, so drop the obsolete bash-2.x set -o pipefail # Don't hash commands' locations, and search every time it is requested. @@ -193,7 +221,7 @@ CT_LogEnable() { exec 6>&1 7>&2 8<&0 CT_BUILD_LOG="${CT_TOP_DIR}/build.log" CT_LOG_ENABLED=y - if [ "$clean" = "yes" ]; then + if [ "$clean" = "yes" ]; then rm -f "${CT_BUILD_LOG}" fi exec >>"${CT_BUILD_LOG}" @@ -255,12 +283,15 @@ CT_DoLog() { _prog_bar[3]='|' indent=$((2*CT_STEP_COUNT)) while read line; do - case "${CT_LOG_SEE_TOOLS_WARN},${line}" in - y,*"warning:"*) cur_L=WARN; cur_l=${CT_LOG_LEVEL_WARN};; - y,*"WARNING:"*) cur_L=WARN; cur_l=${CT_LOG_LEVEL_WARN};; - *"error:"*) cur_L=ERROR; cur_l=${CT_LOG_LEVEL_ERROR};; - *"make["*"]: ***"*) cur_L=ERROR; cur_l=${CT_LOG_LEVEL_ERROR};; - *) cur_L="${LEVEL}"; cur_l="${level}";; + case "${CT_LOG_SEE_TOOLS_WARN:-n},${line}" in + y,*[[:space:]][Ww]arning:*|y,[Ww]arning:*|y,*[[:space:]]WARNING:*|y,WARNING:*) + cur_L=WARN; cur_l=${CT_LOG_LEVEL_WARN};; + *[[:space:]][Ee]rror:*|[yn],[Ee]rror:*) + cur_L=ERROR; cur_l=${CT_LOG_LEVEL_ERROR};; + *"make["*"]: ***"*) + cur_L=ERROR; cur_l=${CT_LOG_LEVEL_ERROR};; + *) + cur_L="${LEVEL}"; cur_l="${level}";; esac # There will always be a log file (stdout, fd #1), be it /dev/null if [ -n "${CT_LOG_ENABLED}" ]; then @@ -276,7 +307,7 @@ CT_DoLog() { _prog_bar_cpt=$(((_prog_bar_cpt+1)%40)) fi elif [ ${cur_l} -le ${CT_LOG_LEVEL_WARN} ]; then - printf "[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" + printf "[%-5s]%*s%s%s\n" "${cur_L}" "${indent}" " " "${line}" >&2 fi done ) @@ -291,10 +322,24 @@ CT_DoExecLog() { local level="$1" local cur_cmd local ret + local cmd_seen shift + ( for i in "$@"; do - cur_cmd+="'${i}' " + case "${i}" in + *=*) + if [ -z "${cmd_seen}" ]; then + cur_cmd+=" ${i%%=*}='${i#*=}'" + else + cur_cmd+=" '${i}'" + fi + ;; + *) + cur_cmd+=" '${i}'" + cmd_seen=y + ;; + esac done while true; do case "${1}" in @@ -341,6 +386,7 @@ CT_DoExecLog() { break fi done + CT_DoLog DEBUG "==> Return status ${ret}" exit ${ret} ) # Catch failure of the sub-shell @@ -422,7 +468,7 @@ CT_SanitizeVarDir() { } if (!seencomp && !isabs && !trail) { # Eliminated all components, but no trailing slash - - # if the result is appened with /foo, must not become absolute + # if the result is appended with /foo, must not become absolute printf "."; } if ((!seencomp && isabs) || (seencomp && trail)) { @@ -530,19 +576,16 @@ CT_Pushd() { pushd "$1" >/dev/null 2>&1 } CT_Popd() { + local dir=`dirs +0` + + CT_DoLog DEBUG "Leaving '${dir}'" popd >/dev/null 2>&1 } -# Create a dir and cd or pushd into it -# Usage: CT_mkdir_cd <dir/to/create> -# CT_mkdir_pushd <dir/to/create> -CT_mkdir_cd() { - local dir="${1}" - - mkdir -p "${dir}" - cd "${dir}" -} -CT_mkdir_pushd() { +# Create a dir and pushd into it +# Usage: CT_mkdir_pushd <dir/to/create> +CT_mkdir_pushd() +{ local dir="${1}" mkdir -p "${dir}" @@ -552,7 +595,8 @@ CT_mkdir_pushd() { # Creates a temporary directory # $1: variable to assign to # Usage: CT_MktempDir foo -CT_MktempDir() { +CT_MktempDir() +{ # Some mktemp do not allow more than 6 Xs eval "$1"=$(mktemp -q -d "${CT_BUILD_DIR}/tmp.XXXXXX") CT_TestOrAbort "Could not make temporary directory" -n "${!1}" -a -d "${!1}" @@ -562,26 +606,29 @@ CT_MktempDir() { # Removes one or more directories, even if it is read-only, or its parent is # Usage: CT_DoForceRmdir dir [...] -CT_DoForceRmdir() { +CT_DoForceRmdir() +{ local dir - local mode + local cnt + for dir in "${@}"; do - [ -d "${dir}" ] || continue - case "${CT_CONFIGURE_has_stat_flavor_GNU},${CT_CONFIGURE_has_stat_flavor_BSD}" in - y,*) - mode="$(stat -c '%a' "$(dirname "${dir}")")" - ;; - *,y) - mode="$(stat -f '%Lp' "$(dirname "${dir}")")" - ;; - *) - CT_Abort "Unknown stat format options" - ;; - esac - CT_DoExecLog ALL chmod u+w "$(dirname "${dir}")" - CT_DoExecLog ALL chmod -R u+w "${dir}" - CT_DoExecLog ALL rm -rf "${dir}" - CT_DoExecLog ALL chmod ${mode} "$(dirname "${dir}")" + [ -e "${dir}" ] || continue + CT_TestOrAbort "Cannot remove '${dir}': not a directory" -d "${dir}" + CT_DoExecLog ALL chmod -R u+w "${dir}" || :; + if CT_DoExecLog ALL rm -rf "${dir}"; then + continue + fi + # If we succeeded in removing the whole directory, good. If not, + # but only the top level directory remains - it is fine, too, because + # this function is used to remove the directories that are going to be + # re-created. Hence, verify we at least succeeded in verifying the + # contents of this directory. + if [ -d "${dir}" ]; then + cnt=$(ls -a "${dir}" | { grep -v '^\.\{1,2\}$' || :; } | wc -l) + if [ "${cnt}" != "0" ]; then + CT_Abort "Failed to remove '${dir}'" + fi + fi done } @@ -590,7 +637,8 @@ CT_DoForceRmdir() { # $1: path to add # $2: add as 'first' or 'last' path, 'first' is assumed if $2 is empty # Usage CT_SetLibPath /some/where/lib [first|last] -CT_SetLibPath() { +CT_SetLibPath() +{ local path="$1" local pos="$2" @@ -617,9 +665,13 @@ CT_SetLibPath() { # Build up the list of allowed tarball extensions # Add them in the prefered order; most preferred comes first -CT_DoListTarballExt() { +CT_DoListTarballExt() +{ printf ".tar.xz\n" printf ".tar.lzma\n" + if [ "${CT_CONFIGURE_has_lzip}" = "y" ]; then + printf ".tar.lz\n" + fi printf ".tar.bz2\n" printf ".tar.gz\n.tgz\n" printf ".tar\n" @@ -630,31 +682,41 @@ CT_DoListTarballExt() { # Usage: CT_GetFileExtension <component_name-component_version> [extension] # If found, echoes the extension to stdout, and return 0 # If not found, echoes nothing on stdout, and return !0. -CT_GetFileExtension() { +CT_GetFileExtension() +{ local ext local file="$1" - shift - local first_ext="$1" - # we need to also check for an empty extension for those very - # peculiar components that don't have one (such as sstrip from - # buildroot). - for ext in ${first_ext} $(CT_DoListTarballExt) /.git ''; do - if [ -e "${CT_TARBALLS_DIR}/${file}${ext}" -o -L "${CT_TARBALLS_DIR}/${file}${ext}" ]; then + for ext in $(CT_DoListTarballExt); do + if [ -e "${file}${ext}" -o -L "${file}${ext}" ]; then echo "${ext}" exit 0 fi done - exit 1 } +# Get file's basename by stripping supported archive extensions +CT_GetFileBasename() +{ + local bn="${1}" + local ext + + for ext in $(CT_DoListTarballExt); do + if [ "${bn%${ext}}" != "${bn}" ]; then + echo "${bn%${ext}}" + exit 0 + fi + done +} + # Try to retrieve the specified URL (HTTP or FTP) # Usage: CT_DoGetFile <URL> # This functions always returns true (0), as it can be legitimate not # to find the requested URL (think about snapshots, different layouts # for different gcc versions, etc...). -CT_DoGetFile() { +CT_DoGetFile() +{ local url="${1}" local dest="${CT_TARBALLS_DIR}/${url##*/}" local tmp="${dest}.tmp-dl" @@ -669,6 +731,7 @@ CT_DoGetFile() { T="${CT_CONNECT_TIMEOUT}" fi + CT_DoLog DEBUG "Trying '${url}'" if [ "${CT_DOWNLOAD_AGENT_WGET}" = "y" ]; then if CT_DoExecLog ALL wget ${CT_DOWNLOAD_WGET_OPTIONS} \ ${T:+-T ${T}} \ @@ -689,629 +752,325 @@ CT_DoGetFile() { # Success, we got it, good! mv "${tmp}" "${dest}" CT_DoLog DEBUG "Got it from: \"${url}\"" + return 0 else - # Woops... + # Whoops... rm -f "${tmp}" CT_DoLog DEBUG "Not at this location: \"${url}\"" + return 1 fi } -# This function tries to retrieve a tarball form a local directory -# Usage: CT_GetLocal <basename> [.extension] -CT_GetLocal() { - local basename="$1" - local first_ext="$2" - local ext - - # Do we already have it in *our* tarballs dir? - if ext="$( CT_GetFileExtension "${basename}" ${first_ext} )"; then - CT_DoLog DEBUG "Already have '${basename}'" - return 0 - fi - - if [ -n "${CT_LOCAL_TARBALLS_DIR}" ]; then - CT_DoLog DEBUG "Trying to retrieve an already downloaded copy of '${basename}'" - # We'd rather have a bzip2'ed tarball, then gzipped tarball, plain tarball, - # or, as a failover, a file without extension. - for ext in ${first_ext} $(CT_DoListTarballExt) ''; do - CT_DoLog DEBUG "Trying '${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}'" - if [ -r "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" -a \ - "${CT_FORCE_DOWNLOAD}" != "y" ]; then - CT_DoLog DEBUG "Got '${basename}' from local storage" - CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" "${CT_TARBALLS_DIR}/${basename}${ext}" - return 0 - fi - done - fi - return 1 -} - -# This function gets the custom source from either a tarball or directory -# Usage: CT_GetCustom <name> <version> <location> -CT_GetCustom() { - local component_name="$1" - local component_version="$2" - local component_location="$3" - - # Some local variables we use to help us figure out what to do - local component_location_type="dir" # str: 'file' or 'dir' - local component_location_filename="" # filename... if it's a file - - CT_TestAndAbort \ - "${component_name}: Custom location setting is empty" \ - -z "${component_location}" - - CT_TestAndAbort \ - "${component_name}: Custom version setting is empty" \ - -z "${component_version}" - - if [ -f "${component_location}" ]; then - component_location_type="file" - component_location_filename="$(basename ${component_location})" - elif [ -d "${component_location}" ]; then - # Yes, it's the default, but it rules out the else case in the `if'. - component_location_type="dir" - # as -d and -f say: it's a <directory|file> and is readable! - else - CT_Abort "${component_name}: Unable to read ${component_location}, make sure the setting is correct and double check the permissions!" - fi - - if [ "${component_location_type}" = "file" ]; then - CT_DoLog EXTRA "Got '${component_location}' from custom location" - # We need to know the custom tarball extension, - # so we can create a properly-named symlink, which - # we use later on in 'extract' - case "${component_location}" in - *.tar.xz|*.tar.bz2|*.tar.lzma|*.tar.gz|*.tgz|*.tar|*.zip) ;; - *) CT_Abort "Unknown extension for custom tarball '${component_location}'" ;; - esac - [ ! -L "${CT_TARBALLS_DIR}/${component_location_filename}" ] && \ - CT_DoExecLog DEBUG ln -sf "${component_location}" \ - "${CT_TARBALLS_DIR}/${component_location_filename}" - elif [ "${component_location_type}" = "dir" ]; then - CT_DoLog EXTRA "Got '${component_location}' from custom location" - [ ! -d "${CT_SRC_DIR}/${component_name}-${component_version}" ] && \ - CT_DoExecLog DEBUG ln -sf "${component_location}" \ - "${CT_SRC_DIR}/${component_name}-${component_version}" - - # Don't try to extract from source directory, it's extracted! - touch "${CT_SRC_DIR}/.${component_name}-${component_version}.extracted" - fi - # Don't patch a custom source, it's custom! - touch "${CT_SRC_DIR}/.${component_name}-${component_version}.patched" -} - # This function saves the specified to local storage if possible, -# and if so, symlinks it for later usage -# Usage: CT_SaveLocal </full/path/file.name> -CT_SaveLocal() { +# and if so, symlinks it for later usage. This function is called from +# the `if' condition (via the CT_GetFile) and therefore must return +# on error rather than relying on the shell's ERR trap to catch it. +# Usage: CT_SaveLocal </full/path/file.name> <subdirectory> +CT_SaveLocal() +{ local file="$1" + local savedir="${CT_LOCAL_TARBALLS_DIR}${CT_TARBALLS_BUILDROOT_LAYOUT:+/$2}" local basename="${file##*/}" if [ "${CT_SAVE_TARBALLS}" = "y" ]; then CT_DoLog EXTRA "Saving '${basename}' to local storage" + # The subdirectory for this package may not exist yet; create it + if [ ! -d "${savedir}" ]; then + CT_DoExecLog ALL mkdir -p "${savedir}" + fi # The file may already exist if downloads are forced: remove it first - CT_DoExecLog ALL rm -f "${CT_LOCAL_TARBALLS_DIR}/${basename}" - CT_DoExecLog ALL mv -f "${file}" "${CT_LOCAL_TARBALLS_DIR}" - CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${basename}" "${file}" + if ! CT_DoExecLog ALL rm -f "${savedir}/${basename}"; then + return 1 + fi + if ! CT_DoExecLog ALL mv -f "${file}" "${savedir}"; then + # Move may have failed if the local tarball storage is on a different + # filesystem. Fallback to copy+delete. + if ! CT_DoExecLog ALL cp -f "${file}" "${savedir}"; then + return 1 + fi + if ! CT_DoExecLog ALL rm -f "${file}"; then + return 1 + fi + fi + if ! CT_DoExecLog ALL ln -s "${savedir}/${basename}" "${file}"; then + return 1 + fi fi } -# Download the file from one of the URLs passed as argument -# Usage: CT_GetFile <basename> [.extension] <url> [url ...] -CT_GetFile() { - local ext - local -a URLS - local url - local file="$1" - local first_ext - shift - # If next argument starts with a dot, then this is not an URL, - # and we can consider that it is a preferred extension. - case "$1" in - .*) first_ext="$1" - shift - ;; - esac - - # Does it exist localy? - if CT_GetLocal "${file}" ${first_ext}; then +# Verify the file against a known digest. +# Usage: CT_DoVerifyDigest <local-file-path> <package-directory> +CT_DoVerifyDigest() +{ + local path="$1" + local file="${path##*/}" + local dir="${path%/*}" + local pkgdir="$2" + local alg="${CT_VERIFY_DOWNLOAD_DIGEST_ALG}" + local chksum a f c + + if [ ! -r "${pkgdir}/chksum" ]; then + CT_DoLog WARN "Not verifying '${file}': digest missing" return 0 fi - # No, it does not... - - # If not allowed to download from the Internet, don't - if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_DoLog DEBUG "Not allowed to download from the Internet, aborting ${file} download" - return 1 - fi - - # Try to retrieve the file - CT_DoLog EXTRA "Retrieving '${file}'" - - # Add URLs on the LAN mirror - if [ "${CT_USE_MIRROR}" = "y" ]; then - CT_TestOrAbort "Please set the mirror base URL" -n "${CT_MIRROR_BASE_URL}" - URLS+=( "${CT_MIRROR_BASE_URL}/${file%-*}" ) - URLS+=( "${CT_MIRROR_BASE_URL}" ) - fi - - if [ "${CT_FORCE_MIRROR}" != "y" ]; then - URLS+=( "${@}" ) - fi + CT_DoLog EXTRA "Verifying ${alg^^} checksum for '${file}'" + chksum=`"${alg}sum" "${path}"` + chksum="${chksum%%[[:space:]]*}" + while read a f c; do + if [ "${a}" != "${alg}" -o "${f}" != "${file}" ]; then + continue + fi + if [ "${c}" = "${chksum}" ]; then + CT_DoLog DEBUG "Correct ${alg} digest for ${file}: ${chksum}" + return 0 + else + CT_DoLog ERROR "Bad ${alg} digest for ${file}: ${chksum}, expect ${c}" + return 1 + fi + done < "${pkgdir}/chksum" + CT_DoLog WARN "Downloaded file ${file} reference digest not available" + return 0 +} - # Scan all URLs in turn, and try to grab a tarball from there - # Do *not* try git trees (ext=/.git), this is handled in a specific - # wrapper, below - for ext in ${first_ext} $(CT_DoListTarballExt) ''; do - # Try all urls in turn - for url in "${URLS[@]}"; do - [ -n "${url}" ] || continue - CT_DoLog DEBUG "Trying '${url}/${file}${ext}'" - CT_DoGetFile "${url}/${file}${ext}" - if [ -f "${CT_TARBALLS_DIR}/${file}${ext}" ]; then - CT_DoLog DEBUG "Got '${file}' from the Internet" - CT_SaveLocal "${CT_TARBALLS_DIR}/${file}${ext}" - return 0 - fi - done - done +# Decompress a file to stdout +CT_ZCat() +{ + local file="$1" - # Just return error, someone may want to catch and handle the error - # (eg. glibc add-ons can be missing). - return 1 + case "${file}" in + *.tar.xz) + xz -fdc "${file}" + ;; + *.tar.lzma) + xz -fdc --format=lzma "${file}" + ;; + *.tar.lz) + lzip -fdc "${file}" + ;; + *.tar.bz2) + bzip2 -dc "${file}" + ;; + *.tar.gz|*.tgz) + gzip -dc "${file}" + ;; + *.tar) + cat "${file}" + ;; + *) + CT_Abort "Unsupported archive file name '${file}'" + esac } -# Get a component from Linaro archives. -# Usage: CT_GetLinaro <component> <version> -CT_GetLinaro() { - local comp="$1" - local version="$2" - local linaro_version - local yyyymm_p - local yymm - local base - - case "${version}" in - linaro-*) - linaro_version="${version#linaro-}" +# Verify the file against a detached signature. +# Fetched from the URL, or obtained from the package directory. +# Usage: CT_DoVerifySignature <local-file-path> <URL-used-for-download> <signature-format> <save-subdirectory> +CT_DoVerifySignature() +{ + local path="$1" + local file="${path##*/}" + local dir="${path%/*}" + local url="$2" + local urldir="${url%/*}" + local format="$3" + local method="${format%/*}" + local ext="${format#*/}" + local save_subdir="$4" + local sigfile + local cat + + CT_DoLog EXTRA "Verifying detached signature for '${file}'" + case "${method}" in + packed) + # Typical case: release is packed, then signed + sigfile="${file}" + cat=cat + ;; + unpacked) + # Linux kernel: uncompressed tarball is signed, them compressed by various methods + case "${file}" in + *.tar.*) + sigfile="${file%.tar.*}.tar" + cat=CT_ZCat ;; *) - CT_Abort "Version ${version} is not a Linaro package" + CT_Abort "'unpacked' signature method only supported for tar archives" ;; - esac - - # Recent releases reside in top of the directory tree; older releases - # are moved into the archive. Subdirectories are named differently - # in archive! - # In archive, some URLs also contain base component version - # (e.g. "gcc-linaro/4.9") while some do not (e.g. just "newlib-linaro"). - base="${linaro_version%%-*}" - # Strip base version, first two digits of the year and optional patchlevel - yymm="${linaro_version#*-??}" - yymm="${yymm%-*}" - CT_GetFile "${comp}-${version}" \ - "https://releases.linaro.org/components/toolchain/${comp}-linaro/${linaro_version}" \ - "https://releases.linaro.org/archive/${yymm}/components/toolchain/${comp}-linaro/${base}" \ - "https://releases.linaro.org/archive/${yymm}/components/toolchain/${comp}-linaro" -} - -# Checkout from CVS, and build the associated tarball -# The tarball will be called ${basename}.tar.bz2 -# Prerequisite: either the server does not require password, -# or the user must already be logged in. -# 'tag' is the tag to retrieve. Must be specified, but can be empty. -# If dirname is specified, then module will be renamed to dirname -# prior to building the tarball. -# Usage: CT_GetCVS <basename> <url> <module> <tag> [dirname[=subdir]] -# Note: if '=subdir' is given, then it is used instead of 'module'. -CT_GetCVS() { - local basename="$1" - local uri="$2" - local module="$3" - local tag="${4:+-r ${4}}" - local dirname="$5" - local tmp_dir - - # First try locally, then the mirror - if CT_GetFile "${basename}"; then - # Got it! Return early! :-) - return 0 - fi - - if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_DoLog WARN "Downloads forbidden, not trying cvs retrieval" - return 1 - fi - - CT_MktempDir tmp_dir - CT_Pushd "${tmp_dir}" - - CT_DoExecLog ALL cvs -z 9 -d "${uri}" co -P ${tag} "${module}" - if [ -n "${dirname}" ]; then - case "${dirname}" in - *=*) - CT_DoExecLog DEBUG mv "${dirname#*=}" "${dirname%%=*}" - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${dirname%%=*}" - ;; - *) - CT_DoExecLog ALL mv "${module}" "${dirname}" - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${dirname:-${module}}" - ;; esac - fi - CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2" - - CT_Popd - CT_DoExecLog ALL rm -rf "${tmp_dir}" -} - -# Check out from SVN, and build the associated tarball -# The tarball will be called ${basename}.tar.bz2 -# Prerequisite: either the server does not require password, -# or the user must already be logged in. -# 'rev' is the revision to retrieve -# Usage: CT_GetSVN <basename> <url> [rev] -CT_GetSVN() { - local basename="$1" - local uri="$2" - local rev="$3" - - # First try locally, then the mirror - if CT_GetFile "${basename}"; then - # Got it! Return early! :-) - return 0 - fi + ;; + *) + CT_Abort "Unsupported signature method ${method}" + ;; + esac - if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_DoLog WARN "Downloads forbidden, not trying svn retrieval" + # No recursion, as we don't pass signature_format argument + if ! CT_DoGetFile "${urldir}/${sigfile}${ext}"; then + CT_DoLog WARN "Failed to download the signature '${sigfile}${ext}'" return 1 fi - CT_MktempDir tmp_dir - CT_Pushd "${tmp_dir}" - - if ! CT_DoExecLog ALL svn export ${rev:+-r ${rev}} "${uri}" "${basename}"; then - CT_DoLog WARN "Could not retrieve '${basename}'" + CT_Pushd "${dir}" + if ! ${cat} "${file}" | CT_DoExecLog ALL gpg --verify "${sigfile}${ext}" -; then + # Remove the signature so it's re-downloaded next time + CT_DoExecLog ALL rm "${sigfile}${ext}" + CT_Popd return 1 fi - CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${basename}" - CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2" - CT_Popd - CT_DoExecLog ALL rm -rf "${tmp_dir}" -} - -# Clone a git tree -# Tries the given URLs in turn until one can get cloned. No tarball will be created. -# 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! -# 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_or_ref="${2}" - local url="${3}" - 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 already have it? - if CT_GetLocal "${file}"; then - echo ${cset} - return 0 - fi - # Nope... - - if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then - CT_DoLog WARN "Downloads forbidden, not trying git retrieval" - return 1 - fi - - # Add URLs on the LAN mirror - # We subvert the normal download method, just to look for - # looking at the local mirror - if CT_GetFile "${basename}-${cset}" .tar.gz; then - return 0 - fi - - CT_DoLog EXTRA "Retrieving '${basename}-${cset}' (git)" - - # Remove potential left-over from a previous run - CT_DoExecLog ALL rm -rf "${tmp}.tar.gz" "${tmp}.tar" "${tmp}" "${dir}" - - if CT_DoExecLog ALL git clone "${url}" "${dir}"; then - # Yep, cloned OK - CT_Pushd "${dir}" - CT_DoExecLog ALL git archive --format=tar \ - --prefix="${basename}-${cset}/" \ - -o "${tmp}.tar" \ - "${cset}" - CT_DoExecLog ALL gzip -9 "${tmp}.tar" - CT_DoExecLog ALL mv -f "${tmp}.tar.gz" "${dest}" - CT_SaveLocal "${dest}" - CT_DoExecLog ALL rm -rf "${tmp}.tar.gz" "${tmp}.tar" "${tmp}" "${dir}" + # If we get here, verification succeeded. + if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${sigfile}${ext}" "${save_subdir}"; then CT_Popd - echo ${cset} - return 0 - else - # Woops... - CT_DoExecLog ALL rm -rf "${dir}" - CT_DoLog DEBUG "Could not clone '${basename}'" return 1 fi -} -# Extract a tarball -# Some tarballs need to be extracted in specific places. Eg.: glibc addons -# must be extracted in the glibc directory; uCLibc locales must be extracted -# in the extra/locale sub-directory of uClibc. This is taken into account -# by the caller, that did a 'cd' into the correct path before calling us -# and sets nochdir to 'nochdir'. -# Note also that this function handles the git trees! -# Usage: CT_Extract [nochdir] <basename> [options] -# where 'options' are dependent on the source (eg. git branch/tag...) -CT_Extract() { - local nochdir="$1" - local basename - local ext - local -a tar_opts - - if [ "${nochdir}" = "nochdir" ]; then - shift - nochdir="$(pwd)" - else - nochdir="${CT_SRC_DIR}" - fi + return 0 +} - basename="$1" - shift +# Download the file from one of the URLs passed as argument +CT_GetFile() +{ + local -a argnames=( + package # Name of the package + pkg_dir # Directory with package's auxiliary files + dir_name # Package's directory name in downloads dir + basename # Base name of file/archive + extensions # Extension(s) for the file/archive + digest # If 'y', verify the digest + signature_format # Format of the signature + mirrors # Mirrors to download from + ) + local dl_dir + local -a URLS + local ext url - # Check if already extracted - if [ -e "${CT_SRC_DIR}/.${basename}.extracted" ]; then - CT_DoLog DEBUG "Already extracted '${basename}'" - return 0 - fi + for arg in "${argnames[@]/%/=}" "$@"; do + eval "local ${arg//[[:space:]]/\\ }" + done - if ! ext="$(CT_GetFileExtension "${basename}")"; then - CT_DoLog WARN "'${basename}' not found in '${CT_TARBALLS_DIR}'" - return 1 - fi - local full_file="${CT_TARBALLS_DIR}/${basename}${ext}" - - # Check if previously partially extracted - if [ -e "${CT_SRC_DIR}/.${basename}.extracting" ]; then - CT_DoLog ERROR "The '${basename}' sources were partially extracted." - CT_DoLog ERROR "Please remove first:" - CT_DoLog ERROR " - the source dir for '${basename}', in '${CT_SRC_DIR}'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.extracting'" - CT_Abort "I'll stop now to avoid any carnage..." - fi - CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.extracting" - - CT_Pushd "${nochdir}" - - CT_DoLog EXTRA "Extracting '${basename}'" - CT_DoExecLog FILE mkdir -p "${basename}" - tar_opts=( "--strip-components=1" ) - tar_opts+=( "-C" "${basename}" ) - tar_opts+=( "-xv" ) - - case "${ext}" in - .tar.xz) xz -fdc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; - .tar.lzma) xz -fdc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; - .tar.bz2) bzip2 -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; - .tar.gz|.tgz) gzip -dc "${full_file}" | CT_DoExecLog FILE tar "${tar_opts[@]}" -f -;; - .tar) CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}";; - .zip) CT_DoExecLog FILE unzip "${@}" "${full_file}";; - /.git) CT_ExtractGit "${basename}" "${@}";; - *) CT_DoLog WARN "Don't know how to handle '${basename}${ext}': unknown extension" - return 1 - ;; - esac + CT_TestOrAbort "Internal error: dir_name not set" -n "${dir_name}" + dl_dir="${CT_LOCAL_TARBALLS_DIR:+${CT_LOCAL_TARBALLS_DIR}${CT_TARBALLS_BUILDROOT_LAYOUT:+/${dir_name}}}" - # Don't mark as being extracted for git - case "${ext}" in - /.git) ;; - *) CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.extracted";; - esac - CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/.${basename}.extracting" + # Does any of the requested files exist localy? + for ext in ${extensions}; do + # Do we already have it in *our* tarballs dir? + if [ -r "${CT_TARBALLS_DIR}/${basename}${ext}" ]; then + CT_DoLog DEBUG "Already have '${CT_TARBALLS_DIR}/${basename}${ext}'" + return 0 + fi - CT_Popd -} + if [ "${CT_FORCE_DOWNLOAD}" != "y" ]; then + if [ -n "${dl_dir}" -a -r "${dl_dir}/${basename}${ext}" ]; then + CT_DoLog DEBUG "Got '${basename}' from local storage" + CT_DoExecLog ALL ln -s "${dl_dir}/${basename}${ext}" \ + "${CT_TARBALLS_DIR}/${basename}${ext}" + return 0 + elif [ -n "${CT_LOCAL_TARBALLS_DIR}" -a -r "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" ]; then + # Only different if we're using new buildroot layout + CT_DoLog DEBUG "Got '${basename}' from local storage" + CT_DoLog INFO "Moving the ${basename}${ext} into ${dir_name}/${basename}${ext}" + if [ ! -d "${dl_dir}" ]; then + CT_DoExecLog ALL mkdir -p "${dl_dir}" + fi + CT_DoExecLog ALL mv "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" "${dl_dir}/${basename}${ext}" + CT_DoExecLog ALL ln -s "${dl_dir}/${basename}${ext}" \ + "${CT_TARBALLS_DIR}/${basename}${ext}" + return 0 + fi + fi + done -# Create a working git clone of a local git repository -# Usage: CT_ExtractGit <basename> [ref] -# where 'ref' is the reference to use: -# the full name of a branch, like "remotes/origin/branch_name" -# a date as understandable by git, like "YYYY-MM-DD[ hh[:mm[:ss]]]" -# a tag name -# If 'ref' is not given, the current repository HEAD will be used -CT_ExtractGit() { - local basename="${1}" - local ref="${2}" - local repo - local ref_type - - # pushd now to be able to get git revlist in case ref is a date - repo="${CT_TARBALLS_DIR}/${basename}" - CT_Pushd "${repo}" - - # What kind of reference is ${ref} ? - if [ -z "${ref}" ]; then - ref_type=head - ref=$(git rev-list -n1 HEAD) - elif git tag |{grep} -E "^${ref}$" >/dev/null 2>&1; then - ref_type=tag - elif git branch -a --no-color |${grep} -E "^. ${ref}$" >/dev/null 2>&1; then - ref_type=branch - elif date -d "${ref}" >/dev/null 2>&1; then - ref_type=date - ref=$(git rev-list -n1 --before="${ref}") - else - CT_Abort "Reference '${ref}' is an incorrect git reference: neither tag, branch nor date" + # No, it does not... If not allowed to download from the Internet, don't. + if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then + CT_DoLog DEBUG "Not allowed to download from the Internet, aborting ${basename} download" + return 1 fi - CT_Popd - - CT_DoExecLog FILE rmdir "${basename}" - case "${ref_type}" in - branch) CT_DoExecLog FILE git clone -b "${ref}" "${repo}" "${basename}" ;; - *) CT_DoExecLog FILE git clone "${repo}" "${basename}" - CT_Pushd "${basename}" - CT_DoExecLog FILE git checkout "${ref}" - CT_Popd - ;; - esac -} - -# Patches the specified component -# See CT_Extract, above, for explanations on 'nochdir' -# Usage: CT_Patch [nochdir] <packagename> <packageversion> -# If the package directory is *not* packagename-packageversion, then -# the caller must cd into the proper directory first, and call us -# with nochdir -CT_Patch() { - local nochdir="$1" - local pkgname - local version - local pkgdir - local base_file - local ver_file - local d - local -a patch_dirs - local bundled_patch_dir - local local_patch_dir - local bundled_exp_patch_dir - local local_exp_patch_dir - - if [ "${nochdir}" = "nochdir" ]; then - shift - pkgname="$1" - version="$2" - pkgdir="${pkgname}-${version}" - nochdir="$(pwd)" - else - pkgname="$1" - version="$2" - pkgdir="${pkgname}-${version}" - nochdir="${CT_SRC_DIR}/${pkgdir}" - fi + # Try to retrieve the file + CT_DoLog EXTRA "Retrieving '${basename}'" - # Check if already patched - if [ -e "${CT_SRC_DIR}/.${pkgdir}.patched" ]; then - CT_DoLog DEBUG "Already patched '${pkgdir}'" - return 0 + # Add URLs on the LAN mirror + if [ "${CT_USE_MIRROR}" = "y" ]; then + CT_TestOrAbort "Please set the mirror base URL" -n "${CT_MIRROR_BASE_URL}" + if [ -n "${package}" ]; then + URLS+=( "${CT_MIRROR_BASE_URL}/${package}" ) + fi + URLS+=( "${CT_MIRROR_BASE_URL}" ) fi - # Check if already partially patched - if [ -e "${CT_SRC_DIR}/.${pkgdir}.patching" ]; then - CT_DoLog ERROR "The '${pkgdir}' sources were partially patched." - CT_DoLog ERROR "Please remove first:" - CT_DoLog ERROR " - the source dir for '${pkgdir}', in '${CT_SRC_DIR}'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${pkgdir}.extracted'" - CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${pkgdir}.patching'" - CT_Abort "I'll stop now to avoid any carnage..." + if [ "${CT_FORCE_MIRROR}" != "y" ]; then + URLS+=( ${mirrors} ) fi - touch "${CT_SRC_DIR}/.${pkgdir}.patching" - - CT_Pushd "${nochdir}" - - CT_DoLog EXTRA "Patching '${pkgdir}'" - bundled_patch_dir="${CT_LIB_DIR}/patches/${pkgname}/${version}" - bundled_patch_arch_dir="${bundled_patch_dir}/${CT_ARCH}" - local_patch_dir="${CT_LOCAL_PATCH_DIR}/${pkgname}/${version}" - - case "${CT_PATCH_ORDER}" in - bundled) patch_dirs=("${bundled_patch_dir}" "${bundled_patch_arch_dir}");; - local) patch_dirs=("${local_patch_dir}");; - bundled,local) patch_dirs=("${bundled_patch_dir}" "${bundled_patch_arch_dir}" "${local_patch_dir}");; - local,bundled) patch_dirs=("${local_patch_dir}" "${bundled_patch_dir}" "${bundled_patch_arch_dir}");; - none) patch_dirs=;; - esac - - for d in "${patch_dirs[@]}"; do - CT_DoLog DEBUG "Looking for patches in '${d}'..." - if [ -n "${d}" -a -d "${d}" ]; then - for p in "${d}"/*.patch; do - if [ -f "${p}" ]; then - CT_DoExecLog ALL ${patch} --no-backup-if-mismatch -g0 -F1 -p1 -f -i "${p}" + # Scan all URLs in turn, and try to grab a tarball from there + for ext in ${extensions}; do + # Try all urls in turn + for url in "${URLS[@]}"; do + [ -n "${url}" ] || continue + if [ "${url}" = "-unknown-" ]; then + CT_Abort "Don't know how to download ${basename}" + fi + if CT_DoGetFile "${url}/${basename}${ext}"; then + if [ -n "${digest}" -a -n "${pkg_dir}" ] && ! CT_DoVerifyDigest \ + "${CT_TARBALLS_DIR}/${basename}${ext}" \ + "${CT_LIB_DIR}/packages/${pkg_dir}"; then + CT_DoLog ERROR "Digest verification failed; removing the download" + CT_DoExecLog ALL rm "${CT_TARBALLS_DIR}/${basename}${ext}" + return 1 fi - done - if [ "${CT_PATCH_SINGLE}" = "y" ]; then - break + if [ -n "${signature_format}" ] && ! CT_DoVerifySignature \ + "${CT_TARBALLS_DIR}/${basename}${ext}" \ + "${url}/${basename}${ext}" \ + "${signature_format}"; then + CT_DoLog ERROR "Signature verification failed; removing the download" + CT_DoExecLog ALL rm "${CT_TARBALLS_DIR}/${basename}${ext}" + return 1 + fi + if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}${ext}" "${dir_name}"; then + return 1 + fi + return 0 fi - fi - done - - if [ "${CT_OVERRIDE_CONFIG_GUESS_SUB}" = "y" ]; then - CT_DoLog ALL "Overiding config.guess and config.sub" - for cfg in config_guess config_sub; do - eval ${cfg}="${CT_LIB_DIR}/scripts/${cfg/_/.}" - [ -e "${CT_TOP_DIR}/scripts/${cfg/_/.}" ] && eval ${cfg}="${CT_TOP_DIR}/scripts/${cfg/_/.}" - # Can't use CT_DoExecLog because of the '{} \;' to be passed un-mangled to find - find . -type f -name "${cfg/_/.}" \ - -exec chmod -v u+w {} \; \ - -exec cp -v "${!cfg}" {} \; |CT_DoLog ALL done - fi - - CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${pkgdir}.patched" - CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/.${pkgdir}.patching" + done - CT_Popd + # Just return error: CT_DoFetch will check it and will handle it appropriately. + return 1 } +# TBD these should not be needed if config.sub/guess is a package # Two wrappers to call config.(guess|sub) either from CT_TOP_DIR or CT_LIB_DIR. # Those from CT_TOP_DIR, if they exist, will be be more recent than those from CT_LIB_DIR. -CT_DoConfigGuess() { - if [ -x "${CT_TOP_DIR}/scripts/config.guess" ]; then - "${CT_TOP_DIR}/scripts/config.guess" +CT_DoConfigGuess() +{ + if [ -r "${CT_TOP_DIR}/scripts/config.guess" ]; then + "${CT_CONFIG_SHELL}" "${CT_TOP_DIR}/scripts/config.guess" else - "${CT_LIB_DIR}/scripts/config.guess" + "${CT_CONFIG_SHELL}" "${CT_LIB_DIR}/scripts/config.guess" fi } -CT_DoConfigSub() { - if [ -x "${CT_TOP_DIR}/scripts/config.sub" ]; then - "${CT_TOP_DIR}/scripts/config.sub" "$@" +CT_DoConfigSub() +{ + if [ -r "${CT_TOP_DIR}/scripts/config.sub" ]; then + "${CT_CONFIG_SHELL}" "${CT_TOP_DIR}/scripts/config.sub" "$@" else - "${CT_LIB_DIR}/scripts/config.sub" "$@" + "${CT_CONFIG_SHELL}" "${CT_LIB_DIR}/scripts/config.sub" "$@" fi } # Normally, each step is executed in a sub-shell and thus cannot modify the # environment for the next step(s). When this is needed, it can do so by # invoking this function. -# Usage: CT_EnvModify VAR VALUE -CT_EnvModify() { - echo "${1}=\"${2}\"" >> "${CT_BUILD_DIR}/env.modify.sh" +# Usage: CT_EnvModify [export] VAR VALUE +CT_EnvModify() +{ + local e + if [ "$1" = "export" ]; then + shift + e="export " + fi + eval "${e}${1}=\"${2}\"" + echo "${e}${1}=\"${2}\"" >> "${CT_BUILD_DIR}/env.modify.sh" } # Compute the target tuple from what is provided by the user @@ -1319,25 +1078,38 @@ CT_EnvModify() { # In fact this function takes the environment variables to build the target # tuple. It is needed both by the normal build sequence, as well as the # sample saving sequence. -CT_DoBuildTargetTuple() { +CT_DoBuildTargetTuple() +{ + local tmp + # Set the endianness suffix, and the default endianness gcc option + target_endian_eb= + target_endian_be= + target_endian_el= + target_endian_le= case "${CT_ARCH_ENDIAN}" in big) target_endian_eb=eb target_endian_be=be - target_endian_el= - target_endian_le= CT_ARCH_ENDIAN_CFLAG="-mbig-endian" CT_ARCH_ENDIAN_LDFLAG="-Wl,-EB" ;; little) - target_endian_eb= - target_endian_be= target_endian_el=el target_endian_le=le CT_ARCH_ENDIAN_CFLAG="-mlittle-endian" CT_ARCH_ENDIAN_LDFLAG="-Wl,-EL" ;; + # big,little and little,big do not need to pass the flags; + # gcc is expected to be configured for that as default. + big,little) + target_endian_eb=eb + target_endian_be=be + ;; + little,big) + target_endian_el=el + target_endian_le=le + ;; esac # Set the bitness suffix @@ -1355,28 +1127,45 @@ CT_DoBuildTargetTuple() { # Build the default architecture tuple part CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX}" - # Set defaults for the system part of the tuple. Can be overriden - # by architecture-specific values. + # Set defaults for the system part of the tuple; only C libraries that + # support multiple architectures. Can be overriden by architecture-specific + # values. case "${CT_LIBC}" in - *glibc) CT_TARGET_SYS=gnu;; - uClibc) CT_TARGET_SYS=uclibc;; - musl) CT_TARGET_SYS=musl;; - avr-libc) - # avr-libc only seems to work with the non-canonical "avr" target. - CT_TARGET_SKIP_CONFIG_SUB=y - CT_TARGET_SYS= # CT_TARGET_SYS must be empty too - ;; - *) CT_TARGET_SYS=elf;; + glibc) CT_TARGET_SYS=gnu;; + uClibc-ng) CT_TARGET_SYS=uclibc;; + musl) CT_TARGET_SYS=musl;; + bionic) CT_TARGET_SYS=android;; + none|newlib|picolibc) CT_TARGET_SYS=elf;; + *) + # Keep empty for the libraries like mingw or avr-libc + CT_TARGET_SYS= + ;; esac # Set the default values for ARCH, ABI, CPU, TUNE, FPU and FLOAT - unset CT_ARCH_ARCH_CFLAG CT_ARCH_ABI_CFLAG CT_ARCH_CPU_CFLAG CT_ARCH_TUNE_CFLAG CT_ARCH_FPU_CFLAG CT_ARCH_FLOAT_CFLAG - unset CT_ARCH_WITH_ARCH CT_ARCH_WITH_ABI CT_ARCH_WITH_CPU CT_ARCH_WITH_TUNE CT_ARCH_WITH_FPU CT_ARCH_WITH_FLOAT - [ "${CT_ARCH_ARCH}" ] && { CT_ARCH_ARCH_CFLAG="-march=${CT_ARCH_ARCH}"; CT_ARCH_WITH_ARCH="--with-arch=${CT_ARCH_ARCH}"; } - [ "${CT_ARCH_ABI}" ] && { CT_ARCH_ABI_CFLAG="-mabi=${CT_ARCH_ABI}"; CT_ARCH_WITH_ABI="--with-abi=${CT_ARCH_ABI}"; } - [ "${CT_ARCH_CPU}" ] && { CT_ARCH_CPU_CFLAG="-mcpu=${CT_ARCH_CPU}"; CT_ARCH_WITH_CPU="--with-cpu=${CT_ARCH_CPU}"; } - [ "${CT_ARCH_TUNE}" ] && { CT_ARCH_TUNE_CFLAG="-mtune=${CT_ARCH_TUNE}"; CT_ARCH_WITH_TUNE="--with-tune=${CT_ARCH_TUNE}"; } - [ "${CT_ARCH_FPU}" ] && { CT_ARCH_FPU_CFLAG="-mfpu=${CT_ARCH_FPU}"; CT_ARCH_WITH_FPU="--with-fpu=${CT_ARCH_FPU}"; } + for tmp in ARCH ABI CPU TUNE FPU FLOAT ENDIAN; do + eval "unset CT_ARCH_${tmp}_CFLAG CT_ARCH_WITH_${tmp} CT_ARCH_WITH_${tmp}_32 CT_ARCH_WITH_${tmp}_64" + done + + [ -n "${CT_ARCH_ABI}" ] && { CT_ARCH_ABI_CFLAG="-mabi=${CT_ARCH_ABI}"; CT_ARCH_WITH_ABI="--with-abi=${CT_ARCH_ABI}"; } + [ -n "${CT_ARCH_FPU}" ] && { CT_ARCH_FPU_CFLAG="-mfpu=${CT_ARCH_FPU}"; CT_ARCH_WITH_FPU="--with-fpu=${CT_ARCH_FPU}"; } + + # The options below have distinct variants for multilib-enabled toolchain. + # At this time, we just always have them equal to the "main" setting; it + # seems that most example configurations are built for a specific CPU. + # If there's demand for it, we can turn them into separate knobs in + # Kconfig later. + for tmp in ARCH CPU TUNE; do + eval "val=\${CT_ARCH_${tmp}}" + if [ -n "${val}" ]; then + eval "CT_ARCH_${tmp}_CFLAG=-m${tmp,,}=${val}" + eval "CT_ARCH_WITH_${tmp}=--with-${tmp,,}=${val}" + if [ -n "${CT_ARCH_SUPPORTS_WITH_32_64}" -a -n "${CT_MULTILIB}" ]; then + eval "CT_ARCH_WITH_${tmp}_32=--with-${tmp,,}-32=${val}" + eval "CT_ARCH_WITH_${tmp}_64=--with-${tmp,,}-64=${val}" + fi + fi + done case "${CT_ARCH_FLOAT}" in hard) @@ -1393,6 +1182,10 @@ CT_DoBuildTargetTuple() { ;; esac + if [ "${CT_ARCH_SUPPORTS_WITH_ENDIAN}" = "y" ]; then + CT_ARCH_WITH_ENDIAN="--with-endian=${CT_ARCH_ENDIAN}" + fi + # Build the default kernel tuple part CT_TARGET_KERNEL="${CT_KERNEL}" @@ -1401,10 +1194,18 @@ CT_DoBuildTargetTuple() { CT_DoKernelTupleValues # Finish the target tuple construction - CT_TARGET="${CT_TARGET_ARCH}" - CT_TARGET="${CT_TARGET}${CT_TARGET_VENDOR:+-${CT_TARGET_VENDOR}}" - CT_TARGET="${CT_TARGET}${CT_TARGET_KERNEL:+-${CT_TARGET_KERNEL}}" - CT_TARGET="${CT_TARGET}${CT_TARGET_SYS:+-${CT_TARGET_SYS}}" + if [ -z "${CT_OMIT_TARGET_ARCH}" ]; then + CT_TARGET="${CT_TARGET_ARCH}" + fi + if [ -z "${CT_OMIT_TARGET_VENDOR}" -a -n "${CT_TARGET_VENDOR}" ]; then + CT_TARGET="${CT_TARGET:+${CT_TARGET}-}${CT_TARGET_VENDOR}" + fi + if [ -n "${CT_TARGET_KERNEL}" ]; then + CT_TARGET="${CT_TARGET:+${CT_TARGET}-}${CT_TARGET_KERNEL}" + fi + if [ -n "${CT_TARGET_SYS}" ]; then + CT_TARGET="${CT_TARGET:+${CT_TARGET}-}${CT_TARGET_SYS}" + fi # Sanity checks __sed_alias="" @@ -1421,6 +1222,12 @@ CT_DoBuildTargetTuple() { # Canonicalise it if [ "${CT_TARGET_SKIP_CONFIG_SUB}" != "y" ]; then CT_TARGET=$(CT_DoConfigSub "${CT_TARGET}") + + if [ -n "${CT_OMIT_TARGET_VENDOR}" ]; then + # config.sub always returns a 3- or 4-part tuple, with vendor + # always being the 2nd part. + CT_TARGET="${CT_TARGET%%-*}-${CT_TARGET#*-*-}" + fi fi # Prepare the target CFLAGS @@ -1445,11 +1252,14 @@ CT_DoBuildTargetTuple() { # Instead, save them into a different variable here. Then, after the first # core pass, we'll know which of them vary with multilibs (i.e. must be # filtered out). - if [ "${CT_MULTILIB}" = "y" ]; then + if [ -n "${CT_MULTILIB}" ]; then CT_ARCH_TARGET_CFLAGS_MULTILIB="${CT_ARCH_TARGET_CFLAGS}" CT_ARCH_TARGET_CFLAGS= CT_ARCH_TARGET_LDFLAGS_MULTILIB="${CT_ARCH_TARGET_LDFLAGS}" CT_ARCH_TARGET_LDFLAGS= + else + CT_ALL_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}" + CT_ALL_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}" fi } @@ -1463,6 +1273,30 @@ CT_DoPause() { return 0 } +# This function sets up trapping export/unset operations so that saving/restoring +# the state can restore status of environment exactly. +CT_TrapEnvExport() +{ + unset() + { + eval "builtin unset $*" + CT_ENVVAR_UNSET="${CT_ENVVAR_UNSET} $*" + } + + export() + { + local v + + for v in "$@"; do + eval "builtin export \"${v}\"" + case "${CT_ENVVAR_EXPORTED} " in + *" ${v%%=*} "*) continue;; + esac + CT_ENVVAR_EXPORTED="${CT_ENVVAR_EXPORTED} ${v%%=*}" + done + } +} + # This function creates a tarball of the specified directory, but # only if it exists # Usage: CT_DoTarballIfExists <dir> <tarball_basename> [extra_tar_options [...]] @@ -1522,26 +1356,35 @@ CT_DoSaveState() { [ "${CT_DEBUG_CT_SAVE_STEPS}" = "y" ] || return 0 local state_name="$1" local state_dir="${CT_STATE_DIR}/${state_name}" + local v CT_DoLog INFO "Saving state to restart at step '${state_name}'..." rm -rf "${state_dir}" mkdir -p "${state_dir}" + # Save only environment variables, not functions. + # Limit saving to our variables (CT_*) and exported variables. + # Also unset variables that have been removed from the environment. + # This generated script will be sourced from a function, so make + # all the definitions global by adding -g. Hope we don't have + # a multi-line variable that has a line starting with "declare" + # (or we'll need to run sed on each variable separately, only on + # the first line of it). CT_DoLog STATE " Saving environment and aliases" - # We must omit shell functions, and some specific bash variables - # that break when restoring the environment, later. We could do - # all the processing in the awk script, but a sed is easier... - set |${awk} ' - BEGIN { _p = 1; } - $0~/^[^ ]+ \(\)/ { _p = 0; } - _p == 1 - $0 == "}" { _p = 1; } - ' |${sed} -r -e '/^BASH_(ARGC|ARGV|LINENO|SOURCE|VERSINFO)=/d; - /^(UID|EUID)=/d; - /^(FUNCNAME|GROUPS|PPID|SHELLOPTS)=/d;' >"${state_dir}/env.sh" + { + for v in "${!CT_@}" ${CT_ENVVAR_EXPORTED}; do + # Check if it is still set + [ -n "${!v+set}" ] && declare -p "${v}" + done | ${sed} 's/^declare /declare -g /' + echo "builtin unset ${CT_ENVVAR_UNSET}" + } >"${state_dir}/env.sh" + + # Save .config to check it hasn't changed when resuming. + CT_DoExecLog STATE cp ".config" "${state_dir}/config" CT_DoTarballIfExists "${CT_BUILDTOOLS_PREFIX_DIR}" "${state_dir}/buildtools_dir" + CT_DoTarballIfExists "${CT_SRC_DIR}" "${state_dir}/src_dir" CT_DoTarballIfExists "${CT_PREFIX_DIR}" "${state_dir}/prefix_dir" --exclude '*.log' CT_DoLog STATE " Saving log file" @@ -1562,10 +1405,14 @@ CT_DoLoadState(){ local old_STOP="${CT_STOP}" CT_TestOrAbort "The previous build did not reach the point where it could be restarted at '${CT_RESTART}'" -d "${state_dir}" + if ! cmp ".config" "${state_dir}/config" >/dev/null 2>&1; then + CT_Abort "The configuration file has changed between two runs" + fi CT_DoLog INFO "Restoring state at step '${state_name}', as requested." CT_DoExtractTarballIfExists "${state_dir}/prefix_dir" "${CT_PREFIX_DIR}" + CT_DoExtractTarballIfExists "${state_dir}/src_dir" "${CT_SRC_DIR}" CT_DoExtractTarballIfExists "${state_dir}/buildtools_dir" "${CT_BUILDTOOLS_PREFIX_DIR}" # Restore the environment, discarding any error message @@ -1576,7 +1423,6 @@ CT_DoLoadState(){ # Restore the new RESTART and STOP steps CT_RESTART="${old_RESTART}" CT_STOP="${old_STOP}" - unset old_stop old_restart CT_DoLog STATE " Restoring log file" CT_LogDisable @@ -1597,6 +1443,7 @@ CT_KconfigSetOption() { local value="$2" local file="$3" + CT_DoLog DEBUG "${file}: set ${option}=${value}" ${grep} -E -q "^${option}=.*" "${file}" && \ ${sed} -i -r -e "s;^${option}=.*$;${option}=${value};" "${file}" || \ ${grep} -E -q "^# ${option} is not set$" "${file}" && \ @@ -1619,6 +1466,7 @@ CT_KconfigDisableOption() { local option="${1}" local file="${2}" + CT_DoLog DEBUG "${file}: disable ${option}" ${grep} -E -q "^# ${option} is not set$" "${file}" || \ ${grep} -E -q "^${option}=.*$" "${file}" && \ ${sed} -i -r -e "s;^${option}=.*$;# ${option} is not set;" "${file}" || \ @@ -1632,6 +1480,7 @@ CT_KconfigDeleteOption() { local option="${1}" local file="${2}" + CT_DoLog DEBUG "${file}: delete ${option}" ${grep} -E -q "^# ${option} is not set$" "${file}" && \ ${sed} -i -r -e "/^# ${option} is not set$/d" "${file}" || \ ${grep} -E -q "^${option}=.*$" "${file}" && \ @@ -1659,6 +1508,7 @@ CT_IterateMultilibs() { local multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_flags multi_index multi_target local root_suffix local dir_postfix + local v # Name used internally below if [ "${prefix}" = "sysroot-check" ]; then @@ -1750,15 +1600,938 @@ CT_IterateMultilibs() { dir_postfix=_${multi_dir//\//_} dir_postfix=${dir_postfix%_.} CT_mkdir_pushd "${prefix}${dir_postfix}" - $func multi_dir="${multi_dir}" \ - multi_os_dir="${multi_os_dir}" \ - multi_flags="${multi_flags}" \ - multi_root="${multi_root}" \ - multi_target="${multi_target}" \ - multi_index="${multi_index}" \ - multi_count="${#multilibs[@]}" \ + CT_DoLog DEBUG "Multilib iterator: call function '${func}' in '${prefix}${dir_postfix}'" + for v in multi_dir multi_os_dir multi_os_dir_gcc multi_flags multi_root multi_target multi_index; do + CT_DoLog DEBUG " ${v}=${!v}" + done + + $func multi_dir="${multi_dir}" \ + multi_os_dir="${multi_os_dir}" \ + multi_os_dir_gcc="${multi_os_dir_gcc}" \ + multi_flags="${multi_flags}" \ + multi_root="${multi_root}" \ + multi_target="${multi_target}" \ + multi_index="${multi_index}" \ + multi_count="${#multilibs[@]}" \ "$@" CT_Popd multi_index=$((multi_index+1)) done } + +# Create symbolic links in buildtools for binutils using a different +# target name. +# Usage: +# CT_SymlinkTools BIN-DIR SRC-DIR NEW-PREFIX SED-EXPR +CT_SymlinkTools() +{ + local bindir="$1" + local srcdir="$2" + local newpfx="$3" + local sedexpr="$4" + local dirpfx + local t _t + + # if bindir==srcdir, create symlinks just with the filename + if [ "${bindir}" != "${srcdir}" ]; then + dirpfx="${srcdir}/" + fi + + CT_Pushd "${srcdir}" + for t in "${CT_TARGET}-"*; do + if [ "${t}" = "${CT_TARGET}-*" ]; then + # No matching files + break + fi + if [ -n "${newpfx}" -a \( "${newpfx}" != "${CT_TARGET}" -o "${bindir}" != "${srcdir}" \) ]; then + _t="${newpfx}-${t#${CT_TARGET}-}" + CT_DoExecLog ALL ln -sfv "${dirpfx}${t}" "${bindir}/${_t}" + fi + if [ -n "${sedexpr}" ]; then + _t=$( echo "${t}" | sed -r -e "${sedexpr}" ) + if [ "${_t}" = "${t}" ]; then + CT_DoLog WARN "The sed expression '${sedexpr}' has no effect on '${t}'" + else + CT_DoExecLog ALL ln -sfv "${dirpfx}${t}" "${bindir}/${_t}" + fi + fi + done + CT_Popd +} + +# Create symbolic links for multilib iterator. Expects ${multi_target} +# variable to indicate the desired triplet for the tools. +CT_SymlinkToolsMultilib() +{ + # Make configure detect ${target}-tool binaries even if it is different + # from configured tuple. Only symlink to final tools if they're executable + # on build. + CT_SymlinkTools "${CT_BUILDTOOLS_PREFIX_DIR}/bin" \ + "${CT_BUILDTOOLS_PREFIX_DIR}/bin" "${multi_target}" + case "${CT_TOOLCHAIN_TYPE}" in + native|cross) + CT_SymlinkTools "${CT_BUILDTOOLS_PREFIX_DIR}/bin" \ + "${CT_PREFIX_DIR}/bin" "${multi_target}" + ;; + esac +} + +# Helper (iterator) for CT_MultilibFixupLDSO +CT__FixupLDSO() +{ + local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count multi_target + local binary + local ldso ldso_l ldso_f ldso_d ldso_u multilib_dir + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'" + + multilib_dir="/lib/${multi_os_dir}" + CT_SanitizeVarDir multilib_dir + + CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" -o test-ldso ../test-ldso.c ${multi_flags} + if [ -r "test-ldso.gdb" ]; then + binary="test-ldso.gdb" + else + binary="test-ldso" + fi + if ${CT_TARGET}-readelf -Wl "${binary}" | grep -q 'Requesting program interpreter: '; then + ldso=$( ${CT_TARGET}-readelf -Wl "${binary}" | \ + grep 'Requesting program interpreter: ' | \ + sed -e 's,.*: ,,' -e 's,\].*,,' ) + fi + CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'" + + # Create symlink if GCC produced a dynamically linked executable. + if [ -z "${ldso}" ]; then + return # Probably, we're building a static toolchain. + fi + + ldso_d="${ldso%/ld*.so.*}" + ldso_f="${ldso##*/}" + + # Convert ldso_d to "how many levels we need to go up" and remove + # leading slash. + ldso_u=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' ) + + # If the requested dynamic linker exists, but is a symlink - check that it is either + # relative (in which case, if it is readable, we trust libc to have created it properly) + # or otherwise, convert it from absolute (target) path to a relative path that works on + # both host & target. + if [ -L "${multi_root}${ldso}" ]; then + ldso_l=`readlink "${multi_root}${ldso}"` + case "${ldso_l}" in + /*) # Absolute, convert to relative + if [ -r "${multi_root}${ldso_l}" ]; then + CT_DoExecLog ALL ln -sfv "${ldso_u}${ldso_l}" "${multi_root}${ldso}" + else + CT_DoLog WARN "Compiler selects '${ldso}' as dynamic linker for '${multi_flags}'" + CT_DoLog WARN "but '${ldso}' is a symlink to '${ldso_l}' which is not valid on target." + fi + ;; + *) # Relative, must be readable + if [ ! -r "${multi_root}${ldso}" ]; then + CT_DoLog WARN "Compiler selects '${ldso}' as dynamic linker for '${multi_flags}'" + CT_DoLog WARN "but '${ldso}' is a symlink to '${ldso_l}' which is invalid relative symlink." + fi + ;; + esac + return + elif [ -r "${multi_root}${ldso}" ]; then + return # Not a symlink but readable - looks like libc installed a real executable. + fi + + # Is it requesting a linker not in the current directory? uClibc case. + if [ "${ldso_d}" != "${multilib_dir}" ]; then + CT_DoExecLog ALL ln -sfv "${ldso_u}${multilib_dir}/${ldso_f}" \ + "${multi_root}${ldso}" + fi +} + +# Go over multilib variants and check that the requested dynamic linker +# is present and resolves on both target and host. +CT_MultilibFixupLDSO() +{ + CT_DoStep INFO "Checking dynamic linker symlinks" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-check-ldso" + echo "int main(void) { return 0; }" > test-ldso.c + CT_IterateMultilibs CT__FixupLDSO ldso_fixup + CT_Popd + CT_EndStep +} + +# List the download mirrors. Usage: +# CT_Mirrors ORGANIZATION PROJECT [...] +# Important: this function should not call CT_Abort. Instead, print a special string, +# -unknown-, to indicate that a certain combination of ORGANIZATION/PROJECT is not handled. +# The reason is that this function is evaluated when config file is loaded - before ct-ng +# determines if it needs to download anything at all. On the other hand, if a component +# comes from a local source directory, it may have a version like "very new" or "very old" +# which will confuse, for example, Linux mirror selection below. +CT_Mirrors() +{ + local org="${1}" + local project="${2}" + + case "${org}" in + GNU) + echo "https://ftpmirror.gnu.org/gnu/${project}" + echo "http://ftpmirror.gnu.org/gnu/${project}" + echo "https://ftp.gnu.org/gnu/${project}" + echo "http://ftp.gnu.org/gnu/${project}" + echo "ftp://ftp.gnu.org/gnu/${project}" + ;; + sourceware) + echo "ftp://sourceware.org/pub/${project}" + echo "http://mirrors.kernel.org/sourceware/${project}" + echo "http://gcc.gnu.org/pub/${project}" + ;; + Linaro) + local version="${3}" + local base yymm + base="${version%%-*}" + yymm="${version##*-??}" + yymm="${yymm%%-*}" + echo "https://releases.linaro.org/components/toolchain/${project}-linaro/${version}" + echo "https://releases.linaro.org/archive/${yymm}/components/toolchain/${project}-linaro/${base}" + echo "https://releases.linaro.org/archive/${yymm}/components/toolchain/${project}-linaro" + ;; + kernel.org) + case "${project}" in + linux) + local version="${CT_LINUX_VERSION}" + case "${version}" in + '') + # Ignore, this happens before .config is fully evaluated + ;; + [345].*) + echo "https://cdn.kernel.org/pub/linux/kernel/v${version%%.*}.x" + ;; + 2.6.*) + echo "https://cdn.kernel.org/pub/linux/kernel/v2.6" + case "${version}" in + 2.6.*.*) + echo "https://cdn.kernel.org/pub/linux/kernel/v2.6/longterm" + echo "https://cdn.kernel.org/pub/linux/kernel/v2.6/longterm/v${version%.*}" + ;; + esac + ;; + *) + echo "-unknown-" + ;; + esac + ;; + dtc) + echo "https://cdn.kernel.org/pub/software/utils/dtc" + ;; + *) + echo "-unknown-" + ;; + esac + ;; + *) + echo "-unknown-" + ;; + esac +} + +# Get most recent version for CVS check-out. +# CVS does not have a repository-wide identifier for a commit, so we must +# use date. Variables are set by CT_PackageRun +CT_GetVersion_cvs() +{ + # If date is not given, use current. Otherwise, check if format is correct. + # We don't support fancy CVS specifications like "1 day ago", as we'll need + # to convert them to some stable representation like 20170617231304. + if [ -z "${devel_revision}" ]; then + devel_revision=`LANG=C TZ=UTC date '+%Y/%m/%d %H:%M:%S'` + else + case "${devel_revision}" in + [12][0-9][0-9][0-9]/[01][0-9]/[0-3][0-9]\ [0-2][0-9]:[0-5][0-9]:[0-5][0-9]) + ;; + *) + CT_Abort "${pkg_name}: invalid date format ${devel_revision}" + ;; + esac + fi + unique_id="${devel_branch:-trunk}-${devel_revision//[^0-9]/}" +} + +# Check out sources from CVS. Variables are set by CT_PackageRun. +CT_Download_cvs() +{ + local pserver="${devel_url%% *}" + local module="${devel_url##* }" + + # CVS has no name for "main" branch, so use -r only if non-default + # TBD try -'d ${basename}', with/without -N + CT_DoExecLog ALL cvs -z 9 -d "${pserver}" co -P ${devel_branch:+-r ${devel_branch}} \ + -D "${devel_revision} UTC" "${module}" + if [ "${module}" != "${pkg_name}" ]; then + CT_DoExecLog ALL mv "${module}" "${pkg_name}" + fi +} + +# Find the most recent version from Subversion. +CT_GetVersion_svn() +{ + devel_branch="${devel_branch:-/trunk}" + + # If revision is not given, find the most recent + if [ -z "${devel_revision}" ]; then + devel_revision=`svn info "${devel_url}${devel_branch}" | sed -n 's/^Last Changed Rev: //p'` + fi + + # Construct unique ID from branch/revision + unique_id="${devel_branch//\//_}" + unique_id="${unique_id#_}" + unique_id="${unique_id%_}" + unique_id="${unique_id}-${devel_revision}" +} + +# Retrieve sources from Subversion. +CT_Download_svn() +{ + CT_DoExecLog ALL svn export -r "${devel_revision}" "${devel_url}${devel_branch}" "${pkg_name}" +} + +# Find the most recent version from Mercurial. +CT_GetVersion_hg() +{ + if [ -n "${devel_branch}" -a -n "${devel_revision}" ]; then + CT_Abort "${pkg_name}: cannot specify both branch and changeset for Mercurial" + fi + + # Mercurial cannot query remote branches except the default, so we'll have + # to clone if cset is not known and a branch is given. + if [ -z "${devel_revision}" ]; then + if [ -z "${devel_branch}" ]; then + devel_revision=`hg identify "${devel_url}"` + else + CT_DoLog WARN "${pkg_name}: Mercurial cannot query non-default branch, will clone" + devel_revision="to.be.determined" + fi + fi + unique_id="${devel_revision}" +} + +# Retrieve sources from Mercurial. +CT_Download_hg() +{ + CT_DoExecLog ALL hg clone "${devel_url}" "${pkg_name}" + CT_Pushd "${pkg_name}" + if [ -n "${devel_branch}" ]; then + CT_DoExecLog ALL hg update "${devel_branch}" + fi + if [ "${devel_revision}" = "to.be.determined" ]; then + # Report what we found out (as common message lacks the revision) + devel_revision=`hg identify -i` + unique_id="${devel_revision}" + CT_DoLog EXTRA "Retrieved revision ${devel_revision}" + else + CT_DoExecLog ALL hg update "${devel_revision}" + fi + CT_DoExecLog ALL rm -rf .hg + CT_Popd +} + +# Get the most recent version from Git. +CT_GetVersion_git() +{ + if [ -n "${devel_branch}" -a -n "${devel_revision}" ]; then + CT_Abort "${pkg_name}: cannot specify both branch and changeset for Git" + fi + + # Do not modify devel_branch so that we can check if it has been set by user + # in CT_Download_git. + local branch="${devel_branch:-master}" + + if [ -z "${devel_revision}" ]; then + # First try to dereference an annotated tag. + local matches=`git ls-remote --exit-code "${devel_url}" --refs "${branch}^{}" \ + || echo "not found"` + # If we don't have an annotated tag, let's take the reference as is. + if [ "${matches}" = "not found" ]; then + matches=`git ls-remote --exit-code "${devel_url}" --refs "${branch}" \ + || echo "not found"` + fi + local best using ref + + # Cannot test $?, setting a trap on ERR prevents bash from returning the + # status code. + if [ "${matches}" = "not found" ]; then + CT_Abort "Failed to find git ref ${branch} at ${devel_url}" + fi + if [ `echo "${matches}" | wc -l` -gt 1 ]; then + if echo "${matches}" | grep '[[:space:]]\(refs/heads/\)\?'"${branch}\$" >/dev/null; then + # Try exact match, or prepended with "refs/heads". Some projects (e.g. binutils) + # have refs/original/refs/heads/master as well as refs/heads/master, and + # `git ls-remote refs/heads/master` prints both. + best=`echo "${matches}" | grep '[[:space:]]\(refs/heads/\)\?'"${branch}\$"` + using="best match" + else + best=`echo "${matches}" | head -n1` + using="first" + fi + ref=`echo "${best}" | sed 's/.*[[:space:]]//'` + CT_DoLog WARN "Ambiguous ref ${branch} at ${devel_url}, using ${using} (${ref})" + else + best="${matches}" + fi + # Similarly, do not modify the devel_revision, we'll need to know if it + # has been set by the user in CT_Download_git. + unique_id=`echo "${best}" | cut -c1-8` + CT_DoLog DEBUG "ref ${branch} at ${devel_url} has cset of ${unique_id}" + else + unique_id=`echo "${devel_revision}" | cut -c1-8` + fi +} + +# Retrieve sources from Git. +CT_Download_git() +{ + local new_unique_id fetched=n shallow_id + + # Some of these operations are part of a `git clone`, but fetching a specific commit + # (if it is supported by the server) is not expressable as a `git clone`. + CT_mkdir_pushd "${pkg_name}" + CT_DoExecLog ALL git init + CT_DoExecLog ALL git remote add origin "${devel_url}" + + if [ -z "${devel_revision}" ]; then + # Configuration didn't care about a specific commit; we'll use the most recent + # commit on the branch and will update the unique_id (and warn the user) if it + # differs from what we've previously determined. + shallow_id="${devel_branch:-master}" + else + local tmp=`echo "${devel_revision}" | sed 's/^[0-9a-z]\{40\}//'` + + if [ -z "${tmp}" ]; then + shallow_id="${devel_revision}" + else + CT_DoLog WARN "Git only allows full 40-character SHA-1 hashes to identify a commit for shallow clone." + fi + fi + + if [ -n "${shallow_id}" ]; then + if CT_DoExecLog ALL git fetch --quiet --depth 1 origin "${shallow_id}"; then + CT_DoExecLog ALL git checkout --quiet FETCH_HEAD -- + else + # Git 2.15 and newer (which must be the case on both the client and the server) + # allows fetching a single commit so long as the server is configured + # to allow it (by having uploadpack.allowReachableSHA1InWant=true set + # in its config). + CT_DoLog WARN "Shallow clone failed (likely disallowed on the server)." + shallow_id= + fi + fi + + if [ -z "${shallow_id}" ]; then + # In this case, we already determined the changeset we need + CT_DoLog WARN "Falling back to full clone; may take some time..." + CT_DoExecLog ALL git fetch --quiet origin + CT_DoExecLog ALL git checkout --quiet "${unique_id}" -- + fi + + new_unique_id=`git rev-parse HEAD | cut -c1-8` + if [ "${new_unique_id}" != "${unique_id}" ]; then + CT_DoLog EXTRA "Revision being fetched changed to ${new_unique_id}; source repository had more revisions pushed?" + unique_id="${new_unique_id}" + fi + + CT_DoExecLog ALL rm -rf .git + CT_Popd +} + +# Helper: run another action after setting local variables +CT_PackageRun() +{ + local sym="${1}" + local run="${2}" + local src_dir="/unknown-src-dir" + local v + + # Get rid of our arguments + shift 2 + + # Variables that are per-project + for v in use dir_name; do + eval "local ${v}=\${CT_${sym}_${v^^}}" + done + + # If $use is not set, we only have one fork to handle + use="${use:-${sym}}" + + # Variables that are per-fork + for v in basename pkg_name version pkg_dir \ + src_release mirrors archive_filename archive_dirname archive_formats signature_format \ + src_devel devel_vcs devel_url devel_branch devel_revision devel_subdir devel_bootstrap \ + src_custom custom_location patch_order; do + eval "CT_DoLog DEBUG \"Package iterator: set ${v}='\${CT_${use}_${v^^}}'\"" + eval "local ${v}=\${CT_${use}_${v^^}}" + done + + if [ -z "${pkg_name}" ]; then + CT_Abort "Internal ct-ng error: '${sym}' not defined, please report a bug" + fi + + for v in archive_filename archive_dirname; do + # kconfig and shell have different quoting rules, so it seems impossible to make + # kconfig quote '$' properly for eval (i.e. not have it expanded when loading the + # .config). Therefore, use '@' instead of '$' in kconfig files and substitute it + # here for select variables. + eval "eval ${v}=\${${v}//@/$}" + done + + CT_DoLog DEBUG "Package iterator: run ${run} $*" + ${run} "$@" + + # Save certain variables that may be modified by the callback. + # Fetching the sources is run in the main process, so no need to + # use CT_EnvModify. + for v in devel_branch devel_revision basename src_dir pkg_dir; do + eval "[ \"\${${v}}\" != \"\${CT_${use}_${v^^}}\" ] || continue" + eval "CT_${use}_${v^^}=\${${v}}" + eval "CT_DoLog DEBUG \"Package iterator: override CT_${use}_${v^^}=\${CT_${use}_${v^^}}\"" + done +} + +# Closure for fetching the sources +CT_DoFetch() +{ + local tmp_dir + local extensions e a + + if [ "${src_release}" = "y" ]; then + # Some packages do not contain any directory level at all + if [ "${archive_dirname}" != "." ]; then + basename="${archive_dirname}" + else + basename="${pkg_name}-${version}" + fi + pkg_dir="${pkg_name}/${version}" + # Check which extensions we are allowed to fetch + for a in ${archive_formats}; do + for e in $(CT_DoListTarballExt); do + if [ "${a}" = "${e}" ]; then + extensions="${extensions} ${a}" + break + fi + done + done + if ! CT_GetFile package="${pkg_name}" pkg_dir="${pkg_dir}" dir_name="${dir_name}" \ + basename="${archive_filename}" extensions="${extensions}" \ + digest="${CT_VERIFY_DOWNLOAD_DIGEST}" \ + signature_format="${CT_VERIFY_DOWNLOAD_SIGNATURE:+${signature_format}}" \ + mirrors="${mirrors}"; then + CT_Abort "${pkg_name}: download failed" + fi + + elif [ "${src_devel}" = "y" ]; then + local unique_id + + if [ -z "${devel_revision}" -a "${CT_FORBID_DOWNLOAD}" = "y" ]; then + CT_Abort "${pkg_name}: cannot find most recent revisions with downloads prohibited" + fi + + # Each VCS backend must provide two methods: + # - CT_GetVersion_xxx that sets the base name for the package (package name + # and some unique identifier for the version) + # - CT_Download_xxx that retrieves the sources into the directory named as + # ${pkg_name} + # Both these methods can also modify devel_branch/devel_revision. Typically, + # this would override empty (default) values with "default branch name" and + # "most current revision", respectively. + + CT_GetVersion_${devel_vcs} + if [ -z "${unique_id}" ]; then + CT_Abort "${pkg_name}: ${devel_vcs} did not set unique ID for branch/revision" + fi + basename="${pkg_name}-${devel_vcs}-${unique_id}" + pkg_dir="${pkg_name}/${devel_vcs}-${unique_id}" + + # Try getting the tarball with empty list of URLs: it will only + # attempt getting it from local storage or from the mirror if configured. + # Bzip2 offers a reasonable compromise between compression speed and size. + if [ "${unique_id}" != "to.be.determined" ] && \ + CT_GetFile package="${pkg_name}" dir_name="${dir_name}" \ + basename="${basename}" extensions='.tar.bz2'; then + return 0 + fi + + if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then + CT_DoLog WARN "Downloads forbidden, not trying ${devel_vcs} retrieval" + CT_Abort "${pkg_name}: cannot check out" + fi + + CT_DoLog EXTRA "Checking out '${basename}' (${devel_vcs} ${devel_url}${devel_branch:+, branch ${devel_branch}}${devel_revision:+, revision ${devel_revision}})" + CT_MktempDir tmp_dir + CT_Pushd "${tmp_dir}" + CT_Download_${devel_vcs} + + # First setting above may not have determined the version (e.g. with Mercurial) + # Set the final, downloaded version. + basename="${pkg_name}-${devel_vcs}-${unique_id}" + pkg_dir="${pkg_name}/${devel_vcs}-${unique_id}" + + CT_DoExecLog ALL mv "${pkg_name}${devel_subdir:+/${devel_subdir}}" "${basename}" + CT_DoExecLog ALL tar cjf "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${basename}" + if ! CT_SaveLocal "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${dir_name}"; then + CT_Abort "${pkg_name}: failed to save to local storage" + fi + CT_Popd + CT_DoExecLog ALL rm -rf "${tmp_dir}" + + elif [ "${src_custom}" = "y" ]; then + # Will be handled during extraction/patching + basename="${dir_name}" + :; + else + CT_Abort "No known source for ${pkg_name}" + fi +} + +# Obtain the sources for a component, either from a tarball, version control system +# or a custom location. +CT_Fetch() +{ + CT_PackageRun "${1}" CT_DoFetch +} + +# Unpack an archive. +CT_Extract() +{ + local file="${1}" + local dir="${2}" + local components="${3}" + + CT_DoExecLog ALL mkdir -p "${dir}" + case "${file}" in + *.tar.*|*.tar) + CT_ZCat "${file}" | CT_DoExecLog FILE tar x -v -f - -C "${dir}" ${components} + ;; + *.zip) + CT_Pushd "${dir}" + CT_DoExecLog FILE unzip "${file}" ${components} + CT_Popd + ;; + *) + CT_Abort "Don't know how to handle ${file}: unknown extension" + ;; + esac +} + +# Closure for unpacking/patching the sources. There are two source directories: +# - CT_COMMON_SRC_DIR stores common sources, such as released tarballs (including +# bundled or local patches, if necessary) or checked out working copies. +# Custom sources cannot be placed here, as they may have similarly named +# packages coming from different origins. +# - CT_SRC_DIR stores per-configuration sources. These are either symlinks back +# to CT_ORIG_SRC_DIR sources, or a copy from the custom source, or a copy +# from CT_ORIG_SRC_DIR + target-specific overrides. +CT_DoExtractPatch() +{ + local patchfunc="${1}" + local archive ext + local -a patch_dirs + local bundled_patch_dir + local bundled_common_patch_dir + local local_patch_dir + local local_common_patch_dir + local overlay + + # Inherit global value if requested + if [ "${patch_order}" = "global" ]; then + patch_order="${CT_PATCH_ORDER}" + fi + + # If using overlay, prepare it first - we need to determine where to unpack + # this component. + if [ "${CT_TARGET_USE_OVERLAY}" = "y" -a ! -d "${CT_BUILD_DIR}/overlay" ]; then + CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}/overlay" + overlay="${CT_OVERLAY_LOCATION}/${CT_ARCH}_${CT_OVERLAY_NAME:-overlay}" + if [ -d "${overlay}" ]; then + CT_DoExecLog ALL cp -av "${overlay}/." "${CT_BUILD_DIR}/overlay" + else + if ! ext=`CT_GetFileExtension "${overlay}"`; then + CT_Abort "Overlay ${overlay} not found" + fi + CT_Extract "${overlay}${ext}" "${CT_BUILD_DIR}/overlay" + fi + fi + + # Can use common location only if using non-custom source, only bundled patches + # and no overlays. Otherwise, this source directory is custom-tailored for this + # particular configuration and cannot be reused by different configurations. + if [ "${src_custom}" != "y" -a \ + "${patch_order}" = "bundled" -a \ + ! -d "${CT_BUILD_DIR}/overlay/${dir_name}" ]; then + src_dir="${CT_COMMON_SRC_DIR}" + else + src_dir="${CT_SRC_DIR}" + fi + + if [ "${src_custom}" != "y" ]; then + # Non-custom: extract to shared location + # If the previous extraction/patching was aborted, clean up. + if [ -r "${src_dir}/.${basename}.extracting" -o \ + -r "${src_dir}/.${basename}.patching" ]; then + CT_DoLog WARN "Sources for ${basename} were partially extracted/patched, cleaning up" + CT_DoExecLog ALL rm -rf "${src_dir}/${basename}" + CT_DoExecLog ALL rm -f "${src_dir}/.${basename}".* + fi + + if [ -f "${src_dir}/.${basename}.extracted" ]; then + CT_DoLog DEBUG "Already extracted ${basename}" + else + CT_DoLog EXTRA "Extracting ${basename}" + CT_DoExecLog ALL touch "${src_dir}/.${basename}.extracting" + if [ "${src_release}" = "y" ]; then + archive="${archive_filename}" + else + archive="${basename}" + fi + # TBD save/discover the extension while fetching + ext=`CT_GetFileExtension "${CT_TARBALLS_DIR}/${archive}"` + if [ "${archive_dirname}" = "." ]; then + CT_mkdir_pushd "${src_dir}/${basename}" + CT_Extract "${CT_TARBALLS_DIR}/${archive}${ext}" "${src_dir}/${basename}" + CT_Popd + else + CT_Extract "${CT_TARBALLS_DIR}/${archive}${ext}" "${src_dir}" + fi + CT_DoExecLog ALL touch "${src_dir}/.${basename}.extracted" + CT_DoExecLog ALL rm -f "${src_dir}/.${basename}.extracting" + fi + + if [ -f "${src_dir}/.${basename}.patched" ]; then + CT_DoLog DEBUG "Already patched ${basename}" + else + CT_DoLog EXTRA "Patching ${basename}" + CT_DoExecLog ALL touch "${src_dir}/.${basename}.patching" + + bundled_patch_dir="${CT_LIB_DIR}/packages/${pkg_dir}" + bundled_common_patch_dir="${CT_LIB_DIR}/packages/${pkg_name}" + local_patch_dir="${CT_LOCAL_PATCH_DIR}/${pkg_dir}" + local_common_patch_dir="${CT_LOCAL_PATCH_DIR}/${pkg_name}" + + case "${patch_order}" in + bundled) patch_dirs=("${bundled_patch_dir}" "${bundled_common_patch_dir}");; + local) patch_dirs=("${local_patch_dir}" "${local_common_patch_dir}");; + bundled,local) patch_dirs=("${bundled_patch_dir}" "${bundled_common_patch_dir}" "${local_patch_dir}" "${local_common_patch_dir}");; + local,bundled) patch_dirs=("${local_patch_dir}" "${local_common_patch_dir}" "${bundled_patch_dir}" "${bundled_common_patch_dir}");; + none) patch_dirs=;; + esac + + CT_Pushd "${src_dir}/${basename}" + for d in "${patch_dirs[@]}"; do + CT_DoLog DEBUG "Looking for patches in '${d}'..." + if [ -n "${d}" -a -d "${d}" ]; then + for p in "${d}"/*.patch; do + if [ -f "${p}" ]; then + CT_DoExecLog ALL ${patch} --no-backup-if-mismatch -g0 -F1 -p1 -f -i "${p}" + fi + done + fi + done + + # TBD create meta-package for config.sub/config.guess with replacement script + if [ "${CT_OVERRIDE_CONFIG_GUESS_SUB}" = "y" ]; then + CT_DoLog ALL "Overiding config.guess and config.sub" + for cfg in config.guess config.sub; do + # Can't use CT_DoExecLog because of the '{} \;' to be passed un-mangled to find + find . -type f -name "${cfg}" \ + -exec chmod -v u+w {} \; \ + -exec cp -v "${CT_LIB_DIR}/scripts/${cfg}" {} \; |CT_DoLog ALL + done + fi + + # FIXME: This currently means we end up using host's autotools, + # but changing this requires reworking the order of operations in crosstool-NG: + # we'd need to defer the download/extraction/patching of a package until after + # the companion tools are built. + if [ -n "${devel_bootstrap}" ]; then + CT_DoExecLog ALL "${CT_CONFIG_SHELL}" -c "${devel_bootstrap}" + fi + + # Fix up the timestamps on the file we may be patching: otherwise, we may + # have a circular dependency. For example, we need make to build autoconf + # and automake companion tools, but we need autoconf and automake to regenerate + # aclocal.m4 or config.h.in after the patch touches configure.ac. Instead, + # assume the patch fixes all the files it needs. + find . -type f -name "aclocal.m4" \ + -exec touch {} \; -exec echo touch {} \; | CT_DoLog ALL + find . -type f -name "config.h.in" \ + -exec touch {} \; -exec echo touch {} \; | CT_DoLog ALL + find . -type f -name "Makefile.in" \ + -exec touch {} \; -exec echo touch {} \; | CT_DoLog ALL + find . -type f -name "configure" \ + -exec touch {} \; -exec echo touch {} \; | CT_DoLog ALL + + if [ -n "${patchfunc}" ]; then + ${patchfunc} + fi + + CT_Popd + + CT_DoExecLog ALL touch "${src_dir}/.${basename}.patched" + CT_DoExecLog ALL rm -f "${src_dir}/.${basename}.patching" + fi + else + CT_DoLog WARN "${pkg_name}: using custom location, no patches applied" + fi + + # Symlink/move/copy into per-target source directory + if [ "${src_custom}" = "y" ]; then + # Custom sources: unpack or copy into per-target directory. Note that + # ${src_dir} is never ${CT_COMMON_SRC_DIR} in this case. + if [ -d "${custom_location}" ]; then + CT_DoExecLog ALL cp -av "${custom_location}" "${src_dir}/${dir_name}" + elif [ -f "${custom_location}" ]; then + # Assume "foo.tar.gz" (or likes) contain the "foo" directory + local bn + + CT_Extract "${custom_location}" "${src_dir}" + bn=`CT_GetFileBasename "${custom_location##*/}"` + CT_TestOrAbort "Unknown file extension: ${custom_location}" -n "${bn}" + CT_DoExecLog ALL mv -v "${src_dir}/${bn%${ext}}" "${src_dir}/${dir_name}" + else + CT_Abort "Neither file nor directory: ${custom_location}" + fi + elif [ "${src_dir}" = "${CT_SRC_DIR}" ]; then + # Sources specific to this target, just move (if we use overlay, symlinks + # would be overwritten and overlayed files will end up in a separate dir). + CT_DoExecLog ALL mv "${src_dir}/${basename}" "${CT_SRC_DIR}/${dir_name}" + else + # Common source, just symlink + CT_DoExecLog ALL ln -s "${src_dir}/${basename}" "${CT_SRC_DIR}/${dir_name}" + fi + + # Check if it has overlays and if it has, apply + if [ "${CT_TARGET_USE_OVERLAY}" = "y" -a \ + -d "${CT_BUILD_DIR}/overlay/${dir_name}" ]; then + tar cf - -C "${CT_BUILD_DIR}/overlay" "${dir_name}" | \ + CT_DoExecLog FILE tar xvf - -C "${src_dir}" + fi + +} + +# Extract/copy the sources to the shared source directory, then either symlink +# or copy the sources into a private source directory and apply target-specific +# changes (such as xtensa overrides). +CT_ExtractPatch() +{ + local pkg="${1}" + + shift + CT_PackageRun "${pkg}" CT_DoExtractPatch "$@" +} + +# Set the specified variable to the version of the package (main or fork) +# Usage: CT_GetPkgVersion PKG VAR +CT_GetPkgVersion() +{ + local rv + __do_GetPkgVersion() { rv="${version}"; } + CT_PackageRun "${1}" __do_GetPkgVersion + eval "${2}=\"${rv}\"" +} + +# Get a package version selected to build. May return an empty string. +# Usage: CT_GetPkgBuildVersion PKG VAR +# where PKG may refer to a specific package (e.g. GCC) or package choice +# (e.g. LIBC). +CT_GetPkgBuildVersion() +{ + local category="${1}" + local component="${2}" + local var="${3}" + local choicename tmp pkg build_version + + # If it is for a choice, not a menu, get the choice name + eval "choicename=\${CT_${category}}" + + # Find the associated package + eval "pkg=\${CT_${category}_${component}_PKG_KSYM}" + if [ -z "${pkg}" ]; then + # This component does not have an associated package, + # return the component name. + if [ -n "${choicename}" ]; then + eval "${var}=\"${choicename}\"" + fi + return + fi + + __do_GetPkgBuildVersion() { + tmp="${pkg_name}" + if [ "${version}" != "unknown" ]; then + tmp+="-${version}" + fi + if [ "${src_devel}" = "y" ]; then + tmp+="-${devel_vcs}" + if [ -n "${devel_revision}" ]; then + tmp+="-${devel_revision}" + fi + elif [ "${src_custom}" = "y" ]; then + tmp+="-custom" + fi + if [ -n "${choicename}" -a "${pkg}" != "${component}" ]; then + tmp+=" (${choicename})" + fi + } + + CT_PackageRun "${pkg}" __do_GetPkgBuildVersion + eval "${var}=\"${tmp}\"" +} + +# Finally, load paths.sh. For --enable-local build, it is located in +# the current directory (CT_TOP_DIR) while the rest of the scripts are +# in the source directory (CT_LIB_DIR). For other setups, paths.sh +# is in CT_LIB_DIR. +if [ -r "${CT_LIB_DIR}/paths.sh" ]; then + paths_sh_location="${CT_LIB_DIR}/paths.sh" +elif [ -r "${CT_TOP_DIR}/paths.sh" ]; then + paths_sh_location="${CT_TOP_DIR}/paths.sh" +else + CT_Error "Not found: paths.sh" +fi +. "${paths_sh_location}" + +CT_InstallCopyingInformation() +{ + local licfile + local dstdir + + CT_DoLog EXTRA "Collect license information from: ${CT_SRC_DIR}" + CT_DoLog EXTRA "Put the license information to: ${CT_PREFIX_DIR}/share/licenses" + + for licfile in $( find "${CT_SRC_DIR}" -follow -type f -a \( -name "COPYING*" -o -name "LICENSE*" \) ); do + dstdir="${licfile%/*}" + dstdir="${CT_PREFIX_DIR}/share/licenses${dstdir#${CT_SRC_DIR}}" + mkdir -p "${dstdir}" + CT_DoExecLog ALL cp -av "${licfile}" "${dstdir}/" + done + + # Also add crosstool's information + for licfile in ${CT_LIB_DIR}/{COPYING*,LICENSE*,licenses.d}; do + dstdir="${CT_PREFIX_DIR}/share/licenses/crosstool-ng" + mkdir -p "${dstdir}" + CT_DoExecLog ALL cp -av "${licfile}" "${dstdir}/" + done + + shopt -u nullglob +} + +CT_InstallConfigurationFile() +{ + local path="${1}" + local suffix="${2}" + + 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}-${suffix}.config" + CT_DoExecLog DEBUG ${sed} -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${suffix}.config" + bzip2 -c -9 "${path}" >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-${suffix}.config" +} diff --git a/scripts/gen_in_frags.sh b/scripts/gen_in_frags.sh deleted file mode 100755 index 9fbb871..0000000 --- a/scripts/gen_in_frags.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/sh -set -e - -# This scripts generates either a choice or a menuconfig -# with the specified entries. -# -# Usage: -# generate a choice: -# gen_in_frags.sh choice <out-file> <label> <config-prefix> <base-dir> <conditionals> entry [entry...] -# -# generate a menuconfig: -# gen_in_frags.sh menu <out-file> <label> <config-prefix> <base-dir> entry [entry...] -# -# where: -# out-file -# put the generated choice/menuconfig into that file -# for choices, it acts as the base bname of the file, the secondary -# parts (the .in.2) are put in out-file.2 -# -# label -# name for the entries family -# eg. Architecture, Kernel... -# -# config-prefix -# prefix for the choice entries -# eg. ARCH, KERNEL... -# -# base-dir -# base directory containing config files -# eg. config/arch, config/kernel... -# -# conditionals (valid only for choice) -# generate backend conditionals if Y/y, don't if anything else -# if 'Y' (or 'y'), a dependency on the backen mode will be added -# to each entry -# -# entry [entry...] -# a list of entry/ies toadd to the choice/menuconfig -# eg.: -# arm mips sh x86... -# linux cygwin mingw32 solaris... -# ... -# -#------------------------------------------------------------------------------ - -# Generate a choice -# See above for usage -gen_choice() { - local out_file="${1}" - local label="${2}" - local cfg_prefix="${3}" - local base_dir="${4}" - local cond="${5}" - shift 5 - local file entry _entry - - # Generate the part-1 - exec >"${out_file}" - printf '# %s menu\n' "${label}" - printf '# Generated file, do not edit!!!\n' - printf '\n' - printf 'choice GEN_CHOICE_%s\n' "${cfg_prefix}" - printf ' bool\n' - printf ' prompt "%s"\n' "${label}" - printf '\n' - for entry in "${@}"; do - file="${base_dir}/${entry}.in" - _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;') - printf 'config %s_%s\n' "${cfg_prefix}" "${_entry}" - printf ' bool\n' - printf ' prompt "%s"\n' "${entry}" - if [ "${cond}" = "Y" -o "${cond}" = "y" ]; then - printf ' depends on %s_%s_AVAILABLE\n' "${cfg_prefix}" "${_entry}" - fi - "${sed}" -r -e '/^## depends on /!d; s/^## / /;' ${file} 2>/dev/null - "${sed}" -r -e '/^## select /!d; s/^## / /;' ${file} 2>/dev/null - if "${grep}" -E '^## help' ${file} >/dev/null 2>&1; then - printf ' help\n' - "${sed}" -r -e '/^## help ?/!d; s/^## help ?/ /;' ${file} 2>/dev/null - fi - printf '\n' - done - printf 'endchoice\n' - - for entry in "${@}"; do - file="${base_dir}/${entry}.in" - _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;') - printf '\n' - if [ "${cond}" = "Y" -o "${cond}" = "y" ]; then - printf 'config %s_%s_AVAILABLE\n' "${cfg_prefix}" "${_entry}" - printf ' bool\n' - printf ' default y if' - printf ' BACKEND_%s = "%s"' "${cfg_prefix}" "${entry}" - printf ' || BACKEND_%s = ""' "${cfg_prefix}" - printf ' || ! BACKEND\n' - fi - printf 'if %s_%s\n' "${cfg_prefix}" "${_entry}" - printf 'config %s\n' "${cfg_prefix}" - printf ' default "%s" if %s_%s\n' "${entry}" "${cfg_prefix}" "${_entry}" - printf 'source "%s"\n' "${file}" - printf 'endif\n' - done - - # Generate the part-2 - exec >"${out_file}.2" - printf '# %s second part options\n' "${label}" - printf '# Generated file, do not edit!!!\n' - for entry in "${@}"; do - file="${base_dir}/${entry}.in" - _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;') - if [ -f "${file}.2" ]; then - printf '\n' - printf 'if %s_%s\n' "${cfg_prefix}" "${_entry}" - printf 'comment "%s other options"\n' "${entry}" - printf 'source "%s.2"\n' "${file}" - printf 'endif\n' - fi - done -} - -# Generate a menuconfig -# See above for usage -gen_menu() { - local out_file="${1}" - local label="${2}" - local cfg_prefix="${3}" - local base_dir="${4}" - shift 4 - local file entry _entry - - # Generate the menuconfig - exec >"${out_file}" - printf '# %s menu\n' "${label}" - printf '# Generated file, do not edit!!!\n' - printf '\n' - for entry in "${@}"; do - file="${base_dir}/${entry}.in" - _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 - if "${grep}" -E '^## help' ${file} >/dev/null 2>&1; then - printf ' help\n' - "${sed}" -r -e '/^## help ?/!d; s/^## help ?/ /;' ${file} 2>/dev/null - fi - printf '\n' - printf 'if %s_%s\n' "${cfg_prefix}" "${_entry}" - printf 'source "%s"\n' "${file}" - printf 'endif\n' - printf '\n' - done -} - -type="${1}" -shift -"gen_${type}" "${@}" diff --git a/scripts/install-sh b/scripts/install-sh index 6781b98..59990a1 100755 --- a/scripts/install-sh +++ b/scripts/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2009-04-28.21; # UTC +scriptversion=2014-09-12.12; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -35,25 +35,21 @@ scriptversion=2009-04-28.21; # UTC # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it +# 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. +tab=' ' nl=' ' -IFS=" "" $nl" +IFS=" $tab$nl" -# set DOITPROG to echo to test this script +# Set DOITPROG to "echo" to test this script. -# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -68,17 +64,6 @@ mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - posix_mkdir= # Desired mode of installed file. @@ -97,7 +82,7 @@ dir_arg= dst_arg= copy_on_change=false -no_target_directory= +is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -137,42 +122,57 @@ while test $# -ne 0; do -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; -s) stripcmd=$stripprog;; - -t) dst_arg=$2 - shift;; + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; - -T) no_target_directory=true;; + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -186,6 +186,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then fi shift # arg dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac done fi @@ -194,13 +198,26 @@ if test $# -eq 0; then echo "$0: no input file specified." >&2 exit 1 fi - # It's OK to call `install-sh -d' without argument. + # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. @@ -211,16 +228,16 @@ if test -z "$dir_arg"; then *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -228,9 +245,9 @@ fi for src do - # Protect names starting with `-'. + # Protect names problematic for 'test' and other utilities. case $src in - -*) src=./$src;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then @@ -252,51 +269,20 @@ do echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - + dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi @@ -307,74 +293,81 @@ do if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + # $RANDOM is not portable (e.g. dash); use it when possible to + # lower collision chance + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 + + # As "mkdir -p" follows symlinks and we work in /tmp possibly; so + # create the $tmpdir first (and fail if unsuccessful) to make sure + # that nobody tries to guess the $tmpdir name. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else @@ -384,53 +377,51 @@ do # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - -*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac - eval "$initialize_posix_glob" - oIFS=$IFS IFS=/ - $posix_glob set -f + set -f set fnord $dstdir shift - $posix_glob set +f + set +f IFS=$oIFS prefixes= for d do - test -z "$d" && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -465,15 +456,12 @@ do # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - + set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then @@ -486,24 +474,24 @@ do # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 diff --git a/scripts/ltmain.sh b/scripts/ltmain.sh new file mode 100644 index 0000000..fb43c68 --- /dev/null +++ b/scripts/ltmain.sh @@ -0,0 +1,4 @@ +# Dummy: crosstool-NG currently does not use libtool itself, it just checks +# its presense/version for the build time... Should be checked at the 'ct-ng build' +# time as well then. +: diff --git a/scripts/missing b/scripts/missing new file mode 100755 index 0000000..f62bbae --- /dev/null +++ b/scripts/missing @@ -0,0 +1,215 @@ +#! /bin/sh +# Common wrapper for a few potentially missing GNU programs. + +scriptversion=2013-10-28.13; # UTC + +# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try '$0 --help' for more information" + exit 1 +fi + +case $1 in + + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; + + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. + +Send bug reports to <bug-automake@gnu.org>." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" + exit 1 + ;; + +esac + +# Run the given program, remember its exit status. +"$@"; st=$? + +# If it succeeded, we are done. +test $st -eq 0 && exit 0 + +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi + +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'autom4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/scripts/override/__default b/scripts/override/__default deleted file mode 100644 index 977b1f5..0000000 --- a/scripts/override/__default +++ /dev/null @@ -1,3 +0,0 @@ -#!@CONFIG_SHELL@ - -exec @TOOL_PATH@ "$@" diff --git a/scripts/override/install b/scripts/override/install index e3954fb..720866f 100644 --- a/scripts/override/install +++ b/scripts/override/install @@ -1,8 +1,22 @@ #!@CONFIG_SHELL@ +# GNU install takes the program to run to strip a binary via a --strip-program= +# argument. Fallback script, install-sh, chokes on any unknown option and takes +# the program name via $STRIPPROG variable - but that variable is ignored by +# GNU install. BSD install uses $STRIPBIN. +# +# If using GNU install, convert to the command line option. In any case, set +# STRIPPROG and STRIPBIN - they're either supported or harmless. +if [ -n "${STRIPPROG}" ]; then + if [ "@INSTALL_WITH_STRIP_PROGRAM@" = "y" ]; then + __strip_opt="--strip-program=${STRIPPROG}" + fi + export STRIPBIN="${STRIPPROG}" +fi + # Do the most common case first if [ -z "${__PORTAGE_HELPER_PATH}" ]; then - exec @TOOL_PATH@ "$@" + exec @TOOL_PATH@ ${__strip_opt} "$@" fi # Not so simple case: Gentoo uses *two* wrappers around install script @@ -32,4 +46,4 @@ for x in ${PATH}; do fi done PATH="${path}" -exec @TOOL_PATH@ "$@" +exec @TOOL_PATH@ ${__strip_opt} "$@" diff --git a/scripts/patch-renumber.sh b/scripts/patch-renumber.sh deleted file mode 100755 index c9650ce..0000000 --- a/scripts/patch-renumber.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -# Yes, this intends to be a true POSIX script file. -set -e - -myname="$0" - -# Parse the tools' paths configuration -# It is expected that this script is only to be run from the -# source directory of crosstool-NG, so it is trivial to find -# paths.sh (we can't use ". paths.sh", as POSIX states that -# $PATH should be searched for, and $PATH most probably doe -# not include "."), hence the "./". -. "./paths.sh" - -doUsage() { - cat <<_EOF_ -Usage: ${myname} <src_dir> <dst_dir> <base> <inc> [sed_re] - Renumbers all patches found in 'src_dir', starting at 'base', with an - increment of 'inc', and puts the renumbered patches in 'dst_dir'. - Leading digits are replaced with the new indexes, and a subsequent '_' - is replaced with a '-'. - If 'sed_re' is given, it is interpreted as a valid sed expression, and - is be applied to the patch name. - If the environment variable FAKE is set to 'y', then nothing gets done, - the command to run is only be printed, and not executed (so you can - check beforehand). - 'dst_dir' must not yet exist. - Eg.: - patch-renumber.sh patches/gcc/4.2.3 patches/gcc/4.2.4 100 10 - patch-renumber.sh /some/dir/my-patches patches/gcc/4.3.1 100 10 's/(all[_-])*(gcc[-_])*//;' -_EOF_ -} - -[ $# -lt 4 -o $# -gt 5 ] && { doUsage; exit 1; } - -src="${1}" -dst="${2}" -cpt="${3}" -inc="${4}" -sed_re="${5}" -if [ ! -d "${src}" ]; then - printf "%s: '%s': not a directory\n" "${myname}" "${src}" - exit 1 -fi -if [ -d "${dst}" ]; then - printf "%s: '%s': directory already exists\n" "${myname}" "${dst}" - exit 1 -fi - -Q= -if [ -n "${FAKE}" ]; then - printf "%s: won't do anything: FAKE='%s'\n" "${myname}" "${FAKE}" - Q="echo" -fi - -${Q} mkdir -pv "${dst}" -for p in "${src}/"*.patch*; do - [ -e "${p}" ] || { echo "No such file '${p}'"; exit 1; } - newname="$(printf "%03d-%s" \ - "${cpt}" \ - "$( basename "${p}" \ - |${sed} -r -e 's/^[[:digit:]]+[-_]//' \ - -e "${sed_re}" \ - )" \ - )" - ${Q} cp -v "${p}" "${dst}/${newname}" - cpt=$((cpt+inc)) -done diff --git a/scripts/patch-rework.sh b/scripts/patch-rework.sh deleted file mode 100755 index d05d2c1..0000000 --- a/scripts/patch-rework.sh +++ /dev/null @@ -1,196 +0,0 @@ -#!/bin/sh - -# Get our required options -base="$1" -src="$2" -dst="$3" -shift 3 - -# The remainder is for diff -diff="$@" - -do_help() { - cat <<-_EOF_ - ${0##*/}: transform a patchset of non-p1 patches into -p1 patches - - Usage: - ${0##*/} <basedir> <src> <dst> [diffopts ...] - - Where: - basedir - points to the directory of the component to patch - - src - points to the directory containing the existing patchset - to transform - - dst - points to the directory where to put transformed patches - - diffopts - optional options to pass to diff, for debug purposes. You - should not need it - - Example: - Transform Gentoo patches against gcc-4.4.2 (some of which are - -p0, -p1 or even -p2 patches) into all -p1 patches: - - tar xjf gcc-4.4.2.tar.bz2 - patch-rework.sh gcc-4.4.2 \\ - /path/to/gentoo/gcc/patches \\ - gcc-4.4.2.patches - _EOF_ -} - -# Sanity checks -if [ -z "${base}" \ - -o ! -d "${base}" \ - -o ! -d "${src}" \ - -o -e "${dst}" -a ! -d "${dst}" \ - ]; then - do_help - exit 1 -fi - -mkdir -p "${dst}" -base="${base%%/}" -src="$( cd "${src}"; pwd )" -dst="$( cd "${dst}"; pwd )" - -# This function checks that the files listed in the file in "$1" -# do exist, at the given depth-stripping level (aka diff -p#) -do_check_files_at_depth() { - local flist="$1" - local depth="$2" - local ret=0 # 0: OK, !0: KO - - exec 6<&0 - exec 7<"${flist}" - - while read f; do - f="$( echo "${f}" |sed -r -e "s:^([^/]+/){${depth}}::;" )" - [ -f "${f}" ] || ret=1 - done </dev/fd/7 - - exec 7<&- - exec <&6 - - return ${ret} -} - -# Iterate through patches -for p in "${src}/"*.patch; do - pname="$( basename "${p}" )" - - printf "Handling patch '${pname}'...\n" - - printf " creating reference..." - cp -a "${base}" "${base}.orig" - printf " done\n" - - printf " retrieving patch comment..." - comment="$( awk ' -BEGIN { mark=0; } -$0~/^diff --/ { nextfile; } -$1=="---" { mark=1; next; } -$1=="+++" && mark==1 { nextfile; } -{ mark=0; print; } -' "${p}" )" - printf " done\n" - - printf " creating patched file list..." - diffstat -f 4 -r 2 -u -p 0 "${p}" \ - |head -n -1 \ - |awk '{ for(i=NF;i>=NF-5;i--) { $(i) = ""; } print; }' \ - |sort \ - >"diffstat.orig" - printf " done\n" - - cd "${base}" - - # Check all files exist, up to depth 3 - printf " checking depth:" - d=0 - while [ $d -lt 4 ]; do - printf " ${d}" - if do_check_files_at_depth "../diffstat.orig" ${d}; then - printf " ok, using depth '${d}'\n" - break - fi - d=$((d + 1)) - done - if [ ${d} -ge 4 ]; then - printf "\n" - printf " checking depth failed\n" - read -p " --> enter patch depth (or Ctrl-C to abort): " d - fi - - # Store the original list of files touched by the patch, - # removing the $d leading components - sed -r -e "s:^([^/]+/){${d}}::;" "../diffstat.orig" >"${dst}/${pname}.diffstat.orig" - - # Apply the patch proper, and check it applied cleanly. - # We can't check with --dry-run because of patches that - # contain multiple accumulated patches onto a single file. - printf " applying patch..." - if ! patch -g0 -F1 -f -p${d} <"${p}" >"../patch.out" 2>&1; then - printf " ERROR\n\n" - cd - >/dev/null - printf "There was an error while applying:\n --> ${p} <--\n" - printf "'${base}' was restored to the state it was prior to applying this faulty patch.\n" - printf "Here's the 'patch' command, and its output:\n" - printf " ----8<----\n" - printf " patch -g0 -F1 -f -p${d} <'${p}'\n" - sed -r -e 's/^/ /;' "patch.out" - printf " ----8<----\n" - exit 1 - fi - printf " done\n" - - printf " removing '.orig' files..." - find . -type f -name '*.orig' -exec rm -f {} + - printf " done\n" - - cd - >/dev/null - - printf " re-diffing the patch..." - printf "%s\n\n" "${comment}" >"${dst}/${pname}" - diff -durN "${base}.orig" "${base}" >>"${dst}/${pname}" - printf " done\n" - - if [ -n "${diff}" ]; then - printf " applying diff filter..." - filterdiff -x "${diff}" "${dst}/${pname}" >"tmp-diff" - mv "tmp-diff" "${dst}/${pname}" - printf " done\n" - fi - - printf " creating new patched file list..." - diffstat -f 4 -r 2 -u -p 1 "${dst}/${pname}" \ - |head -n -1 \ - |awk '{ for(i=NF;i>=NF-5;i--) { $(i) = ""; } print; }' \ - |sort \ - >"${dst}/${pname}.diffstat.new" - printf " done\n" - - printf " removing temporary files/dirs..." - rm -f "patch.out" - rm -f "diffstat.tmp" - rm -f "diffstat.orig" - rm -rf "${base}.orig" - printf " done\n" -done - -# Scan all new patches to see if they touch -# more files than the original patches -printf "\nChecking resulting patchset:\n" -for p in "${dst}/"*.patch; do - pname="$( basename "${p}" )" - - if ! cmp "${p}.diffstat.orig" "${p}.diffstat.new" >/dev/null; then - printf " --> '${pname}' differ in touched files <--\n" - else - rm -f "${p}.diffstat.orig" "${p}.diffstat.new" - fi -done -printf " done.\n" diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh index 2e413bd..e367e6e 100644 --- a/scripts/saveSample.sh.in +++ b/scripts/saveSample.sh @@ -1,5 +1,3 @@ -#!@@CT_bash@@ - # This script is responsible for saving the current configuration into a # sample to be used later on as a pre-configured target. @@ -9,11 +7,14 @@ # - info about who reported the sample # Parse the tools' paths configuration -. "${CT_LIB_DIR}/paths.sh" . "${CT_LIB_DIR}/scripts/functions" CT_LoadConfig +# Override CT_VCHECK: we're going to be saving it so need to force saving of +# the config version. +export CT_VCHECK=save + # We can not reliably save a sample which either uses local patches # and/or custom Linux kernel headers. Warn the user about this issue # and continue if he/she confirms sving the sample. @@ -74,8 +75,8 @@ fi # Save the uClibc .config file if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then # We save the file, and then point the saved sample to this file - CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${samp_dir}/${CT_LIBC}-${CT_LIBC_VERSION}.config" - "${sed}" -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE)=.+$|\1="'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \ + CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${samp_dir}/${CT_LIBC}.config" + "${sed}" -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE)=.+$|\1="'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}.config"|;' \ .defconfig else # remove any dangling files @@ -86,7 +87,7 @@ fi # Now, actually save the defconfig export KCONFIG_CONFIG="$(pwd)/.defconfig" -${CONF} --savedefconfig="${samp_dir}/crosstool.config" "${KCONFIG_TOP}" +srctree="${CT_LIB_DIR}" ${CONF} --savedefconfig="${samp_dir}/crosstool.config" "${KCONFIG_TOP}" rm -f .defconfig # Fill-in the reported-by info diff --git a/scripts/scripts.mk.in b/scripts/scripts.mk index 99b9d76..eeb8a50 100644 --- a/scripts/scripts.mk.in +++ b/scripts/scripts.mk @@ -31,11 +31,11 @@ ifneq ($(strip $(V)),2) curl_silent_opt = --silent endif -ifneq (@@CT_wget@@,) -download_cmd = wget --passive-ftp $(wget_silent_opt) -O $@ +ifneq ($(CT_WGET),) +download_cmd = $(CT_WGET) --passive-ftp $(wget_silent_opt) -O $@ else -ifneq (@@CT_curl@@,) -download_cmd = curl --ftp-pasv $(curl_silent_opt) -o $@ +ifneq ($(CT_CURL),) +download_cmd = $(CT_CURL) --ftp-pasv $(curl_silent_opt) -o $@ else download_cmd = $(error wget or curl needed for downloads) endif diff --git a/scripts/show-config.sh b/scripts/show-config.sh new file mode 100644 index 0000000..36ade9e --- /dev/null +++ b/scripts/show-config.sh @@ -0,0 +1,108 @@ +# Parses all samples on the command line, and for each of them, prints +# the versions of the main tools + +# Use tools discovered by ./configure +. "${CT_LIB_DIR}/scripts/functions" + +[ "$1" = "-v" ] && opt="$1" && shift + +# GREP_OPTIONS screws things up. +export GREP_OPTIONS= + +fieldwidth=15 + +# Dummy version which is invoked from .config +CT_Mirrors() { :; } + +# Dump a short package description with a name and version in a format +# " <name>[-<version>]" +dump_pkgs_desc() +{ + local category="${1}" + local field="${2}" + local pkgs + shift 2 + local show_version + local tmp p + + eval "pkgs=\"\${CT_ALL_${category}_CHOICES}\"" + printf " %-*s :" ${fieldwidth} "${field}" + for p in ${pkgs}; do + # FIXME: multiple choices use category_package; single choice + # use category_package for the primary selection and category_package_SHOW + # for all other selections enabled by the primary. Cannot unify this syntax + # without a really extensive change. + eval "tmp=\"\${CT_${category}_${p}}\${CT_${category}_${p}_SHOW}\"" + if [ -n "${tmp}" ]; then + CT_GetPkgBuildVersion "${category}" "${p}" show_version + printf " %s" "${show_version}" + fi + done + printf "\n" +} + +# Dump a single sample +# Note: we use the specific .config.sample config file +dump_single_sample() +{ + local verbose=0 + local complibs + [ "$1" = "-v" ] && verbose=1 && shift + local sample="$1" + . $(pwd)/.config.sample + + case "${sample}" in + current) + sample_type="l" + sample="$( ${CT_NG} show-tuple )" + case "${CT_TOOLCHAIN_TYPE}" in + canadian) + sample="${CT_HOST},${sample}" + ;; + esac + ;; + *) if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then + sample_top="${CT_TOP_DIR}" + sample_type="L" + else + sample_top="${CT_LIB_DIR}" + sample_type="G" + fi + ;; + esac + printf "[%s" "${sample_type}" + [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf "." + [ "${CT_CONFIG_VERSION}" != "${CT_CONFIG_VERSION_CURRENT}" ] && printf "O" || printf "." + [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf "." + printf "] %s\n" "${sample}" + if [ ${verbose} -ne 0 ]; then + case "${CT_TOOLCHAIN_TYPE}" in + cross) ;; + canadian) + printf " %-*s : %s\n" ${fieldwidth} "Host" "${CT_HOST}" + ;; + esac + printf " %-*s : %s" ${fieldwidth} "Languages" "C" + [ "${CT_CC_LANG_CXX}" = "y" ] && printf ",C++" + [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran" + [ "${CT_CC_LANG_JAVA}" = "y" ] && printf ",Java" + [ "${CT_CC_LANG_ADA}" = "y" ] && printf ",ADA" + [ "${CT_CC_LANG_OBJC}" = "y" ] && printf ",Objective-C" + [ "${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" + + dump_pkgs_desc KERNEL "OS" + dump_pkgs_desc BINUTILS "Binutils" + dump_pkgs_desc CC "Compiler" + dump_pkgs_desc LIBC "C library" + dump_pkgs_desc DEBUG "Debug tools" + dump_pkgs_desc COMP_LIBS "Companion libs" + dump_pkgs_desc COMP_TOOLS "Companion tools" + fi +} + +for sample in "${@}"; do + dump_single_sample ${opt} "${sample}" +done diff --git a/scripts/showConfig.sh.in b/scripts/show-tuple.sh index b439995..4b0b9b0 100644 --- a/scripts/showConfig.sh.in +++ b/scripts/show-tuple.sh @@ -1,11 +1,6 @@ -#!@@CT_bash@@ - # What we need: # - the .config file -# Parse the tools' paths configuration -. "${CT_LIB_DIR}/paths.sh" - # Parse the common functions . "${CT_LIB_DIR}/scripts/functions" diff --git a/scripts/showSamples.sh b/scripts/showSamples.sh deleted file mode 100755 index f3a21d2..0000000 --- a/scripts/showSamples.sh +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/sh -# Yes, this is supposed to be a POSIX-compliant shell script. - -# Parses all samples on the command line, and for each of them, prints -# the versions of the main tools - -# Use tools discovered by ./configure -. "${CT_LIB_DIR}/paths.sh" - -[ "$1" = "-v" ] && opt="$1" && shift -[ "$1" = "-w" ] && opt="$1" && shift -[ "$1" = "-W" ] && opt="$1" && shift - -# GREP_OPTIONS screws things up. -export GREP_OPTIONS= - -# Dump a single sample -# Note: we use the specific .config.sample config file -dump_single_sample() { - local verbose=0 - local wiki=0 - local complibs - [ "$1" = "-v" ] && verbose=1 && shift - [ "$1" = "-w" ] && wiki=1 && shift - local sample="$1" - . $(pwd)/.config.sample - - # libc needs some love - local libc_name="${CT_LIBC}" - local libc_ver="${CT_LIBC_VERSION}" - if [ "${CT_LIBC}" = "uClibc" -a "${CT_LIBC_UCLIBC_NG}" = "y" ]; then - libc_name="uClibc-ng" - elif [ "${CT_LIBC}" = "mingw" ]; then - libc_ver="${CT_WINAPI_VERSION}" - fi - - case "${sample}" in - current) - sample_type="l" - sample="$( ${CT_NG} show-tuple )" - case "${CT_TOOLCHAIN_TYPE}" in - canadian) - sample="${CT_HOST},$sample" - ;; - esac - ;; - *) if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then - sample_top="${CT_TOP_DIR}" - sample_type="L" - else - sample_top="${CT_LIB_DIR}" - sample_type="G" - fi - ;; - esac - if [ ${wiki} -eq 0 ]; then - width=14 - printf "[%s" "${sample_type}" - [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf "." - [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf "." - printf "] %s\n" "${sample}" - if [ ${verbose} -ne 0 ]; then - case "${CT_TOOLCHAIN_TYPE}" in - cross) ;; - canadian) - printf " %-*s : %s\n" ${width} "Host" "${CT_HOST}" - ;; - esac - printf " %-*s : %s\n" ${width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}" - if [ -n "${CT_GMP}" \ - -o -n "${CT_MPFR}" \ - -o -n "${CT_ISL}" \ - -o -n "${CT_CLOOG}" \ - -o -n "${CT_MPC}" \ - -o -n "${CT_LIBELF}" \ - -o -n "${CT_EXPAT}" \ - -o -n "${CT_NCURSES}" \ - -o -n "${CT_GMP_TARGET}" \ - -o -n "${CT_MPFR_TARGET}" \ - -o -n "${CT_ISL_TARGET}" \ - -o -n "${CT_CLOOG_TARGET}" \ - -o -n "${CT_MPC_TARGET}" \ - -o -n "${CT_LIBELF_TARGET}" \ - -o -n "${CT_EXPAT_TARGET}" \ - -o -n "${CT_NCURSES_TARGET}" \ - ]; then - printf " %-*s :" ${width} "Companion libs" - complibs=1 - fi - [ -z "${CT_GMP}" -a -z "${CT_GMP_TARGET}" ] || printf " gmp-%s" "${CT_GMP_VERSION}" - [ -z "${CT_MPFR}" -a -z "${CT_MPFR_TARGET}" ] || printf " mpfr-%s" "${CT_MPFR_VERSION}" - [ -z "${CT_ISL}" -a -z "${CT_ISL_TARGET}" ] || printf " isl-%s" "${CT_ISL_VERSION}" - [ -z "${CT_CLOOG}" -a -z "${CT_CLOOG_TARGET}" ] || printf " cloog-%s" "${CT_CLOOG_VERSION}" - [ -z "${CT_MPC}" -a -z "${CT_MPC_TARGET}" ] || printf " mpc-%s" "${CT_MPC_VERSION}" - [ -z "${CT_LIBELF}" -a -z "${CT_LIBELF_TARGET}" ] || printf " libelf-%s" "${CT_LIBELF_VERSION}" - [ -z "${CT_EXPAT}" -a -z "${CT_EXPAT_TARGET}" ] || printf " expat-%s" "${CT_EXPAT_VERSION}" - [ -z "${CT_NCURSES}" -a -z "${CT_NCURSES_TARGET}" ] || printf " ncurses-%s" "${CT_NCURSES_VERSION}" - [ -z "${complibs}" ] || printf "\n" - printf " %-*s : %s\n" ${width} "binutils" "binutils-${CT_BINUTILS_VERSION}" - printf " %-*s :" ${width} "C compilers" - cc=$(echo ${CT_CC} | ${awk} '{ print toupper($0)}') - version=$(eval echo \${CT_CC_${cc}_VERSION}) - compiler=$(echo $cc | ${awk} '{print tolower($0)}') - printf " $compiler | $version" - 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" - [ "${CT_CC_LANG_ADA}" = "y" ] && printf ",ADA" - [ "${CT_CC_LANG_OBJC}" = "y" ] && printf ",Objective-C" - [ "${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 " %-*s : %s (threads: %s)\n" ${width} "C library" "${libc_name}${libc_ver:+-}${libc_ver}" "${CT_THREADS}" - printf " %-*s :" ${width} "Tools" - [ "${CT_TOOL_sstrip}" ] && printf " sstrip" - [ "${CT_DEBUG_duma}" ] && printf " duma-${CT_DUMA_VERSION}" - [ "${CT_DEBUG_gdb}" ] && printf " gdb-${CT_GDB_VERSION}" - [ "${CT_DEBUG_ltrace}" ] && printf " ltrace-${CT_LTRACE_VERSION}" - [ "${CT_DEBUG_strace}" ] && printf " strace-${CT_STRACE_VERSION}" - printf "\n" - fi - else - case "${CT_TOOLCHAIN_TYPE}" in - cross) - printf "| ''${sample}'' | " - ;; - canadian) - printf "| ''" - printf "${sample}" |${sed} -r -e 's/.*,//' - printf "'' | ${CT_HOST} " - ;; - *) ;; - esac - printf "| " - [ "${CT_EXPERIMENTAL}" = "y" ] && printf "**X**" - [ -f "${sample_top}/samples/${sample}/broken" ] && printf "**B**" - printf " | ''${CT_KERNEL}'' |" - if [ "${CT_KERNEL}" != "bare-metal" ];then - if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then - printf " //custom// " - else - printf " ${CT_KERNEL_VERSION} " - fi - fi - printf "| ${CT_BINUTILS_VERSION} " - printf "| " - cc=$(echo ${CT_CC} | ${awk} '{ print toupper($0)}') - version=$(eval echo \${CT_CC_${cc}_VERSION}) - compiler=$(echo $cc | ${awk} '{print tolower($0)}') - printf " $compiler | $version" - printf " " - printf "| ''${libc_name}'' |" - if [ "${libc_name}" != "none" ]; then - printf " ${libc_ver} " - fi - printf "| ${CT_THREADS:-none} " - printf "| ${CT_ARCH_FLOAT} " - printf "| C" - [ "${CT_CC_LANG_CXX}" = "y" ] && printf ", C++" - [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran" - [ "${CT_CC_LANG_JAVA}" = "y" ] && printf ", Java" - [ "${CT_CC_LANG_ADA}" = "y" ] && printf ", ADA" - [ "${CT_CC_LANG_OBJC}" = "y" ] && printf ", Objective-C" - [ "${CT_CC_LANG_OBJCXX}" = "y" ] && printf ", Objective-C++" - [ -n "${CT_CC_LANG_OTHERS}" ] && printf "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}" - printf " " - ( . "${sample_top}/samples/${sample}/reported.by" - if [ -n "${reporter_name}" ]; then - if [ -n "${reporter_url}" ]; then - printf "| [[${reporter_url}|${reporter_name}]] " - else - printf "| ${reporter_name} " - fi - else - printf "| (//unknown//) " - fi - ) - sample_updated="$( git log -n1 --pretty=format:'%ci' "${sample_top}/samples/${sample}" \ - |${awk} '{ print $1; }' )" - printf "| ${sample_updated} " - echo "|" - fi -} - -if [ "${opt}" = "-w" -a ${#} -eq 0 ]; then - printf "^ %s |||||||||||||||\n" "$( date "+%Y%m%d.%H%M %z" )" - printf "^ Target " - printf "^ Host " - printf "^ Status " - printf "^ Kernel headers\\\\\\\\ version ^" - printf "^ binutils\\\\\\\\ version " - printf "^ C compiler\\\\\\\\ version ^" - printf "^ C library\\\\\\\\ version ^" - printf "^ Threading\\\\\\\\ model " - printf "^ Floating point\\\\\\\\ support " - printf "^ Languages " - printf "^ Initially\\\\\\\\ reported by " - printf "^ Last\\\\\\\\ updated " - echo "^" - exit 0 -elif [ "${opt}" = "-W" ]; then - printf "^ Total: ${#} samples || **X**: sample uses features marked as being EXPERIMENTAL.\\\\\\\\ **B**: sample is currently BROKEN. |||||||||||||" - echo "" - exit 0 -fi - -for sample in "${@}"; do - ( dump_single_sample ${opt} "${sample}" ) -done diff --git a/scripts/upgrade/README b/scripts/upgrade/README new file mode 100644 index 0000000..51760ea --- /dev/null +++ b/scripts/upgrade/README @@ -0,0 +1,23 @@ +Upgrade scripts for specific versions of the config file. +Each script must define a function `upgrade` that can +assume `${opt}` and `${val}` variables set on input. On +output, if `${opt}` is unset - so will be the corresponding +option. + +One thing to keep in mind is that this script may be invoked +on full config - or on a defconfig. Do not assume that all +options will be present! If an option is not specified, use +the value it had as a default for the fallback; to check if +it has been specified, use `$selected_opts` associative +array to check if it has been present in the config file +(otherwise, you an option not being set after sourcing the +previous version of the config is ambiguous - it could be +that the option is called out as `# CT_FOO is not set` (i.e. +selected as false) or not present at all (i.e. selected as +default). + +If it is not possible to determine the settings of an option +because a different controlling option is not set, either +err out (see CT_LIBC_UCLIBC_CUSTOM in v0 for an example) +or select a sane default and issue a warning (see CT_GDB_CUSTOM +in v0 for an example). diff --git a/scripts/upgrade/v0 b/scripts/upgrade/v0 new file mode 100644 index 0000000..68dfca0 --- /dev/null +++ b/scripts/upgrade/v0 @@ -0,0 +1,351 @@ +# vim: set filetype=sh : + +# Upgrade from v0: select Linaro as the vendor if a Linaro version was selected +# (in v0, both GNU and Linaro versions were combined in a single list). GNU is +# the default, leave it to olddefconfig to select it if we don't see a Linaro version. +# We don't depend on CT_xxx_SHOW_LINARO symbols: they just enabled showing Linaro +# versions in that list, but it may have been GNU version that was actually selected. +select_linaro() +{ + if is_set; then + echo "# CT_${1}_USE_GNU is not set" + echo "CT_${1}_USE_LINARO=y" + fi +} + +# Upgrade from version 0 (which is 1.23, as released) to version 1 +# (current state of master as of 2019/01/20). Upgrades in the interim +# versions may be broken. +upgrade() +{ + case "${opt}" in + CT_ARCH_alpha|CT_ARCH_arm|CT_ARCH_avr|CT_ARCH_m68k|CT_ARCH_microblaze|\ + CT_ARCH_mips|CT_ARCH_nios2|CT_ARCH_powerpc|CT_ARCH_s390|CT_ARCH_sh|\ + CT_ARCH_sparc|CT_ARCH_x86|CT_ARCH_xtensa|\ + CT_BINUTILS_binutils|\ + CT_CC_gcc|\ + CT_COMP_TOOLS_autoconf|CT_COMP_TOOLS_automake|CT_COMP_TOOLS_libtool|\ + CT_COMP_TOOLS_m4|CT_COMP_TOOLS_make|\ + CT_DEBUG_duma|CT_DEBUG_gdb|CT_DEBUG_ltrace|CT_DEBUG_strace|\ + CT_KERNEL_bare_metal|CT_KERNEL_linux|CT_KERNEL_windows|\ + CT_LIBC_avr_libc|CT_LIBC_glibc|CT_LIBC_musl|CT_LIBC_newlib|CT_LIBC_none|\ + CT_LIBC_uClibc) + # Renamed to upper-case + replace ${opt^^} + ;; + CT_ARCH_XTENSA_CUSTOM_NAME) + replace CT_OVERLAY_NAME + ;; + CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION) + replace CT_OVERLAY_LOCATION + ;; + CT_LIBC_mingw) + # Renamed to MINGW_W64 + opt=CT_LIBC_MINGW_W64 + ;; + CT_ARCH_*_AVAILABLE|CT_KERNEL_*_AVAILABLE|CT_LIBC_*_AVAILABLE) + # Previously used "backend selectors". Autogenerated, no warning + unset opt + ;; + CT_CONFIGURE_has_*) + # Configure-detected build machine options. Drop, will use current. + unset opt + ;; + CT_*_or_later) + # Automatically selected version constraints. Drop, will auto-select current ones. + unset opt + ;; + CT_BACKEND_ARCH|CT_BACKEND_KERNEL|CT_BACKEND_LIBC|CT_IS_A_BACKEND) + warning "Option ${opt} is no longer supported, dropping" + unset opt + ;; + CT_*_SHOW_LINARO) + # Used to just include Linaro versions into the list. We'll infer whether Linaro is + # actually used from the actual version selected, below. + unset opt + ;; + CT_CC_GCC_4_8|CT_CC_GCC_4_9|CT_CC_GCC_5|CT_CC_GCC_6|\ + CT_LIBC_NEWLIB_2_0|CT_LIBC_NEWLIB_2_1|CT_LIBC_NEWLIB_2_2|CT_LIBC_NEWLIB_2_3|CT_LIBC_NEWLIB_2_4|CT_LIBC_NEWLIB_2_5) + # In 1.23.0, each package had its own ad-hoc version constraints. Drop, new ones + # will be autoselected. + unset opt + ;; + # Custom location: translate to the new framework. No generic way to interpret the version + # string user may have configured; just warn him to select it manually. + CT_BINUTILS_CUSTOM) + warning_if_set "Assuming custom location contains GNU sources; edit the configuration if it was Linaro version" + replace CT_BINUTILS_SRC_CUSTOM + ;; + CT_CC_GCC_CUSTOM) + warning_if_set "Assuming custom location contains GNU sources; edit the configuration if it was Linaro version" + replace CT_GCC_SRC_CUSTOM + ;; + CT_CC_GCC_CUSTOM_LOCATION) + replace CT_GCC_CUSTOM_LOCATION + ;; + CT_ELF2FLT_CUSTOM) + replace CT_ELF2FLT_SRC_CUSTOM + ;; + CT_ELF2FLT_GIT) + if is_set; then + echo "CT_ELF2FLT_SRC_DEVEL=y" + fi + replace CT_ELF2FLT_DEVEL_VCS_git + ;; + CT_ELF2FLT_GIT_CSET) + replace CT_ELF2FLT_DEVEL_REVISION + ;; + CT_GDB_CUSTOM) + warning_if_set "Assuming custom location contains GNU sources; edit the configuration if it was Linaro version" + replace CT_GDB_SRC_CUSTOM + ;; + CT_KERNEL_LINUX_CUSTOM) + replace CT_LINUX_SRC_CUSTOM + ;; + CT_KERNEL_LINUX_CUSTOM_LOCATION) + replace CT_LINUX_CUSTOM_LOCATION + ;; + CT_LIBC_AVR_LIBC_CUSTOM) + replace CT_AVR_LIBC_SRC_CUSTOM + ;; + CT_LIBC_AVR_LIBC_CUSTOM_LOCATION) + replace CT_AVR_LIBC_CUSTOM_LOCATION + ;; + CT_LIBC_GLIBC_CUSTOM) + warning_if_set "Assuming custom location contains GNU sources; edit the configuration if it was Linaro version" + replace CT_GLIBC_SRC_CUSTOM + ;; + CT_LIBC_GLIBC_CUSTOM_LOCATION) + replace CT_GLIBC_CUSTOM_LOCATION + ;; + CT_LIBC_MUSL_CUSTOM) + replace CT_MUSL_SRC_CUSTOM + ;; + CT_LIBC_MUSL_CUSTOM_LOCATION) + replace CT_MUSL_CUSTOM_LOCATION + ;; + CT_LIBC_NEWLIB_CUSTOM) + warning_if_set "Assuming custom location contains GNU sources; edit the configuration if it was Linaro version" + replace CT_NEWLIB_SRC_CUSTOM + ;; + CT_LIBC_NEWLIB_CUSTOM_LOCATION) + replace CT_NEWLIB_CUSTOM_LOCATION + ;; + CT_LIBC_UCLIBC_CUSTOM) + if is_set; then + if [ "${selected_opts[CT_LIBC_UCLIBC_CUSTOM_UCLIBC]+set}" != "set" ]; then + error "This option requires full config file, not defconfig" + elif [ "${CT_LIBC_UCLIBC_CUSTOM_UCLIBC}" = "y" ]; then + replace CT_UCLIBC_USE_UCLIBC_ORG + else + replace CT_UCLIBC_USE_UCLIBC_NG_ORG + fi + fi + ;; + CT_LIBC_UCLIBC_CUSTOM_UCLIBC) + replace CT_UCLIBC_SRC_CUSTOM + ;; + CT_LIBC_UCLIBC_CUSTOM_UCLIBC_NG) + replace CT_UCLIBC_NG_SRC_CUSTOM + ;; + CT_LIBC_UCLIBC_CUSTOM_UCLIBC_NG_OLD) + warning_if_set "uClibc-NG versions before 1.0.15 no longer supported" + replace CT_UCLIBC_NG_SRC_CUSTOM + ;; + CT_LIBC_UCLIBC_CUSTOM_LOCATION) + if [ "${CT_LIBC_UCLIBC_CUSTOM_UCLIBC}" = "y" ]; then + replace CT_UCLIBC_CUSTOM_LOCATION + else + replace CT_UCLIBC_NG_CUSTOM_LOCATION + fi + ;; + CT_WINAPI_V_DEVEL) + replace CT_MINGW_W64_SRC_DEVEL + ;; + CT_WINAPI_V_select) + # Internal selector + unset opt + ;; + CT_BINUTILS_CUSTOM_VERSION|CT_CC_GCC_CUSTOM_VERSION|CT_ELF2FLT_CUSTOM_VERSION|CT_KERNEL_LINUX_CUSTOM_VERSION|\ + CT_LIBC_AVR_LIBC_CUSTOM_VERSION|CT_LIBC_GLIBC_CUSTOM_VERSION|CT_LIBC_MUSL_CUSTOM_VERSION|\ + CT_LIBC_NEWLIB_CUSTOM_VERSION|CT_LIBC_UCLIBC_CUSTOM_VERSION|CT_GDB_CUSTOM_VERSION) + warning_if_set "Cannot automatically convert custom version; edit configuration to select it" + unset opt + ;; + CT_CC_GCC_VERSION|CT_CC_VERSION|CT_KERNEL_VERSION|CT_WINAPI_VERSION|CT_LIBC_VERSION) + # Auto-selected; the symbol was just renamed + unset opt + ;; + CT_LIBC_glibc_family) + # Internal selector, not user-visible + unset opt + ;; + CT_LIBC_ADDONS_LIST) + warning_if_set "Support for custom add-ons has been removed. If using libidn add-on, edit the configuration." + ;; + CT_LIBC_DISABLE_VERSIONING) + replace CT_GLIBC_DISABLE_VERSIONING + ;; + CT_LIBC_ENABLE_FORTIFIED_BUILD) + replace CT_GLIBC_ENABLE_FORTIFIED_BUILD + ;; + CT_LIBC_GLIBC_CONFIGPARMS|CT_LIBC_GLIBC_EXTRA_CFLAGS|CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY|\ + CT_LIBC_GLIBC_FORCE_UNWIND|CT_LIBC_GLIBC_KERNEL_VERSION_AS_HEADERS|CT_LIBC_GLIBC_KERNEL_VERSION_CHOSEN|\ + CT_LIBC_GLIBC_KERNEL_VERSION_NONE|CT_LIBC_GLIBC_MIN_KERNEL|CT_LIBC_GLIBC_MIN_KERNEL_VERSION) + replace CT_GLIBC_${opt#CT_LIBC_GLIBC_} + ;; + CT_LIBC_LOCALES) + replace CT_GLIBC_LOCALES + ;; + CT_LIBC_OLDEST_ABI) + replace CT_GLIBC_OLDEST_ABI + ;; + CT_LIBC_GLIBC_NEEDS_PORTS|CT_LIBC_GLIBC_PORTS_EXTERNAL|CT_LIBC_GLIBC_USE_PORTS) + # Auto-selected + unset opt + ;; + CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA) + warning_if_set "Support for pregenerated locales in uClibc has been removed" + unset opt + ;; + # Trivial version replacements + CT_AUTOMAKE_V_1_11_1) replace CT_AUTOMAKE_V_1_11_6;; + CT_AUTOMAKE_V_1_11_6) replacement_for CT_AUTOMAKE_V_1_11_1;; + CT_AUTOMAKE_V_1_14) replace CT_AUTOMAKE_V_1_14_1;; + CT_AUTOMAKE_V_1_15) replace CT_AUTOMAKE_V_1_15_1;; + CT_BINUTILS_V_2_26) replace CT_BINUTILS_V_2_26_1;; + CT_BINUTILS_V_2_28) replace CT_BINUTILS_V_2_28_1;; + CT_BINUTILS_LINARO_V_2_23_2) select_linaro BINUTILS; replace CT_BINUTILS_LINARO_V_2_23_2_2013_10_4;; + CT_BINUTILS_LINARO_V_2_24) select_linaro BINUTILS; replace CT_BINUTILS_LINARO_V_2_24_0_2014_11_2;; + CT_BINUTILS_LINARO_V_2_25) select_linaro BINUTILS; replace CT_BINUTILS_LINARO_V_2_25_0_2015_01_2;; + CT_CC_GCC_V_4_8_5) replace CT_GCC_V_4_8_5;; + CT_CC_GCC_V_4_9_4) replace CT_GCC_V_4_9_4;; + CT_CC_GCC_V_5_4_0) replace CT_GCC_V_5_5_0;; + CT_CC_GCC_V_6_3_0) replace CT_GCC_V_6_5_0;; + CT_CC_GCC_V_linaro_4_8) select_linaro GCC; replace CT_GCC_LINARO_V_4_8_2015_06;; + CT_CC_GCC_V_linaro_4_9) select_linaro GCC; replace CT_GCC_LINARO_V_4_9_2017_01;; + CT_CC_GCC_V_linaro_5_4) select_linaro GCC; replace CT_GCC_LINARO_V_5_5_2017_10;; + CT_CC_GCC_V_linaro_6_3) select_linaro GCC; replace CT_GCC_LINARO_V_6_4_2018_05;; + CT_CLOOG_V_0_18_0) replace CT_CLOOG_V_0_18_1;; + CT_CLOOG_V_0_18_1) replacement_for CT_CLOOG_V_0_18_0;; + CT_EXPAT_V_2_2_0) replace CT_EXPAT_V_2_2_6;; # 2.2.6 was not available in ct-ng 1.23.0 - no replacement_for + CT_GDB_V_6_8a) replace CT_GDB_V_6_8A;; + CT_GDB_V_7_0a) replace CT_GDB_V_7_0_1A;; + CT_GDB_V_7_0_1a) replace CT_GDB_V_7_0_1A;; + CT_GDB_V_7_1a) replace CT_GDB_V_7_1A;; + CT_GDB_V_7_2a) replace CT_GDB_V_7_2A;; + CT_GDB_V_7_3a) replace CT_GDB_V_7_3A;; + CT_GDB_V_7_4) replace CT_GDB_V_7_4_1;; + CT_GDB_V_7_7) replace CT_GDB_V_7_7_1;; + CT_GDB_V_7_8|CT_GDB_V_7_8_1) replace CT_GDB_V_7_8_2;; + CT_GDB_V_7_8_2) replacement_for CT_GDB_V_7_8 CT_GDB_V_7_8_1;; + CT_GDB_V_7_9) replace CT_GDB_V_7_9_1;; + CT_GDB_V_7_10) replace CT_GDB_V_7_10_1;; + CT_GDB_V_linaro_7_3) select_linaro GDB; replace CT_GDB_LINARO_V_7_3_2011_12;; + CT_GDB_V_linaro_7_4) select_linaro GDB; replace CT_GDB_LINARO_V_7_4_2012_06;; + CT_GDB_V_linaro_7_5) select_linaro GDB; replace CT_GDB_LINARO_V_7_5_2012_12;; + CT_GDB_V_linaro_7_6) select_linaro GDB; replace CT_GDB_LINARO_V_7_6_1_2013_10;; + CT_GDB_V_linaro_7_7) select_linaro GDB; replace CT_GDB_LINARO_V_7_7_1_2014_06_1;; + CT_GDB_V_linaro_7_7_1) select_linaro GDB; replace CT_GDB_LINARO_V_7_7_1_2014_06_1;; + CT_GDB_V_linaro_7_8) select_linaro GDB; replace CT_GDB_LINARO_V_7_8_2014_09;; + CT_GMP_V_4_3_0|CT_GMP_V_4_3_1) replace CT_GMP_V_4_3_2;; + CT_GMP_V_4_3_2) replacement_for CT_GMP_V_4_3_0 CT_GMP_V_4_3_1;; + CT_GMP_V_5_0_1|CT_GMP_V_5_0_2) replace CT_GMP_V_5_0_5;; # 5.0.5 not in ct-ng 1.23.0 + CT_GMP_V_5_1_1) replace CT_GMP_V_5_1_3;; + CT_GMP_V_5_1_3) replacement_for CT_GMP_V_5_1_1;; + CT_GMP_V_6_0_0) replace CT_GMP_V_6_0_0A;; # 6.0.0a not in ct-ng 1.23.0 + CT_GMP_V_6_1_0) replace CT_GMP_V_6_1_2;; + CT_GMP_V_6_1_2) replacement_for CT_GMP_V_6_1_0;; + CT_ISL_V_0_11_1) replace CT_ISL_V_0_11_2;; + CT_ISL_V_0_14) replace CT_ISL_V_0_14_1;; + CT_KERNEL_V_2_6_32|CT_KERNEL_V_2_6_33|CT_KERNEL_V_2_6_34|CT_KERNEL_V_2_6_35|\ + CT_KERNEL_V_2_6_36|CT_KERNEL_V_2_6_37|CT_KERNEL_V_2_6_38|CT_KERNEL_V_2_6_39|\ + CT_KERNEL_V_3_0|CT_KERNEL_V_3_1|CT_KERNEL_V_3_2|CT_KERNEL_V_3_3|CT_KERNEL_V_3_4|CT_KERNEL_V_3_5|\ + CT_KERNEL_V_3_6|CT_KERNEL_V_3_7|CT_KERNEL_V_3_8|CT_KERNEL_V_3_9|CT_KERNEL_V_3_10|CT_KERNEL_V_3_11|\ + CT_KERNEL_V_3_12|CT_KERNEL_V_3_13|CT_KERNEL_V_3_14|CT_KERNEL_V_3_15|CT_KERNEL_V_3_16|\ + CT_KERNEL_V_3_17|CT_KERNEL_V_3_18|CT_KERNEL_V_3_19|\ + CT_KERNEL_V_4_0|CT_KERNEL_V_4_1|CT_KERNEL_V_4_2|CT_KERNEL_V_4_3|CT_KERNEL_V_4_4|\ + CT_KERNEL_V_4_5|CT_KERNEL_V_4_6|CT_KERNEL_V_4_7|CT_KERNEL_V_4_8|CT_KERNEL_V_4_9|CT_KERNEL_V_4_10) + replace CT_LINUX_${opt#CT_KERNEL_};; + CT_LIBC_AVR_LIBC_V_1_8_0) replace CT_AVR_LIBC_V_1_8_1;; + CT_LIBC_AVR_LIBC_V_1_8_1) replace CT_AVR_LIBC_V_1_8_1;; + CT_LIBC_AVR_LIBC_V_2_0_0) replace CT_AVR_LIBC_V_2_0_0;; + CT_LIBC_GLIBC_V_2_12_1|CT_LIBC_GLIBC_V_2_12_2|CT_LIBC_GLIBC_V_2_13|CT_LIBC_GLIBC_V_2_14|\ + CT_LIBC_GLIBC_V_2_14_1|CT_LIBC_GLIBC_V_2_15|CT_LIBC_GLIBC_V_2_16_0|CT_LIBC_GLIBC_V_2_17|\ + CT_LIBC_GLIBC_V_2_18|CT_LIBC_GLIBC_V_2_19|CT_LIBC_GLIBC_V_2_20|CT_LIBC_GLIBC_V_2_21|\ + CT_LIBC_GLIBC_V_2_22|CT_LIBC_GLIBC_V_2_23|CT_LIBC_GLIBC_V_2_24|CT_LIBC_GLIBC_V_2_25) + replace CT_GLIBC_${opt#CT_LIBC_GLIBC_};; + CT_LIBC_GLIBC_LINARO_V_2_20) replace CT_GLIBC_LINARO_V_2_20_2014_11;; + CT_LIBC_MUSL_V_1_1_15|CT_LIBC_MUSL_V_1_1_16) + replace CT_MUSL_${opt#CT_LIBC_MUSL_};; + CT_LIBC_NEWLIB_V_1_17_0|CT_LIBC_NEWLIB_V_1_18_0|CT_LIBC_NEWLIB_V_1_19_0|CT_LIBC_NEWLIB_V_1_20_0|\ + CT_LIBC_NEWLIB_V_2_0_0|CT_LIBC_NEWLIB_V_2_1_0|CT_LIBC_NEWLIB_V_2_2_0|CT_LIBC_NEWLIB_V_2_3_0|\ + CT_LIBC_NEWLIB_V_2_4_0|CT_LIBC_NEWLIB_V_2_5_0) + replace CT_NEWLIB_${opt#CT_LIBC_NEWLIB_};; + CT_LIBC_NEWLIB_LINARO_V_2_1_0) select_linaro NEWLIB; replace CT_NEWLIB_LINARO_V_2_1_0_2014;; + CT_LIBC_NEWLIB_LINARO_V_2_2_0) select_linaro NEWLIB; replace CT_NEWLIB_LINARO_V_2_2_0_2015;; + CT_LIBELF_V_0_8_12) replace CT_LIBELF_V_0_8_13;; + CT_LIBELF_V_0_8_13) replacement_for CT_LIBELF_V_0_8_12;; + CT_M4_V_1_4_13|CT_M4_V_1_4_17) replace CT_M4_V_1_4_18;; + CT_M4_V_1_4_18) replacement_for CT_M4_V_1_4_13 CT_M4_V_1_4_17;; + CT_MPC_V_0_8_1) replace CT_MPC_V_0_8_2;; + CT_MPC_V_0_8_2) replacement_for CT_MPC_V_0_8_1;; + CT_MPC_V_1_0|CT_MPC_V_1_0_1|CT_MPC_V_1_0_2) + replace CT_MPC_V_1_0_3;; + CT_MPC_V_1_0_3) replacement_for CT_MPC_V_1_0 CT_MPC_V_1_0_1 CT_MPC_V_1_0_2;; + CT_MPFR_V_2_4_0|CT_MPFR_V_2_4_1) + replace CT_MPFR_V_2_4_2;; + CT_MPFR_V_2_4_2) replacement_for CT_MPFR_V_2_4_0 CT_MPFR_V_2_4_1;; + CT_MPFR_V_3_0_0) replace CT_MPFR_V_3_0_1;; + CT_MPFR_V_3_0_1) replacement_for CT_MPFR_V_3_0_0;; + CT_MPFR_V_3_1_0|CT_MPFR_V_3_1_2|CT_MPFR_V_3_1_3|CT_MPFR_V_3_1_5) + replace CT_MPFR_V_3_1_6;; + CT_MPFR_V_3_1_6) replacement_for CT_MPFR_V_3_1_0 CT_MPFR_V_3_1_2 CT_MPFR_V_3_1_3 CT_MPFR_V_3_1_5;; + CT_STRACE_V_4_5_18|CT_STRACE_V_4_5_19) + replace CT_STRACE_V_4_5_20;; + CT_STRACE_V_4_5_20) replacement_for CT_STRACE_V_4_5_18 CT_STRACE_V_4_5_19;; + CT_LIBC_UCLIBC_NG_V_1_0_20|CT_LIBC_UCLIBC_NG_V_1_0_21|CT_LIBC_UCLIBC_NG_V_1_0_22) + if is_set; then + echo "CT_UCLIBC_USE_UCLIBC_NG_ORG=y" + fi + replace CT_UCLIBC_NG_V_1_0_25 + ;; + CT_LIBC_UCLIBC_V_0_9_33_2) + if is_set; then + echo "CT_UCLIBC_USE_UCLIBC_ORG=y" + fi + replace CT_UCLIBC_V_0_9_33_2 + ;; + CT_WINAPI_V_2_0_7|CT_WINAPI_V_2_0_7|CT_WINAPI_V_2_0_9) + replace CT_MINGW_W64_V_V2_0_10;; + CT_WINAPI_V_3_0_0) replace CT_MINGW_W64_V_V3_0_0;; + CT_WINAPI_V_3_1_0) replace CT_MINGW_W64_V_V3_1_0;; + CT_WINAPI_V_3_2_0) replace CT_MINGW_W64_V_V3_2_0;; + CT_WINAPI_V_3_3_0) replace CT_MINGW_W64_V_V3_3_0;; + CT_WINAPI_V_4_0_0|CT_WINAPI_V_4_0_1|CT_WINAPI_V_4_0_2|CT_WINAPI_V_4_0_3|\ + CT_WINAPI_V_4_0_4|CT_WINAPI_V_4_0_5|CT_WINAPI_V_4_0_6) + replace CT_MINGW_W64_V_V4_0_6;; + CT_WINAPI_V_5_0_0|CT_WINAPI_V_5_0_1) + replace CT_MINGW_W64_V_V5_0_3;; + + # Misc + CT_CLOOG_NEEDS_AUTORECONF) + # Was unused in 1.23, just drop + unset opt + ;; + CT_PATCH_SINGLE) + # Internal selector in 1.23 + unset opt + ;; + CT_PATCH_BUNDLED_FALLBACK_LOCAL|CT_PATCH_LOCAL_FALLBACK_BUNDLED) + warning_if_set "Fallback patch order has been removed" + ;; + CT_CC_GCC_TARGET_FINAL) + warning_if_set "Option removed" + ;; + CT_COMPLIBS|CT_COMPLIBS_NEEDED|CT_CC_GCC_latest) + # Internal selectors + unset opt + ;; + esac +} diff --git a/scripts/upgrade/v1 b/scripts/upgrade/v1 new file mode 100644 index 0000000..0794722 --- /dev/null +++ b/scripts/upgrade/v1 @@ -0,0 +1,114 @@ +# vim: set filetype=sh : + +# Upgrade v1 -> v2: several packages had their config options renamed +# to leave only the relevant part - so that further upgrades of, say, +# GCC 6.5.0 to 6.6.0 do not result in config changes. +upgrade() +{ + case "${opt}" in + CT_ANDROID_NDK_V_R10E|CT_ANDROID_NDK_V_R11C|CT_ANDROID_NDK_V_R12B|\ + CT_ANDROID_NDK_V_R13B|CT_ANDROID_NDK_V_R14B|CT_ANDROID_NDK_V_R15C|\ + CT_ANDROID_NDK_V_R16B|CT_ANDROID_NDK_V_R17C) + replace "${opt%[A-Z]}" + ;; + CT_AUTOMAKE_V_1_11_6|CT_AUTOMAKE_V_1_14_1|\ + CT_AUTOMAKE_V_1_15_1|CT_AUTOMAKE_V_1_16_1) + replace "${opt%_[0-9]}" + ;; + CT_BINUTILS_LINARO_V_2_23_2_2013_10_4|CT_BINUTILS_LINARO_V_2_24_0_2014_11_2|\ + CT_BINUTILS_LINARO_V_2_25_0_2015_01_2) + replace "${opt%_[0-9]_201[345]*}" + ;; + CT_BINUTILS_V_2_23_2|CT_BINUTILS_V_2_25_1|CT_BINUTILS_V_2_26_1|\ + CT_BINUTILS_V_2_28_1|CT_BINUTILS_V_2_29_1|CT_BINUTILS_V_2_31_1) + replace "${opt%_[0-9]}" + ;; + CT_DTC_V_1_4_7) + replace CT_DTC_V_1_4 + ;; + CT_EXPAT_V_2_1_1|CT_EXPAT_V_2_2_6) + replace "${opt%_[0-9]}" + ;; + CT_GCC_LINARO_V_4_8_2015_06|CT_GCC_LINARO_V_4_9_2017_01) + replace "${opt%_201[57]*}" + ;; + CT_GCC_LINARO_V_5_5_2017_10|CT_GCC_LINARO_V_6_4_2018_05|\ + CT_GCC_LINARO_V_7_3_2018_05) + replace "${opt%_[0-9]_201[78]*}" + ;; + CT_GCC_V_4_8_5|CT_GCC_V_4_9_4) + replace "${opt%_[0-9]}" + ;; + CT_GCC_V_5_5_0|CT_GCC_V_6_5_0|CT_GCC_V_7_4_0|CT_GCC_V_8_2_0) + replace "${opt%_[0-9]_[0-9]}" + ;; + CT_GDB_LINARO_V_7_3_2011_12|CT_GDB_LINARO_V_7_4_2012_06|CT_GDB_LINARO_V_7_5_2012_12|\ + CT_GDB_LINARO_V_7_7_2014_05|CT_GDB_LINARO_V_7_8_2014_09) + replace "${opt%_201[57]*}" + ;; + CT_GDB_LINARO_V_7_6_1_2013_10|CT_GDB_LINARO_V_7_7_1_2014_06_1) + replace "${opt%_[0-9]_201[345]*}" + ;; + + CT_GDB_V_6_8A|CT_GDB_V_7_1A|CT_GDB_V_7_2A) + replace "${opt%A}" + ;; + CT_GDB_V_7_0_1A) + replace CT_GDB_V_7_0 + ;; + CT_GDB_V_7_3_1|CT_GDB_V_7_4_1|CT_GDB_V_7_5_1|CT_GDB_V_7_6_1|CT_GDB_V_7_7_1|\ + CT_GDB_V_7_8_2|CT_GDB_V_7_9_1|CT_GDB_V_7_10_1|CT_GDB_V_7_11_1|CT_GDB_V_7_12_1|\ + CT_GDB_V_8_0_1|CT_GDB_V_8_1_1) + replace "${opt%_[0-9]}" + ;; + CT_GLIBC_LINARO_V_2_20_2014_11) + replace CT_GLIBC_LINARO_V_2_20 + ;; + CT_GMP_V_4_3_2|CT_GMP_V_5_0_5|CT_GMP_V_5_1_3|CT_GMP_V_6_0_0A|CT_GMP_V_6_1_2) + replace "${opt%_[0-9]*}" + ;; + CT_ISL_V_0_11_2|CT_ISL_V_0_12_2|CT_ISL_V_0_14_1|CT_ISL_V_0_16_1|CT_ISL_V_0_17_1) + replace "${opt%_[0-9]}" + ;; + CT_LIBELF_V_0_8_13) + replace CT_LIBELF_V_0_8 + ;; + CT_LIBTOOL_V_2_4_6) + replace CT_LIBTOOL_V_2_4 + ;; + CT_M4_V_1_4_18) + replace CT_M4_V_1_4 + ;; + CT_MAKE_V_4_2_1) + replace CT_MAKE_V_4_2 + ;; + CT_MINGW_W64_V_V2_0_10|CT_MINGW_W64_V_V3_0_0|CT_MINGW_W64_V_V3_1_0|CT_MINGW_W64_V_V3_2_0|\ + CT_MINGW_W64_V_V3_3_0|CT_MINGW_W64_V_V4_0_6|CT_MINGW_W64_V_V5_0_3|CT_MINGW_W64_V_V6_0_0) + replace "${opt%_[0-9]}" + ;; + CT_MPC_V_0_8_2|CT_MPC_V_1_0_3|CT_MPC_V_1_1_0) + replace "${opt%_[0-9]}" + ;; + CT_MPFR_V_2_4_2|CT_MPFR_V_3_0_1|CT_MPFR_V_3_1_6|CT_MPFR_V_4_0_1) + replace "${opt%_[0-9]}" + ;; + CT_NEWLIB_LINARO_V_2_1_0_2014|CT_NEWLIB_LINARO_V_2_2_0_2015) + replace "${opt%_[0-9]_201[345]*}" + ;; + CT_NEWLIB_V_1_17_0|CT_NEWLIB_V_1_18_0|CT_NEWLIB_V_1_19_0|CT_NEWLIB_V_1_20_0|CT_NEWLIB_V_2_0_0|\ + CT_NEWLIB_V_2_1_0|CT_NEWLIB_V_2_2_0|CT_NEWLIB_V_2_3_0|CT_NEWLIB_V_2_4_0|CT_NEWLIB_V_2_5_0|\ + CT_NEWLIB_V_3_0_0) + replace "${opt%_[0-9]}" + ;; + + CT_CLOOG_HAS_WITH_GMP_ISL_OSL|CT_CLOOG_0_18_or_later|CT_CLOOG_0_18_or_older|\ + CT_CLOOG_REQUIRE_0_18_or_later|CT_CLOOG_REQUIRE_0_18_or_older|\ + CT_CLOOG_REQUIRE_later_than_0_18|CT_CLOOG_REQUIRE_older_than_0_18|\ + CT_CLOOG_later_than_0_18|CT_CLOOG_older_than_0_18|CT_GCC_REQUIRE_4_9_2_or_later|\ + CT_GCC_REQUIRE_4_9_2_or_older|CT_GCC_REQUIRE_later_than_4_9_2|\ + CT_GCC_REQUIRE_older_than_4_9_2|CT_GCC_4_9_2_or_later|CT_GCC_4_9_2_or_older|\ + CT_GCC_BUG_61144|CT_GCC_later_than_4_9_2|CT_GCC_older_than_4_9_2) + unset opt # No longer used auto-selectors + ;; + esac +} diff --git a/scripts/upgrade/v2 b/scripts/upgrade/v2 new file mode 100644 index 0000000..afff176 --- /dev/null +++ b/scripts/upgrade/v2 @@ -0,0 +1,25 @@ +# vim: set filetype=sh : + +# Upgrade v2 -> v3: unified build of native gdb and gdbserver, +# combining their options +upgrade() +{ + case "${opt}" in + CT_GDB_GDBSERVER_BUILD_IPA_LIB) + replace CT_GDB_NATIVE_BUILD_IPA_LIB + ;; + CT_GDB_GDBSERVER_STATIC) + if [ "${CT_GDB_GDBSERVER_STATIC}" != "${CT_GDB_GDBSERVER_STATIC}" ]; then + warning "Both native gdb and gdbserver must now be built in the same way" + fi + unset opt + ;; + CT_GDB_GDBSERVER_STATIC_LIBSTDCXX) + replace GDB_NATIVE_STATIC_LIBSTDCXX + ;; + CT_GDB_GDBSERVER_HAS_IPA_LIB) + # not user-selectable + unset opt + ;; + esac +} diff --git a/scripts/upgrade/v3 b/scripts/upgrade/v3 new file mode 100644 index 0000000..1b8fce8 --- /dev/null +++ b/scripts/upgrade/v3 @@ -0,0 +1,12 @@ +# vim: set filetype=sh : + +# Upgrade v3 -> v4: +# - uClibc retired, leaving only uClibc-ng +upgrade() +{ + case "${opt}" in + CT_LIBC_UCLIBC) + replace CT_LIBC_UCLIBC_NG + ;; + esac +} diff --git a/scripts/version-check.sh b/scripts/version-check.sh new file mode 100644 index 0000000..1f4fea4 --- /dev/null +++ b/scripts/version-check.sh @@ -0,0 +1,214 @@ +# This script checks the version of the configuration file and either +# alerts the user about the need to run the upgrade, or attempts to +# perform such an upgrade. + +CFGFILE="${1}" + +. "${CT_LIB_DIR}/scripts/functions" +. "${CFGFILE}" + +# If an old config does not define a version, assume it is 0. This is used +# if we run this script on an old full .config file, not restored from a +# defconfig. +CT_CONFIG_VERSION="${CT_CONFIG_VERSION:-0}" +if [ "${CT_CONFIG_VERSION_CURRENT}" == "${CT_CONFIG_VERSION}" ]; then + # Nothing to do + exit 0 +fi + +if [ -z "${CT_UPGRADECONFIG}" ]; then + if [ "${CT_CONFIG_VERSION}" != "0" ]; then + oldversion="is version ${CT_CONFIG_VERSION}" + else + oldversion="has no version" + fi + cat 2>&1 <<EOF + +Configuration file was generated by an older version of crosstool-NG; +configuration file ${oldversion}; crosstool-NG currently expects +version ${CT_CONFIG_VERSION_CURRENT}. If this configuration file was generated by a crosstool-NG +version 1.23.0 or later, you can run 'ct-ng upgradeconfig'. +Compatibility with previous releases is not guaranteed. In any case, +verify the resulting configuration. + +EOF + if [ "${CT_VCHECK}" = "strict" ]; then + exit 1 + else + exit 0 + fi +fi + +# From now on, we're running actual upgrade, not just a check. Preserve the CT_xxx +# variables that we need using a different prefix so that we can unset the stale +# values at each iteration. +MY_LIB_DIR="${CT_LIB_DIR}" +MY_CONFIG_VERSION_CURRENT="${CT_CONFIG_VERSION_CURRENT}" + +is_set() +{ + if [ "x${val+set}" = "xset" ]; then + return 0 + else + return 1 + fi +} + +info() +{ + # $opt comes from the caller + echo "INFO ${opt:+:: ${opt} }:: $1" >&2 +} + +warning() +{ + # $opt comes from the caller + echo "WARN ${opt:+:: ${opt} }:: $1" >&2 +} + +error() +{ + # $opt comes from the caller + echo " ERR ${opt:+:: ${opt} }:: $1" >&2 + exit 1 +} + +warning_if_set() +{ + if is_set; then + warning "$@" + fi +} + +# When a symbol is replaced with a newer version. If it is a choice and +# the replacement existed in the old version as well, add a replacement_for +# handler for the other symbol to avoid kconfig warnings. +replace() +{ + local newopt="${1}" + + if is_set; then + info "No longer supported; replacing with '${newopt}'". + opt="${newopt}" + else + # Wasn't set; just drop it silently + unset opt + fi +} + +# Avoid multiple definitions for a symbol when multiple old symbols are folded into one +# in a new version. If any of the variable names passed as arguments are set, skip +# emitting this variable (which, presumably, is "not set"). +replacement_for() +{ + while [ -n "${1}" ]; do + if [ -n "${!1}" ]; then + unset opt + return + fi + shift + done +} + +# Helper: takes ${ln} in the caller's environment and sets ${opt} and ${val} +# accordingly. Returns 0 if this line was an option, 1 otherwise. +set_opt_and_val() +{ + case "${ln}" in + CT_*=*) + opt=${ln%%=*} + val=${ln#*=} + case "${val}" in + \"*\") + val="${val%\"}" + val="${val#\"}" + q=\" + ;; + esac + return 0 + ;; + "# CT_"*" is not set") + opt=${ln#* } + opt=${opt%% *} + return 0 + ;; + *) + ;; + esac + return 1 +} + + +# Main upgrade driver. One version at a time, read line by line, interpret +# the options and replace anything that needs replacing. +input="${CFGFILE}" +while :; do + # Purge any possibly stale values + unset "${!CT_@}" + # Reload the next input so that the upgrade function can rely on other CT_xxx variables, + # not just the currently processed variable. + . "${input}" + v=${CT_CONFIG_VERSION:-0} + if [ "${v}" -ge "${MY_CONFIG_VERSION_CURRENT}" ]; then + break + fi + + vn=$[ v + 1 ] + info "Upgrading v${v} to v${vn}" + if [ ! -r "${MY_LIB_DIR}/scripts/upgrade/v${v}" ]; then + error "Missing upgrade script for v${v} of the config file" + fi + unset upgrade + . "${MY_LIB_DIR}/scripts/upgrade/v${v}" + # First pass: read in the whole file and mark the options mentioned; + # it may not be possible to upgrade a defconfig if some non-trivial + # option dependencies need to be resolved. We are not interested in + # values yet. + unset selected_opts + declare -A selected_opts + while read ln; do + if set_opt_and_val; then + selected_opts[${opt}]=1 + fi + done < "${input}" + + # Second pass: actually upgrade the options. + { + while read ln; do + unset opt + unset val + q= + if set_opt_and_val; then + case "${opt}" in + CT_CONFIG_VERSION_CURRENT|CT_CONFIG_VERSION) + continue + ;; + esac + else + echo "${ln}" + fi + upgrade + # Emit the option(s) + if [ x${opt+set} = x ]; then + continue + elif [ x${val+set} = x ]; then + echo "# ${opt} is not set" + else + echo "${opt}=${q}${val}${q}" + fi + done + echo "CT_CONFIG_VERSION=\"${vn}\"" + echo "CT_CONFIG_VERSION_CURRENT=\"${CT_CONFIG_VERSION_CURRENT}\"" + } < "${input}" > "${CFGFILE}.${vn}" + unset opt + v=${vn} + rm -f "${input}" + input="${CFGFILE}.${vn}" + # Ideally, we'd do 'ct-ng olddefconfig' after each step with the appropriate + # Kconfig so that the next step would be able to use auto-set values from the + # previous step. However, that would require us to keep archived config/ trees + # from every config file version, which is not practical. So, I decided to defer + # this until it is actually needed. Even then, it is probably sufficient to only + # keep the versions where there is such a dependency. +done +mv "${CFGFILE}.${MY_CONFIG_VERSION_CURRENT}" "${CFGFILE}" diff --git a/scripts/xldd.in b/scripts/xldd.in index 0e8c0d0..8089426 100644 --- a/scripts/xldd.in +++ b/scripts/xldd.in @@ -16,6 +16,10 @@ fake_load_addr_rpath="$((0xdeadc0de))" fake_load_addr_sysroot="$((0x8badf00d))" ld_library_path="/lib:/usr/lib" +need_e_class= +need_e_flags= +need_e_mach= + do_error() { printf "%s: %s\n" "${my_name}" "$*" >&2 } @@ -42,7 +46,7 @@ ldd (crosstool-NG) ${version} Copyright (C) 2010 "Yann E. MORIN" <yann.morin.1998@free.fr> This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Licensed under the GPLv2, see the file LICENSES in the top-directory of the +Licensed under the GPLv2, see the file LICENSE in the top-directory of the sources for this package. _EOF_ } @@ -200,6 +204,103 @@ do_report_needed_found() { "${sys}" } +# Helper: passed flags and needed flags must either both have +# a given flag set, or neither must have it. +flag_match() { + local flags="${1}" + local e_flags="${2}" + local dso="${3}" + local f + + for f in ${flags}; do + case "${e_flags}:${need_e_flags}" in + *,${f},*:*,${f},*) + # Both have it, continue + ;; + *,${f},*) + # Only one has it + do_trace "-> skip incompatible '%s' (flags '%s', need '%s')" \ + "${dso}" "${e_flags}" "${need_e_flags}" + return 1;; + *) ;; # Neither one has it, continue + esac + done + return 0 +} + +__warned_unknown_machine=no +do_check_compat() { + local file="${1}" + local info e_mach e_class e_flags + local dso + local -a flags + + if [ ! -r "${file}" ]; then + return 1 + fi + info=`${readelf} -Wh "${file}"` + e_class=`echo "${info}" | "${sed}" -nr 's/.*Class:[[:space:]]*//p'` + e_mach=`echo "${info}" | "${sed}" -nr 's/.*Machine:[[:space:]]*//p'` + e_flags=`echo "${info}" | "${sed}" -nr -e 's/$/,/' -e 's/, /,/g' -e 's/.*Flags:[[:space:]]*0x[0-9a-f]{1,}//p'` + dso="${base}${d}/${needed}" + if [ "${e_class}" != "${need_e_class}" ]; then + do_trace "-> skip incompatible '%s' (class '%s', need '%s')\n" \ + "${dso}" "${e_class}" "${need_e_class}" + return 1 + fi + if [ "${e_mach}" != "${need_e_mach}" ]; then + do_trace "-> skip incompatible '%s' (machine '%s', need '%s')\n" \ + "${dso}" "${e_mach}" "${need_e_mach}" + return 1 + fi + + # ElfXX_Ehdr.e_flags is trickier, the rules for compatibility are + # different for different architectures (machines). The logic is + # the same as in elf_machine_matches_host() in GNU libc. + case "${e_mach}" in + AArch64|"Advanced Micro Devices X86-64"|Alpha|ARM|"Intel 80386"|\ + MC68000|"Xilinx MicroBlaze"|"Altera Nios II"|"Renesas / SuperH SH") + # Simple cases: flags are not taken into the account + ;; + "MIPS R3000") + # glibc just rejects "fp64", says it is unsupported on linux. + # but who knows, maybe one day ct-ng will be targeting non-linux too. + if ! flag_match "abi2 nan2008 fp64" "${e_flags}" "${dso}"; then + return 1 + fi + ;; + PowerPC) + # For 32-bit PowerPC, flags not checked. For 64-bit, check ABI version: + # 0 means "not using any features affected by the differences"; v1 and v2 + # are the defined ABI versions. Here we have a different check than glibc: + # in glibc, the dynamic linker checks the ABI compatibility against its own + # ABI while we here check against the binary ABI. Doing it properly requires + # a rework of this script, and the current check seems to work even with a + # trivial "hello world" (it is reported as "abiv1", so apparently no + # applications report 0 as ABI version). + if [ "${e_class}" = "ELF64" ] && ! flag_match "abiv1 abiv2" "${e_flags}" "${dso}"; then + return 1 + fi + ;; + "IBM S/390") + # Dynamic linker checks against the kernel capability for "highgprs" flag + # at runtime, but we cannot do that. Report success. + ;; + Sparc|"Sparc v8+"|"Sparc v9") + # According to glibc sources, even DSOs reporting these different e_machine + # values may be compatible. We currently don't handle that, but might need to. + ;; + *) + # Warn once on an unhandled architecture and assume flags are compatible + if [ "${__warned_unknown_machine}" = "no" ]; then + __warned_unknown_machine=yes + do_error "Architecture ${e_mach} not handled by cross-ldd script; assuming match" + fi + ;; + esac + return 0 +} + # Search a needed file, scanning ${lib_dir} in the root directory do_find_needed() { local needed="${1}" @@ -229,7 +330,7 @@ do_find_needed() { fi for d in "${dirs[@]}"; do do_trace "-> looking in '%s' (%s)\n" "${d}" "${where}" - if [ -f "${base}${d}/${needed}" ]; then + if do_check_compat "${base}${d}/${needed}"; then found="${d}/${needed}" do_trace "---> found\n" break 2 @@ -250,9 +351,11 @@ do_find_needed() { # Scan a file for all NEEDED tags do_process_file() { local file="${1}" + local initial="${2}" local -a save_search_rpath local n m local found + local info do_trace "Parsing file '%s'\n" "${file}" @@ -270,6 +373,17 @@ do_process_file() { done do_trace ": end search path\n" + if [ -n "${initial}" ]; then + if ! "${readelf}" -Wl "${file}" | + "${grep}" 'Requesting program interpreter: ' >/dev/null; then + printf " not a dynamic executable\n" + exit 1 + fi + info=`${readelf} -Wh "${file}"` + need_e_class=`echo "${info}" | "${sed}" -nr 's/.*Class:[[:space:]]*//p'` + need_e_mach=`echo "${info}" | "${sed}" -nr 's/.*Machine:[[:space:]]*//p'` + need_e_flags=`echo "${info}" | "${sed}" -nr -e 's/$/,/' -e 's/, /,/g' -e 's/.*Flags:[[:space:]]*0x[0-9a-f]{1,}//p'` + fi for n in $( "${readelf}" -d "${file}" \ |"${grep}" -E '\(NEEDED\)' \ |"${sed}" -r -e 's/^.*Shared library:[[:space:]]+\[([^]]+)\].*/\1/;' \ @@ -324,6 +438,12 @@ do_scan_etc_ldsoconf() { do_trace "Finished parsing ld.so.conf: '%s'\n" "${ldsoconf}" } +if [ -z "${1}" ]; then + show_help +elif [ ! -r "${1}" ]; then + do_error "${1}: No such file or directory" +fi + # Build up the full list of search directories declare -a needed_search_path do_trace "Adding basic lib dirs\n" @@ -348,5 +468,5 @@ done declare -a needed_list declare -a search_rpath do_trace "Scanning file '%s'\n" "${1}" -do_process_file "${1}" +do_process_file "${1}" initial do_trace "Done scanning file '%s'\n" "${1}" |