From 4e7d0906c1047516ab6517e3abd4a83cba98139d Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 7 Apr 2018 14:39:56 -0700 Subject: Support out-of-tree local builds Signed-off-by: Alexey Neyman diff --git a/ct-ng.in b/ct-ng.in index 926ba71..2331b86 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -17,7 +17,7 @@ export CT_TOP_DIR:=$(shell pwd) ifeq (@enable_local@,yes) # automake does not allow to set pkgxxxdir, they are always derived from # a respective xxxdir. So, for enable-local case, set them directly here. -export CT_LIB_DIR:=$(CT_TOP_DIR) +export CT_LIB_DIR:=$(shell cd "@srcdir@" && pwd) export CT_LIBEXEC_DIR:=$(CT_TOP_DIR)/kconfig export CT_DOC_DIR:=$(CT_TOP_DIR)/docs else diff --git a/scripts/crosstool-NG.sh b/scripts/crosstool-NG.sh index 4d79e48..d4414b5 100644 --- a/scripts/crosstool-NG.sh +++ b/scripts/crosstool-NG.sh @@ -111,7 +111,7 @@ CT_TestOrAbort "The CONFIG_SHELL '${CT_CONFIG_SHELL}' is not valid" -f "${CT_CON CT_TOOLS_OVERRIDE_DIR="${CT_WORK_DIR}/tools" CT_DoLog DEBUG "Creating bin-override for tools in '${CT_TOOLS_OVERRIDE_DIR}'" CT_DoExecLog DEBUG mkdir -p "${CT_TOOLS_OVERRIDE_DIR}/bin" -cat "${CT_LIB_DIR}/paths.sh" |while read trash line; do +cat "${paths_sh_location}" |while read trash line; do tool="${line%%=*}" # Suppress extra quoting eval path=${line#*=} diff --git a/scripts/functions b/scripts/functions index 62966fd..0b8fba5 100644 --- a/scripts/functions +++ b/scripts/functions @@ -985,7 +985,7 @@ CT_GetFile() # Two wrappers to call config.(guess|sub) either from CT_TOP_DIR or CT_LIB_DIR. # Those from CT_TOP_DIR, if they exist, will be be more recent than those from CT_LIB_DIR. CT_DoConfigGuess() { - if [ -x "${CT_TOP_DIR}/scripts/config.guess" ]; then + if [ -r "${CT_TOP_DIR}/scripts/config.guess" ]; then "${CT_CONFIG_SHELL}" "${CT_TOP_DIR}/scripts/config.guess" else "${CT_CONFIG_SHELL}" "${CT_LIB_DIR}/scripts/config.guess" @@ -993,7 +993,7 @@ CT_DoConfigGuess() { } CT_DoConfigSub() { - if [ -x "${CT_TOP_DIR}/scripts/config.sub" ]; then + if [ -r "${CT_TOP_DIR}/scripts/config.sub" ]; then "${CT_CONFIG_SHELL}" "${CT_TOP_DIR}/scripts/config.sub" "$@" else "${CT_CONFIG_SHELL}" "${CT_LIB_DIR}/scripts/config.sub" "$@" @@ -2283,3 +2283,16 @@ CT_GetChoicePkgBuildVersion() eval "component=\${CT_${choice}_CHOICE_KSYM}" CT_GetPkgBuildVersion "${choice}" "${component}" "${var}" } + +# Finally, load paths.sh. For --enable-local build, it is located in +# the current directory (CT_TOP_DIR) while the rest of the scripts are +# in the source directory (CT_LIB_DIR). For other setups, paths.sh +# is in CT_LIB_DIR. +if [ -r "${CT_LIB_DIR}/paths.sh" ]; then + paths_sh_location="${CT_LIB_DIR}/paths.sh" +elif [ -r "${CT_TOP_DIR}/paths.sh" ]; then + paths_sh_location="${CT_TOP_DIR}/paths.sh" +else + CT_Error "Not found: paths.sh" +fi +. "${paths_sh_location}" diff --git a/scripts/saveSample.sh b/scripts/saveSample.sh index 5fab6d9..2f4a10b 100644 --- a/scripts/saveSample.sh +++ b/scripts/saveSample.sh @@ -7,7 +7,6 @@ # - info about who reported the sample # Parse the tools' paths configuration -. "${CT_LIB_DIR}/paths.sh" . "${CT_LIB_DIR}/scripts/functions" CT_LoadConfig diff --git a/scripts/show-config.sh b/scripts/show-config.sh index 9e56f07..7112269 100644 --- a/scripts/show-config.sh +++ b/scripts/show-config.sh @@ -2,7 +2,6 @@ # the versions of the main tools # Use tools discovered by ./configure -. "${CT_LIB_DIR}/paths.sh" . "${CT_LIB_DIR}/scripts/functions" [ "$1" = "-v" ] && opt="$1" && shift diff --git a/scripts/show-tuple.sh b/scripts/show-tuple.sh index 9031b3c..4b0b9b0 100644 --- a/scripts/show-tuple.sh +++ b/scripts/show-tuple.sh @@ -1,9 +1,6 @@ # What we need: # - the .config file -# Parse the tools' paths configuration -. "${CT_LIB_DIR}/paths.sh" - # Parse the common functions . "${CT_LIB_DIR}/scripts/functions" -- cgit v0.10.2-6-g49f6