Mercurial > octave-antonio
annotate scripts/miscellaneous/mkoctfile.m @ 12662:2c54fde0f397 stable
Fix passing compiler options to mkoctfile
* mkoctfile.in: Only pass the part after -W to the compiler, plus add
a comma for consistency with -Wl option.
* mkoctfile.m: Document the change.
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Wed, 11 May 2011 00:23:46 -0500 |
parents | 2090995ca588 |
children | 00fbb05f099c |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2006-2011 Keith Goodman |
5671 | 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. | |
5671 | 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/>. | |
5671 | 18 |
19 ## -*- texinfo -*- | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
20 ## @deftypefn {Command} {} mkoctfile [-options] file @dots{} |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
21 ## |
5695 | 22 ## The @code{mkoctfile} function compiles source code written in C, |
23 ## C++, or Fortran. Depending on the options used with @code{mkoctfile}, the | |
24 ## compiled code can be called within Octave or can be used as a stand-alone | |
25 ## application. | |
26 ## | |
27 ## @code{mkoctfile} can be called from the shell prompt or from the Octave | |
28 ## prompt. | |
29 ## | |
30 ## @code{mkoctfile} accepts the following options, all of which are optional | |
31 ## except for the file name of the code you wish to compile: | |
32 ## | |
33 ## @table @samp | |
34 ## @item -I DIR | |
35 ## Add the include directory DIR to compile commands. | |
36 ## | |
37 ## @item -D DEF | |
38 ## Add the definition DEF to the compiler call. | |
39 ## | |
40 ## @item -l LIB | |
41 ## Add the library LIB to the link command. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
42 ## |
5695 | 43 ## @item -L DIR |
44 ## Add the library directory DIR to the link command. | |
45 ## | |
6573 | 46 ## @item -M |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
47 ## @itemx --depend |
5695 | 48 ## Generate dependency files (.d) for C and C++ source files. |
10996
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
49 ## |
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
50 ## @item -R DIR |
11575
d6619410e79c
Spellcheck documentation before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11563
diff
changeset
|
51 ## Add the run-time path to the link command. |
10996
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
52 ## |
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
53 ## @item -Wl,@dots{} |
12662
2c54fde0f397
Fix passing compiler options to mkoctfile
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12175
diff
changeset
|
54 ## Pass flags through the linker e.g. "-Wl,-rpath=@dots{}". |
10996
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
55 ## The quotes are needed since commas are interpreted as command |
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
56 ## separators. |
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
57 ## |
12662
2c54fde0f397
Fix passing compiler options to mkoctfile
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12175
diff
changeset
|
58 ## @item -W,@dots{} |
2c54fde0f397
Fix passing compiler options to mkoctfile
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12175
diff
changeset
|
59 ## Pass flags through the compiler, e.g. "-W,-O2". The quotes are needed |
2c54fde0f397
Fix passing compiler options to mkoctfile
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12175
diff
changeset
|
60 ## since commas are interpreted as command separators. |
10996
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
61 ## |
5695 | 62 ## @item -c |
63 ## Compile but do not link. | |
64 ## | |
5904 | 65 ## @item -g |
66 ## Enable debugging options for compilers. | |
67 ## | |
6573 | 68 ## @item -o FILE |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
69 ## @itemx --output FILE |
5904 | 70 ## Output file name. Default extension is .oct |
12175
2090995ca588
Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
71 ## (or .mex if @samp{--mex} is specified) unless linking |
5904 | 72 ## a stand-alone executable. |
5695 | 73 ## |
6573 | 74 ## @item -p VAR |
75 ## @itemx --print VAR | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
76 ## Print the configuration variable VAR@. Recognized variables are: |
5671 | 77 ## |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
78 ## @example |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
79 ## ALL_CFLAGS FFTW_LIBS |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
80 ## ALL_CXXFLAGS FLIBS |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
81 ## ALL_FFLAGS FPICFLAG |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
82 ## ALL_LDFLAGS INCFLAGS |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
83 ## BLAS_LIBS LDFLAGS |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
84 ## CC LD_CXX |
5695 | 85 ## CFLAGS LD_STATIC_FLAG |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
86 ## CPICFLAG LFLAGS |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
87 ## CPPFLAGS LIBCRUFT |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
88 ## CXX LIBOCTAVE |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
89 ## CXXFLAGS LIBOCTINTERP |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
90 ## CXXPICFLAG LIBREADLINE |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
91 ## DEPEND_EXTRA_SED_PATTERN LIBS |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
92 ## DEPEND_FLAGS OCTAVE_LIBS |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
93 ## DL_LD RDYNAMIC_FLAG |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
94 ## DL_LDFLAGS RLD_FLAG |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
95 ## F2C SED |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
96 ## F2CFLAGS XTRA_CFLAGS |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
97 ## F77 XTRA_CXXFLAGS |
5695 | 98 ## FFLAGS |
99 ## @end example | |
5671 | 100 ## |
5745 | 101 ## @item --link-stand-alone |
102 ## Link a stand-alone executable file. | |
103 ## | |
5904 | 104 ## @item --mex |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
105 ## Assume we are creating a MEX file. Set the default output extension |
5904 | 106 ## to ".mex". |
107 ## | |
6573 | 108 ## @item -s |
109 ## @itemx --strip | |
5695 | 110 ## Strip the output file. |
111 ## | |
6573 | 112 ## @item -v |
113 ## @itemx --verbose | |
5695 | 114 ## Echo commands as they are executed. |
115 ## | |
116 ## @item file | |
9080
ec41eabf4499
Cleanup documentation files dynamic.texi, testfun.texi, tips.texi
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
117 ## The file to compile or link. Recognized file types are |
5695 | 118 ## |
119 ## @example | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
120 ## @group |
5695 | 121 ## .c C source |
122 ## .cc C++ source | |
123 ## .C C++ source | |
124 ## .cpp C++ source | |
10996
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
125 ## .f Fortran source (fixed form) |
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
126 ## .F Fortran source (fixed form) |
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
127 ## .f90 Fortran source (free form) |
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
128 ## .F90 Fortran source (free form) |
5695 | 129 ## .o object file |
10996
72640afb02b9
mkoctfile.m: Change help text to be consistent with the shell version.
Ben Abbott <bpabbott@mac.com>
parents:
10793
diff
changeset
|
130 ## .a library file |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
131 ## @end group |
5695 | 132 ## @end example |
133 ## | |
134 ## @end table | |
5671 | 135 ## @end deftypefn |
136 | |
5695 | 137 function mkoctfile (varargin) |
5671 | 138 |
5696 | 139 bindir = octave_config_info ("bindir"); |
140 | |
141 shell_script = fullfile (bindir, sprintf ("mkoctfile-%s", OCTAVE_VERSION)); | |
142 | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
143 cmd = cstrcat ("\"", shell_script, "\""); |
5695 | 144 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
|
145 cmd = cstrcat (cmd, " \"", varargin{i}, "\""); |
5695 | 146 endfor |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11575
diff
changeset
|
147 |
5695 | 148 status = system (cmd); |
149 | |
150 if (status == 127) | |
5696 | 151 warning ("unable to find mkoctfile in expected location: `%s'", |
10549 | 152 shell_script); |
6706 | 153 |
5695 | 154 warning ("mkoctfile exited with failure status"); |
155 endif | |
5671 | 156 |
157 endfunction |