summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2016-12-03 03:18:56 (GMT)
committerGitHub <noreply@github.com>2016-12-03 03:18:56 (GMT)
commit4042269de621e166235308f139e89c92e379040d (patch)
tree093329f6412837d89e1e849575a3f1579412802f
parenta787e410dc7133fb371e71161663639e1c0dc89b (diff)
parentbf0d593639d0c9451b13be4965bc6766cc90fed9 (diff)
Merge pull request #487 from stilor/host-comp-tools
Allow for installation of companion tools for host
-rw-r--r--config/companion_tools.in10
-rw-r--r--samples/x86_64-multilib-linux-uclibc,powerpc-unknown-elf/crosstool.config3
-rw-r--r--scripts/build/companion_tools.sh45
-rw-r--r--scripts/build/companion_tools/050-make.sh59
-rw-r--r--scripts/build/companion_tools/100-m4.sh62
-rw-r--r--scripts/build/companion_tools/200-autoconf.sh40
-rw-r--r--scripts/build/companion_tools/300-automake.sh42
-rw-r--r--scripts/build/companion_tools/400-libtool.sh42
-rw-r--r--scripts/crosstool-NG.sh.in19
-rw-r--r--steps.mk2
10 files changed, 263 insertions, 61 deletions
diff --git a/config/companion_tools.in b/config/companion_tools.in
index ece3552..1df9802 100644
--- a/config/companion_tools.in
+++ b/config/companion_tools.in
@@ -24,7 +24,15 @@ config COMP_TOOLS
If your system has older versions, we can build them for you,
but you are strongly encouraged to update your system instead!
-if COMP_TOOLS
+config COMP_TOOLS_FOR_HOST
+ bool
+ prompt "Install companion tools for host"
+ help
+ Enable this option if you want to include the selected companion
+ tools into the final toolchain (rather than just using them
+ to build it).
+
+if COMP_TOOLS || COMP_TOOLS_FOR_HOST
source "config.gen/companion_tools.in"
endif
diff --git a/samples/x86_64-multilib-linux-uclibc,powerpc-unknown-elf/crosstool.config b/samples/x86_64-multilib-linux-uclibc,powerpc-unknown-elf/crosstool.config
index 7728d14..af0e7bd 100644
--- a/samples/x86_64-multilib-linux-uclibc,powerpc-unknown-elf/crosstool.config
+++ b/samples/x86_64-multilib-linux-uclibc,powerpc-unknown-elf/crosstool.config
@@ -9,3 +9,6 @@ CT_BINUTILS_PLUGINS=y
CT_CC_LANG_CXX=y
CT_DEBUG_gdb=y
# CT_GDB_CROSS_PYTHON is not set
+CT_COMP_TOOLS_FOR_HOST=y
+CT_COMP_TOOLS_m4=y
+CT_COMP_TOOLS_make=y
diff --git a/scripts/build/companion_tools.sh b/scripts/build/companion_tools.sh
index b703c41..415f3a2 100644
--- a/scripts/build/companion_tools.sh
+++ b/scripts/build/companion_tools.sh
@@ -7,11 +7,11 @@ for f in "${CT_LIB_DIR}/scripts/build/companion_tools/"*.sh; do
_f="${_f#???-}"
__f="CT_COMP_TOOLS_${_f}"
if [ "${!__f}" = "y" ]; then
- CT_DoLog DEBUG "Enabling companion tools '${_f}'"
+ CT_DoLog DEBUG "Enabling companion tool '${_f}'"
. "${f}"
CT_COMP_TOOLS_FACILITY_LIST="${CT_COMP_TOOLS_FACILITY_LIST} ${_f}"
else
- CT_DoLog DEBUG "Disabling companion tools '${_f}'"
+ CT_DoLog DEBUG "Disabling companion tool '${_f}'"
fi
done
@@ -29,10 +29,45 @@ do_companion_tools_extract() {
done
}
-# Build the companion tools facilities
-do_companion_tools() {
+# Build the companion tools facilities for build
+do_companion_tools_for_build() {
+ # Skip out if:
+ # - native/cross, and companion tools were neither selected
+ # to be built, nor included in the final toolchain
+ # - canadian/cross-native, and companion tools were not
+ # selected to be built
+ case "${CT_TOOLCHAIN_TYPE}" in
+ native|cross)
+ if [ -z "${CT_COMP_TOOLS}${CT_COMP_TOOLS_FOR_HOST}" ]; then
+ return
+ fi
+ ;;
+ canadian|cross-native)
+ if [ -z "${CT_COMP_TOOLS}" ]; then
+ return
+ fi
+ ;;
+ esac
for f in ${CT_COMP_TOOLS_FACILITY_LIST}; do
- do_companion_tools_${f}_build
+ do_companion_tools_${f}_for_build
done
}
+# Build the companion tools facilities for host
+do_companion_tools_for_host() {
+ # For native/cross, build==host, and the tools were built
+ # earlier by do_companion_tools_for_build.
+ case "${CT_TOOLCHAIN_TYPE}" in
+ native|cross)
+ return
+ ;;
+ canadian|cross-native)
+ if [ -z "${CT_COMP_TOOLS_FOR_HOST}" ]; then
+ return
+ fi
+ ;;
+ esac
+ for f in ${CT_COMP_TOOLS_FACILITY_LIST}; do
+ do_companion_tools_${f}_for_host
+ done
+}
diff --git a/scripts/build/companion_tools/050-make.sh b/scripts/build/companion_tools/050-make.sh
index 9458a25..d8f6b66 100644
--- a/scripts/build/companion_tools/050-make.sh
+++ b/scripts/build/companion_tools/050-make.sh
@@ -11,18 +11,57 @@ do_companion_tools_make_extract() {
CT_Patch "make" "${CT_MAKE_VERSION}"
}
-do_companion_tools_make_build() {
- CT_DoStep EXTRA "Installing make"
- mkdir -p "${CT_BUILD_DIR}/build-make"
- CT_Pushd "${CT_BUILD_DIR}/build-make"
-
- CT_DoExecLog CFG "${CT_SRC_DIR}/make-${CT_MAKE_VERSION}/configure" \
- --prefix="${CT_BUILDTOOLS_PREFIX_DIR}"
- CT_DoExecLog ALL make
- CT_DoExecLog ALL make install
+do_companion_tools_make_for_build() {
+ CT_DoStep EXTRA "Installing make for build"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-make-build"
+ do_make_backend \
+ host=${CT_BUILD} \
+ prefix="${CT_BUILD_COMPTOOLS_DIR}" \
+ cflags="${CT_CFLAGS_FOR_BUILD}" \
+ ldflags="${CT_LDFLAGS_FOR_BUILD}"
+ CT_Popd
if [ "${CT_MAKE_GMAKE_SYMLINK}" = "y" ]; then
- CT_DoExecLog ALL ln -sv make "${CT_BUILDTOOLS_PREFIX_DIR}/bin/gmake"
+ CT_DoExecLog ALL ln -sv make "${CT_BUILD_COMPTOOLS_DIR}/bin/gmake"
fi
+ CT_EndStep
+}
+
+do_companion_tools_make_for_host() {
+ CT_DoStep EXTRA "Installing make for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-make-host"
+ do_make_backend \
+ host=${CT_HOST} \
+ prefix="${CT_PREFIX_DIR}" \
+ cflags="${CT_CFLAGS_FOR_HOST}" \
+ ldflags="${CT_LDFLAGS_FOR_HOST}"
CT_Popd
+ if [ "${CT_MAKE_GMAKE_SYMLINK}" = "y" ]; then
+ CT_DoExecLog ALL ln -sv make "${CT_PREFIX_DIR}/bin/gmake"
+ fi
CT_EndStep
}
+
+do_make_backend() {
+ local host
+ local prefix
+ local cflags
+ local ldflags
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoLog EXTRA "Configuring make"
+ CT_DoExecLog CFG \
+ CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
+ "${CT_SRC_DIR}/make-${CT_MAKE_VERSION}/configure" \
+ --host="${host}" \
+ --prefix="${prefix}"
+
+ CT_DoLog EXTRA "Building make"
+ CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing make"
+ CT_DoExecLog ALL make install
+}
diff --git a/scripts/build/companion_tools/100-m4.sh b/scripts/build/companion_tools/100-m4.sh
index 83ab815..96cde39 100644
--- a/scripts/build/companion_tools/100-m4.sh
+++ b/scripts/build/companion_tools/100-m4.sh
@@ -10,16 +10,60 @@ do_companion_tools_m4_extract() {
CT_Patch "m4" "${CT_M4_VERSION}"
}
-do_companion_tools_m4_build() {
- CT_DoStep EXTRA "Installing m4"
- mkdir -p "${CT_BUILD_DIR}/build-m4"
- CT_Pushd "${CT_BUILD_DIR}/build-m4"
-
+do_companion_tools_m4_for_build() {
+ CT_DoStep EXTRA "Installing m4 for build"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-m4-build"
+ do_m4_backend \
+ host=${CT_BUILD} \
+ prefix="${CT_BUILD_COMPTOOLS_DIR}" \
+ cflags="${CT_CFLAGS_FOR_BUILD}" \
+ ldflags="${CT_LDFLAGS_FOR_BUILD}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_companion_tools_m4_for_host() {
+ CT_DoStep EXTRA "Installing m4 for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-m4-host"
+ do_m4_backend \
+ host=${CT_HOST} \
+ prefix="${CT_PREFIX_DIR}" \
+ cflags="${CT_CFLAGS_FOR_HOST}" \
+ ldflags="${CT_LDFLAGS_FOR_HOST}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_m4_backend() {
+ local host
+ local prefix
+ local cflags
+ local ldflags
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ case "${host}" in
+ *-uclibc)
+ # uClibc has posix_spawn in librt, but m4 configure only
+ # searches in libc. This leads to a later failure when
+ # it includes system <spawn.h> but expects a locally-built
+ # posix_spawn().
+ ldflags="${ldflags} -lrt"
+ esac
+
+ CT_DoLog EXTRA "Configuring m4"
CT_DoExecLog CFG \
- "${CT_SRC_DIR}/m4-${CT_M4_VERSION}/configure" \
- --prefix="${CT_BUILDTOOLS_PREFIX_DIR}"
+ CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
+ "${CT_SRC_DIR}/m4-${CT_M4_VERSION}/configure" \
+ --host="${host}" \
+ --prefix="${prefix}"
+
+ CT_DoLog EXTRA "Building m4"
CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing m4"
CT_DoExecLog ALL make install
- CT_Popd
- CT_EndStep
}
diff --git a/scripts/build/companion_tools/200-autoconf.sh b/scripts/build/companion_tools/200-autoconf.sh
index e6e5764..95b7115 100644
--- a/scripts/build/companion_tools/200-autoconf.sh
+++ b/scripts/build/companion_tools/200-autoconf.sh
@@ -11,21 +11,43 @@ do_companion_tools_autoconf_extract() {
CT_Patch "autoconf" "${CT_AUTOCONF_VERSION}"
}
-do_companion_tools_autoconf_build() {
- CT_DoStep EXTRA "Installing autoconf"
- mkdir -p "${CT_BUILD_DIR}/build-autoconf"
- CT_Pushd "${CT_BUILD_DIR}/build-autoconf"
-
+do_companion_tools_autoconf_for_build() {
+ CT_DoStep EXTRA "Installing autoconf for build"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-autoconf-build"
+ do_autoconf_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_companion_tools_autoconf_for_host() {
+ CT_DoStep EXTRA "Installing autoconf for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-autoconf-host"
+ do_autoconf_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_autoconf_backend() {
+ local host
+ local prefix
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
# Ensure configure gets run using the CONFIG_SHELL as configure seems to
# have trouble when CONFIG_SHELL is set and /bin/sh isn't bash
# For reference see:
# http://www.gnu.org/software/autoconf/manual/autoconf.html#CONFIG_005fSHELL
-
+ CT_DoLog EXTRA "Configuring autoconf"
CT_DoExecLog CFG ${CONFIG_SHELL} \
"${CT_SRC_DIR}/autoconf-${CT_AUTOCONF_VERSION}/configure" \
- --prefix="${CT_BUILDTOOLS_PREFIX_DIR}"
+ --host="${host}" \
+ --prefix="${prefix}"
+
+ CT_DoLog EXTRA "Building autoconf"
CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing autoconf"
CT_DoExecLog ALL make install
- CT_Popd
- CT_EndStep
}
diff --git a/scripts/build/companion_tools/300-automake.sh b/scripts/build/companion_tools/300-automake.sh
index 52f62d2..85afaea 100644
--- a/scripts/build/companion_tools/300-automake.sh
+++ b/scripts/build/companion_tools/300-automake.sh
@@ -11,16 +11,38 @@ do_companion_tools_automake_extract() {
CT_Patch "automake" "${CT_AUTOMAKE_VERSION}"
}
-do_companion_tools_automake_build() {
- CT_DoStep EXTRA "Installing automake"
- mkdir -p "${CT_BUILD_DIR}/build-automake"
- CT_Pushd "${CT_BUILD_DIR}/build-automake"
-
- CT_DoExecLog CFG \
- "${CT_SRC_DIR}/automake-${CT_AUTOMAKE_VERSION}/configure" \
- --prefix="${CT_BUILDTOOLS_PREFIX_DIR}"
- CT_DoExecLog ALL make
- CT_DoExecLog ALL make install
+do_companion_tools_automake_for_build() {
+ CT_DoStep EXTRA "Installing automake for build"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-automake-build"
+ do_automake_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}"
CT_Popd
CT_EndStep
}
+
+do_companion_tools_automake_for_host() {
+ CT_DoStep EXTRA "Installing automake for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-automake-host"
+ do_automake_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_automake_backend() {
+ local host
+ local prefix
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoLog EXTRA "Configuring automake"
+ CT_DoExecLog CFG "${CT_SRC_DIR}/automake-${CT_AUTOMAKE_VERSION}/configure" \
+ --host="${host}" \
+ --prefix="${prefix}"
+
+ CT_DoLog EXTRA "Building automake"
+ CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing automake"
+ CT_DoExecLog ALL make install
+}
diff --git a/scripts/build/companion_tools/400-libtool.sh b/scripts/build/companion_tools/400-libtool.sh
index cfe0f63..39aa204 100644
--- a/scripts/build/companion_tools/400-libtool.sh
+++ b/scripts/build/companion_tools/400-libtool.sh
@@ -11,16 +11,38 @@ do_companion_tools_libtool_extract() {
CT_Patch "libtool" "${CT_LIBTOOL_VERSION}"
}
-do_companion_tools_libtool_build() {
- CT_DoStep EXTRA "Installing libtool"
- mkdir -p "${CT_BUILD_DIR}/build-libtool"
- CT_Pushd "${CT_BUILD_DIR}/build-libtool"
-
- CT_DoExecLog CFG \
- "${CT_SRC_DIR}/libtool-${CT_LIBTOOL_VERSION}/configure" \
- --prefix="${CT_BUILDTOOLS_PREFIX_DIR}"
- CT_DoExecLog ALL make
- CT_DoExecLog ALL make install
+do_companion_tools_libtool_for_build() {
+ CT_DoStep EXTRA "Installing libtool for build"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libtool-build"
+ do_libtool_backend host=${CT_BUILD} prefix="${CT_BUILD_COMPTOOLS_DIR}"
CT_Popd
CT_EndStep
}
+
+do_companion_tools_libtool_for_host() {
+ CT_DoStep EXTRA "Installing libtool for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-libtool-host"
+ do_libtool_backend host=${CT_HOST} prefix="${CT_PREFIX_DIR}"
+ CT_Popd
+ CT_EndStep
+}
+
+do_libtool_backend() {
+ local host
+ local prefix
+
+ for arg in "$@"; do
+ eval "${arg// /\\ }"
+ done
+
+ CT_DoLog EXTRA "Configuring libtool"
+ CT_DoExecLog CFG "${CT_SRC_DIR}/libtool-${CT_LIBTOOL_VERSION}/configure" \
+ --host="${host}" \
+ --prefix="${prefix}"
+
+ CT_DoLog EXTRA "Building libtool"
+ CT_DoExecLog ALL make
+
+ CT_DoLog EXTRA "Installing libtool"
+ CT_DoExecLog ALL make install
+}
diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in
index 3d7b91a..063162d 100644
--- a/scripts/crosstool-NG.sh.in
+++ b/scripts/crosstool-NG.sh.in
@@ -185,12 +185,23 @@ CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state"
# sub-dir. So we won't have to save/restore it, not even create it.
# In case of cross or native, host-complibs are used for build-complibs;
# in case of canadian or cross-native, host-complibs are specific
+# Note about BUILD_COMPTOOLS_DIR: if installing companion tools for "host" in
+# a native or simple cross, we can can use the same binaries we built for
+# "build". However, we need companion tools for "build" early - as other
+# components may depend on them - so we may skip building for "host" rather
+# than for "build" in that case.
case "${CT_TOOLCHAIN_TYPE}" in
native|cross)
CT_HOST_COMPLIBS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}"
+ if [ -n "${CT_COMP_TOOLS_FOR_HOST}" ]; then
+ CT_BUILD_COMPTOOLS_DIR="${CT_PREFIX_DIR}"
+ else
+ CT_BUILD_COMPTOOLS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}"
+ fi
;;
canadian|cross-native)
CT_HOST_COMPLIBS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}/complibs-host"
+ CT_BUILD_COMPTOOLS_DIR="${CT_BUILDTOOLS_PREFIX_DIR}"
;;
esac
@@ -580,14 +591,8 @@ if [ -z "${CT_RESTART}" ]; then
CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
fi
- if [ "${CT_COMP_TOOLS}" = "y" ]; then
- CT_DoStep INFO "Extracting, patching and installing companion tools"
- do_companion_tools_extract
- do_companion_tools
- CT_EndStep
- fi
-
CT_DoStep INFO "Extracting and patching toolchain components"
+ do_companion_tools_extract
do_kernel_extract
do_companion_libs_extract
do_binutils_extract
diff --git a/steps.mk b/steps.mk
index 15b9a01..e3c4874 100644
--- a/steps.mk
+++ b/steps.mk
@@ -19,8 +19,10 @@ help-env::
# Please keep the last line with a '\' and keep the following empty line:
# it helps when diffing and merging.
CT_STEPS := \
+ companion_tools_for_build \
companion_libs_for_build \
binutils_for_build \
+ companion_tools_for_host \
companion_libs_for_host \
binutils_for_host \
cc_core_pass_1 \