summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/arch.sh6
-rw-r--r--scripts/build/arch/arm.sh4
-rw-r--r--scripts/build/arch/microblaze.sh15
-rw-r--r--scripts/build/arch/nios2.sh10
-rw-r--r--scripts/build/arch/sh.sh160
-rw-r--r--scripts/build/arch/sparc.sh2
-rw-r--r--scripts/build/arch/x86.sh2
-rw-r--r--scripts/build/arch/xtensa.sh61
-rw-r--r--scripts/build/binutils/binutils.sh51
-rw-r--r--scripts/build/cc.sh58
-rw-r--r--scripts/build/cc/gcc.sh (renamed from scripts/build/cc/100-gcc.sh)96
-rw-r--r--scripts/build/companion_libs/050-zlib.sh10
-rw-r--r--scripts/build/companion_libs/100-gmp.sh13
-rw-r--r--scripts/build/companion_libs/110-mpfr.sh10
-rw-r--r--scripts/build/companion_libs/121-isl.sh12
-rw-r--r--scripts/build/companion_libs/130-cloog.sh14
-rw-r--r--scripts/build/companion_libs/140-mpc.sh9
-rw-r--r--scripts/build/companion_libs/200-libelf.sh10
-rw-r--r--scripts/build/companion_libs/210-expat.sh8
-rw-r--r--scripts/build/companion_libs/220-ncurses.sh10
-rw-r--r--scripts/build/companion_libs/320-libiconv.sh8
-rw-r--r--scripts/build/companion_libs/330-gettext.sh8
-rw-r--r--scripts/build/companion_tools.sh2
-rw-r--r--scripts/build/companion_tools/050-make.sh9
-rw-r--r--scripts/build/companion_tools/100-m4.sh8
-rw-r--r--scripts/build/companion_tools/200-autoconf.sh9
-rw-r--r--scripts/build/companion_tools/300-automake.sh9
-rw-r--r--scripts/build/companion_tools/400-libtool.sh9
-rw-r--r--scripts/build/debug.sh2
-rw-r--r--scripts/build/debug/200-duma.sh19
-rw-r--r--scripts/build/debug/300-gdb.sh38
-rw-r--r--scripts/build/debug/400-ltrace.sh15
-rw-r--r--scripts/build/debug/500-strace.sh10
-rw-r--r--scripts/build/internals.sh11
-rw-r--r--scripts/build/kernel/linux.sh77
-rw-r--r--scripts/build/libc/avr-libc.sh38
-rw-r--r--scripts/build/libc/bionic.sh22
-rw-r--r--scripts/build/libc/glibc.sh251
-rw-r--r--scripts/build/libc/mingw-w64.sh (renamed from scripts/build/libc/mingw.sh)36
-rw-r--r--scripts/build/libc/musl.sh14
-rw-r--r--scripts/build/libc/newlib.sh36
-rw-r--r--scripts/build/libc/uClibc.sh87
-rw-r--r--scripts/build/test_suite.sh3
-rw-r--r--scripts/build/test_suite/gcc.sh2
-rw-r--r--scripts/crosstool-NG.sh.in86
-rw-r--r--scripts/functions1321
-rw-r--r--scripts/saveSample.sh.in4
-rw-r--r--scripts/showSamples.sh33
-rw-r--r--scripts/upgrade.sed25
49 files changed, 1310 insertions, 1443 deletions
diff --git a/scripts/build/arch.sh b/scripts/build/arch.sh
index 5a8d84c..de3e3c9 100644
--- a/scripts/build/arch.sh
+++ b/scripts/build/arch.sh
@@ -22,6 +22,12 @@ 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
# Usage: CT_DoArchUClibcSelectArch <config-file> <architecture>
CT_DoArchUClibcSelectArch() {
diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh
index 8733ac3..7433c92 100644
--- a/scripts/build/arch/arm.sh
+++ b/scripts/build/arch/arm.sh
@@ -15,10 +15,10 @@ CT_DoArchTupleValues() {
# The system part of the tuple:
case "${CT_LIBC},${CT_ARCH_ARM_EABI}" in
- *glibc,y) CT_TARGET_SYS=gnueabi;;
+ glibc,y) CT_TARGET_SYS=gnueabi;;
uClibc,y) CT_TARGET_SYS=uclibc${CT_LIBC_UCLIBC_USE_GNU_SUFFIX:+gnu}eabi;;
musl,y) CT_TARGET_SYS=musleabi;;
- bionic,y) CT_TARGET_SYS=android;;
+ bionic,y) CT_TARGET_SYS=androideabi;;
*,y) CT_TARGET_SYS=eabi;;
esac
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/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/sh.sh b/scripts/build/arch/sh.sh
index 59bc08a..1911b20 100644
--- a/scripts/build/arch/sh.sh
+++ b/scripts/build/arch/sh.sh
@@ -4,36 +4,29 @@ 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
+ # 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() {
@@ -45,13 +38,19 @@ CT_DoArchMultilibList() {
# 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.
+ # 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}"
@@ -59,15 +58,110 @@ CT_DoArchMultilibList() {
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}";;
@@ -81,6 +175,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}"
;;
@@ -90,7 +214,6 @@ CT_DoArchUClibcCflags() {
;;
-m4-nofpu)
CT_KconfigEnableOption "CONFIG_SH4" "${cfg}"
- CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}"
;;
-m4a)
CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}"
@@ -98,8 +221,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 b5f8140..7433c4d 100644
--- a/scripts/build/arch/sparc.sh
+++ b/scripts/build/arch/sparc.sh
@@ -60,7 +60,7 @@ 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
+ 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..471d377 100644
--- a/scripts/build/arch/x86.sh
+++ b/scripts/build/arch/x86.sh
@@ -86,7 +86,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..744bbb2 100644
--- a/scripts/build/arch/xtensa.sh
+++ b/scripts/build/arch/xtensa.sh
@@ -12,67 +12,6 @@ CT_DoArchTupleValues() {
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() {
local cfg="${1}"
diff --git a/scripts/build/binutils/binutils.sh b/scripts/build/binutils/binutils.sh
index f378b4f..703a6fa 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}"
@@ -100,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}"
@@ -181,7 +154,7 @@ do_binutils_backend() {
extra_config+=( --enable-plugins )
fi
if [ "${CT_BINUTILS_HAS_PKGVERSION_BUGURL}" = "y" ]; then
- 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}")
fi
if [ "${CT_MULTILIB}" = "y" ]; then
@@ -207,7 +180,7 @@ do_binutils_backend() {
CXXFLAGS="${cflags}" \
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} \
@@ -215,7 +188,7 @@ 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
@@ -291,7 +264,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} \
@@ -334,7 +307,7 @@ 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_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
fi
if [ "${CT_MULTILIB}" = "y" ]; then
@@ -351,7 +324,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} \
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 2ca8e6f..5430341 100644
--- a/scripts/build/cc/100-gcc.sh
+++ b/scripts/build/cc/gcc.sh
@@ -3,53 +3,32 @@
# 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 ecj ecj-latest .jar $(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
}
@@ -205,7 +184,7 @@ cc_gcc_multilib_housekeeping() {
#------------------------------------------------------------------------------
# Core gcc pass 1
-do_gcc_core_pass_1() {
+do_cc_core_pass_1() {
local -a core_opts
if [ "${CT_CC_CORE_PASS_1_NEEDED}" != "y" ]; then
@@ -231,7 +210,7 @@ do_gcc_core_pass_1() {
}
# Core gcc pass 2
-do_gcc_core_pass_2() {
+do_cc_core_pass_2() {
local -a core_opts
if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then
@@ -254,7 +233,11 @@ do_gcc_core_pass_2() {
# later, we need to build libgcc
case "${CT_THREADS}" in
nptl)
- core_opts+=( "mode=shared" )
+ if [ "${CT_SHARED_LIBS}" = "y" ]; then
+ core_opts+=( "mode=shared" )
+ else
+ core_opts+=( "mode=static" )
+ fi
core_opts+=( "build_libgcc=yes" )
;;
win32)
@@ -371,14 +354,14 @@ do_gcc_core_backend() {
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 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}")
if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
@@ -474,6 +457,18 @@ do_gcc_core_backend() {
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.
+ # Pass-2 should be able to get it from the headers, but for some options
+ # (such as --with-long-double-128) we need to get it right even in pass-1.
+ # GCC expects just two numbers separated by a dot.
+ local glibc_version
+
+ CT_GetPkgVersion GLIBC glibc_version
+ glibc_version=`echo "${glibc_version}" | sed 's/\([1-9][0-9]*\.[1-9][0-9]*\).*/\1/'`
+ extra_config+=("--with-glibc-version=${glibc_version}")
+ fi
+
case "${CT_CC_GCC_LDBL_128}" in
y) extra_config+=("--with-long-double-128");;
m) ;;
@@ -575,13 +570,13 @@ do_gcc_core_backend() {
CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
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}" \
--with-local-prefix="${CT_SYSROOT_DIR}" \
- ${CC_CORE_SYSROOT_ARG} \
+ ${CT_CC_CORE_SYSROOT_ARG} \
"${extra_config[@]}" \
--enable-languages="${lang_list}" \
"${extra_user_config[@]}"
@@ -603,7 +598,7 @@ 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
+ if [ ! -f "${CT_SRC_DIR}/gcc/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
@@ -613,12 +608,12 @@ do_gcc_core_backend() {
CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp all-build-libiberty
fi
# HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
- if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libdecnumber" ]; then
+ if [ -d "${CT_SRC_DIR}/gcc/libdecnumber" ]; then
CT_DoExecLog CFG make ${JOBSFLAGS} configure-libdecnumber
CT_DoExecLog ALL make ${JOBSFLAGS} -C libdecnumber libdecnumber.a
fi
# HACK: gcc-4.8 uses libbacktrace to make libgcc.mvars, so make it here.
- if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libbacktrace" ]; then
+ if [ -d "${CT_SRC_DIR}/gcc/libbacktrace" ]; then
CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace
CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace
fi
@@ -711,7 +706,7 @@ do_gcc_core_backend() {
#------------------------------------------------------------------------------
# Build complete gcc to run on build
-do_gcc_for_build() {
+do_cc_for_build() {
local -a build_final_opts
local build_final_backend
@@ -796,7 +791,7 @@ gcc_movelibs() {
#------------------------------------------------------------------------------
# Build final gcc to run on host
-do_gcc_for_host() {
+do_cc_for_host() {
local -a final_opts
local final_backend
@@ -882,10 +877,13 @@ do_gcc_backend() {
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) ;;
@@ -1121,12 +1119,12 @@ do_gcc_backend() {
CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
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} \
+ ${CT_CC_SYSROOT_ARG} \
"${extra_config[@]}" \
--with-local-prefix="${CT_SYSROOT_DIR}" \
--enable-long-long \
diff --git a/scripts/build/companion_libs/050-zlib.sh b/scripts/build/companion_libs/050-zlib.sh
index a3ba638..868bf3d 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
@@ -87,7 +85,7 @@ do_zlib_backend() {
# 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-${CT_ZLIB_VERSION}/." .
+ cp -av "${CT_SRC_DIR}/zlib/." .
extra_make=( -f win32/Makefile.gcc \
PREFIX="${host}-" \
SHAREDLIB= \
@@ -107,7 +105,7 @@ do_zlib_backend() {
LDFLAGS="${ldflags}" \
CHOST="${host}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/zlib-${CT_ZLIB_VERSION}/configure" \
+ "${CT_SRC_DIR}/zlib/configure" \
--prefix="${prefix}" \
--static \
"${extra_config[@]}"
diff --git a/scripts/build/companion_libs/100-gmp.sh b/scripts/build/companion_libs/100-gmp.sh
index e6a4875..272af66 100644
--- a/scripts/build/companion_libs/100-gmp.sh
+++ b/scripts/build/companion_libs/100-gmp.sh
@@ -13,15 +13,12 @@ if [ "${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
@@ -84,7 +81,9 @@ do_gmp_backend() {
CT_DoLog EXTRA "Configuring GMP"
- if [ ! "${CT_GMP_5_0_2_or_later}" = "y" ]; then
+ # FIXME is it needed even for older versions? They seem to compile fine
+ # without it.
+ if [ "${CT_GMP_HAS_MPBSD}" = "y" ]; then
extra_config+=("--enable-mpbsd")
fi
@@ -95,7 +94,7 @@ do_gmp_backend() {
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}" \
diff --git a/scripts/build/companion_libs/110-mpfr.sh b/scripts/build/companion_libs/110-mpfr.sh
index 5a89077..b4be3f4 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}" \
diff --git a/scripts/build/companion_libs/121-isl.sh b/scripts/build/companion_libs/121-isl.sh
index ef93bbd..d96e9ce 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,12 +84,12 @@ do_isl_backend() {
CT_DoLog EXTRA "Configuring ISL"
- if [ "${CT_ISL_V_0_12_or_later}" != "y" ]; then
+ if [ "${CT_ISL_NEEDS_WITH_GMP}" != "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
+ if [ "${CT_ISL_HAS_WITH_PIPLIB}" != "y" ]; then
extra_config+=("--with-piplib=no")
fi
@@ -100,7 +98,7 @@ do_isl_backend() {
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}" \
diff --git a/scripts/build/companion_libs/130-cloog.sh b/scripts/build/companion_libs/130-cloog.sh
index b21b028..445d259 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,7 +79,7 @@ do_cloog_backend() {
eval "${arg// /\\ }"
done
- if [ "${CT_CLOOG_0_18_or_later}" = y ]; then
+ if [ "${CT_CLOOG_HAS_WITH_GMP_ISL_OSL}" = y ]; then
cloog_opts+=( --with-gmp=system --with-gmp-prefix="${prefix}" )
cloog_opts+=( --with-isl=system --with-isl-prefix="${prefix}" )
cloog_opts+=( --without-osl )
@@ -98,7 +92,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}" \
diff --git a/scripts/build/companion_libs/140-mpc.sh b/scripts/build/companion_libs/140-mpc.sh
index e6efb4f..3136ab4 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}" \
diff --git a/scripts/build/companion_libs/200-libelf.sh b/scripts/build/companion_libs/200-libelf.sh
index 807ce7e..d1ac0b4 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
@@ -131,7 +127,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..dcb7208 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
@@ -95,7 +93,7 @@ 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}" \
diff --git a/scripts/build/companion_libs/220-ncurses.sh b/scripts/build/companion_libs/220-ncurses.sh
index 7a1379d..815cf4b 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
@@ -157,7 +153,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}" \
diff --git a/scripts/build/companion_libs/320-libiconv.sh b/scripts/build/companion_libs/320-libiconv.sh
index f2f0bef..ad571a9 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}" \
diff --git a/scripts/build/companion_libs/330-gettext.sh b/scripts/build/companion_libs/330-gettext.sh
index 8828e5d..f3f1497 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
@@ -112,7 +110,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}" \
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 76b24aa..3253f5b 100644
--- a/scripts/build/companion_tools/050-make.sh
+++ b/scripts/build/companion_tools/050-make.sh
@@ -1,14 +1,11 @@
# Build script for make
do_companion_tools_make_get() {
- CT_GetFile "make-${CT_MAKE_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/make
+ 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}"
+ CT_ExtractPatch MAKE
}
do_companion_tools_make_for_build() {
@@ -61,7 +58,7 @@ do_make_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/make-${CT_MAKE_VERSION}/configure" \
+ "${CT_SRC_DIR}/make/configure" \
--host="${host}" \
--prefix="${prefix}" \
"${extra_config[@]}"
diff --git a/scripts/build/companion_tools/100-m4.sh b/scripts/build/companion_tools/100-m4.sh
index e0fccd7..1707d64 100644
--- a/scripts/build/companion_tools/100-m4.sh
+++ b/scripts/build/companion_tools/100-m4.sh
@@ -1,13 +1,11 @@
# Build script for m4
do_companion_tools_m4_get() {
- CT_GetFile "m4-${CT_M4_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/m4
+ CT_Fetch M4
}
do_companion_tools_m4_extract() {
- CT_Extract "m4-${CT_M4_VERSION}"
- CT_Patch "m4" "${CT_M4_VERSION}"
+ CT_ExtractPatch M4
}
do_companion_tools_m4_for_build() {
@@ -58,7 +56,7 @@ do_m4_backend() {
CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" \
${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..52149ea 100644
--- a/scripts/build/companion_tools/200-autoconf.sh
+++ b/scripts/build/companion_tools/200-autoconf.sh
@@ -1,14 +1,11 @@
# Build script for autoconf
do_companion_tools_autoconf_get() {
- CT_GetFile "autoconf-${CT_AUTOCONF_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/autoconf
+ 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}"
+ CT_ExtractPatch AUTOCONF
}
do_companion_tools_autoconf_for_build() {
@@ -42,7 +39,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..2d7eded 100644
--- a/scripts/build/companion_tools/300-automake.sh
+++ b/scripts/build/companion_tools/300-automake.sh
@@ -1,14 +1,11 @@
# Build script for automake
do_companion_tools_automake_get() {
- CT_GetFile "automake-${CT_AUTOMAKE_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/automake
+ 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}"
+ CT_ExtractPatch AUTOMAKE
}
do_companion_tools_automake_for_build() {
@@ -38,7 +35,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..3733072 100644
--- a/scripts/build/companion_tools/400-libtool.sh
+++ b/scripts/build/companion_tools/400-libtool.sh
@@ -1,14 +1,11 @@
# Build script for libtool
do_companion_tools_libtool_get() {
- CT_GetFile "libtool-${CT_LIBTOOL_VERSION}" \
- {http,ftp,https}://ftp.gnu.org/gnu/libtool
+ 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}"
+ CT_ExtractPatch LIBTOOL
}
do_companion_tools_libtool_for_build() {
@@ -38,7 +35,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/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/200-duma.sh b/scripts/build/debug/200-duma.sh
index 2a9b01f..bd35030 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,7 +13,7 @@ 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=(
diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh
index e5276d0..e3a40d0 100644
--- a/scripts/build/debug/300-gdb.sh
+++ b/scripts/build/debug/300-gdb.sh
@@ -1,40 +1,17 @@
# 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
+ 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
+ CT_ExtractPatch GDB
}
do_debug_gdb_build() {
local -a extra_config
- gdb_src_dir="${CT_SRC_DIR}/gdb-${CT_GDB_VERSION}"
+ gdb_src_dir="${CT_SRC_DIR}/gdb"
# Version 6.3 and below behave badly with gdbmi
case "${CT_GDB_VERSION}" in
@@ -42,7 +19,7 @@ do_debug_gdb_build() {
esac
if [ "${CT_GDB_HAS_PKGVERSION_BUGURL}" = "y" ]; then
- 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}")
fi
@@ -174,11 +151,12 @@ do_debug_gdb_build() {
if [ "${CT_GDB_INSTALL_GDBINIT}" = "y" ]; then
CT_DoLog EXTRA "Installing '.gdbinit' template"
# See in scripts/build/internals.sh for why we do this
- if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then
- gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" )
+ # 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-${CT_CC_GCC_VERSION}/gcc/version.c" \
+ "${CT_SRC_DIR}/gcc/gcc/version.c" \
)
fi
sed -r \
diff --git a/scripts/build/debug/400-ltrace.sh b/scripts/build/debug/400-ltrace.sh
index 6b860e9..ce299c2 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,7 +14,7 @@ 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"
@@ -63,4 +55,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..cb4643a 100644
--- a/scripts/build/debug/500-strace.sh
+++ b/scripts/build/debug/500-strace.sh
@@ -1,15 +1,11 @@
# 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"*
+ CT_Fetch STRACE
}
do_debug_strace_extract() {
- CT_Extract "strace-${CT_STRACE_VERSION}"
- CT_Patch "strace" "${CT_STRACE_VERSION}"
+ CT_ExtractPatch STRACE
}
do_debug_strace_build() {
@@ -23,7 +19,7 @@ do_debug_strace_build() {
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
diff --git a/scripts/build/internals.sh b/scripts/build/internals.sh
index db9b1fd..e407de8 100644
--- a/scripts/build/internals.sh
+++ b/scripts/build/internals.sh
@@ -69,18 +69,19 @@ 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
+ # TBD GCC 3.x/2.x is no longer supported by ctng
+ # 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" )
+ 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-${CT_CC_GCC_VERSION}/gcc/version.c" \
+ "${CT_SRC_DIR}/gcc/gcc/version.c" \
)
fi
for _t in "bin/${CT_TARGET}-"* \
diff --git a/scripts/build/kernel/linux.sh b/scripts/build/kernel/linux.sh
index cd4a456..5ab4918 100644
--- a/scripts/build/kernel/linux.sh
+++ b/scripts/build/kernel/linux.sh
@@ -19,69 +19,26 @@ CT_DoKernelTupleValues() {
# Download the kernel
do_kernel_get() {
- local k_ver
- local custom_name
- local rel_dir
- local korg_base mirror_base
+ 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.
@@ -93,7 +50,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}"
diff --git a/scripts/build/libc/avr-libc.sh b/scripts/build/libc/avr-libc.sh
index f94b601..7003f38 100644
--- a/scripts/build/libc/avr-libc.sh
+++ b/scripts/build/libc/avr-libc.sh
@@ -1,33 +1,11 @@
# 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
+ CT_Fetch AVR_LIBC
}
do_libc_extract() {
- CT_Extract "avr-libc-${CT_LIBC_VERSION}"
- CT_Patch "avr-libc" "${CT_LIBC_VERSION}"
-}
-
-do_libc_configure() {
- CT_DoLog EXTRA "Configuring C library"
-
- CT_DoExecLog CFG \
- ${CONFIG_SHELL} \
- ./configure \
- --build=${CT_BUILD} \
- --host=${CT_TARGET} \
- --prefix=${CT_PREFIX_DIR} \
- "${CT_LIBC_AVR_LIBC_EXTRA_CONFIG_ARRAY[@]}"
+ CT_ExtractPatch AVR_LIBC
}
do_libc_start_files() {
@@ -42,11 +20,19 @@ 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_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 \
+ ${CONFIG_SHELL} \
+ ./configure \
+ --build=${CT_BUILD} \
+ --host=${CT_TARGET} \
+ --prefix=${CT_PREFIX_DIR} \
+ "${CT_LIBC_AVR_LIBC_EXTRA_CONFIG_ARRAY[@]}"
CT_DoLog EXTRA "Building C library"
CT_DoExecLog ALL make ${JOBSFLAGS}
diff --git a/scripts/build/libc/bionic.sh b/scripts/build/libc/bionic.sh
index fcdc57f..027493d 100644
--- a/scripts/build/libc/bionic.sh
+++ b/scripts/build/libc/bionic.sh
@@ -3,37 +3,29 @@
# Licensed under the GPL v2. See COPYING in the root of this package
do_libc_get() {
- if [ "${CT_LIBC_BIONIC_CUSTOM}" = "y" ]; then
- CT_GetCustom "bionic" "${CT_LIBC_BIONIC_CUSTOM_VERSION}" \
- "${CT_LIBC_BIONIC_CUSTOM_LOCATION}"
- else # ! custom location
- CT_GetFile "android-ndk-${CT_LIBC_VERSION}-linux-x86_64.zip" https://dl.google.com/android/repository
- fi # ! custom location
+ CT_Fetch ANDROID_NDK
}
do_libc_extract() {
- CT_Extract "android-ndk-${CT_LIBC_VERSION}-linux-x86_64"
- CT_Pushd "${CT_SRC_DIR}/android-ndk-${CT_LIBC_VERSION}/"
- CT_Patch nochdir bionic "${CT_LIBC_VERSION}"
- CT_Popd
+ CT_ExtractPatch ANDROID_NDK
}
# Install Unified headers
do_libc_start_files() {
CT_DoStep INFO "Installing C library headers"
- CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk-${CT_LIBC_VERSION}/sysroot/usr" "${CT_SYSROOT_DIR}"
+ CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/sysroot/usr" "${CT_SYSROOT_DIR}"
}
do_libc() {
local arch="${CT_ARCH}"
if [ "${CT_ARCH_64}" = "y" ]; then
if [ "${CT_ARCH}" = "x86" ]; then
- arch="${arch}_"
- fi
- arch="${arch}64"
+ arch="${arch}_"
+ fi
+ arch="${arch}64"
fi
CT_DoStep INFO "Installing C library binaries"
- CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk-${CT_LIBC_VERSION}/platforms/android-${CT_ANDROID_API}/arch-${arch}/usr" "${CT_SYSROOT_DIR}"
+ CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/platforms/android-${CT_ANDROID_API}/arch-${arch}/usr" "${CT_SYSROOT_DIR}"
CT_EnvModify CT_TARGET_CFLAGS "${CT_TARGET_CFLAGS} -D__ANDROID_API__=${CT_ANDROID_API}"
}
diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh
index 3eac3ba..3b4b626 100644
--- a/scripts/build/libc/glibc.sh
+++ b/scripts/build/libc/glibc.sh
@@ -5,104 +5,28 @@
do_libc_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
+ 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_GLIBC_PORTS_SRC_DIR}/${CT_GLIBC_PORTS_BASENAME}" \
+ "${CT_GLIBC_SRC_DIR}/${CT_GLIBC_BASENAME}/ports"
+ fi
+ # TBD make the configure timestamp fix in all patched packages (e.g. part of CT_ExtractPatch)
}
# Build and install headers and start files
@@ -161,7 +85,7 @@ do_libc_backend_once() {
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
@@ -204,12 +128,13 @@ do_libc_backend_once() {
# Also, 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)")
@@ -218,24 +143,27 @@ do_libc_backend_once() {
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
@@ -243,7 +171,7 @@ do_libc_backend_once() {
*) extra_config+=("--enable-add-ons=$(do_libc_add_ons_list ,)");;
esac
- 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}")
touch config.cache
@@ -251,25 +179,25 @@ do_libc_backend_once() {
# Hide host C++ binary from configure
echo "ac_cv_prog_ac_ct_CXX=${CT_TARGET}-g++" >>config.cache
- if [ "${CT_LIBC_GLIBC_FORCE_UNWIND}" = "y" ]; then
+ 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"
- 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_GLIBC_EXTRA_CFLAGS}"
glibc_cflags+=" ${multi_flags}"
# Analyze the resulting options for any extra configure switches to throw in.
@@ -283,6 +211,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_!
@@ -336,7 +265,7 @@ 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
case "${CT_ARCH},${CT_ARCH_CPU}" in
@@ -383,42 +312,39 @@ do_libc_backend_once() {
"${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
+ # 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/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
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
@@ -475,7 +401,7 @@ do_libc_backend_once() {
${CT_PREFIX_DIR}/share/doc
fi
- if [ "${CT_LIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then
+ if [ "${CT_GLIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then
do_libc_locales
fi
fi # libc_mode = final
@@ -486,27 +412,28 @@ do_libc_backend_once() {
# Build up the addons list, separated with $1
do_libc_add_ons_list() {
local sep="$1"
- local addons_list="$( echo "${CT_LIBC_ADDONS_LIST}" \
- |sed -r -e "s/[[:space:],]/${sep}/g;" \
- )"
- if [ "${CT_LIBC_GLIBC_2_20_or_later}" != "y" ]; then
- case "${CT_THREADS}" in
- none) ;;
- *) addons_list="${addons_list}${sep}${CT_THREADS}";;
- esac
+ 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
+ if [ "${CT_GLIBC_USE_LIBIDN_ADDON}" = "y" ]; then
+ addons_list="${addons_list}${sep}libidn"
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}\$//;"
+ echo "${addons_list#${sep}}" # Remove leading separator if any
}
# Compute up the minimum supported Linux kernel version
do_libc_min_kernel_config() {
local min_kernel_config
- case "${CT_LIBC_GLIBC_EXTRA_CONFIG_ARRAY[*]}" in
+ 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
@@ -523,9 +450,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
@@ -536,7 +463,7 @@ do_libc_min_kernel_config() {
# Build and install the libc locales
do_libc_locales() {
- local src_dir="${CT_SRC_DIR}/glibc-${CT_LIBC_VERSION}"
+ local src_dir="${CT_SRC_DIR}/glibc"
local -a extra_config
local glibc_cflags
@@ -558,7 +485,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}")
@@ -567,7 +494,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
diff --git a/scripts/build/libc/mingw.sh b/scripts/build/libc/mingw-w64.sh
index 1471785..21afb29 100644
--- a/scripts/build/libc/mingw.sh
+++ b/scripts/build/libc/mingw-w64.sh
@@ -1,29 +1,17 @@
# Copyright 2012 Yann Diorcet
# Licensed under the GPL v2. See COPYING in the root of this package
-CT_WINAPI_VERSION_DOWNLOADED=
-
do_libc_get() {
- 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 DEBUG "Fetched mingw-w64 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_Fetch MINGW_W64
}
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
+ CT_ExtractPatch MINGW_W64
}
do_set_mingw_install_prefix(){
MINGW_INSTALL_PREFIX=/usr/${CT_TARGET}
- if [[ ${CT_WINAPI_VERSION} == 2* ]]; then
+ if [[ ${CT_MINGW_W64_VERSION} == 2* ]]; then
MINGW_INSTALL_PREFIX=/usr
fi
}
@@ -51,7 +39,7 @@ do_libc_start_files() {
do_set_mingw_install_prefix
CT_DoExecLog CFG \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-headers/configure" \
+ "${CT_SRC_DIR}/mingw-w64/mingw-w64-headers/configure" \
--build=${CT_BUILD} \
--host=${CT_TARGET} \
--prefix=${MINGW_INSTALL_PREFIX} \
@@ -75,10 +63,10 @@ do_libc_start_files() {
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 developers."
+ if [ "${CT_MINGW_W64_REQUIRES_W64_VENDOR}" = "y" ]; then
+ 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
@@ -92,7 +80,7 @@ do_mingw_tools()
for f in "${CT_MINGW_TOOL_LIST_ARRAY[@]}"; do
CT_mkdir_pushd "${f}"
- if [ ! -d "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-tools/${f}" ]; then
+ if [ ! -d "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}" ]; then
CT_DoLog WARN "Skipping ${f}: not found"
CT_Popd
continue
@@ -101,7 +89,7 @@ do_mingw_tools()
CT_DoLog EXTRA "Configuring ${f}"
CT_DoExecLog CFG \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-tools/${f}/configure" \
+ "${CT_SRC_DIR}/mingw-w64/mingw-w64-tools/${f}/configure" \
--build=${CT_BUILD} \
--host=${CT_HOST} \
--target=${CT_TARGET} \
@@ -159,7 +147,7 @@ do_mingw_pthreads()
RCFLAGS="${rcflags}" \
DLLTOOLFLAGS="${dlltoolflags}" \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-libraries/winpthreads/configure" \
+ "${CT_SRC_DIR}/mingw-w64/mingw-w64-libraries/winpthreads/configure" \
--with-sysroot=${CT_SYSROOT_DIR} \
--prefix=${MINGW_INSTALL_PREFIX} \
--libdir=${libprefix} \
@@ -189,7 +177,7 @@ do_libc()
do_set_mingw_install_prefix
CT_DoExecLog CFG \
${CONFIG_SHELL} \
- "${CT_SRC_DIR}/mingw-w64-${CT_WINAPI_VERSION_DOWNLOADED}/mingw-w64-crt/configure" \
+ "${CT_SRC_DIR}/mingw-w64/mingw-w64-crt/configure" \
--with-sysroot=${CT_SYSROOT_DIR} \
--prefix=${MINGW_INSTALL_PREFIX} \
--build=${CT_BUILD} \
diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh
index 5a53fd0..430fb8d 100644
--- a/scripts/build/libc/musl.sh
+++ b/scripts/build/libc/musl.sh
@@ -3,17 +3,11 @@
# 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
+ CT_Fetch MUSL
}
do_libc_extract() {
- CT_Extract "musl-${CT_LIBC_VERSION}"
- CT_Patch "musl" "${CT_LIBC_VERSION}"
+ CT_ExtractPatch MUSL
}
# Build and install headers and start files
@@ -62,7 +56,7 @@ do_libc_backend_once() {
local libc_mode
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
@@ -83,7 +77,7 @@ do_libc_backend_once() {
# 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
+ if [ "${CT_GCC_BUG_61144}" = "y" ]; then
extra_cflags+=("-fno-toplevel-reorder")
fi
diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh
index 3b48507..5c4a356 100644
--- a/scripts/build/libc/newlib.sh
+++ b/scripts/build/libc/newlib.sh
@@ -6,44 +6,20 @@
#
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
+ CT_Fetch NEWLIB
}
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
+ CT_ExtractPatch NEWLIB
}
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_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." \
"${CT_HEADERS_DIR}"
- if [ "${CT_ARCH_xtensa}" = "y" ]; then
+ 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
@@ -131,7 +107,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} \
diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh
index a730a1d..599283e 100644
--- a/scripts/build/libc/uClibc.sh
+++ b/scripts/build/libc/uClibc.sh
@@ -2,53 +2,14 @@
# 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
+ CT_Fetch UCLIBC
}
# 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
+ CT_ExtractPatch UCLIBC
}
# Build and install headers and start files
@@ -93,16 +54,19 @@ do_libc_backend_once() {
local -a make_args
local extra_cflags f cfg_cflags cf
local hdr_install_subdir
+ local uclibc_name
for arg in "$@"; do
eval "${arg// /\\ }"
done
- CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'"
+ if [ "${CT_UCLIBC_USE_UCLIBC_NG_ORG}" = "y" ]; then
+ uclibc_name="uClibc-ng"
+ elif [ "${CT_UCLIBC_USE_UCLIBC_ORG}" = "y" ]; then
+ uclibc_name="uClibc"
+ fi
- # 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_name}-${CT_LIBC_VERSION}/." .
+ CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'"
multilib_dir="lib/${multi_os_dir}"
startfiles_dir="${multi_root}/usr/${multilib_dir}"
@@ -122,11 +86,14 @@ do_libc_backend_once() {
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/." .
+
# Force the date of the pregen locale data, as the
# newer ones that are referenced are not available
CT_DoLog EXTRA "Applying configuration"
@@ -257,13 +224,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}"
@@ -323,27 +290,15 @@ 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_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
+ fi
# WCHAR support
if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ]; then
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/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in
index 78b3d0f..cc216f9 100644
--- a/scripts/crosstool-NG.sh.in
+++ b/scripts/crosstool-NG.sh.in
@@ -40,6 +40,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,19 +53,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_TestAndAbort "Don't set CC. It screws up the build." -n "${CC}"
-CT_TestAndAbort "Don't set CXX. It screws up the build." -n "${CXX}"
-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=
@@ -141,9 +143,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"
@@ -158,15 +164,33 @@ CT_PREFIX_DIR="$( ${sed} -r -e 's:/+:/:g; s:/*$::;' <<<"${CT_PREFIX_DIR}" )"
# Put user-supplied flags at the end, so that they take precedence.
CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}"
CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}"
+
+# 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_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"
# Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a
@@ -244,12 +268,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}"
@@ -264,6 +290,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"
@@ -300,9 +327,9 @@ if [ -z "${CT_RESTART}" ]; then
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_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_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!
@@ -316,11 +343,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}"
@@ -525,11 +552,6 @@ 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=
# Override the configured jobs with what's been given on the command line
@@ -597,9 +619,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
@@ -647,7 +667,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/functions b/scripts/functions
index c1b99ce..b8b4913 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -5,7 +5,7 @@
# 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
@@ -23,7 +23,7 @@ CT_LoadConfig() {
. "${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/cc/${CT_CC}.sh"
. "${CT_LIB_DIR}/scripts/build/debug.sh"
. "${CT_LIB_DIR}/scripts/build/test_suite.sh"
@@ -155,8 +155,28 @@ 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 ">>"
@@ -178,7 +198,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.
@@ -200,7 +220,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}"
@@ -283,7 +303,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
)
@@ -298,10 +318,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
@@ -537,18 +571,14 @@ 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}"
-}
+# Create a dir and pushd into it
+# Usage: CT_mkdir_pushd <dir/to/create>
CT_mkdir_pushd() {
local dir="${1}"
@@ -624,9 +654,11 @@ 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"
+ printf ".tar.lz\n"
printf ".tar.bz2\n"
printf ".tar.gz\n.tgz\n"
printf ".tar\n"
@@ -637,25 +669,34 @@ 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
@@ -676,6 +717,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}} \
@@ -696,98 +738,15 @@ 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>
@@ -805,29 +764,34 @@ CT_SaveLocal() {
}
# Download the file from one of the URLs passed as argument
-# Usage: CT_GetFile <basename> [.extension] <url> [url ...]
+# Usage: CT_GetFile <packagename> <basename> <extensions> <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
+ local package="$1"
+ local file="$2"
+ local extensions="$3"
+ shift 3
+
+ # 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}/${file}${ext}" ]; then
+ CT_DoLog DEBUG "Already have '${CT_TARBALLS_DIR}/${file}${ext}'"
+ return 0
+ fi
- # Does it exist localy?
- if CT_GetLocal "${file}" ${first_ext}; then
- return 0
- fi
- # No, it does not...
+ if [ -n "${CT_LOCAL_TARBALLS_DIR}" -a "${CT_FORCE_DOWNLOAD}" != "y" -a \
+ -r "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" ]; then
+ CT_DoLog DEBUG "Got '${file}' from local storage"
+ CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" \
+ "${CT_TARBALLS_DIR}/${file}${ext}"
+ return 0
+ fi
+ done
- # If not allowed to download from the Internet, don't
+ # 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
@@ -839,7 +803,9 @@ CT_GetFile() {
# 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%-*}" )
+ if [ -n "${package}" ]; then
+ URLS+=( "${CT_MIRROR_BASE_URL}/${package}" )
+ fi
URLS+=( "${CT_MIRROR_BASE_URL}" )
fi
@@ -850,451 +816,22 @@ CT_GetFile() {
# 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
+ for ext in ${extensions}; 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"
+ if CT_DoGetFile "${url}/${file}${ext}"; then
CT_SaveLocal "${CT_TARBALLS_DIR}/${file}${ext}"
return 0
fi
done
done
- # Just return error, someone may want to catch and handle the error
- # (eg. glibc add-ons can be missing).
+ # Just return error: CT_DoFetch will check it and will handle it appropriately.
return 1
}
-# 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-}"
- ;;
- *)
- CT_Abort "Version ${version} is not a Linaro package"
- ;;
- 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
-
- if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then
- CT_DoLog WARN "Downloads forbidden, not trying svn retrieval"
- 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}'"
- 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 DEBUG "ref ${ref} at ${url} has cset of ${cset}"
- else
- local cset=${cset_or_ref}
- CT_DoLog DEBUG "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}"
- 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
-
- basename="$1"
- shift
-
- # Check if already extracted
- if [ -e "${CT_SRC_DIR}/.${basename}.extracted" ]; then
- CT_DoLog DEBUG "Already extracted '${basename}'"
- return 0
- fi
-
- 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
-
- # 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"
-
- CT_Popd
-}
-
-# 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"
- 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
-
- # Check if already patched
- if [ -e "${CT_SRC_DIR}/.${pkgdir}.patched" ]; then
- CT_DoLog DEBUG "Already patched '${pkgdir}'"
- return 0
- 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..."
- 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}"
- fi
- done
- if [ "${CT_PATCH_SINGLE}" = "y" ]; then
- break
- 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"
-
- CT_Popd
-}
-
+# 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() {
@@ -1328,23 +865,33 @@ CT_EnvModify() {
# sample saving sequence.
CT_DoBuildTargetTuple() {
# 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
@@ -1379,7 +926,7 @@ CT_DoBuildTargetTuple() {
# 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
+ 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_WITH_ENDIAN
[ "${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}"; }
@@ -1401,6 +948,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}"
@@ -1471,6 +1022,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 [...]]
@@ -1530,26 +1105,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"
@@ -1570,10 +1154,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
@@ -1584,7 +1172,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
@@ -1915,3 +1502,577 @@ CT_MultilibFixupLDSO()
CT_Popd
CT_EndStep
}
+
+# List the download mirrors. Usage:
+# CT_Mirrors ORGANIZATION PROJECT [...]
+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)
+ # TBD move to linux.sh?
+ if [ "${project}" != "linux" ]; then
+ CT_Abort "Unsupported project"
+ fi
+ local version="${CT_LINUX_VERSION}"
+ case "${version}" in
+ '')
+ # Ignore, this happens before .config is fully evaluated
+ ;;
+ [34].*)
+ echo "http://www.kernel.org/pub/linux/kernel/v${version%%.*}.x"
+ ;;
+ 2.6.*)
+ echo "http://www.kernel.org/pub/linux/kernel/v2.6"
+ case "${version}" in
+ 2.6.*.*)
+ echo "http://www.kernel.org/pub/linux/kernel/v2.6/longterm"
+ echo "http://www.kernel.org/pub/linux/kernel/v2.6/longterm/v${version%.*}"
+ ;;
+ esac
+ ;;
+ *)
+ CT_Abort "Unsupported Linux kernel version '${version}'"
+ ;;
+ esac
+ ;;
+ *)
+ CT_Abort "Unknown mirror '${org}'"
+ ;;
+ 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()
+{
+ local version
+
+ 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 version from branch/revision
+ version="${devel_branch//\//_}"
+ version="${version#_}"
+ version="${version%_}"
+ version="${version}-${devel_revision}"
+ unique_id="${version}"
+}
+
+# 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
+ # Mercurial does not allow querying branches
+ 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
+
+ devel_branch="${devel_branch:-master}"
+ if [ -z "${devel_revision}" ]; then
+ local matches=`git ls-remote --exit-code "${devel_url}" --refs "${devel_branch}" \
+ || echo "not found"`
+ 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 ${devel_branch} at ${devel_url}"
+ fi
+ if [ `echo "${matches}" | wc -l` -gt 1 ]; then
+ if echo "${matches}" | grep '[[:space:]]\(refs/heads/\)\?'"${devel_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/\)\?'"${devel_branch}\$"`
+ using="best match"
+ else
+ best=`echo "${matches}" | head -n1`
+ using="first"
+ fi
+ ref=`echo "${best}" | sed 's/.*[[:space:]]//'`
+ CT_DoLog WARN "Ambiguous ref ${devel_branch} at ${devel_url}, using ${using} (${ref})"
+ else
+ best="${matches}"
+ fi
+ devel_revision=`echo "${best}" | cut -c1-8`
+ CT_DoLog DEBUG "ref ${devel_branch} at ${devel_url} has cset of ${devel_revision}"
+ fi
+ unique_id="${devel_revision}"
+}
+
+# Retrieve sources from Git.
+CT_Download_git()
+{
+ # Git does not allow making a shallow clone of a specific commit.
+ CT_DoExecLog ALL git clone "${devel_url}" "${pkg_name}"
+ CT_Pushd "${pkg_name}"
+ CT_DoExecLog ALL git checkout "${devel_revision}" --
+ 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 \
+ src_release mirrors archive_filename archive_dirname archive_formats \
+ src_devel devel_vcs devel_url devel_branch devel_revision devel_subdir devel_bootstrap \
+ src_custom custom_location; do
+ eval "local ${v}=\${CT_${use}_${v^^}}"
+ done
+
+ 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
+
+ ${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 version src_dir; do
+ eval "[ \"\${${v}}\" != \"\${CT_${use}_${v^^}}\" ] || continue"
+ eval "CT_${use}_${v^^}=\${${v}}"
+ eval "CT_DoLog DEBUG \"Override CT_${use}_${v^^}=\${CT_${use}_${v^^}}\""
+ done
+}
+
+# Closure for fetching the sources
+CT_DoFetch()
+{
+ local tmp_dir
+
+ 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
+ if ! CT_GetFile "${pkg_name}" "${archive_filename}" "${archive_formats}" ${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}"
+ version="${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 "${pkg_name}" "${basename}" '.tar.bz2'; then
+ return 0
+ fi
+
+ if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then
+ CT_DoLog WARN "Downloads forbidden, not trying ${devel_vcs} retrieval"
+ return 1
+ fi
+
+ CT_DoLog EXTRA "Retrieving '${basename}' (${devel_vcs} ${devel_url} ${devel_branch} ${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.
+ version="${devel_vcs}-${unique_id}"
+ basename="${pkg_name}-${version}"
+
+ CT_DoExecLog ALL mv "${pkg_name}${devel_subdir:+/${devel_subdir}}" "${basename}"
+ 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}"
+
+ elif [ "${src_custom}" = "y" ]; then
+ # Will be handled during extraction/patching
+ version="local"
+ 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.xz)
+ xz -fdc "${file}" | CT_DoExecLog FILE tar x -v -f - -C "${dir}" ${components}
+ ;;
+ *.tar.lzma)
+ xz -fdc "${file}" | CT_DoExecLog FILE tar x -v -f - -C "${dir}" ${components}
+ ;;
+ *.tar.lz)
+ lzip -fdc "${file}" | CT_DoExecLog FILE tar x -v -f - -C "${dir}" ${components}
+ ;;
+ *.tar.bz2)
+ bzip2 -dc "${file}" | CT_DoExecLog FILE tar x -v -f - -C "${dir}" ${components}
+ ;;
+ *.tar.gz|*.tgz)
+ gzip -dc "${file}" | CT_DoExecLog FILE tar x -v -f - -C "${dir}" ${components}
+ ;;
+ *.tar)
+ CT_DoExecLog FILE tar x -v -f "${file}" -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 local_patch_dir
+ local overlay
+
+ # 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}"
+ ext=`CT_GetFileExtension "${overlay}"`
+ if [ ! -r "${overlay}${ext}" ]; then
+ CT_Abort "Overlay ${overlay} not found"
+ fi
+ CT_Extract "${overlay}${ext}" "${CT_BUILD_DIR}/overlay"
+ 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 \
+ "${CT_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_name}/${version}"
+ local_patch_dir="${CT_LOCAL_PATCH_DIR}/${pkg_name}/${version}"
+
+ case "${CT_PATCH_ORDER}" in
+ bundled) patch_dirs=("${bundled_patch_dir}");;
+ local) patch_dirs=("${local_patch_dir}");;
+ bundled,local) patch_dirs=("${bundled_patch_dir}" "${local_patch_dir}");;
+ local,bundled) patch_dirs=("${local_patch_dir}" "${bundled_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
+
+ 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/copy/overlay 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
+ 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}\""
+}
diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh.in
index d9d999c..5fab6d9 100644
--- a/scripts/saveSample.sh.in
+++ b/scripts/saveSample.sh.in
@@ -72,8 +72,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
diff --git a/scripts/showSamples.sh b/scripts/showSamples.sh
index 1e5d50b..726ea2e 100644
--- a/scripts/showSamples.sh
+++ b/scripts/showSamples.sh
@@ -11,6 +11,9 @@
# GREP_OPTIONS screws things up.
export GREP_OPTIONS=
+# Dummy version which is invoked from .config
+CT_Mirrors() { :; }
+
# Dump a single sample
# Note: we use the specific .config.sample config file
dump_single_sample() {
@@ -23,13 +26,26 @@ dump_single_sample() {
. $(pwd)/.config.sample
# libc needs some love
+ # TBD after conversion of gen-kconfig to template, use CT_LIBC_USE as a selector for other variables
+ # (i.e. whether to use CT_GLIBC_VERSION or CT_MUSL_VERSION)
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
+ local libc_ver ksym
+
+ ksym=${libc_name//[^0-9A-Za-z_]/_}
+ ksym=${ksym^^}
+ case ${ksym} in
+ GLIBC|NEWLIB)
+ if eval "[ \"\${CT_${ksym}_USE_LINARO}\" = y ]"; then
+ ksym="${ksym}_LINARO"
+ fi
+ ;;
+ UCLIBC)
+ if [ "${UCLIBC_NG_USE_UCLIBC_NG_ORG}" = y ]; then
+ ksym="${ksym}_NG"
+ fi
+ ;;
+ esac
+ eval "libc_ver=\"\${CT_${ksym}_VERSION}\""
case "${sample}" in
current)
@@ -63,7 +79,8 @@ dump_single_sample() {
printf " %-*s : %s\n" ${width} "Host" "${CT_HOST}"
;;
esac
- printf " %-*s : %s\n" ${width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}"
+ # TBD currently only Linux is used. General handling for single-select (compiler/binutils/libc/os) and multi-select (debug/companions) components?
+ printf " %-*s : %s\n" ${width} "OS" "${CT_KERNEL}${CT_LINUX_VERSION:+-}${CT_LINUX_VERSION}"
if [ -n "${CT_GMP}" \
-o -n "${CT_MPFR}" \
-o -n "${CT_ISL}" \
@@ -139,7 +156,7 @@ dump_single_sample() {
if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
printf " //custom// "
else
- printf " ${CT_KERNEL_VERSION} "
+ printf " ${CT_LINUX_VERSION} "
fi
fi
printf "| ${CT_BINUTILS_VERSION} "
diff --git a/scripts/upgrade.sed b/scripts/upgrade.sed
new file mode 100644
index 0000000..995b804
--- /dev/null
+++ b/scripts/upgrade.sed
@@ -0,0 +1,25 @@
+# After 1.23.0, generated config options were standardized to upper case
+s/\<CT_ARCH_(alpha|arm|avr|m68k|microblaze|mips|msp430|nios2|powerpc|s390|sh|sparc|x86|xtensa)\>/CT_ARCH_\U\1/g
+s/\<CT_BINUTILS_binutils\>/CT_BINUTILS_BINUTILS/g
+s/\<CT_CC_gcc\>/CT_CC_GCC/g
+s/\<CT_COMP_TOOLS_(autoconf|automake|libtool|m4|make)\>/CT_COMP_TOOLS_\U\1/g
+s/\<CT_DEBUG_(duma|gdb|ltrace|strace)\>/CT_DEBUG_\U\1/g
+s/\<CT_KERNEL_(bare_metal|linux|windows)\>/CT_KERNEL_\U\1/g
+s/\<CT_LIBC_(avr_libc|bionic|glibc|mingw|musl|newlib|none|uClibc)\>/CT_LIBC_\U\1/g
+
+# Also after 1.23.0, package versions were brought to the same format
+s/\<CT_LIBC_BIONIC_V_([0-9a-z]+)\>/CT_ANDROID_NDK_V_R\U\1/g
+s/\<CT_ANDROID_NDK_V_R15BETA1\>/CT_ANDROID_NDK_V_R15B/g
+s/\<CT_LIBC_AVR_LIBC_V_/CT_AVR_LIBC_V_/g
+s/\<CT_CC_GCC_V_/CT_GCC_V_/g
+s/\<CT_LIBC_GLIBC_V_/CT_GLIBC_V_/g
+s/\<CT_KERNEL_V_/CT_LINUX_V_/g
+s/\<CT_WINAPI_V_/CT_MINGW_W64_V_V/g
+s/\<CT_LIBC_MUSL_V_/CT_MUSL_V_/g
+s/\<CT_LIBC_NEWLIB_V_/CT_NEWLIB_V_/g
+s/\<CT_LIBC_UCLIBC_NG_V_/CT_UCLIBC_NG_V_/g
+
+# Special cases that need manual intervention (require setting of supporting options)
+s/\<CT_LIBC_UCLIBC_V_.*/# [&] not handled by upgrade script, use menuconfig./w/dev/stderr
+s/\<CT_[A-Za-z0-9_]*_SHOW_LINARO.*/# [&] not handled by upgrade script, use menuconfig./w/dev/stderr
+s/\<CT_[A-Za-z0-9_]*_CUSTOM_LOCATION.*/# [&] not handled by upgrade script, use menuconfig./w/dev/stderr