# HG changeset patch # User John W. Eaton # Date 1387484668 18000 # Node ID 91a3858ef8cfbf185a1df39ce62058d7b7d7e673 # Parent bc1809fe55e483255e5b503af69200675dcf8e8c invoke versioned binaries from octave driver program (bug #40957) * main.in.cc (OCTAVE_VERSION): New macro. (main) Append OCTAVE_VERSION to exec file name. Always set new_argv[0] to full name of file that is executed. * Makefile.am (octave-cli-$(version), octave-gui-$(version), all-local): New rules. (OCTAVE_VERSION_LINKS): New variable. (CLEANFILES): Include $(OCTAVE_VERSION_LINKS) in the list. diff -r bc1809fe55e4 -r 91a3858ef8cf src/Makefile.am --- a/src/Makefile.am Wed Dec 18 17:47:21 2013 +0000 +++ b/src/Makefile.am Thu Dec 19 15:24:28 2013 -0500 @@ -49,8 +49,11 @@ octave \ octave-cli +OCTAVE_VERSION_LINKS = octave-cli-$(version) + if AMCOND_BUILD_GUI OCTAVE_BINARIES += octave-gui + OCTAVE_VERSION_LINKS += octave-gui-$(version) endif OCTAVE_CORE_LIBS = \ @@ -136,6 +139,8 @@ octave-config endif +all-local: $(OCTAVE_VERSION_LINKS) + if AMCOND_BUILD_COMPILED_AUX_PROGRAMS octave-config.cc: octave-config.in.cc Makefile @$(do_subst_default_vals) @@ -189,5 +194,17 @@ .PHONY: make-version-links remove-version-links +## We need these file names in the build tree because the wrapper +## program (main.cc) will try to invoke the versioned binaries. + +octave-cli-$(version): octave-cli + rm -f $@ + $(LN_S) $< $@ + +octave-gui-$(version): octave-gui + rm -f $@ + $(LN_S) $< $@ + CLEANFILES = \ - $(bin_SCRIPTS) + $(bin_SCRIPTS) \ + $(OCTAVE_VERSION_LINKS) diff -r bc1809fe55e4 -r 91a3858ef8cf src/main.in.cc --- a/src/main.in.cc Wed Dec 18 17:47:21 2013 +0000 +++ b/src/main.in.cc Thu Dec 19 15:24:28 2013 -0500 @@ -42,6 +42,18 @@ #include #include +#ifndef OCTAVE_VERSION +#define OCTAVE_VERSION %OCTAVE_VERSION% +#endif + +#ifndef OCTAVE_BINDIR +#define OCTAVE_BINDIR %OCTAVE_BINDIR% +#endif + +#ifndef OCTAVE_PREFIX +#define OCTAVE_PREFIX %OCTAVE_PREFIX% +#endif + #if defined (__WIN32__) && ! defined (_POSIX_VERSION) #define WIN32_LEAN_AND_MEAN @@ -358,14 +370,6 @@ #endif -#ifndef OCTAVE_BINDIR -#define OCTAVE_BINDIR %OCTAVE_BINDIR% -#endif - -#ifndef OCTAVE_PREFIX -#define OCTAVE_PREFIX %OCTAVE_PREFIX% -#endif - // Find the directory where the octave binary is supposed to be // installed. @@ -590,16 +594,12 @@ std::string octave_bindir = get_octave_bindir (); - std::string file = octave_bindir + dir_sep_char + "octave-cli"; + std::string file + = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION;; char **new_argv = new char * [argc + 1]; -#if defined (__WIN32__) && ! defined (__CYGWIN__) int k = 1; -#else - int k = 0; - new_argv[k++] = strsave ("octave"); -#endif bool warn_display = true; @@ -611,9 +611,9 @@ gui_libs = true; file = octave_bindir + dir_sep_char; #if defined (HAVE_OCTAVE_GUI) - file += "octave-gui"; + file += "octave-gui-" OCTAVE_VERSION; #else - file += "octave-cli"; + file += "octave-cli-" OCTAVE_VERSION; #endif new_argv[k++] = argv[i]; } @@ -631,9 +631,9 @@ { // If we see this option, then we can just exec octave; we // don't have to create a child process and wait for it to - // exit. But do exec "octave", not "octave-cli", because even - // if the --no-gui option is given, we may be asked to do some - // plotting or ui* calls. + // exit. But do exec "octave-gui", not "octave-cli", because + // even if the --no-gui option is given, we may be asked to do + // some plotting or ui* calls. // This option calls the cli executable for the 3.8 release. } @@ -658,7 +658,7 @@ start_gui = false; gui_libs = false; - file = octave_bindir + dir_sep_char + "octave-cli"; + file = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION; if (warn_display) { @@ -668,6 +668,12 @@ } } +#if defined (__WIN32__) && ! defined (__CYGWIN__) + file += ".exe"; +#endif + + new_argv[0] = strsave (file.c_str ()); + #if (defined (HAVE_OCTAVE_GUI) \ && ! defined (__WIN32__) || defined (__CYGWIN__)) @@ -733,10 +739,6 @@ #else -#if defined (__WIN32__) && ! defined (__CYGWIN__) - file += ".exe"; - new_argv[0] = strsave (file.c_str ()); -#endif retval = octave_exec (file, new_argv); #endif