Providing parameters to `.` when sourcing is a bashism and not supported
by POSIX shell which causes a build failure when compiling a toolchain
for nvptx-none with dash as /bin/sh.

gen-copyright.sh takes a parameter for the format of copyright notice
required. Switch that to using an environment variable `NVPTX_GEN_COPYRIGHT`,
although this could be changed to a function if desired (just more churn
in gen-copyright.sh then).

gcc/ChangeLog:
        PR target/117854

        * config/nvptx/gen-copyright.sh: Read NVPTX_GEN_COPYRIGHT envvar.
        * config/nvptx/gen-h.sh: Set NVPTX_GEN_COPYRIGHT.
        * config/nvptx/gen-opt.sh: Ditto.
---
Testing it now with a build for nvptx-none. Is this approach OK or
would you prefer the function approach (which will make the diff larger
because of reformatting)?

 gcc/config/nvptx/gen-copyright.sh | 2 +-
 gcc/config/nvptx/gen-h.sh         | 2 +-
 gcc/config/nvptx/gen-opt.sh       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/nvptx/gen-copyright.sh 
b/gcc/config/nvptx/gen-copyright.sh
index d0a86acb832c..b140de0eb76d 100644
--- a/gcc/config/nvptx/gen-copyright.sh
+++ b/gcc/config/nvptx/gen-copyright.sh
@@ -18,7 +18,7 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-style="$1"
+style="${1:-${NVPTX_GEN_COPYRIGHT}}"
 case $style in
     opt)
     ;;
diff --git a/gcc/config/nvptx/gen-h.sh b/gcc/config/nvptx/gen-h.sh
index ea75e127cdeb..beafd5a9d2c4 100644
--- a/gcc/config/nvptx/gen-h.sh
+++ b/gcc/config/nvptx/gen-h.sh
@@ -32,7 +32,7 @@ EOF
 # Separator.
 echo
 
-. $gen_copyright_sh c
+NVPTX_GEN_COPYRIGHT=c . $gen_copyright_sh
 
 # Separator.
 echo
diff --git a/gcc/config/nvptx/gen-opt.sh b/gcc/config/nvptx/gen-opt.sh
index 6022f51f8975..267a5005f66b 100644
--- a/gcc/config/nvptx/gen-opt.sh
+++ b/gcc/config/nvptx/gen-opt.sh
@@ -36,7 +36,7 @@ EOF
 # Separator.
 echo
 
-. $gen_copyright_sh opt
+NVPTX_GEN_COPYRIGHT=opt . $gen_copyright_sh
 
 # Not emitting the following here (in addition to having it in 'nvptx.opt'), as
 # we'll otherwise run into:
-- 
2.47.1

Reply via email to