# HG changeset patch # User John W. Eaton # Date 1382992726 14400 # Node ID 7ae9bc04ec07e4f4afe1e9f58fd820e0dbd9b49d # Parent eca761671f1613904573f6f00b075e8ec350395c allow octave binary to work if building GUI is disabled (bug #40395) * src/Makefile.in: If building GUI, compile main.cc with -DHAVE_OCTAVE_GUI. * main.in.cc (main): If HAVE_OCTAVE_GUI is not defined, then simply exec octave-cli. diff -r eca761671f16 -r 7ae9bc04ec07 src/Makefile.am --- a/src/Makefile.am Mon Oct 28 21:11:45 2013 +0100 +++ b/src/Makefile.am Mon Oct 28 16:38:46 2013 -0400 @@ -69,6 +69,14 @@ $(NO_UNDEFINED_LDFLAG) \ $(OCTAVE_LINK_OPTS) +if AMCOND_BUILD_GUI + OCTAVE_CPPFLAGS = -DHAVE_OCTAVE_GUI +endif + +octave_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(OCTAVE_CPPFLGAS) + octave_cli_SOURCES = main-cli.cc octave_cli_LDADD = \ diff -r eca761671f16 -r 7ae9bc04ec07 src/main.in.cc --- a/src/main.in.cc Mon Oct 28 21:11:45 2013 +0100 +++ b/src/main.in.cc Mon Oct 28 16:38:46 2013 -0400 @@ -102,7 +102,8 @@ #endif -#if ! defined (__WIN32__) && ! defined (__CYGWIN__) +#if (defined (HAVE_OCTAVE_GUI) \ + && ! defined (__WIN32__) && ! defined (__CYGWIN__)) #include #include @@ -395,12 +396,20 @@ { int retval = 0; +#if defined (HAVE_OCTAVE_GUI) bool start_gui = true; bool cli_only = false; +#endif std::string octave_bindir = get_octave_bindir (); - std::string file = octave_bindir + dir_sep_char + "octave-gui"; + std::string file = octave_bindir + dir_sep_char; + +#if defined (HAVE_OCTAVE_GUI) + file += "octave-gui"; +#else + file += "octave-cli"; +#endif char **new_argv = new char * [argc + 1]; @@ -417,7 +426,9 @@ // require less memory. Don't pass the --no-gui-libs option // on as that option is not recognized by Octave. +#if defined (HAVE_OCTAVE_GUI) cli_only = true; +#endif file = octave_bindir + dir_sep_char + "octave-cli"; } else if (! strcmp (argv[i], "--no-gui")) @@ -428,7 +439,9 @@ // if the --no-gui option is given, we may be asked to do some // plotting or ui* calls. +#if defined (HAVE_OCTAVE_GUI) start_gui = false; +#endif new_argv[k++] = argv[i]; } else @@ -437,7 +450,7 @@ new_argv[k] = 0; -#if defined (__WIN32__) || defined (__CYGWIN__) +#if ! defined (HAVE_OCTAVE_GUI) || defined (__WIN32__) || defined (__CYGWIN__) retval = octave_exec (file, new_argv);