From bug-request at octave dot org Sat Mar 18 20:38:06 2006 Subject: Re: [Pkg-octave-devel] Update for mkoctfile manpage From: "Keith Goodman" To: "John W. Eaton" Cc: "octave bug mailing list" Date: Sat, 18 Mar 2006 18:36:02 -0800 ------=_Part_8247_27798708.1142735762884 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 3/17/06, John W. Eaton wrote: > On 17-Mar-2006, I wrote: > > | status =3D system ("mkoctfile args ..."); > | > | if (status =3D=3D 127) > | warning ("unable to find info program `%s'", INFO_PROGRAM); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > Oops, sorry, I copied this from the new doc.m and forgot to change the > message. You might watn to make it mention mkoctfile... Here's a patch that makes it possible to call mkoctfile from the Octave prompt. But I probably need to do so more work on it. If the file to compile is not specified with a path and is not in the current working directory should I try to find it with file_in_loadpath? Or is that dangerous? How do you compile a stand-alone application? In Da Coda Al Fine I see mkoctfile --link-stand-alone but that's not mentioned in mkoctfile's info file. Are there any other options that are not mentioned? Some examples in the doc string would be helpful. But the only example I know is mkoctfile myfun.cc. (BTW, that is the only example I have tested.) I assigned the copyright to myself but I copy and pasted some text from the info file and from John and David's emails. What's the right way to deal with that? Sorry to ask so many questions. ------=_Part_8247_27798708.1142735762884 Content-Type: application/octet-stream; name=mkoctfile_patch Content-Transfer-Encoding: 7bit X-Attachment-Id: f_ekyr4oru Content-Disposition: attachment; filename="mkoctfile_patch" 2006-03-18 Keith Goodman * miscellaneous/mkoctfile.m: Added ability to call mkoctfile from Octave prompt. Index: mkoctfile.m =================================================================== RCS file: /cvs/octave/scripts/miscellaneous/mkoctfile.m,v retrieving revision 1.1 diff -u -r1.1 mkoctfile.m --- mkoctfile.m 15 Mar 2006 20:10:45 -0000 1.1 +++ mkoctfile.m 19 Mar 2006 02:32:54 -0000 at @ -18,19 +18,109 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## at deftypefn {Function File} {} mkoctfile () -## The at code{mkoctfile} shell script compiles source code written in C, -## C++, or Fortran. Depending on the command-line options used with -## at code{mkoctfile}, the compiled code can be called within Octave or -## can be used as a stand-alone application. +## at deftypefn {Function File} {} mkoctfile [-options] file ... +## +## The at code{mkoctfile} function compiles source code written in C, +## C++, or Fortran. Depending on the options used with at code{mkoctfile}, the +## compiled code can be called within Octave or can be used as a stand-alone +## application. ## -## Run at code{mkoctfile} from the shell prompt, not from the Octave prompt. +## at code{mkoctfile} can be called from the shell prompt or from the Octave +## prompt. ## -## See the man or info page of at code{mkoctfile} for a full description. +## at code{mkoctfile} accepts the following options, all of which are optional +## except for the file name of the code you wish to compile: +## +## at table @samp +## at item -I DIR +## Add the include directory DIR to compile commands. +## +## at item -D DEF +## Add the definition DEF to the compiler call. +## +## at item -l LIB +## Add the library LIB to the link command. +## +## at item -L DIR +## Add the library directory DIR to the link command. +## +## at item| -M -M|--depend +## Generate dependency files (.d) for C and C++ source files. +## +## at item -c +## Compile but do not link. +## +## at item| -o FILE -o FILE|--output FILE +## Output file name; by default extension is .oct. +## +## at item| -p VAR -p VAR|--print VAR +## Print the configuration variable VAR. Recognized variables are: +## +## at example +## ALL_CFLAGS FFTW_LIBS +## ALL_CXXFLAGS FLIBS +## ALL_FFLAGS FPICFLAG +## ALL_LDFLAGS INCFLAGS +## BLAS_LIBS LDFLAGS +## CC LD_CXX +## CFLAGS LD_STATIC_FLAG +## CPICFLAG LFLAGS +## CPPFLAGS LIBCRUFT +## CXX LIBOCTAVE +## CXXFLAGS LIBOCTINTERP +## CXXPICFLAG LIBREADLINE +## DEPEND_EXTRA_SED_PATTERN LIBS +## DEPEND_FLAGS OCTAVE_LIBS +## DL_LD RDYNAMIC_FLAG +## DL_LDFLAGS RLD_FLAG +## F2C SED +## F2CFLAGS XTRA_CFLAGS +## F77 XTRA_CXXFLAGS +## FFLAGS +## at end example +## +## at item| -s -s|--strip +## Strip the output file. +## +## at item| -v -v|--verbose +## Echo commands as they are executed. +## +## at item file +## The file to compile or link. Recognised file types are +## +## at example +## .c C source +## .cc C++ source +## .C C++ source +## .cpp C++ source +## .f Fortran source +## .F Fortran source +## .o object file +## at end example +## +## at end table ## at end deftypefn -function mkoctfile () +## PKG_ADD: mark_as_command mkoctfile + + +function mkoctfile (varargin) + + mkoctpath = strcat(octave_config_info.bindir, filesep, "mkoctfile"); + + options = ""; + for i = 1:nargin + options = strcat (options, " ", varargin{i}); + endfor + + cmd = strcat (mkoctpath, options); + + status = system (cmd); - error ("run mkoctfile from the shell prompt, not from the Octave prompt"); + if (status == 127) + warning ("unable to find mkoctfile in expected location: %s", mkoctpath); + elseif (status != 0) + warning ("mkoctfile exited with failure status"); + endif endfunction ------=_Part_8247_27798708.1142735762884-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------