Mercurial > octave
annotate scripts/pkg/private/configure_make.m @ 28200:bc6dae9cbe73 stable
pkg: insert missing space in configure command
* configure_make.m: Insert missing space between environment variables and
configure command.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Thu, 09 Apr 2020 15:35:57 -0700 |
parents | c26838a3afa6 |
children | b8384ed4d500 64d1c7af5b18 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 ## Copyright (C) 2005-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
7 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24370
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24370
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
14 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
19 ## |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24370
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
25 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20713
diff
changeset
|
27 ## @deftypefn {} {} configure_make (@var{desc}, @var{packdir}, @var{verbose}) |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
28 ## Undocumented internal function. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
29 ## @end deftypefn |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
30 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
31 function configure_make (desc, packdir, verbose) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21751
diff
changeset
|
32 |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
33 ## Perform ./configure, make, make install in "src". |
25787
3293cd2651fb
prefer 'isfolder' over 'exist (..., "dir")' in Octave functions
Mike Miller <mtmiller@octave.org>
parents:
25564
diff
changeset
|
34 if (isfolder (fullfile (packdir, "src"))) |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
35 src = fullfile (packdir, "src"); |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
20955
diff
changeset
|
36 octave_bindir = __octave_config_info__ ("bindir"); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
37 ver = version (); |
21434
1da428cbf401
deprecate octave_config_info
John W. Eaton <jwe@octave.org>
parents:
20955
diff
changeset
|
38 ext = __octave_config_info__ ("EXEEXT"); |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
39 mkoctfile_program = fullfile (octave_bindir, ... |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
40 sprintf ("mkoctfile-%s%s", ver, ext)); |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
41 octave_config_program = fullfile (octave_bindir, ... |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
42 sprintf ("octave-config-%s%s", ver, ext)); |
25564
65a28dec405b
use octave bat file in pkg install configure/make when in windows (Bug #53938)
John Donoghue
parents:
25054
diff
changeset
|
43 if (ispc () && ! isunix ()) |
65a28dec405b
use octave bat file in pkg install configure/make when in windows (Bug #53938)
John Donoghue
parents:
25054
diff
changeset
|
44 octave_binary = fullfile (octave_bindir, sprintf ("octave-%s.bat", ver)); |
65a28dec405b
use octave bat file in pkg install configure/make when in windows (Bug #53938)
John Donoghue
parents:
25054
diff
changeset
|
45 else |
65a28dec405b
use octave bat file in pkg install configure/make when in windows (Bug #53938)
John Donoghue
parents:
25054
diff
changeset
|
46 octave_binary = fullfile (octave_bindir, sprintf ("octave-%s%s", ver, ext)); |
65a28dec405b
use octave bat file in pkg install configure/make when in windows (Bug #53938)
John Donoghue
parents:
25054
diff
changeset
|
47 endif |
16824
51bcaa55f120
pkg: display output of shell commands on real time if verbose.
Carnë Draug <carandraug+dev@gmail.com>
parents:
16724
diff
changeset
|
48 |
17516
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
49 if (! exist (mkoctfile_program, "file")) |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
50 __gripe_missing_component__ ("pkg", "mkoctfile"); |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
51 endif |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
52 if (! exist (octave_config_program, "file")) |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
53 __gripe_missing_component__ ("pkg", "octave-config"); |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
54 endif |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
55 if (! exist (octave_binary, "file")) |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
56 __gripe_missing_component__ ("pkg", "octave"); |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
57 endif |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17016
diff
changeset
|
58 |
18420
c2d1869a95ee
Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
59 if (verbose) |
c2d1869a95ee
Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
60 mkoctfile_program = [mkoctfile_program " --verbose"]; |
c2d1869a95ee
Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
61 endif |
c2d1869a95ee
Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
62 |
c2d1869a95ee
Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
63 cenv = {"MKOCTFILE"; mkoctfile_program; |
c2d1869a95ee
Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
64 "OCTAVE_CONFIG"; octave_config_program; |
21519
8e5eca2c5a64
pkg install: drop INSTALLDIR and stop calling configure with --prefix.
Carnë Draug <carandraug@octave.org>
parents:
21518
diff
changeset
|
65 "OCTAVE"; octave_binary}; |
19584
e33427a854ec
* configure_make.m: Single-quote environment variable values.
John W. Eaton <jwe@octave.org>
parents:
18986
diff
changeset
|
66 scenv = sprintf ("%s='%s' ", cenv{:}); |
18420
c2d1869a95ee
Pass --verbose option to mkoctfile when installing packages with --verbose (bug #41351).
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
67 |
28186
c26838a3afa6
pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents:
27923
diff
changeset
|
68 if (verbose) |
c26838a3afa6
pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents:
27923
diff
changeset
|
69 ## Add standard V=1 make argument for verbose build rules |
c26838a3afa6
pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents:
27923
diff
changeset
|
70 scenv = [scenv, "V=1"]; |
c26838a3afa6
pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents:
27923
diff
changeset
|
71 endif |
c26838a3afa6
pkg: build with "V=1" for verbose build rules
Mike Miller <mtmiller@octave.org>
parents:
27923
diff
changeset
|
72 |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
73 ## Configure. |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
74 if (exist (fullfile (src, "configure"), "file")) |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
75 flags = ""; |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
76 if (isempty (getenv ("CC"))) |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16824
diff
changeset
|
77 flags = [flags ' CC="' mkoctfile("-p", "CC") '"']; |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
78 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
79 if (isempty (getenv ("CXX"))) |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16824
diff
changeset
|
80 flags = [flags ' CXX="' mkoctfile("-p", "CXX") '"']; |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
81 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
82 if (isempty (getenv ("AR"))) |
17016
a3f6790df115
Fix typos from cstrcat to matrix concatenation changeset (333243133364).
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
83 flags = [flags ' AR="' mkoctfile("-p", "AR") '"']; |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
84 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
85 if (isempty (getenv ("RANLIB"))) |
17016
a3f6790df115
Fix typos from cstrcat to matrix concatenation changeset (333243133364).
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
86 flags = [flags ' RANLIB="' mkoctfile("-p", "RANLIB") '"']; |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
87 endif |
28200
bc6dae9cbe73
pkg: insert missing space in configure command
Mike Miller <mtmiller@octave.org>
parents:
28186
diff
changeset
|
88 cmd = ["cd '" src "'; " scenv " ./configure " flags]; |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16824
diff
changeset
|
89 [status, output] = shell (cmd, verbose); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
90 if (status != 0) |
14471
d2c095e45196
maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
14466
diff
changeset
|
91 rmdir (desc.dir, "s"); |
16824
51bcaa55f120
pkg: display output of shell commands on real time if verbose.
Carnë Draug <carandraug+dev@gmail.com>
parents:
16724
diff
changeset
|
92 disp (output); |
51bcaa55f120
pkg: display output of shell commands on real time if verbose.
Carnë Draug <carandraug+dev@gmail.com>
parents:
16724
diff
changeset
|
93 error ("pkg: error running the configure script for %s.", desc.name); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
94 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
95 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
96 |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
97 ## Make. |
19603
b74ae93040e8
limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents:
19584
diff
changeset
|
98 if (ispc ()) |
b74ae93040e8
limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents:
19584
diff
changeset
|
99 jobs = 1; |
b74ae93040e8
limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents:
19584
diff
changeset
|
100 else |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
101 jobs = nproc ("overridable"); |
19603
b74ae93040e8
limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents:
19584
diff
changeset
|
102 endif |
b74ae93040e8
limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents:
19584
diff
changeset
|
103 |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
104 if (exist (fullfile (src, "Makefile"), "file")) |
18986
7141d9728ee0
pkg.m: run make with multiple simultaneous jobs (bug #42915)
Carnë Draug <carandraug@octave.org>
parents:
18420
diff
changeset
|
105 [status, output] = shell (sprintf ("%s make --jobs %i --directory '%s'", |
19603
b74ae93040e8
limit number of jobs for make command to 1 under windows (bug #44053)
Avinoam Kalma
parents:
19584
diff
changeset
|
106 scenv, jobs, src), verbose); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
107 if (status != 0) |
14471
d2c095e45196
maint: Remove redundant private function from the package manager.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
14466
diff
changeset
|
108 rmdir (desc.dir, "s"); |
16824
51bcaa55f120
pkg: display output of shell commands on real time if verbose.
Carnë Draug <carandraug+dev@gmail.com>
parents:
16724
diff
changeset
|
109 disp (output); |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
110 error ("pkg: error running 'make' for the %s package.", desc.name); |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
111 endif |
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
112 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21751
diff
changeset
|
113 endif |
21519
8e5eca2c5a64
pkg install: drop INSTALLDIR and stop calling configure with --prefix.
Carnë Draug <carandraug@octave.org>
parents:
21518
diff
changeset
|
114 |
14466
cfb0173fe1ca
maint: Refactor pkg.m and move subfunctions to private/ directory.
Carlo de Falco <kingcrimson@tiscali.it>
parents:
diff
changeset
|
115 endfunction |
21615
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
116 |
21759
b002b4331a12
maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
117 ## Executes a shell command. |
b002b4331a12
maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
118 ## In the end it calls system(), but in the case of MS Windows it will first |
b002b4331a12
maint: Use two newlines after endfunction and start of BIST tests.
Rik <rik@octave.org>
parents:
21758
diff
changeset
|
119 ## check if sh.exe works. |
21615
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
120 ## |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
121 ## If VERBOSE is true, it will prints the output to STDOUT in real time and |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21615
diff
changeset
|
122 ## the second output argument will be an empty string. Otherwise, it will |
21615
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
123 ## contain the output of the execeuted command. |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
124 function [status, output] = shell (cmd, verbose) |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
125 persistent have_sh; |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
126 |
24370
b1d1229d9e83
maint: Use single quotes to simplify excessive backslash escapes in code.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
127 cmd = strrep (cmd, '\', '/'); |
21615
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
128 if (ispc () && ! isunix ()) |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
129 if (isempty (have_sh)) |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
130 if (system ('sh.exe -c "exit"')) |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
131 have_sh = false; |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
132 else |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
133 have_sh = true; |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
134 endif |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
135 endif |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
136 if (have_sh) |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
137 cmd = ['sh.exe -c "' cmd '"']; |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
138 else |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
139 error ("pkg: unable to find the command shell."); |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
140 endif |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
141 endif |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21615
diff
changeset
|
142 ## if verbose, we want to display the output in real time. To do this, we |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
143 ## must call system with 1 output argument. But then the variable 'output' |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21615
diff
changeset
|
144 ## won't exist. So we initialize it empty. If an error does occur, and we |
21615
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
145 ## are verbose we will return an empty string but it's all fine since |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
146 ## the error message has already been displayed. |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
147 output = ""; |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
148 if (verbose) |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
149 [status] = system (cmd); |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
150 else |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
151 [status, output] = system (cmd); |
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
152 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21751
diff
changeset
|
153 |
21615
9ccd64201b4d
pkg: remove excessive number of private function files.
Carnë Draug <carandraug@octave.org>
parents:
21519
diff
changeset
|
154 endfunction |