# HG changeset patch
# User John Donoghue
# Date 1530811252 14400
#      Thu Jul 05 13:20:52 2018 -0400
# Node ID a94168bc3578f9c8c00c817683052a51d7214b1d
# Parent  9feff7f3b0132e43e5556877e515ad9a09bb1c2e
use .bat file for octave.exe/octave-version.exe (Bug #53938)

* binary-dist-rules.mk: in windows, remove octave.exe and octave-version.exe
  and replace with octave.bat, copied to bin dir

* installer-files/octave.bat: update path finding with .bat file in /bin instead of /

* tools/makeinst-script.sh.in: remove octave.bat from toplevel of installer,
  look for octave-cli.exe not octave.exe in prev installed check

diff -r 9feff7f3b013 -r a94168bc3578 binary-dist-rules.mk
--- a/binary-dist-rules.mk	Thu Jul 05 07:50:24 2018 -0400
+++ b/binary-dist-rules.mk	Thu Jul 05 13:20:52 2018 -0400
@@ -89,11 +89,16 @@
       cp $(TOP_DIR)/installer-files/README.html $(OCTAVE_DIST_DIR)/
       echo "  refblas..."
       cp $(OCTAVE_DIST_DIR)/bin/libblas.dll $(OCTAVE_DIST_DIR)/bin/librefblas.dll
-      echo "  octave.bat..."
-      cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/
+      echo "  octave.vbs..."
       cp $(TOP_DIR)/installer-files/octave.vbs $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/octave-firsttime.vbs $(OCTAVE_DIST_DIR)/
+      cp $(TOP_DIR)/installer-files/fc_update.bat $(OCTAVE_DIST_DIR)/
       cp $(TOP_BUILD_DIR)/HG-ID $(OCTAVE_DIST_DIR)/
+      echo "  updating octave .exe to script files..."
+      rm -f $(OCTAVE_DIST_DIR)/bin/octave.exe
+      rm -f $(OCTAVE_DIST_DIR)/bin/octave-$($(OCTAVE_TARGET)_VERSION).exe
+      cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/bin/octave.bat
+      cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/bin/octave-$($(OCTAVE_TARGET)_VERSION).bat
       echo "  updating libtool references..."
       find '$(OCTAVE_DIST_DIR)/' -type f -name "*.la" \
         -exec $(SED) -i 's|$(HOST_PREFIX)|/usr|g;s|$(BUILD_TOOLS_PREFIX)|/usr|g' {} \; ;
@@ -106,7 +111,6 @@
       echo "  updating script config tool references..."
       find '$(OCTAVE_DIST_DIR)/bin' -type f -name "*-config" \
         -exec $(SED) -i 's|$(HOST_PREFIX)|/usr|g;s|$(BUILD_TOOLS_PREFIX)|/usr|g' {} \; ;
-      cp $(TOP_DIR)/installer-files/fc_update.bat $(OCTAVE_DIST_DIR)/
     endef
   else
     define copy-windows-dist-files
@@ -116,9 +120,15 @@
       cp $(TOP_DIR)/installer-files/README.html $(OCTAVE_DIST_DIR)/
       echo "  refblas..."
       cp $(OCTAVE_DIST_DIR)/bin/libblas.dll $(OCTAVE_DIST_DIR)/bin/librefblas.dll
-      echo "  octave.bat..."
-      cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/
+      echo "  octave.vbs..."
+      cp $(TOP_DIR)/installer-files/octave.vbs $(OCTAVE_DIST_DIR)/
+      cp $(TOP_DIR)/installer-files/octave-firsttime.vbs $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/fc_update.bat $(OCTAVE_DIST_DIR)/
+      echo "  updating octave .exe to script files..."
+      rm -f $(OCTAVE_DIST_DIR)/bin/octave.exe
+      rm -f $(OCTAVE_DIST_DIR)/bin/octave-$($(OCTAVE_TARGET)_VERSION).exe
+      cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/bin/octave.bat
+      cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/bin/octave-$($(OCTAVE_TARGET)_VERSION).bat
     endef
   endif
 endif
diff -r 9feff7f3b013 -r a94168bc3578 installer-files/octave.bat
--- a/installer-files/octave.bat	Thu Jul 05 07:50:24 2018 -0400
+++ b/installer-files/octave.bat	Thu Jul 05 13:20:52 2018 -0400
@@ -1,10 +1,10 @@
 @echo off
 Rem   Find Octave's install directory through cmd.exe variables.
-Rem   This batch file should reside in Octaves installation subdir!
+Rem   This batch file should reside in Octaves installation bin dir!
 Rem
 Rem   This trick finds the location where the batch file resides.
 Rem   Note: the result ends with a backslash.
-set OCT_HOME=%~dp0
+set OCT_HOME=%~dp0\.\..\
 Rem Convert to 8.3 format so we don't have to worry about spaces.
 for %%I in ("%OCT_HOME%") do set OCT_HOME=%%~sI
 
diff -r 9feff7f3b013 -r a94168bc3578 tools/makeinst-script.sh.in
--- a/tools/makeinst-script.sh.in	Thu Jul 05 07:50:24 2018 -0400
+++ b/tools/makeinst-script.sh.in	Thu Jul 05 13:20:52 2018 -0400
@@ -227,12 +227,10 @@
   SetOutPath "\$INSTDIR" 
   File "$OCTAVE_SOURCE/README.html"
 
-  ; include the octave.bat file
+  ; include octave.vbs and other scripts
   SetOutPath "\$INSTDIR" 
-  File "$OCTAVE_SOURCE/octave.bat"
   File "$OCTAVE_SOURCE/octave.vbs"
   File "$OCTAVE_SOURCE/octave-firsttime.vbs"
-
   File "$OCTAVE_SOURCE/fc_update.bat"
 
   File "$OCTAVE_SOURCE/HG-ID"
@@ -612,7 +610,7 @@
 
 ; Check whether prev install is here and no spaces in dest name
 Function CheckPrevInstallAndDest
-  IfFileExists "\$INSTDIR\\bin\\octave.exe" inst_exists  inst_none
+  IfFileExists "\$INSTDIR\\bin\\octave-cli.exe" inst_exists  inst_none
 inst_exists:
   MessageBox MB_YESNO|MB_ICONEXCLAMATION "Another Octave installation has been detected at that destination. It is recommended to uninstall it if you intend to use the same installation directory. Do you want to proceed with the installation anyway?" /SD IDYES IDYES inst_none IDNO 0
   Abort 
