annotate scripts/miscellaneous/mkoctfile.m @ 6573:9180be9d3d08

[project @ 2007-04-25 04:27:16 by jwe]
author jwe
date Wed, 25 Apr 2007 04:27:16 +0000
parents 4fb053f24fd6
children f9c19d0447a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 2006 Keith Goodman
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
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 2, or (at your option)
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
8 ## any later version.
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
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
18 ## 02110-1301, USA.
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
19
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
6547
4fb053f24fd6 [project @ 2007-04-19 21:47:40 by jwe]
jwe
parents: 5904
diff changeset
21 ## @deftypefn {Function File} {} mkoctfile [-options] file @dots{}
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
22 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
23 ## 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
24 ## 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
25 ## 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
26 ## application.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
27 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
28 ## @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
29 ## prompt.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
30 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
31 ## @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
32 ## 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
33 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
34 ## @table @samp
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
35 ## @item -I DIR
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
36 ## Add the include directory DIR to compile commands.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
37 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
38 ## @item -D DEF
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
39 ## Add the definition DEF to the compiler call.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
40 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
41 ## @item -l LIB
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
42 ## Add the library LIB to the link command.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
43 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
44 ## @item -L DIR
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
45 ## Add the library directory DIR to the link command.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
46 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
47 ## @item -M
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
48 ## @itemx --depend
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
49 ## 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
50 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
51 ## @item -c
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
52 ## Compile but do not link.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
53 ##
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
54 ## @item -g
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
55 ## Enable debugging options for compilers.
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
56 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
57 ## @item -o FILE
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
58 ## @itemx --output FILE
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
59 ## Output file name. Default extension is .oct
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
60 ## (or .mex if --mex is specified) unless linking
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
61 ## a stand-alone executable.
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
62 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
63 ## @item -p VAR
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
64 ## @itemx --print VAR
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
65 ## Print the configuration variable VAR. Recognized variables are:
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
66 ##
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
67 ## @example
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
68 ## ALL_CFLAGS FFTW_LIBS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
69 ## ALL_CXXFLAGS FLIBS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
70 ## ALL_FFLAGS FPICFLAG
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
71 ## ALL_LDFLAGS INCFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
72 ## BLAS_LIBS LDFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
73 ## CC LD_CXX
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
74 ## CFLAGS LD_STATIC_FLAG
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
75 ## CPICFLAG LFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
76 ## CPPFLAGS LIBCRUFT
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
77 ## CXX LIBOCTAVE
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
78 ## CXXFLAGS LIBOCTINTERP
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
79 ## CXXPICFLAG LIBREADLINE
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
80 ## DEPEND_EXTRA_SED_PATTERN LIBS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
81 ## DEPEND_FLAGS OCTAVE_LIBS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
82 ## DL_LD RDYNAMIC_FLAG
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
83 ## DL_LDFLAGS RLD_FLAG
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
84 ## F2C SED
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
85 ## F2CFLAGS XTRA_CFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
86 ## F77 XTRA_CXXFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
87 ## FFLAGS
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
88 ## @end example
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
89 ##
5745
0559ebb94bf0 [project @ 2006-04-06 20:33:40 by jwe]
jwe
parents: 5696
diff changeset
90 ## @item --link-stand-alone
0559ebb94bf0 [project @ 2006-04-06 20:33:40 by jwe]
jwe
parents: 5696
diff changeset
91 ## Link a stand-alone executable file.
0559ebb94bf0 [project @ 2006-04-06 20:33:40 by jwe]
jwe
parents: 5696
diff changeset
92 ##
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
93 ## @item --mex
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
94 ## 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
95 ## to ".mex".
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5745
diff changeset
96 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
97 ## @item -s
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
98 ## @itemx --strip
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
99 ## Strip the output file.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
100 ##
6573
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
101 ## @item -v
9180be9d3d08 [project @ 2007-04-25 04:27:16 by jwe]
jwe
parents: 6547
diff changeset
102 ## @itemx --verbose
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
103 ## Echo commands as they are executed.
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
104 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
105 ## @item file
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
106 ## 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
107 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
108 ## @example
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
109 ## .c C source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
110 ## .cc C++ source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
111 ## .C C++ source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
112 ## .cpp C++ 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 ## .F Fortran source
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
115 ## .o object file
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
116 ## @end example
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
117 ##
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
118 ## @end table
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
119 ## @end deftypefn
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
120
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
121 ## PKG_ADD: mark_as_command mkoctfile
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
122
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
123 function mkoctfile (varargin)
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
124
5696
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
125 bindir = octave_config_info ("bindir");
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
126
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
127 shell_script = fullfile (bindir, sprintf ("mkoctfile-%s", OCTAVE_VERSION));
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
128
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
129 cmd = shell_script;
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
130 for i = 1:nargin
5696
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
131 cmd = strcat (cmd, " ", varargin{i});
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
132 endfor
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
133
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
134 status = system (cmd);
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
135
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
136 if (status == 127)
5696
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
137 warning ("unable to find mkoctfile in expected location: `%s'",
70cc04f9af41 [project @ 2006-03-20 18:52:45 by jwe]
jwe
parents: 5695
diff changeset
138 shell_script);
5695
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
139 elseif (status != 0)
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
140 warning ("mkoctfile exited with failure status");
f6ddb906e30f [project @ 2006-03-20 18:34:13 by jwe]
jwe
parents: 5671
diff changeset
141 endif
5671
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
142
387dd5b34757 [project @ 2006-03-15 20:10:45 by jwe]
jwe
parents:
diff changeset
143 endfunction