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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
2 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
4 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5427
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5427
diff changeset
8 ## your option) any later version.
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
9 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
14 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5427
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5427
diff changeset
17 ## <http://www.gnu.org/licenses/>.
4691
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
18
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
22 ## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os}
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
23 ## that identifies the kind of computer Octave is running on. If invoked
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
26 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
27 ## @example
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
28 ## @group
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
31 ##
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
34 ## @end group
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
35 ## @end example
5427
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
36 ##
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
37 ## If two output arguments are requested, also return the maximum number
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
38 ## of elements for an array.
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
39 ##
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
40 ## If three output arguments are requested, also return the byte order
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
41 ## of the current system as a character (@code{"B"} for big-endian or
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
47 ## @end deftypefn
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
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
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
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
a92afe70fb8d [project @ 2005-08-16 19:49:23 by jwe]
jwe
parents: 5307
diff changeset
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
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
84 endif
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
85
bdc51b369a78 [project @ 2004-01-10 18:16:02 by jwe]
jwe
parents:
diff changeset
86 endfunction
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
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