scripts: fix tools override
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 16 23:36:42 2012 +0100 (2012-01-16)
changeset 2838822af73497bf
parent 2837 db26e387b70b
child 2839 8e8313e40f8a
scripts: fix tools override

The tools found by the new autostuff configure can contain arguments,
for example: grep -E

This needs separating the paths set for the Makfile from the paths
set for the scripts.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
.hgignore
Makefile.in
scripts/addToolVersion.sh
scripts/crosstool-NG.sh.in
scripts/patch-renumber.sh
scripts/saveSample.sh.in
scripts/showSamples.sh
scripts/showTuple.sh.in
     1.1 --- a/.hgignore	Fri Jan 13 12:24:55 2012 +0100
     1.2 +++ b/.hgignore	Mon Jan 16 23:36:42 2012 +0100
     1.3 @@ -10,6 +10,7 @@
     1.4  docs/*ct-ng*.1
     1.5  docs/*ct-ng*.1.gz
     1.6  paths.mk
     1.7 +paths.sh
     1.8  scripts/crosstool-NG.sh
     1.9  scripts/saveSample.sh
    1.10  scripts/showTuple.sh
     2.1 --- a/Makefile.in	Fri Jan 13 12:24:55 2012 +0100
     2.2 +++ b/Makefile.in	Mon Jan 16 23:36:42 2012 +0100
     2.3 @@ -151,8 +151,9 @@
     2.4             scripts/showTuple.sh
     2.5  	@chmod 755 $^
     2.6  
     2.7 -build-lib: paths.mk             \
     2.8 -           config/configure.in
     2.9 +build-lib: config/configure.in  \
    2.10 +           paths.mk             \
    2.11 +           paths.sh
    2.12  
    2.13  build-lib-kconfig:
    2.14  	@$(MAKE) -C kconfig
    2.15 @@ -189,24 +190,36 @@
    2.16  	$(call sed_it)
    2.17  
    2.18  # We create a script fragment that is parseable from inside a Makefile,
    2.19 -# but also from inside a shell script, hence the reason why we don't
    2.20 -# use := to set variables, although that will incur a (very small)
    2.21 -# penalty from the Makefile that includes it (due to re-evaluation at
    2.22 -# each call).
    2.23 +# and one from inside a shell script
    2.24  paths.mk: FORCE
    2.25  	@echo "  GEN    '$@'"
    2.26 -	@(echo "export install=$(install)"; \
    2.27 -	  echo "export bash=$(bash)";       \
    2.28 -	  echo "export grep=$(grep)";       \
    2.29 -	  echo "export make=$(make)";       \
    2.30 -	  echo "export sed=$(sed)";         \
    2.31 -	  echo "export libtool=$(libtool)"; \
    2.32 -	  echo "export libtoolize=$(libtoolize)"; \
    2.33 -	  echo "export objcopy=$(objcopy)"; \
    2.34 -	  echo "export objdump=$(objdump)"; \
    2.35 -	  echo "export readelf=$(readelf)"; \
    2.36 -	  echo "export patch=$(patch)";     \
    2.37 -	 ) >paths.mk
    2.38 +	@(echo 'export install=$(install)';         \
    2.39 +	  echo 'export bash=$(bash)';               \
    2.40 +	  echo 'export grep=$(grep)';               \
    2.41 +	  echo 'export make=$(make)';               \
    2.42 +	  echo 'export sed=$(sed)';                 \
    2.43 +	  echo 'export libtool=$(libtool)';         \
    2.44 +	  echo 'export libtoolize=$(libtoolize)';   \
    2.45 +	  echo 'export objcopy=$(objcopy)';         \
    2.46 +	  echo 'export objdump=$(objdump)';         \
    2.47 +	  echo 'export readelf=$(readelf)';         \
    2.48 +	  echo 'export patch=$(patch)';             \
    2.49 +	 ) >$@
    2.50 +
    2.51 +paths.sh: FORCE
    2.52 +	@echo "  GEN    '$@'"
    2.53 +	@(echo 'export install="$(install)"';       \
    2.54 +	  echo 'export bash="$(bash)"';             \
    2.55 +	  echo 'export grep="$(grep)"';             \
    2.56 +	  echo 'export make="$(make)"';             \
    2.57 +	  echo 'export sed="$(sed)"';               \
    2.58 +	  echo 'export libtool="$(libtool)"';       \
    2.59 +	  echo 'export libtoolize="$(libtoolize)"'; \
    2.60 +	  echo 'export objcopy="$(objcopy)"';       \
    2.61 +	  echo 'export objdump="$(objdump)"';       \
    2.62 +	  echo 'export readelf="$(readelf)"';       \
    2.63 +	  echo 'export patch="$(patch)"';           \
    2.64 +	 ) >$@
    2.65  
    2.66  config/configure.in: FORCE
    2.67  	@echo "  GEN    '$@'"
    2.68 @@ -239,8 +252,8 @@
    2.69  	@rm -f scripts/showTuple.sh
    2.70  
    2.71  clean-lib:
    2.72 -	@echo "  RM     'paths.mk'"
    2.73 -	@rm -f paths.mk
    2.74 +	@echo "  RM     'paths'"
    2.75 +	@rm -f paths.mk paths.sh
    2.76  	@echo "  RM     'config/configure.in'"
    2.77  	@rm -f config/configure.in
    2.78  
    2.79 @@ -304,8 +317,8 @@
    2.80  install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
    2.81  	@echo "  INST    'steps.mk'"
    2.82  	@$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
    2.83 -	@echo "  INST    'paths.mk'"
    2.84 -	@$(install) -m 644 paths.mk "$(DESTDIR)$(libdir)/paths.mk"
    2.85 +	@echo "  INST    'paths'"
    2.86 +	@$(install) -m 644 paths.mk paths.sh "$(DESTDIR)$(libdir)"
    2.87  
    2.88  # Samples need a little love:
    2.89  #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
     3.1 --- a/scripts/addToolVersion.sh	Fri Jan 13 12:24:55 2012 +0100
     3.2 +++ b/scripts/addToolVersion.sh	Mon Jan 16 23:36:42 2012 +0100
     3.3 @@ -7,10 +7,10 @@
     3.4  # Parse the tools' paths configuration
     3.5  # It is expected that this script is only to be run from the
     3.6  # source directory of crosstool-NG, so it is trivial to find
     3.7 -# paths.mk (we can't use  ". paths.mk", as POSIX states that
     3.8 +# paths.sh (we can't use  ". paths.sh", as POSIX states that
     3.9  # $PATH should be searched for, and $PATH most probably doe
    3.10  # not include "."), hence the "./".
    3.11 -. "./paths.mk"
    3.12 +. "./paths.sh"
    3.13  
    3.14  doHelp() {
    3.15      cat <<-EOF
     4.1 --- a/scripts/crosstool-NG.sh.in	Fri Jan 13 12:24:55 2012 +0100
     4.2 +++ b/scripts/crosstool-NG.sh.in	Mon Jan 16 23:36:42 2012 +0100
     4.3 @@ -78,11 +78,13 @@
     4.4  CT_TOOLS_OVERIDE_DIR="${CT_WORK_DIR}/tools"
     4.5  CT_DoLog DEBUG "Creating bin-override for tools in '${CT_TOOLS_OVERIDE_DIR}'"
     4.6  CT_DoExecLog DEBUG mkdir -p "${CT_TOOLS_OVERIDE_DIR}/bin"
     4.7 -cat "${CT_LIB_DIR}/paths.mk" |while read trash line; do
     4.8 +cat "${CT_LIB_DIR}/paths.sh" |while read trash line; do
     4.9      tool="${line%%=*}"
    4.10      path="${line#*=}"
    4.11      CT_DoLog DEBUG "Creating script-override for '${tool}' -> '${path}'"
    4.12 -    printf "#${BANG}${CT_CONFIG_SHELL}\nexec '${path}' \"\${@}\"\n" >"${CT_TOOLS_OVERIDE_DIR}/bin/${tool}"
    4.13 +    # Note: we need to supress the " in the path because
    4.14 +    # there can be arguments in there (thanks autostuff...)
    4.15 +    printf "#${BANG}${CT_CONFIG_SHELL}\nexec ${path//\"/} \"\${@}\"\n" >"${CT_TOOLS_OVERIDE_DIR}/bin/${tool}"
    4.16      CT_DoExecLog ALL chmod 700 "${CT_TOOLS_OVERIDE_DIR}/bin/${tool}"
    4.17  done
    4.18  export PATH="${CT_TOOLS_OVERIDE_DIR}/bin:${PATH}"
     5.1 --- a/scripts/patch-renumber.sh	Fri Jan 13 12:24:55 2012 +0100
     5.2 +++ b/scripts/patch-renumber.sh	Mon Jan 16 23:36:42 2012 +0100
     5.3 @@ -7,10 +7,10 @@
     5.4  # Parse the tools' paths configuration
     5.5  # It is expected that this script is only to be run from the
     5.6  # source directory of crosstool-NG, so it is trivial to find
     5.7 -# paths.mk (we can't use  ". paths.mk", as POSIX states that
     5.8 +# paths.sh (we can't use  ". paths.sh", as POSIX states that
     5.9  # $PATH should be searched for, and $PATH most probably doe
    5.10  # not include "."), hence the "./".
    5.11 -. "./paths.mk"
    5.12 +. "./paths.sh"
    5.13  
    5.14  doUsage() {
    5.15    cat <<_EOF_
     6.1 --- a/scripts/saveSample.sh.in	Fri Jan 13 12:24:55 2012 +0100
     6.2 +++ b/scripts/saveSample.sh.in	Mon Jan 16 23:36:42 2012 +0100
     6.3 @@ -9,7 +9,7 @@
     6.4  #  - info about who reported the sample
     6.5  
     6.6  # Parse the tools' paths configuration
     6.7 -. "${CT_LIB_DIR}/paths.mk"
     6.8 +. "${CT_LIB_DIR}/paths.sh"
     6.9  
    6.10  # We'll need the stdout later, save it
    6.11  exec 7>&1
     7.1 --- a/scripts/showSamples.sh	Fri Jan 13 12:24:55 2012 +0100
     7.2 +++ b/scripts/showSamples.sh	Mon Jan 16 23:36:42 2012 +0100
     7.3 @@ -5,7 +5,7 @@
     7.4  # the versions of the main tools
     7.5  
     7.6  # Use tools discovered by ./configure
     7.7 -. "${CT_LIB_DIR}/paths.mk"
     7.8 +. "${CT_LIB_DIR}/paths.sh"
     7.9  
    7.10  [ "$1" = "-v" ] && opt="$1" && shift
    7.11  [ "$1" = "-w" ] && opt="$1" && shift
     8.1 --- a/scripts/showTuple.sh.in	Fri Jan 13 12:24:55 2012 +0100
     8.2 +++ b/scripts/showTuple.sh.in	Mon Jan 16 23:36:42 2012 +0100
     8.3 @@ -4,7 +4,7 @@
     8.4  #  - the .config file
     8.5  
     8.6  # Parse the tools' paths configuration
     8.7 -. "${CT_LIB_DIR}/paths.mk"
     8.8 +. "${CT_LIB_DIR}/paths.sh"
     8.9  
    8.10  # We'll need the stdout later, save it
    8.11  exec 7>&1