From 61cbe8676d4b887ce8319dc3ca72545e0df448e3 Mon Sep 17 00:00:00 2001
From: Mick Jordan <mick.jordan@oracle.com>
Date: Wed, 22 Apr 2015 10:46:32 -0700
Subject: [PATCH] refactoring Rscript into two pieces

---
 .hgignore                                     |  1 +
 .../gnur/Makefile.platform                    |  2 +-
 com.oracle.truffle.r.native/run/Makefile      |  8 +++--
 com.oracle.truffle.r.native/run/R.sh          | 27 ++++++++++-----
 com.oracle.truffle.r.native/run/Rscript.sh    | 33 +++++++++++++------
 .../run/Rscript_exec.sh                       | 32 ++++++++++++++++++
 mx.fastr/copyrights/overrides                 |  2 --
 7 files changed, 81 insertions(+), 24 deletions(-)
 create mode 100644 com.oracle.truffle.r.native/run/Rscript_exec.sh

diff --git a/.hgignore b/.hgignore
index 531ede8950..518ecbc357 100644
--- a/.hgignore
+++ b/.hgignore
@@ -96,6 +96,7 @@ com.oracle.truffle.r.native/library/*/lib/*
 com.oracle.truffle.r.native/library/stats/src/fft.c
 com.oracle.truffle.r.native/platform.mk
 com.oracle.truffle.r.native/gnur/Makeconf.done
+com.oracle.truffle.r.native/run/Makeconf.etc
 com.oracle.truffle.r.native/include/jni/include
 com.oracle.truffle.r.native/include/jni/linked
 com.oracle.truffle.r.test.native/packages/*/lib/*
diff --git a/com.oracle.truffle.r.native/gnur/Makefile.platform b/com.oracle.truffle.r.native/gnur/Makefile.platform
index 73079adebd..b8b8a70698 100644
--- a/com.oracle.truffle.r.native/gnur/Makefile.platform
+++ b/com.oracle.truffle.r.native/gnur/Makefile.platform
@@ -33,7 +33,7 @@ all: $(TOPDIR)/platform.mk
 
 $(TOPDIR)/platform.mk: sedMakeconf $(GNUR_HOME)/Makeconf
 	sed -f sedMakeconf $(GNUR_HOME)/Makeconf > /dev/null 2>&1
-	cp platform.mk.temp $(TOPDIR)/run/Makeconf
+	cp platform.mk.temp $(TOPDIR)/run/Makeconf.etc
 	echo OS_NAME = $(OS_NAME) >> platform.mk.temp
 	echo OS_DIR = $(OS_DIR) >> platform.mk.temp
 	mv platform.mk.temp $(TOPDIR)/platform.mk
diff --git a/com.oracle.truffle.r.native/run/Makefile b/com.oracle.truffle.r.native/run/Makefile
index 18f9287940..b2c7ce97a9 100644
--- a/com.oracle.truffle.r.native/run/Makefile
+++ b/com.oracle.truffle.r.native/run/Makefile
@@ -50,15 +50,17 @@ rundirs:
 	
 rcmds: $(FASTR_BINDIR)/R
 
-$(FASTR_BINDIR)/R: Makefile R.sh Rscript.sh
+$(FASTR_BINDIR)/R: Makefile R.sh Rscript.sh Rscript_exec.sh
 	cp R.sh $(FASTR_BINDIR)/exec/R
-	chmod +x $(FASTR_BINDIR)/exec/R
+	cp Rscript_exec.sh $(FASTR_BINDIR)/exec/Rscript
 	cp Rscript.sh $(FASTR_BINDIR)/Rscript
+	chmod +x $(FASTR_BINDIR)/exec/R $(FASTR_BINDIR)/exec/Rscript $(FASTR_BINDIR)/Rscript
 	cp $(SUPPORT_SCRIPTS) $(FASTR_BINDIR)
 	sed -e 's!\(^R_HOME_DIR=\)\(.*\)!\1"$(FASTR_R_HOME)"!' < $(R_SCRIPT) > $(FASTR_BINDIR)/R
 	touch $(FASTR_ETCDIR)/ldpaths
 	cp $(GNUR_HOME)/etc/Renviron $(FASTR_ETCDIR)
-	cp Makeconf $(FASTR_ETCDIR)/Makeconf
+	cp Makeconf.etc $(FASTR_ETCDIR)/Makeconf
 
 clean:
 	rm -rf $(FASTR_BINDIR)
+	rm -f Makeconf.etc
diff --git a/com.oracle.truffle.r.native/run/R.sh b/com.oracle.truffle.r.native/run/R.sh
index 5aeefab240..231d5a85bb 100644
--- a/com.oracle.truffle.r.native/run/R.sh
+++ b/com.oracle.truffle.r.native/run/R.sh
@@ -1,17 +1,28 @@
 #!/bin/bash
 #
-# This material is distributed under the GNU General Public License
-# Version 2. You may review the terms of this license at
-# http://www.gnu.org/licenses/gpl-2.0.html
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
-# Copyright (c) 1995-2015, The R Core Team
-# Copyright (c) 2003, The R Foundation
-# Copyright (c) 2015, Oracle and/or its affiliates
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
 #
-# All rights reserved.
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
 #
 
-# Startup FastR using the mx tool (development)
+# Startup FastR (R) using the mx tool (development)
 # This is exec'ed by the (generic) R script in the parent directory.
 #
 
diff --git a/com.oracle.truffle.r.native/run/Rscript.sh b/com.oracle.truffle.r.native/run/Rscript.sh
index 4ce11bef4e..26c3ba3c48 100755
--- a/com.oracle.truffle.r.native/run/Rscript.sh
+++ b/com.oracle.truffle.r.native/run/Rscript.sh
@@ -1,20 +1,33 @@
 #!/bin/bash
 #
-# This material is distributed under the GNU General Public License
-# Version 2. You may review the terms of this license at
-# http://www.gnu.org/licenses/gpl-2.0.html
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
-# Copyright (c) 1995-2015, The R Core Team
-# Copyright (c) 2003, The R Foundation
-# Copyright (c) 2015, Oracle and/or its affiliates
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
 #
-# All rights reserved.
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
 #
 
-# Fledgling Rscript command to startup FastR
+# In GnuR Rscript is an executable in the bin directory.
+# In FastR Rscript and R are combined in the same image. For consistency
+# Rscript is a script in the bin directory that simply invokes bin/exec/Rscript
 
 source="${BASH_SOURCE[0]}"
 while [ -h "$source" ] ; do source="$(readlink "$source")"; done
-PRIMARY_PATH="$( cd -P "$( dirname "$source" )" && pwd )"/..
+here="$( cd -P "$( dirname "$source" )" && pwd )"
 
-mx --primary-suite-path $PRIMARY_PATH Rscript "$@"
+exec $here/exec/Rscript "$@"
diff --git a/com.oracle.truffle.r.native/run/Rscript_exec.sh b/com.oracle.truffle.r.native/run/Rscript_exec.sh
new file mode 100644
index 0000000000..69517e1185
--- /dev/null
+++ b/com.oracle.truffle.r.native/run/Rscript_exec.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# Startup FastR (Rscript) using the mx tool (development)
+# This is exec'ed by the (generic) Rscript script in the parent directory.
+
+source="${BASH_SOURCE[0]}"
+while [ -h "$source" ] ; do source="$(readlink "$source")"; done
+PRIMARY_PATH="$( cd -P "$( dirname "$source" )" && pwd )"/../..
+
+mx $MX_R_GLOBAL_ARGS --primary-suite-path $PRIMARY_PATH Rscript $MX_R_CMD_ARGS "$@"
diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides
index 819b21ce2e..209469b7e7 100644
--- a/mx.fastr/copyrights/overrides
+++ b/mx.fastr/copyrights/overrides
@@ -22,8 +22,6 @@ com.oracle.truffle.r.native/library/tools/src/tools.h,no.copyright
 com.oracle.truffle.r.native/library/tools/src/init.c,no.copyright
 com.oracle.truffle.r.native/library/utils/src/utils.h,no.copyright
 com.oracle.truffle.r.native/library/utils/src/init.c,no.copyright
-com.oracle.truffle.r.native/run/R.sh,gnu_r_bash.copyright
-com.oracle.truffle.r.native/run/Rscript.sh,gnu_r_bash.copyright
 com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallMatcherNode.java,purdue.copyright
 com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/GroupDispatchNode.java,purdue.copyright
 com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/S3FunctionLookupNode.java,purdue.copyright
-- 
GitLab