comparison src/main.in.cc @ 18156:d13fb462dd92 gui-release

maint: Periodic merge of stable to gui-release.
author John W. Eaton <jwe@octave.org>
date Sat, 21 Dec 2013 13:44:13 -0500
parents 76006571e45a 91a3858ef8cf
children eb51f47d9dee
comparison
equal deleted inserted replaced
18155:14acb08d75fa 18156:d13fb462dd92
40 #include <string> 40 #include <string>
41 41
42 #include <sys/types.h> 42 #include <sys/types.h>
43 #include <unistd.h> 43 #include <unistd.h>
44 44
45 #ifndef OCTAVE_VERSION
46 #define OCTAVE_VERSION %OCTAVE_VERSION%
47 #endif
48
49 #ifndef OCTAVE_BINDIR
50 #define OCTAVE_BINDIR %OCTAVE_BINDIR%
51 #endif
52
53 #ifndef OCTAVE_PREFIX
54 #define OCTAVE_PREFIX %OCTAVE_PREFIX%
55 #endif
56
45 #if defined (__WIN32__) && ! defined (_POSIX_VERSION) 57 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
46 58
47 #define WIN32_LEAN_AND_MEAN 59 #define WIN32_LEAN_AND_MEAN
48 #include <tlhelp32.h> 60 #include <tlhelp32.h>
49 61
354 } 366 }
355 367
356 return retval; 368 return retval;
357 } 369 }
358 370
359 #endif
360
361 #ifndef OCTAVE_BINDIR
362 #define OCTAVE_BINDIR %OCTAVE_BINDIR%
363 #endif
364
365 #ifndef OCTAVE_PREFIX
366 #define OCTAVE_PREFIX %OCTAVE_PREFIX%
367 #endif 371 #endif
368 372
369 // Find the directory where the octave binary is supposed to be 373 // Find the directory where the octave binary is supposed to be
370 // installed. 374 // installed.
371 375
591 std::string octave_bindir = get_octave_bindir (); 595 std::string octave_bindir = get_octave_bindir ();
592 596
593 std::string file = octave_bindir + dir_sep_char; 597 std::string file = octave_bindir + dir_sep_char;
594 598
595 #if defined (HAVE_OCTAVE_GUI) 599 #if defined (HAVE_OCTAVE_GUI)
596 file += "octave-gui"; 600 file += "octave-gui-" OCTAVE_VERSION;
597 #else 601 #else
598 file += "octave-cli"; 602 file += "octave-cli-" OCTAVE_VERSION;
599 #endif 603 #endif
600 604
601 char **new_argv = new char * [argc + 1]; 605 char **new_argv = new char * [argc + 1];
602 606
603 #if defined (__WIN32__) && ! defined (__CYGWIN__)
604 int k = 1; 607 int k = 1;
605 #else
606 int k = 0;
607 new_argv[k++] = strsave ("octave");
608 #endif
609 608
610 bool warn_display = true; 609 bool warn_display = true;
611 610
612 for (int i = 1; i < argc; i++) 611 for (int i = 1; i < argc; i++)
613 { 612 {
625 } 624 }
626 else if (! strcmp (argv[i], "--no-gui")) 625 else if (! strcmp (argv[i], "--no-gui"))
627 { 626 {
628 // If we see this option, then we can just exec octave; we 627 // If we see this option, then we can just exec octave; we
629 // don't have to create a child process and wait for it to 628 // don't have to create a child process and wait for it to
630 // exit. But do exec "octave", not "octave-cli", because even 629 // exit. But do exec "octave-gui", not "octave-cli", because
631 // if the --no-gui option is given, we may be asked to do some 630 // even if the --no-gui option is given, we may be asked to do
632 // plotting or ui* calls. 631 // some plotting or ui* calls.
633 632
634 start_gui = false; 633 start_gui = false;
635 new_argv[k++] = argv[i]; 634 new_argv[k++] = argv[i];
636 } 635 }
637 else if (! strcmp (argv[i], "--silent") || ! strcmp (argv[i], "--quiet") 636 else if (! strcmp (argv[i], "--silent") || ! strcmp (argv[i], "--quiet")
653 if (! display_available (display_check_err_msg)) 652 if (! display_available (display_check_err_msg))
654 { 653 {
655 start_gui = false; 654 start_gui = false;
656 gui_libs = false; 655 gui_libs = false;
657 656
658 file = octave_bindir + dir_sep_char + "octave-cli"; 657 file = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION;
659 658
660 if (warn_display) 659 if (warn_display)
661 { 660 {
662 std::cerr << "octave: " << display_check_err_msg << std::endl; 661 std::cerr << "octave: " << display_check_err_msg << std::endl;
663 std::cerr << "octave: disabling GUI features" << std::endl; 662 std::cerr << "octave: disabling GUI features" << std::endl;
664 } 663 }
665 } 664 }
666 } 665 }
666
667 #if defined (__WIN32__) && ! defined (__CYGWIN__)
668 file += ".exe";
669 #endif
670
671 new_argv[0] = strsave (file.c_str ());
667 672
668 #if (defined (HAVE_OCTAVE_GUI) \ 673 #if (defined (HAVE_OCTAVE_GUI) \
669 && ! defined (__WIN32__) || defined (__CYGWIN__)) 674 && ! defined (__WIN32__) || defined (__CYGWIN__))
670 675
671 if (gui_libs && start_gui && have_controlling_terminal ()) 676 if (gui_libs && start_gui && have_controlling_terminal ())
728 else 733 else
729 retval = octave_exec (file, new_argv); 734 retval = octave_exec (file, new_argv);
730 735
731 #else 736 #else
732 737
733 #if defined (__WIN32__) && ! defined (__CYGWIN__)
734 file += ".exe";
735 new_argv[0] = strsave (file.c_str ());
736 #endif
737 retval = octave_exec (file, new_argv); 738 retval = octave_exec (file, new_argv);
738 739
739 #endif 740 #endif
740 741
741 return retval; 742 return retval;