GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
mkoctfile.in.cc
Go to the documentation of this file.
1 // %NO_EDIT_WARNING%
2 
3 ////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2008-2021 The Octave Project Developers
6 //
7 // See the file COPYRIGHT.md in the top-level directory of this
8 // distribution or <https://octave.org/copyright/>.
9 //
10 // This file is part of Octave.
11 //
12 // Octave is free software: you can redistribute it and/or modify it
13 // under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // Octave is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with Octave; see the file COPYING. If not, see
24 // <https://www.gnu.org/licenses/>.
25 //
26 ////////////////////////////////////////////////////////////////////////
27 
28 #if defined (HAVE_CONFIG_H)
29 # include "config.h"
30 #endif
31 
32 #include <string>
33 #include <cstring>
34 #include <map>
35 #include <list>
36 #include <algorithm>
37 #include <iostream>
38 #include <fstream>
39 #include <sstream>
40 #include <vector>
41 #include <cstdlib>
42 
43 // Programming note: The CROSS macro here refers to building a
44 // cross-compiler aware version of mkoctfile that can be used to cross
45 // compile .oct file for Windows builds of Octave, not that mkoctfile
46 // itself is being cross compiled.
47 //
48 // We don't use the wrapper and gnulib functions when we are building
49 // with CROSS defined. This configuration is only expected to work on
50 // modern systems that should not need to have gnulib to fix POSIX
51 // portability problems. So we just assume a working POSIX system when
52 // CROSS is defined.
53 
54 #if defined (CROSS)
55 # include <stdlib.h>
56 # include <sys/types.h>
57 # include <sys/wait.h>
58 # include <unistd.h>
59 # ifndef OCTAVE_UNUSED
60 # define OCTAVE_UNUSED
61 # endif
62 #else
63 # include "mkostemps-wrapper.h"
64 # include "uniconv-wrappers.h"
65 # include "unistd-wrappers.h"
66 # include "wait-wrappers.h"
67 #endif
68 
69 static std::map<std::string, std::string> vars;
70 
71 #if ! defined (OCTAVE_VERSION)
72 # define OCTAVE_VERSION %OCTAVE_CONF_VERSION%
73 #endif
74 
75 #if ! defined (OCTAVE_PREFIX)
76 # define OCTAVE_PREFIX %OCTAVE_CONF_PREFIX%
77 #endif
78 
79 #if ! defined (OCTAVE_EXEC_PREFIX)
80 # define OCTAVE_EXEC_PREFIX %OCTAVE_CONF_EXEC_PREFIX%
81 #endif
82 
83 #include "shared-fcns.h"
84 
85 #if defined (CROSS)
86 
87 static int
88 octave_mkostemps_wrapper (char *tmpl, int suffixlen)
89 {
90  return mkostemps (tmpl, suffixlen, 0);
91 }
92 
93 static char *
94 octave_u8_conv_to_encoding (const char *tocode, const uint8_t *src,
95  size_t srclen, size_t *lengthp)
96 {
97  // FIXME: Do we need to provide the conversion here?
98  return nullptr;
99 }
100 
101 static int
102 octave_unlink_wrapper (const char *nm)
103 {
104  return unlink (nm);
105 }
106 
107 static bool
108 octave_wifexited_wrapper (int status)
109 {
110  return WIFEXITED (status);
111 }
112 
113 static int
114 octave_wexitstatus_wrapper (int status)
115 {
116  return WEXITSTATUS (status);
117 }
118 
119 #endif
120 
121 static std::string
122 get_line (FILE *fp)
123 {
124  std::ostringstream buf;
125 
126  while (true)
127  {
128  int c = std::fgetc (fp);
129 
130  if (c == '\n' || c == EOF)
131  break;
132 
133  buf << static_cast<char> (c);
134  }
135 
136  return buf.str ();
137 }
138 
139 static std::string
140 get_variable (const char *name, const std::string& defval)
141 {
142  const char *val = getenv (name);
143 
144  if (val && *val)
145  return std::string (val);
146  else
147  return defval;
148 }
149 
150 static std::string
151 quote_path (const std::string& s)
152 {
153  if (s.find (' ') != std::string::npos && s[0] != '"')
154  return '"' + s + '"';
155  else
156  return s;
157 }
158 
159 static std::string
160 replace_prefix (std::string s)
161 {
162  const std::string match = "${prefix}";
163  size_t pos = s.find (match);
164  while (pos != std::string::npos )
165  {
166  s.replace(pos, match.length (), prepend_octave_exec_home (""));
167  pos = s.find (match);
168  }
169 
170  return s;
171 }
172 
173 static void
175 {
176  set_octave_home ();
177 
178  vars["OCTAVE_HOME"] = Voctave_home;
179  vars["OCTAVE_EXEC_HOME"] = Voctave_exec_home;
180 
181  vars["API_VERSION"] = %OCTAVE_API_VERSION%;
182  vars["CANONICAL_HOST_TYPE"] = %OCTAVE_CANONICAL_HOST_TYPE%;
183  vars["DEFAULT_PAGER"] = %OCTAVE_DEFAULT_PAGER%;
184  vars["EXEEXT"] = %OCTAVE_EXEEXT%;
185  vars["MAN1EXT"] = %OCTAVE_MAN1EXT%;
186  vars["OCTAVE_VERSION"] = %OCTAVE_VERSION%;
187 
188  vars["ARCHLIBDIR"] = prepend_octave_exec_home (%OCTAVE_ARCHLIBDIR%);
190  vars["DATADIR"] = prepend_octave_home (%OCTAVE_DATADIR%);
191  vars["DATAROOTDIR"] = prepend_octave_home (%OCTAVE_DATAROOTDIR%);
192  vars["FCNFILEDIR"] = prepend_octave_home (%OCTAVE_FCNFILEDIR%);
193  vars["IMAGEDIR"] = prepend_octave_home (%OCTAVE_IMAGEDIR%);
194  vars["INFODIR"] = prepend_octave_home (%OCTAVE_INFODIR%);
195  vars["INFOFILE"] = prepend_octave_home (%OCTAVE_INFOFILE%);
196  vars["LIBEXECDIR"] = prepend_octave_exec_home (%OCTAVE_LIBEXECDIR%);
197  vars["LOCALAPIARCHLIBDIR"] = prepend_octave_exec_home (%OCTAVE_LOCALAPIARCHLIBDIR%);
198  vars["LOCALAPIFCNFILEDIR"] = prepend_octave_home (%OCTAVE_LOCALAPIFCNFILEDIR%);
199  vars["LOCALAPIOCTFILEDIR"] = prepend_octave_exec_home (%OCTAVE_LOCALAPIOCTFILEDIR%);
200  vars["LOCALARCHLIBDIR"] = prepend_octave_exec_home (%OCTAVE_LOCALARCHLIBDIR%);
201  vars["LOCALFCNFILEDIR"] = prepend_octave_home (%OCTAVE_LOCALFCNFILEDIR%);
202  vars["LOCALOCTFILEDIR"] = prepend_octave_exec_home (%OCTAVE_LOCALOCTFILEDIR%);
203  vars["LOCALSTARTUPFILEDIR"] = prepend_octave_home (%OCTAVE_LOCALSTARTUPFILEDIR%);
204  vars["LOCALVERARCHLIBDIR"] = prepend_octave_exec_home (%OCTAVE_LOCALVERARCHLIBDIR%);
205  vars["LOCALVERFCNFILEDIR"] = prepend_octave_home (%OCTAVE_LOCALVERFCNFILEDIR%);
206  vars["LOCALVEROCTFILEDIR"] = prepend_octave_exec_home (%OCTAVE_LOCALVEROCTFILEDIR%);
207  vars["MAN1DIR"] = prepend_octave_home (%OCTAVE_MAN1DIR%);
208  vars["MANDIR"] = prepend_octave_home (%OCTAVE_MANDIR%);
209  vars["OCTDATADIR"] = prepend_octave_home (%OCTAVE_OCTDATADIR%);
210  vars["OCTDOCDIR"] = prepend_octave_home (%OCTAVE_OCTDOCDIR%);
211  vars["OCTFILEDIR"] = prepend_octave_exec_home (%OCTAVE_OCTFILEDIR%);
212  vars["OCTFONTSDIR"] = prepend_octave_home (%OCTAVE_OCTFONTSDIR%);
213  vars["STARTUPFILEDIR"] = prepend_octave_home (%OCTAVE_STARTUPFILEDIR%);
214 
215  vars["OCTINCLUDEDIR"]
216  = get_variable ("OCTINCLUDEDIR",
217  prepend_octave_home (%OCTAVE_CONF_OCTINCLUDEDIR%));
218 
219  vars["INCLUDEDIR"]
220  = get_variable ("INCLUDEDIR",
221  prepend_octave_home (%OCTAVE_CONF_INCLUDEDIR%));
222 
223  vars["LIBDIR"]
224  = get_variable ("LIBDIR", prepend_octave_exec_home (%OCTAVE_CONF_LIBDIR%));
225 
226  vars["OCTLIBDIR"]
227  = get_variable ("OCTLIBDIR",
228  prepend_octave_exec_home (%OCTAVE_CONF_OCTLIBDIR%));
229 
230 #if defined (OCTAVE_USE_WINDOWS_API)
231  std::string DEFAULT_INCFLAGS
232  = "-I" + quote_path (vars["OCTINCLUDEDIR"] + R"(\..)")
233  + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
234 #else
235  std::string DEFAULT_INCFLAGS
236  = "-I" + quote_path (vars["OCTINCLUDEDIR"] + "/..")
237  + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
238 #endif
239 
240  if (vars["INCLUDEDIR"] != "/usr/include")
241  DEFAULT_INCFLAGS += " -I" + quote_path (vars["INCLUDEDIR"]);
242 
243  std::string DEFAULT_LDFLAGS;
244 
245 #if (defined (OCTAVE_USE_WINDOWS_API) || defined (CROSS)) || (defined __APPLE__ && defined __MACH__)
246 
247  // We'll be linking the files we compile with -loctinterp and -loctave,
248  // so we need to know where to find them.
249  DEFAULT_LDFLAGS += "-L" + quote_path (vars["OCTLIBDIR"]);
250 #endif
251 
252  if (vars["LIBDIR"] != "/usr/lib")
253  DEFAULT_LDFLAGS += " -L" + quote_path (vars["LIBDIR"]);
254 
255  vars["CPPFLAGS"] = get_variable ("CPPFLAGS",
256  replace_prefix (%OCTAVE_CONF_CPPFLAGS%));
257 
258  vars["INCFLAGS"] = get_variable ("INCFLAGS", DEFAULT_INCFLAGS);
259 
260  vars["F77"] = get_variable ("F77", %OCTAVE_CONF_MKOCTFILE_F77%);
261 
262  vars["FFLAGS"] = get_variable ("FFLAGS", %OCTAVE_CONF_FFLAGS%);
263 
264  vars["FPICFLAG"] = get_variable ("FPICFLAG", %OCTAVE_CONF_FPICFLAG%);
265 
266  vars["CC"] = get_variable ("CC", %OCTAVE_CONF_MKOCTFILE_CC%);
267 
268  vars["CFLAGS"] = get_variable ("CFLAGS", %OCTAVE_CONF_CFLAGS%);
269 
270  vars["CPICFLAG"] = get_variable ("CPICFLAG", %OCTAVE_CONF_CPICFLAG%);
271 
272  vars["CXX"] = get_variable ("CXX", %OCTAVE_CONF_MKOCTFILE_CXX%);
273 
274  vars["CXXFLAGS"] = get_variable ("CXXFLAGS", %OCTAVE_CONF_CXXFLAGS%);
275 
276  vars["CXXLD"] = get_variable ("CXXLD", vars["CXX"]);
277 
278  vars["CXXPICFLAG"] = get_variable ("CXXPICFLAG", %OCTAVE_CONF_CXXPICFLAG%);
279 
280  vars["XTRA_CFLAGS"] = get_variable ("XTRA_CFLAGS", %OCTAVE_CONF_XTRA_CFLAGS%);
281 
282  vars["XTRA_CXXFLAGS"] = get_variable ("XTRA_CXXFLAGS",
283  %OCTAVE_CONF_XTRA_CXXFLAGS%);
284 
285  vars["AR"] = get_variable ("AR", %OCTAVE_CONF_MKOCTFILE_AR%);
286 
287  vars["RANLIB"] = get_variable ("RANLIB", %OCTAVE_CONF_MKOCTFILE_RANLIB%);
288 
289  vars["DEPEND_FLAGS"] = get_variable ("DEPEND_FLAGS",
290  %OCTAVE_CONF_DEPEND_FLAGS%);
291 
292  vars["DEPEND_EXTRA_SED_PATTERN"]
293  = get_variable ("DEPEND_EXTRA_SED_PATTERN",
294  %OCTAVE_CONF_DEPEND_EXTRA_SED_PATTERN%);
295 
296  vars["DL_LDFLAGS"] = get_variable ("DL_LDFLAGS",
297  %OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%);
298 
299  vars["RDYNAMIC_FLAG"] = get_variable ("RDYNAMIC_FLAG",
300  %OCTAVE_CONF_RDYNAMIC_FLAG%);
301 
302  vars["LIBOCTAVE"] = "-loctave";
303 
304  vars["LIBOCTINTERP"] = "-loctinterp";
305 
306  vars["READLINE_LIBS"] = "-lreadline";
307 
308  vars["LAPACK_LIBS"] = get_variable ("LAPACK_LIBS", %OCTAVE_CONF_LAPACK_LIBS%);
309 
310  vars["BLAS_LIBS"] = get_variable ("BLAS_LIBS", %OCTAVE_CONF_BLAS_LIBS%);
311 
312  vars["FFTW3_LDFLAGS"]
313  = get_variable ("FFTW3_LDFLAGS",
314  replace_prefix (%OCTAVE_CONF_FFTW3_LDFLAGS%));
315 
316  vars["FFTW3_LIBS"] = get_variable ("FFTW3_LIBS", %OCTAVE_CONF_FFTW3_LIBS%);
317 
318  vars["FFTW3F_LDFLAGS"]
319  = get_variable ("FFTW3F_LDFLAGS",
320  replace_prefix (%OCTAVE_CONF_FFTW3F_LDFLAGS%));
321 
322  vars["FFTW3F_LIBS"] = get_variable ("FFTW3F_LIBS", %OCTAVE_CONF_FFTW3F_LIBS%);
323 
324  vars["LIBS"] = get_variable ("LIBS", %OCTAVE_CONF_LIBS%);
325 
326  vars["FLIBS"] = get_variable ("FLIBS",
327  replace_prefix (%OCTAVE_CONF_FLIBS%));
328 
329  vars["OCTAVE_LINK_DEPS"] = get_variable ("OCTAVE_LINK_DEPS",
330  %OCTAVE_CONF_MKOCTFILE_OCTAVE_LINK_DEPS%);
331 
332  vars["OCTAVE_LINK_OPTS"] = get_variable ("OCTAVE_LINK_OPTS",
333  %OCTAVE_CONF_OCTAVE_LINK_OPTS%);
334 
335  vars["OCT_LINK_DEPS"] = get_variable ("OCT_LINK_DEPS",
336  %OCTAVE_CONF_MKOCTFILE_OCT_LINK_DEPS%);
337 
338  vars["OCT_LINK_OPTS"]
339  = get_variable ("OCT_LINK_OPTS",
340  replace_prefix (%OCTAVE_CONF_OCT_LINK_OPTS%));
341 
342  vars["LDFLAGS"] = get_variable ("LDFLAGS",
343  replace_prefix (%OCTAVE_CONF_LDFLAGS%));
344 
345  vars["LD_STATIC_FLAG"] = get_variable ("LD_STATIC_FLAG",
346  %OCTAVE_CONF_LD_STATIC_FLAG%);
347 
348  // FIXME: Remove LFLAGS in Octave 8.0
349  vars["LFLAGS"] = get_variable ("LFLAGS", DEFAULT_LDFLAGS);
350  if (vars["LFLAGS"] != DEFAULT_LDFLAGS)
351  std::cerr << "warning: LFLAGS is deprecated and will be removed in a future version of Octave, use LDFLAGS instead" << std::endl;
352 
353  vars["F77_INTEGER8_FLAG"] = get_variable ("F77_INTEGER8_FLAG",
354  %OCTAVE_CONF_F77_INTEGER_8_FLAG%);
355  vars["ALL_FFLAGS"] = vars["FFLAGS"] + ' ' + vars["F77_INTEGER8_FLAG"];
356 
357  vars["ALL_CFLAGS"]
358  = vars["INCFLAGS"] + ' ' + vars["XTRA_CFLAGS"] + ' ' + vars["CFLAGS"];
359 
360  vars["ALL_CXXFLAGS"]
361  = vars["INCFLAGS"] + ' ' + vars["XTRA_CXXFLAGS"] + ' ' + vars["CXXFLAGS"];
362 
363  vars["ALL_LDFLAGS"]
364  = vars["LD_STATIC_FLAG"] + ' ' + vars["CPICFLAG"] + ' ' + vars["LDFLAGS"];
365 
366  vars["OCTAVE_LIBS"]
367  = (vars["LIBOCTINTERP"] + ' ' + vars["LIBOCTAVE"] + ' '
368  + vars["SPECIAL_MATH_LIB"]);
369 
370  vars["FFTW_LIBS"] = vars["FFTW3_LDFLAGS"] + ' ' + vars["FFTW3_LIBS"] + ' '
371  + vars["FFTW3F_LDFLAGS"] + ' ' + vars["FFTW3F_LIBS"];
372 }
373 
374 static std::string usage_msg = "usage: mkoctfile [options] file ...";
375 
376 static std::string version_msg = "mkoctfile, version " OCTAVE_VERSION;
377 
378 static bool debug = false;
379 
380 static std::string help_msg =
381  "\n"
382  "Options:\n"
383  "\n"
384  " -h, -?, --help Print this message.\n"
385  "\n"
386  " -IDIR Add -IDIR to compile commands.\n"
387  "\n"
388  " -idirafter DIR Add -idirafter DIR to compile commands.\n"
389  "\n"
390  " -DDEF Add -DDEF to compile commands.\n"
391  "\n"
392  " -lLIB Add library LIB to link command.\n"
393  "\n"
394  " -LDIR Add -LDIR to link command.\n"
395  "\n"
396  " -M, --depend Generate dependency files (.d) for C and C++\n"
397  " source files.\n"
398 #if ! defined (OCTAVE_USE_WINDOWS_API)
399  "\n"
400  " -pthread Add -pthread to link command.\n"
401 #endif
402  "\n"
403  " -RDIR Add -RDIR to link command.\n"
404  "\n"
405  " -Wl,... Pass flags though the linker like -Wl,-rpath=...\n"
406  "\n"
407  " -W... Pass flags though the compiler like -Wa,OPTION.\n"
408  "\n"
409  " -c, --compile Compile, but do not link.\n"
410  "\n"
411  " -o FILE, --output FILE Output filename. Default extension is .oct\n"
412  " (or .mex if --mex is specified) unless linking\n"
413  " a stand-alone executable.\n"
414  "\n"
415  " -g Enable debugging options for compilers.\n"
416  "\n"
417  " -p VAR, --print VAR Print configuration variable VAR. There are\n"
418  " three categories of variables:\n"
419  "\n"
420  " Octave configuration variables that users may\n"
421  " override with environment variables. These are\n"
422  " used in commands that mkoctfile executes.\n"
423  "\n"
424  " ALL_CFLAGS INCLUDEDIR\n"
425  " ALL_CXXFLAGS LAPACK_LIBS\n"
426  " ALL_FFLAGS LDFLAGS\n"
427  " ALL_LDFLAGS LD_STATIC_FLAG\n"
428  " BLAS_LIBS LIBDIR\n"
429  " CC LIBOCTAVE\n"
430  " CFLAGS LIBOCTINTERP\n"
431  " CPICFLAG OCTAVE_LINK_OPTS\n"
432  " CPPFLAGS OCTINCLUDEDIR\n"
433  " CXX OCTAVE_LIBS\n"
434  " CXXFLAGS OCTAVE_LINK_DEPS\n"
435  " CXXLD OCTLIBDIR\n"
436  " CXXPICFLAG OCT_LINK_DEPS\n"
437  " DL_LDFLAGS OCT_LINK_OPTS\n"
438  " F77 RDYNAMIC_FLAG\n"
439  " F77_INTEGER8_FLAG SPECIAL_MATH_LIB\n"
440  " FFLAGS XTRA_CFLAGS\n"
441  " FPICFLAG XTRA_CXXFLAGS\n"
442  " INCFLAGS\n"
443  "\n"
444  " Octave configuration variables as above, but\n"
445  " currently unused by mkoctfile.\n"
446  "\n"
447  " AR\n"
448  " DEPEND_EXTRA_SED_PATTERN\n"
449  " DEPEND_FLAGS\n"
450  " FFTW3F_LDFLAGS\n"
451  " FFTW3F_LIBS\n"
452  " FFTW3_LDFLAGS\n"
453  " FFTW3_LIBS\n"
454  " FFTW_LIBS\n"
455  " FLIBS\n"
456  " LIBS\n"
457  " RANLIB\n"
458  " READLINE_LIBS\n"
459  "\n"
460  " Octave configuration variables that are provided\n"
461  " for informational purposes only. Except for\n"
462  " OCTAVE_HOME and OCTAVE_EXEC_HOME, users may not\n"
463  " override these variables.\n"
464  "\n"
465  " If OCTAVE_HOME or OCTAVE_EXEC_HOME are set in\n"
466  " the environment, then other variables are adjusted\n"
467  " accordingly with OCTAVE_HOME or OCTAVE_EXEC_HOME\n"
468  " substituted for the original value of the directory\n"
469  " specified by the --prefix or --exec-prefix options\n"
470  " that were used when Octave was configured.\n"
471  "\n"
472  " API_VERSION LOCALFCNFILEDIR\n"
473  " ARCHLIBDIR LOCALOCTFILEDIR\n"
474  " BINDIR LOCALSTARTUPFILEDIR\n"
475  " CANONICAL_HOST_TYPE LOCALVERARCHLIBDIR\n"
476  " DATADIR LOCALVERFCNFILEDIR\n"
477  " DATAROOTDIR LOCALVEROCTFILEDIR\n"
478  " DEFAULT_PAGER MAN1DIR\n"
479  " EXEC_PREFIX MAN1EXT\n"
480  " EXEEXT MANDIR\n"
481  " FCNFILEDIR OCTAVE_EXEC_HOME\n"
482  " IMAGEDIR OCTAVE_HOME\n"
483  " INFODIR OCTAVE_VERSION\n"
484  " INFOFILE OCTDATADIR\n"
485  " LIBEXECDIR OCTDOCDIR\n"
486  " LOCALAPIARCHLIBDIR OCTFILEDIR\n"
487  " LOCALAPIFCNFILEDIR OCTFONTSDIR\n"
488  " LOCALAPIOCTFILEDIR STARTUPFILEDIR\n"
489  " LOCALARCHLIBDIR\n"
490  "\n"
491  " --link-stand-alone Link a stand-alone executable file.\n"
492  "\n"
493  " --mex Assume we are creating a MEX file. Set the\n"
494  " default output extension to \".mex\".\n"
495  "\n"
496  " -s, --strip Strip output file.\n"
497  "\n"
498  " -n, --just-print, --dry-run\n"
499  " Print commands, but do not execute them.\n"
500  "\n"
501  " -v, --verbose Echo commands as they are executed.\n"
502  "\n"
503  " --silent Ignored. Intended to suppress output from\n"
504  " compiler steps.\n"
505  "\n"
506  " FILE Compile or link FILE. Recognized file types are:\n"
507  "\n"
508  " .c C source\n"
509  " .cc C++ source\n"
510  " .cp C++ source\n"
511  " .cpp C++ source\n"
512  " .CPP C++ source\n"
513  " .cxx C++ source\n"
514  " .c++ C++ source\n"
515  " .C C++ source\n"
516  " .f Fortran source (fixed form)\n"
517  " .F Fortran source (fixed form)\n"
518  " .f90 Fortran source (free form)\n"
519  " .F90 Fortran source (free form)\n"
520  " .o object file\n"
521  " .a library file\n"
522 #if defined (_MSC_VER)
523  " .lib library file\n"
524 #endif
525  "\n";
526 
527 static std::string
528 basename (const std::string& s, bool strip_path = false)
529 {
530  std::string retval;
531 
532  size_t pos = s.rfind ('.');
533 
534  if (pos == std::string::npos)
535  retval = s;
536  else
537  retval = s.substr (0, pos);
538 
539  if (strip_path)
540  {
541  size_t p1 = retval.rfind ('/'), p2 = retval.rfind ('\\');
542 
543  pos = (p1 != std::string::npos && p2 != std::string::npos
544  ? std::max (p1, p2) : (p2 != std::string::npos ? p2 : p1));
545 
546  if (pos != std::string::npos)
547  retval = retval.substr (++pos, std::string::npos);
548  }
549 
550  return retval;
551 }
552 
553 inline bool
554 starts_with (const std::string& s, const std::string& prefix)
555 {
556  return (s.length () >= prefix.length () && s.find (prefix) == 0);
557 }
558 
559 inline bool
560 ends_with (const std::string& s, const std::string& suffix)
561 {
562  return (s.length () >= suffix.length ()
563  && s.rfind (suffix) == s.length () - suffix.length ());
564 }
565 
566 static int
567 run_command (const std::string& cmd, bool printonly = false)
568 {
569  if (printonly)
570  {
571  std::cout << cmd << std::endl;
572  return 0;
573  }
574 
575  if (debug)
576  std::cout << cmd << std::endl;
577 
578  int result = system (cmd.c_str ());
579 
580  if (octave_wifexited_wrapper (result))
581  result = octave_wexitstatus_wrapper (result);
582 
583  return result;
584 }
585 
586 bool
587 is_true (const std::string& s)
588 {
589  return (s == "yes" || s == "true");
590 }
591 
592 static std::string
594 {
595  std::string tempd;
596 
597  tempd = octave_getenv ("TMPDIR");
598 
599 #if defined (__MINGW32__) || defined (_MSC_VER)
600 
601  if (tempd.empty ())
602  tempd = octave_getenv ("TEMP");
603 
604  if (tempd.empty ())
605  tempd = octave_getenv ("TMP");
606 
607 #if defined (P_tmpdir)
608  if (tempd.empty ())
609  tempd = P_tmpdir;
610 #endif
611 
612  // Some versions of MinGW and MSVC either don't define P_tmpdir, or
613  // define it to a single backslash. In such cases just use C:\temp.
614  if (tempd.empty () || tempd == R"(\)")
615  tempd = R"(c:\temp)";
616 
617 #else
618 
619 #if defined (P_tmpdir)
620  if (tempd.empty ())
621  tempd = P_tmpdir;
622 #else
623  if (tempd.empty ())
624  tempd = "/tmp";
625 #endif
626 
627 #endif
628 
629  return tempd;
630 }
631 
632 static std::string
634 {
635  std::string tmpl = get_temp_directory () + "/oct-XXXXXX.o";
636 
637  char *ctmpl = new char [tmpl.length () + 1];
638 
639  ctmpl = strcpy (ctmpl, tmpl.c_str ());
640 
641  // mkostemps will open the file and return a file descriptor. We
642  // won't worry about closing it because we will need the file until we
643  // are done and then the file will be closed when mkoctfile exits.
644  octave_mkostemps_wrapper (ctmpl, 2);
645 
646  std::string retval (ctmpl); // make C++ string from filled-in template
647  delete [] ctmpl;
648 
649  return retval;
650 }
651 
652 static void
653 clean_up_tmp_files (const std::list<std::string>& tmp_files)
654 {
655  for (const auto& file : tmp_files)
656  octave_unlink_wrapper (file.c_str ());
657 }
658 
659 int
660 main (int argc, char **argv)
661 {
662  initialize ();
663 
664  if (argc == 1)
665  {
666  std::cout << usage_msg << std::endl;
667  return 1;
668  }
669 
670  if (argc == 2 && (! strcmp (argv[1], "-v")
671  || ! strcmp (argv[1], "-version")
672  || ! strcmp (argv[1], "--version")))
673  {
674  std::cout << version_msg << std::endl;
675  return 0;
676  }
677 
678  std::list<std::string> cfiles, ccfiles, f77files, tmp_objfiles;
679  std::string output_ext = ".oct";
680  std::string objfiles, libfiles, octfile, outputfile;
681  std::string incflags, defs, ldflags, pass_on_options;
682  bool strip = false;
683  bool no_oct_file_strip_on_this_platform = is_true ("%NO_OCT_FILE_STRIP%");
684  bool compile_only = false;
685  bool link_stand_alone = false;
686  bool depend = false;
687  bool printonly = false;
688  bool output_file_option = false;
689 
690  for (int i = 1; i < argc; i++)
691  {
692  std::string arg = argv[i];
693 
694  std::string file;
695 
696  if (ends_with (arg, ".c"))
697  {
698  file = arg;
699  cfiles.push_back (file);
700  }
701  else if (ends_with (arg, ".cc") || ends_with (arg, ".cp")
702  || ends_with (arg, ".cpp") || ends_with (arg, ".CPP")
703  || ends_with (arg, ".cxx") || ends_with (arg, ".c++")
704  || ends_with (arg, ".C"))
705  {
706  file = arg;
707  ccfiles.push_back (file);
708  }
709  else if (ends_with (arg, ".f") || ends_with (arg, ".F")
710  || ends_with (arg, "f90") || ends_with (arg, ".F90"))
711  {
712  file = arg;
713  f77files.push_back (file);
714  }
715  else if (ends_with (arg, ".o") || ends_with (arg, ".obj"))
716  {
717  file = arg;
718  objfiles += (' ' + quote_path (arg));
719  }
720  else if (ends_with (arg, ".lib") || ends_with (arg, ".a"))
721  {
722  file = arg;
723  libfiles += (' ' + quote_path (arg));
724  }
725  else if (arg == "-d" || arg == "-debug" || arg == "--debug"
726  || arg == "-v" || arg == "-verbose" || arg == "--verbose")
727  {
728  debug = true;
729  if (vars["CC"] == "cc-msvc")
730  vars["CC"] += " -d";
731  if (vars["CXX"] == "cc-msvc")
732  vars["CXX"] += " -d";
733  if (vars["CXXLD"] == "cc-msvc")
734  vars["CXXLD"] += " -d";
735  }
736  else if (arg == "-silent" || arg == "--silent")
737  {
738  // Ignored for now.
739  }
740  else if (arg == "-h" || arg == "-?" || arg == "-help" || arg == "--help")
741  {
742  std::cout << usage_msg << std::endl;
743  std::cout << help_msg << std::endl;
744  return 0;
745  }
746  else if (starts_with (arg, "-I"))
747  {
748  incflags += (' ' + quote_path (arg));
749  }
750  else if (arg == "-idirafter")
751  {
752  if (i < argc-1)
753  {
754  arg = argv[++i];
755  incflags += (" -idirafter " + arg);
756  }
757  else
758  std::cerr << "mkoctfile: include directory name missing"
759  << std::endl;
760  }
761  else if (starts_with (arg, "-D"))
762  {
763  defs += (' ' + arg);
764  }
765  else if (arg == "-largeArrayDims" || arg == "-compatibleArrayDims")
766  {
767  std::cerr << "warning: -largeArrayDims and -compatibleArrayDims are accepted for compatibility, but ignored" << std::endl;
768  }
769  else if (starts_with (arg, "-Wl,") || starts_with (arg, "-l")
770  || starts_with (arg, "-L") || starts_with (arg, "-R"))
771  {
772  ldflags += (' ' + quote_path (arg));
773  }
774 #if ! defined (OCTAVE_USE_WINDOWS_API)
775  else if (arg == "-pthread")
776  {
777  ldflags += (' ' + arg);
778  }
779 #endif
780  else if (arg == "-M" || arg == "-depend" || arg == "--depend")
781  {
782  depend = true;
783  }
784  else if (arg == "-o" || arg == "-output" || arg == "--output")
785  {
786  output_file_option = true;
787 
788  if (i < argc-1)
789  {
790  arg = argv[++i];
791  outputfile = arg;
792  }
793  else
794  std::cerr << "mkoctfile: output filename missing" << std::endl;
795  }
796  else if (arg == "-n" || arg == "--dry-run" || arg == "--just-print")
797  {
798  printonly = true;
799  }
800  else if (arg == "-p" || arg == "-print" || arg == "--print")
801  {
802  if (i < argc-1)
803  {
804  arg = argv[++i];
805  // FIXME: Remove LFLAGS checking in Octave 7.0
806  if (arg == "LFLAGS")
807  std::cerr << "warning: LFLAGS is deprecated and will be removed in a future version of Octave, use LDFLAGS instead" << std::endl;
808 
809  std::cout << vars[arg] << std::endl;
810  return 0;
811  }
812  else
813  std::cerr << "mkoctfile: --print requires argument" << std::endl;
814  }
815  else if (arg == "-s" || arg == "-strip" || arg == "--strip")
816  {
817  if (no_oct_file_strip_on_this_platform)
818  std::cerr << "mkoctfile: stripping disabled on this platform"
819  << std::endl;
820  else
821  strip = true;
822  }
823  else if (arg == "-c" || arg == "-compile" || arg == "--compile")
824  {
825  compile_only = true;
826  }
827  else if (arg == "-g")
828  {
829  vars["ALL_CFLAGS"] += " -g";
830  vars["ALL_CXXFLAGS"] += " -g";
831  vars["ALL_FFLAGS"] += " -g";
832  }
833  else if (arg == "-link-stand-alone" || arg == "--link-stand-alone")
834  {
835  link_stand_alone = true;
836  }
837  else if (arg == "-mex" || arg == "--mex")
838  {
839  incflags += " -I.";
840 #if defined (_MSC_VER)
841  ldflags += " -Wl,-export:mexFunction";
842 #endif
843  output_ext = ".mex";
844  }
845  else if (starts_with (arg, "-W"))
846  {
847  pass_on_options += (' ' + arg);
848  }
849  else if (starts_with (arg, "-O"))
850  {
851  pass_on_options += (' ' + arg);
852  }
853  else if (starts_with (arg, "-"))
854  {
855  // Pass through any unrecognized options.
856  pass_on_options += (' ' + arg);
857  // Check for an additional argument following the option.
858  // However, don't check the final position which is typically a file
859  if (i < argc-2)
860  {
861  arg = argv[i+1];
862  if (arg[0] != '-')
863  {
864  pass_on_options += (' ' + arg);
865  i++;
866  }
867  }
868  }
869  else
870  {
871  std::cerr << "mkoctfile: unrecognized argument " << arg << std::endl;
872  return 1;
873  }
874 
875  if (! file.empty () && octfile.empty ())
876  octfile = file;
877  }
878 
879  if (output_ext == ".mex"
880  && vars["ALL_CFLAGS"].find ("-g") != std::string::npos)
881  {
882  defs += " -DMEX_DEBUG";
883  }
884 
885  if (compile_only && output_file_option
886  && (cfiles.size () + ccfiles.size () + f77files.size ()) > 1)
887  {
888  std::cerr << "mkoctfile: may not use -c and -o with multiple source files"
889  << std::endl;
890  return 1;
891  }
892 
893  std::string output_option;
894 
895  if (link_stand_alone)
896  {
897  if (! outputfile.empty ())
898  output_option = "-o " + outputfile;
899  }
900  else
901  {
902  if (! outputfile.empty ())
903  {
904  // FIXME: should probably do a better job of finding the
905  // filename extension instead of just looking at the filename
906  // length.
907 
908  octfile = outputfile;
909  size_t len = octfile.length ();
910  size_t len_ext = output_ext.length ();
911  if (len <= len_ext || octfile.substr (len-len_ext) != output_ext)
912  octfile += output_ext;
913  }
914  else
915  octfile = basename (octfile, true) + output_ext;
916  }
917 
918  if (depend)
919  {
920  for (const auto& f : cfiles)
921  {
922  std::string dfile = basename (f, true) + ".d", line;
923 
924  octave_unlink_wrapper (dfile.c_str ());
925 
926  std::string cmd
927  = (vars["CC"] + ' ' + vars["DEPEND_FLAGS"] + ' '
928  + vars["CPPFLAGS"] + ' ' + vars["ALL_CFLAGS"] + ' '
929  + incflags + ' ' + defs + ' ' + quote_path (f));
930 
931  // FIXME: Use wide character API for popen on Windows.
932  FILE *fd = popen (cmd.c_str (), "r");
933 
934 #if defined (OCTAVE_USE_WINDOWS_API)
935  // FIXME: liboctinterp isn't linked in to mkoctfile.
936  // So we cannot use octave::sys::ofstream. Instead we fall back
937  // on using the functions available from libwrappers.
938  size_t srclen = dfile.length ();
939  const uint8_t *src = reinterpret_cast<const uint8_t *>
940  (dfile.c_str ());
941 
942  size_t length = 0;
943  wchar_t *wchar = reinterpret_cast<wchar_t *>
944  (octave_u8_conv_to_encoding ("wchar_t", src, srclen,
945  &length));
946 
947  std::ofstream fo;
948  if (wchar != nullptr)
949  {
950  fo.open (wchar);
951  free (static_cast<void *> (wchar));
952  }
953  else
954  fo.open (dfile.c_str ());
955 #else
956  std::ofstream fo (dfile.c_str ());
957 #endif
958  size_t pos;
959  while (! feof (fd))
960  {
961  line = get_line (fd);
962  if ((pos = line.rfind (".o:")) != std::string::npos)
963  {
964  size_t spos = line.rfind ('/', pos);
965  std::string ofile
966  = (spos == std::string::npos
967  ? line.substr (0, pos+2)
968  : line.substr (spos+1, pos-spos+1));
969  fo << "pic/" << ofile << ' ' << ofile << ' '
970  << dfile << line.substr (pos) << std::endl;
971  }
972  else
973  fo << line << std::endl;
974  }
975  pclose (fd);
976  fo.close ();
977  }
978 
979  for (const auto& f : ccfiles)
980  {
981  std::string dfile = basename (f, true) + ".d", line;
982 
983  octave_unlink_wrapper (dfile.c_str ());
984 
985  std::string cmd
986  = (vars["CXX"] + ' ' + vars["DEPEND_FLAGS"] + ' '
987  + vars["CPPFLAGS"] + ' ' + vars["ALL_CXXFLAGS"] + ' '
988  + incflags + ' ' + defs + ' ' + quote_path (f));
989 
990  // FIXME: Use wide character API for popen on Windows.
991  FILE *fd = popen (cmd.c_str (), "r");
992 
993 #if defined (OCTAVE_USE_WINDOWS_API)
994  // FIXME: liboctinterp isn't linked in to mkoctfile.
995  // So we cannot use octave::sys::ofstream. Instead we fall back
996  // on using the functions available from libwrappers.
997  size_t srclen = dfile.length ();
998  const uint8_t *src = reinterpret_cast<const uint8_t *>
999  (dfile.c_str ());
1000 
1001  size_t length = 0;
1002  wchar_t *wchar = reinterpret_cast<wchar_t *>
1003  (octave_u8_conv_to_encoding ("wchar_t", src, srclen,
1004  &length));
1005 
1006  std::ofstream fo;
1007  if (wchar != nullptr)
1008  {
1009  fo.open (wchar);
1010  free (static_cast<void *> (wchar));
1011  }
1012  else
1013  fo.open (dfile.c_str ());
1014 #else
1015  std::ofstream fo (dfile.c_str ());
1016 #endif
1017  size_t pos;
1018  while (! feof (fd))
1019  {
1020  line = get_line (fd);
1021  if ((pos = line.rfind (".o:")) != std::string::npos)
1022  {
1023  size_t spos = line.rfind ('/', pos);
1024  std::string ofile
1025  = (spos == std::string::npos
1026  ? line.substr (0, pos+2)
1027  : line.substr (spos+1, pos-spos+1));
1028  fo << "pic/" << ofile << ' ' << ofile << ' '
1029  << dfile << line.substr (pos+2) << std::endl;
1030  }
1031  else
1032  fo << line << std::endl;
1033  }
1034  pclose (fd);
1035  fo.close ();
1036  }
1037 
1038  return 0;
1039  }
1040 
1041  for (const auto& f : f77files)
1042  {
1043  if (! vars["F77"].empty ())
1044  {
1045  std::string o;
1046  if (compile_only)
1047  {
1048  if (! outputfile.empty ())
1049  o = outputfile;
1050  else
1051  o = basename (f, true) + ".o";
1052  }
1053  else
1054  {
1055  o = tmp_objfile_name ();
1056 
1057  tmp_objfiles.push_back (o);
1058 
1059  objfiles += (' ' + o);
1060  }
1061 
1062  std::string cmd
1063  = (vars["F77"] + " -c " + vars["FPICFLAG"] + ' '
1064  + vars["ALL_FFLAGS"] + ' ' + incflags + ' ' + defs + ' '
1065  + pass_on_options + ' ' + f + " -o " + o);
1066 
1067  int status = run_command (cmd, printonly);
1068 
1069  if (status)
1070  return status;
1071  }
1072  else
1073  {
1074  std::cerr << "mkoctfile: no way to compile Fortran file " << f
1075  << std::endl;
1076  return 1;
1077  }
1078  }
1079 
1080  for (const auto& f : cfiles)
1081  {
1082  if (! vars["CC"].empty ())
1083  {
1084  std::string o;
1085  if (compile_only)
1086  {
1087  if (! outputfile.empty ())
1088  o = outputfile;
1089  else
1090  o = basename (f, true) + ".o";
1091  }
1092  else
1093  {
1094  o = tmp_objfile_name ();
1095 
1096  tmp_objfiles.push_back (o);
1097 
1098  objfiles += (' ' + o);
1099  }
1100 
1101  std::string cmd
1102  = (vars["CC"] + " -c " + vars["CPPFLAGS"] + ' '
1103  + vars["CPICFLAG"] + ' ' + vars["ALL_CFLAGS"] + ' '
1104  + pass_on_options + ' ' + incflags + ' ' + defs + ' '
1105  + quote_path (f) + " -o " + quote_path (o));
1106 
1107  int status = run_command (cmd, printonly);
1108 
1109  if (status)
1110  return status;
1111  }
1112  else
1113  {
1114  std::cerr << "mkoctfile: no way to compile C file " << f
1115  << std::endl;
1116  return 1;
1117  }
1118  }
1119 
1120  for (const auto& f : ccfiles)
1121  {
1122  if (! vars["CXX"].empty ())
1123  {
1124  std::string o;
1125  if (compile_only)
1126  {
1127  if (! outputfile.empty ())
1128  o = outputfile;
1129  else
1130  o = basename (f, true) + ".o";
1131  }
1132  else
1133  {
1134  o = tmp_objfile_name ();
1135 
1136  tmp_objfiles.push_back (o);
1137 
1138  objfiles += (' ' + o);
1139  }
1140 
1141  std::string cmd
1142  = (vars["CXX"] + " -c " + vars["CPPFLAGS"] + ' '
1143  + vars["CXXPICFLAG"] + ' ' + vars["ALL_CXXFLAGS"] + ' '
1144  + pass_on_options + ' ' + incflags + ' ' + defs + ' '
1145  + quote_path (f) + " -o " + quote_path (o));
1146 
1147  int status = run_command (cmd, printonly);
1148 
1149  if (status)
1150  return status;
1151  }
1152  else
1153  {
1154  std::cerr << "mkoctfile: no way to compile C++ file " << f
1155  << std::endl;
1156  return 1;
1157  }
1158  }
1159 
1160  // If we are only compiling, we are done.
1161 
1162  if (compile_only)
1163  return 0;
1164 
1165  if (objfiles.empty ())
1166  {
1167  std::cerr << "mkoctfile: no objects to link" << std::endl;
1168  return 1;
1169  }
1170 
1171  std::string octave_libs;
1172 
1173  if (link_stand_alone)
1174  {
1175  if (! vars["CXXLD"].empty ())
1176  {
1177  octave_libs = "-L" + quote_path (vars["OCTLIBDIR"])
1178  + ' ' + vars["OCTAVE_LIBS"];
1179 
1180  std::string cmd
1181  = (vars["CXXLD"] + ' ' + vars["CPPFLAGS"] + ' '
1182  + vars["ALL_CXXFLAGS"] + ' ' + vars["RDYNAMIC_FLAG"] + ' '
1183  + pass_on_options + ' ' + output_option + ' ' + objfiles + ' '
1184  + libfiles + ' ' + vars["ALL_LDFLAGS"] + ' ' + ldflags + ' '
1185  + vars["LFLAGS"] + ' ' + octave_libs + ' '
1186  + vars["OCTAVE_LINK_OPTS"] + ' ' + vars["OCTAVE_LINK_DEPS"]);
1187 
1188  int status = run_command (cmd, printonly);
1189 
1190  clean_up_tmp_files (tmp_objfiles);
1191 
1192  if (status)
1193  return status;
1194  }
1195  else
1196  {
1197  std::cerr
1198  << "mkoctfile: no way to link stand-alone executable file"
1199  << std::endl;
1200  return 1;
1201  }
1202  }
1203  else
1204  {
1205 #if defined (OCTAVE_USE_WINDOWS_API) || defined(CROSS)
1206  octave_libs = "-L" + quote_path (vars["OCTLIBDIR"])
1207  + ' ' + vars["OCTAVE_LIBS"];
1208 #endif
1209 
1210  std::string cmd
1211  = (vars["CXXLD"] + ' ' + vars["ALL_CXXFLAGS"] + ' '
1212  + pass_on_options + " -o " + octfile + ' ' + objfiles + ' '
1213  + libfiles + ' ' + vars["DL_LDFLAGS"] + ' ' + vars["LDFLAGS"] + ' '
1214  + ldflags + ' ' + vars["LFLAGS"] + ' ' + octave_libs + ' '
1215  + vars["OCT_LINK_OPTS"] + ' ' + vars["OCT_LINK_DEPS"]);
1216 
1217 #if defined (OCTAVE_USE_WINDOWS_API) || defined(CROSS)
1218  if (! f77files.empty () && ! vars["FLIBS"].empty ())
1219  cmd += ' ' + vars["FLIBS"];
1220 #endif
1221 
1222  int status = run_command (cmd, printonly);
1223 
1224  clean_up_tmp_files (tmp_objfiles);
1225 
1226  if (status)
1227  return status;
1228  }
1229 
1230  if (strip)
1231  {
1232  std::string cmd = "strip " + octfile;
1233 
1234  int status = run_command (cmd, printonly);
1235 
1236  if (status)
1237  return status;
1238  }
1239 
1240  return 0;
1241 }
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
Definition: colamd.cc:104
#define OCTAVE_LOCALSTARTUPFILEDIR
#define OCTAVE_LOCALVERFCNFILEDIR
#define OCTAVE_LOCALAPIOCTFILEDIR
#define OCTAVE_OCTDOCDIR
#define OCTAVE_LIBEXECDIR
#define OCTAVE_INFOFILE
#define OCTAVE_LOCALVEROCTFILEDIR
#define OCTAVE_OCTFONTSDIR
#define OCTAVE_OCTDATADIR
#define OCTAVE_FCNFILEDIR
#define OCTAVE_MAN1EXT
#define OCTAVE_LOCALOCTFILEDIR
#define OCTAVE_MANDIR
#define OCTAVE_LOCALAPIARCHLIBDIR
#define OCTAVE_STARTUPFILEDIR
#define OCTAVE_INFODIR
#define OCTAVE_DEFAULT_PAGER
#define OCTAVE_OCTFILEDIR
#define OCTAVE_LOCALARCHLIBDIR
#define OCTAVE_LOCALVERARCHLIBDIR
#define OCTAVE_IMAGEDIR
#define OCTAVE_LOCALFCNFILEDIR
#define OCTAVE_LOCALAPIFCNFILEDIR
#define OCTAVE_MAN1DIR
#define OCTAVE_DATADIR
#define OCTAVE_DATAROOTDIR
QString name
F77_RET_T const F77_DBLE const F77_DBLE * f
#define OCTAVE_BINDIR
Definition: main.in.cc:60
#define OCTAVE_ARCHLIBDIR
Definition: main.in.cc:56
static std::string version_msg
static std::string quote_path(const std::string &s)
static std::string tmp_objfile_name(void)
static std::string get_line(FILE *fp)
static std::string help_msg
static std::string basename(const std::string &s, bool strip_path=false)
static bool debug
int main(int argc, char **argv)
#define OCTAVE_VERSION
Definition: mkoctfile.in.cc:72
bool is_true(const std::string &s)
bool ends_with(const std::string &s, const std::string &suffix)
static void initialize(void)
static std::string get_temp_directory(void)
static int run_command(const std::string &cmd, bool printonly=false)
static std::string get_variable(const char *name, const std::string &defval)
static std::string replace_prefix(std::string s)
static std::string usage_msg
bool starts_with(const std::string &s, const std::string &prefix)
static void clean_up_tmp_files(const std::list< std::string > &tmp_files)
static std::map< std::string, std::string > vars
Definition: mkoctfile.in.cc:69
int octave_mkostemps_wrapper(char *tmpl, int suffixlen)
bool strcmp(const T &str_a, const T &str_b)
True if strings are the same.
Definition: oct-string.cc:122
int unlink(const std::string &name)
Definition: file-ops.cc:626
std::ofstream ofstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:395
FILE * popen(const char *command, const char *mode)
Definition: sysdep.cc:619
int pclose(FILE *f)
Definition: sysdep.cc:643
void free(void *)
octave_value::octave_value(const Array< char > &chm, char type) return retval
Definition: ov.cc:811
static std::string Voctave_home
Definition: shared-fcns.h:101
static void set_octave_home(void)
Definition: shared-fcns.h:105
static std::string prepend_octave_exec_home(const std::string &s)
Definition: shared-fcns.h:189
static std::string Voctave_exec_home
Definition: shared-fcns.h:102
static std::string octave_getenv(const std::string &name)
Definition: shared-fcns.h:94
static OCTAVE_UNUSED std::string prepend_octave_home(const std::string &s)
Definition: shared-fcns.h:183
char * octave_u8_conv_to_encoding(const char *tocode, const uint8_t *src, size_t srclen, size_t *lengthp)
int octave_unlink_wrapper(const char *nm)
#define OCTAVE_CANONICAL_HOST_TYPE
Definition: version.in.h:53
#define OCTAVE_API_VERSION
Definition: version.in.h:49
int octave_wexitstatus_wrapper(int status)
bool octave_wifexited_wrapper(int status)
F77_RET_T len
Definition: xerbla.cc:61