Mercurial > hg > octave-nkf
annotate scripts/miscellaneous/computer.m @ 15107:03381a36f70d
generate convenience libraries for new parse-tree and interpfcn subdirectories
* src/Makefile.am (liboctinterp_la_SOURCES): Include octave.cc in the
list, not $(DIST_SRC).
(liboctinterp_la_LIBADD): Include octave-value/liboctave-value.la,
parse-tree/libparse-tree.la, interp-core/libinterp-core.la,
interpfcn/libinterpfcn.la, and corefcn/libcorefcn.la in the list.
* src/interp-core/module.mk (noinst_LTLIBRARIES): Add
interp-core/libinterp-core.la to the list.
(interp_core_libinterp_core_la_SOURCES): New variable.
* src/interpfcn/module.mk (noinst_LTLIBRARIES): Add
interpfcn/libinterpfcn.la to the list.
(interpfcn_libinterpfcn_la_SOURCES): New variable.
* src/parse-tree/module.mk (noinst_LTLIBRARIES): Add
parse-tree/libparse-tree.la to the list.
(parse_tree_libparse_tree_la_SOURCES): New variable.
* src/octave-value/module.mk (noinst_LTLIBRARIES): Add
octave-value/liboctave-value.la to the list.
(octave_value_liboctave_value_la_SOURCES): New variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 05 Aug 2012 09:04:30 -0400 |
parents | f3d52523cde1 |
children | 1de4ec2a856d |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13929
diff
changeset
|
1 ## Copyright (C) 2004-2012 John W. Eaton |
4691 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
4691 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
4691 | 18 |
19 ## -*- texinfo -*- | |
13929
9cae456085c2
Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13117
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{c}, @var{maxsize}, @var{endian}] =} computer () |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
21 ## @deftypefnx {Function File} {@var{arch} =} computer ("arch") |
4691 | 22 ## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os} |
23 ## that identifies the kind of computer Octave is running on. If invoked | |
24 ## with an output argument, the value is returned instead of printed. For | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
25 ## example: |
4691 | 26 ## |
27 ## @example | |
28 ## @group | |
29 ## computer () | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
30 ## @print{} i586-pc-linux-gnu |
4691 | 31 ## |
32 ## x = computer () | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
33 ## @result{} x = "i586-pc-linux-gnu" |
4691 | 34 ## @end group |
35 ## @end example | |
5427 | 36 ## |
37 ## If two output arguments are requested, also return the maximum number | |
38 ## of elements for an array. | |
39 ## | |
40 ## If three output arguments are requested, also return the byte order | |
41 ## of the current system as a character (@code{"B"} for big-endian or | |
42 ## @code{"L"} for little-endian). | |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
43 ## |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
44 ## If the argument @code{"arch"} is specified, return a string |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
45 ## indicating the architecture of the computer on which Octave is |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
46 ## running. |
4691 | 47 ## @end deftypefn |
48 | |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
49 function [c, maxsize, endian] = computer (a) |
4691 | 50 |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
51 if (nargin == 1 && ischar (a) && strcmpi (a, "arch")) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
52 tmp = strsplit (octave_config_info ("canonical_host_type"), "-"); |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
53 if (numel (tmp) == 4) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
54 c = sprintf ("%s-%s-%s", tmp{4}, tmp{3}, tmp{1}); |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
55 else |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
56 c = sprintf ("%s-%s", tmp{3}, tmp{1}); |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
57 endif |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
58 elseif (nargin == 0) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
59 msg = octave_config_info ("canonical_host_type"); |
4691 | 60 |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
61 if (strcmp (msg, "unknown")) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
62 msg = "Hi Dave, I'm a HAL-9000"; |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
63 endif |
4691 | 64 |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
65 if (nargout == 0) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
66 printf ("%s\n", msg); |
5427 | 67 else |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
68 c = msg; |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
69 if (strcmp (octave_config_info ("USE_64_BIT_IDX_T"), "true")) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
70 maxsize = 2^63-1; |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
71 else |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
72 maxsize = 2^31-1; |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
73 endif |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
74 if (octave_config_info ("words_big_endian")) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
75 endian = "B"; |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
76 elseif (octave_config_info ("words_little_endian")) |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
77 endian = "L"; |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
78 else |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
79 endian = "?"; |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
80 endif |
5427 | 81 endif |
13117
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
82 else |
9bebb2322c4e
computer: accept "arch" argument
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
83 print_usage (); |
4691 | 84 endif |
85 | |
86 endfunction | |
7411 | 87 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
88 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
89 %!assert (ischar (computer ())) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
90 %!assert (computer (), octave_config_info ("canonical_host_type")) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
91 %!assert (ischar (computer ("arch"))) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
92 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
93 %!error computer (2) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
94 |