annotate scripts/miscellaneous/mkoctfile.m @ 8920:eb63fbe60fab

update copyright notices
author John W. Eaton <jwe@octave.org>
date Sat, 07 Mar 2009 10:41:27 -0500
parents 5dd06f19e9be
children 1bf0ce0930be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8746
diff changeset
1 ## Copyright (C) 2006, 2007, 2008, 2009 Keith Goodman
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
2 ##
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
4 ##
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
387dd5b34757 [project @ 2006-03-15 20:10:45 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: 6717
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: 6717
diff changeset
8 ## your option) any later version.
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
9 ##
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
14 ##
387dd5b34757 [project @ 2006-03-15 20:10:45 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: 6717
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: 6717
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
18
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
6547
4fb053f24fd6 [project @ 2007-04-19 21:47:40 by jwe]
jwe
parents: 5904
diff changeset
20 ## @deftypefn {Function File} {} mkoctfile [-options] file @dots{}
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
21 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
22 ## The @code{mkoctfile} function compiles source code written in C,
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
23 ## C++, or Fortran. Depending on the options used with @code{mkoctfile}, the
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
24 ## compiled code can be called within Octave or can be used as a stand-alone
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
25 ## application.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
26 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
27 ## @code{mkoctfile} can be called from the shell prompt or from the Octave
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
28 ## prompt.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
29 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
30 ## @code{mkoctfile} accepts the following options, all of which are optional
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
31 ## except for the file name of the code you wish to compile:
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
32 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
33 ## @table @samp
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
34 ## @item -I DIR
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
35 ## Add the include directory DIR to compile commands.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
36 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
37 ## @item -D DEF
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
38 ## Add the definition DEF to the compiler call.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
39 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
40 ## @item -l LIB
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
41 ## Add the library LIB to the link command.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
42 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
43 ## @item -L DIR
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
44 ## Add the library directory DIR to the link command.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
45 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
46 ## @item -M
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
47 ## @itemx --depend
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
48 ## Generate dependency files (.d) for C and C++ source files.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
49 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
50 ## @item -c
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
51 ## Compile but do not link.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
52 ##
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
53 ## @item -g
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
54 ## Enable debugging options for compilers.
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
55 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
56 ## @item -o FILE
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
57 ## @itemx --output FILE
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
58 ## Output file name. Default extension is .oct
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
59 ## (or .mex if --mex is specified) unless linking
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
60 ## a stand-alone executable.
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
61 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
62 ## @item -p VAR
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
63 ## @itemx --print VAR
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
64 ## Print the configuration variable VAR. Recognized variables are:
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
65 ##
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
66 ## @example
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
67 ## ALL_CFLAGS FFTW_LIBS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
68 ## ALL_CXXFLAGS FLIBS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
69 ## ALL_FFLAGS FPICFLAG
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
70 ## ALL_LDFLAGS INCFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
71 ## BLAS_LIBS LDFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
72 ## CC LD_CXX
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
73 ## CFLAGS LD_STATIC_FLAG
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
74 ## CPICFLAG LFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
75 ## CPPFLAGS LIBCRUFT
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
76 ## CXX LIBOCTAVE
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
77 ## CXXFLAGS LIBOCTINTERP
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
78 ## CXXPICFLAG LIBREADLINE
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
79 ## DEPEND_EXTRA_SED_PATTERN LIBS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
80 ## DEPEND_FLAGS OCTAVE_LIBS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
81 ## DL_LD RDYNAMIC_FLAG
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
82 ## DL_LDFLAGS RLD_FLAG
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
83 ## F2C SED
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
84 ## F2CFLAGS XTRA_CFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
85 ## F77 XTRA_CXXFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
86 ## FFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
87 ## @end example
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
88 ##
5745
0559ebb94bf0 [project @ 2006-04-06 20:33:40 by jwe]
jwe
parents: 5696
diff changeset
89 ## @item --link-stand-alone
0559ebb94bf0 [project @ 2006-04-06 20:33:40 by jwe]
jwe
parents: 5696
diff changeset
90 ## Link a stand-alone executable file.
0559ebb94bf0 [project @ 2006-04-06 20:33:40 by jwe]
jwe
parents: 5696
diff changeset
91 ##
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
92 ## @item --mex
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
93 ## Assume we are creating a MEX file. Set the default output extension
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
94 ## to ".mex".
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
95 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
96 ## @item -s
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
97 ## @itemx --strip
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
98 ## Strip the output file.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
99 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
100 ## @item -v
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
101 ## @itemx --verbose
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
102 ## Echo commands as they are executed.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
103 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
104 ## @item file
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
105 ## The file to compile or link. Recognised file types are
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
106 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
107 ## @example
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
108 ## .c C source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
109 ## .cc C++ source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
110 ## .C C++ source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
111 ## .cpp C++ source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
112 ## .f Fortran source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
113 ## .F Fortran source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
114 ## .o object file
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
115 ## @end example
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
116 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
117 ## @end table
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
118 ## @end deftypefn
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
119
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
120 function mkoctfile (varargin)
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
121
5696
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
122 bindir = octave_config_info ("bindir");
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
123
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
124 shell_script = fullfile (bindir, sprintf ("mkoctfile-%s", OCTAVE_VERSION));
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
125
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
126 cmd = cstrcat ("\"", shell_script, "\"");
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
127 for i = 1:nargin
7540
3422f39573b1 strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents: 7017
diff changeset
128 cmd = cstrcat (cmd, " \"", varargin{i}, "\"");
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
129 endfor
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
130
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
131 status = system (cmd);
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
132
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
133 if (status == 127)
5696
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
134 warning ("unable to find mkoctfile in expected location: `%s'",
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
135 shell_script);
6706
f9c19d0447a2 [project @ 2007-06-13 05:55:42 by jwe]
jwe
parents: 6573
diff changeset
136
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
137 warning ("mkoctfile exited with failure status");
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
138 endif
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
139
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
140 endfunction