5671
|
1 ## Copyright (C) 2006 Keith Goodman |
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
5695
|
21 ## @deftypefn {Function File} {} mkoctfile [-options] file ... |
|
22 ## |
|
23 ## The @code{mkoctfile} function compiles source code written in C, |
|
24 ## C++, or Fortran. Depending on the options used with @code{mkoctfile}, the |
|
25 ## compiled code can be called within Octave or can be used as a stand-alone |
|
26 ## application. |
|
27 ## |
|
28 ## @code{mkoctfile} can be called from the shell prompt or from the Octave |
|
29 ## prompt. |
|
30 ## |
|
31 ## @code{mkoctfile} accepts the following options, all of which are optional |
|
32 ## except for the file name of the code you wish to compile: |
|
33 ## |
|
34 ## @table @samp |
|
35 ## @item -I DIR |
|
36 ## Add the include directory DIR to compile commands. |
|
37 ## |
|
38 ## @item -D DEF |
|
39 ## Add the definition DEF to the compiler call. |
|
40 ## |
|
41 ## @item -l LIB |
|
42 ## Add the library LIB to the link command. |
|
43 ## |
|
44 ## @item -L DIR |
|
45 ## Add the library directory DIR to the link command. |
|
46 ## |
|
47 ## @item -M|--depend |
|
48 ## Generate dependency files (.d) for C and C++ source files. |
|
49 ## |
|
50 ## @item -c |
|
51 ## Compile but do not link. |
|
52 ## |
5904
|
53 ## @item -g |
|
54 ## Enable debugging options for compilers. |
|
55 ## |
|
56 ## @item -o FILE|--output FILE |
|
57 ## Output file name. Default extension is .oct |
|
58 ## (or .mex if --mex is specified) unless linking |
|
59 ## a stand-alone executable. |
5695
|
60 ## |
|
61 ## @item -p VAR|--print VAR |
|
62 ## Print the configuration variable VAR. Recognized variables are: |
5671
|
63 ## |
5695
|
64 ## @example |
|
65 ## ALL_CFLAGS FFTW_LIBS |
|
66 ## ALL_CXXFLAGS FLIBS |
|
67 ## ALL_FFLAGS FPICFLAG |
|
68 ## ALL_LDFLAGS INCFLAGS |
|
69 ## BLAS_LIBS LDFLAGS |
|
70 ## CC LD_CXX |
|
71 ## CFLAGS LD_STATIC_FLAG |
|
72 ## CPICFLAG LFLAGS |
|
73 ## CPPFLAGS LIBCRUFT |
|
74 ## CXX LIBOCTAVE |
|
75 ## CXXFLAGS LIBOCTINTERP |
|
76 ## CXXPICFLAG LIBREADLINE |
|
77 ## DEPEND_EXTRA_SED_PATTERN LIBS |
|
78 ## DEPEND_FLAGS OCTAVE_LIBS |
|
79 ## DL_LD RDYNAMIC_FLAG |
|
80 ## DL_LDFLAGS RLD_FLAG |
|
81 ## F2C SED |
|
82 ## F2CFLAGS XTRA_CFLAGS |
|
83 ## F77 XTRA_CXXFLAGS |
|
84 ## FFLAGS |
|
85 ## @end example |
5671
|
86 ## |
5745
|
87 ## @item --link-stand-alone |
|
88 ## Link a stand-alone executable file. |
|
89 ## |
5904
|
90 ## @item --mex |
|
91 ## Assume we are creating a MEX file. Set the default output extension |
|
92 ## to ".mex". |
|
93 ## |
5695
|
94 ## @item -s|--strip |
|
95 ## Strip the output file. |
|
96 ## |
|
97 ## @item -v|--verbose |
|
98 ## Echo commands as they are executed. |
|
99 ## |
|
100 ## @item file |
|
101 ## The file to compile or link. Recognised file types are |
|
102 ## |
|
103 ## @example |
|
104 ## .c C source |
|
105 ## .cc C++ source |
|
106 ## .C C++ source |
|
107 ## .cpp C++ source |
|
108 ## .f Fortran source |
|
109 ## .F Fortran source |
|
110 ## .o object file |
|
111 ## @end example |
|
112 ## |
|
113 ## @end table |
5671
|
114 ## @end deftypefn |
|
115 |
5695
|
116 ## PKG_ADD: mark_as_command mkoctfile |
|
117 |
|
118 function mkoctfile (varargin) |
5671
|
119 |
5696
|
120 bindir = octave_config_info ("bindir"); |
|
121 |
|
122 shell_script = fullfile (bindir, sprintf ("mkoctfile-%s", OCTAVE_VERSION)); |
|
123 |
|
124 cmd = shell_script; |
5695
|
125 for i = 1:nargin |
5696
|
126 cmd = strcat (cmd, " ", varargin{i}); |
5695
|
127 endfor |
|
128 |
|
129 status = system (cmd); |
|
130 |
|
131 if (status == 127) |
5696
|
132 warning ("unable to find mkoctfile in expected location: `%s'", |
|
133 shell_script); |
5695
|
134 elseif (status != 0) |
|
135 warning ("mkoctfile exited with failure status"); |
|
136 endif |
5671
|
137 |
|
138 endfunction |