28 #if defined (HAVE_CONFIG_H)
43 #if defined (OCTAVE_USE_WINDOWS_API)
61 # include <sys/types.h>
62 # include <sys/wait.h>
64 # ifndef OCTAVE_UNUSED
65 # define OCTAVE_UNUSED
78 #if ! defined (OCTAVE_VERSION)
79 # define OCTAVE_VERSION %OCTAVE_CONF_VERSION%
82 #if ! defined (OCTAVE_PREFIX)
83 # define OCTAVE_PREFIX %OCTAVE_CONF_PREFIX%
86 #if ! defined (OCTAVE_EXEC_PREFIX)
87 # define OCTAVE_EXEC_PREFIX %OCTAVE_CONF_EXEC_PREFIX%
97 return mkostemps (tmpl, suffixlen, 0);
109 return WIFEXITED (status);
115 return WEXITSTATUS (status);
123 std::ostringstream buf;
127 int c = std::fgetc (fp);
129 if (c ==
'\n' || c == EOF)
132 buf << static_cast<char> (c);
141 const char *val = getenv (name);
144 return std::string (val);
152 if (s.find (
' ') != std::string::npos && s[0] !=
'"')
153 return '"' + s +
'"';
161 #if defined (OCTAVE_REPLACE_PREFIX)
162 const std::string match =
"${prefix}";
164 std::size_t pos = s.find (match);
165 while (pos != std::string::npos )
167 s.replace (pos, match.length (), repl);
168 pos = s.find (match);
175 static std::map<std::string, std::string>
180 std::map<std::string, std::string>
vars;
185 vars[
"API_VERSION"] = %OCTAVE_API_VERSION%;
186 vars[
"CANONICAL_HOST_TYPE"] = %OCTAVE_CANONICAL_HOST_TYPE%;
187 vars[
"DEFAULT_PAGER"] = %OCTAVE_DEFAULT_PAGER%;
188 vars[
"EXEEXT"] = %OCTAVE_EXEEXT%;
189 vars[
"MAN1EXT"] = %OCTAVE_MAN1EXT%;
219 vars[
"OCTINCLUDEDIR"]
234 std::string DEFAULT_INCFLAGS;
236 #if defined (OCTAVE_USE_WINDOWS_API)
237 DEFAULT_INCFLAGS =
"-I" +
quote_path (
vars[
"OCTINCLUDEDIR"] + R
"(\..)")
240 DEFAULT_INCFLAGS =
"-I" +
quote_path (
vars[
"OCTINCLUDEDIR"] +
"/..")
244 if (
vars[
"INCLUDEDIR"] !=
"/usr/include")
247 std::string DEFAULT_LDFLAGS;
249 #if (defined (OCTAVE_USE_WINDOWS_API) || defined (CROSS) || defined (OCTAVE_LINK_ALL_DEPS))
255 if (
vars[
"LIBDIR"] !=
"/usr/lib")
270 if (verbose &&
vars[
"CC"] ==
"cc-msvc")
278 if (verbose &&
vars[
"CXX"] ==
"cc-msvc")
279 vars[
"CXX"] +=
" -d";
284 if (verbose &&
vars[
"CXXLD"] ==
"cc-msvc")
285 vars[
"CXXLD"] +=
" -d";
289 vars[
"XTRA_CFLAGS"] =
get_variable (
"XTRA_CFLAGS", %OCTAVE_CONF_XTRA_CFLAGS%);
292 %OCTAVE_CONF_XTRA_CXXFLAGS%);
299 %OCTAVE_CONF_DEPEND_FLAGS%);
301 vars[
"DEPEND_EXTRA_SED_PATTERN"]
303 %OCTAVE_CONF_DEPEND_EXTRA_SED_PATTERN%);
306 %OCTAVE_CONF_MKOCTFILE_DL_LDFLAGS%);
308 if (! link_stand_alone)
309 DEFAULT_LDFLAGS +=
' ' +
vars[
"DL_LDFLAGS"];
312 %OCTAVE_CONF_RDYNAMIC_FLAG%);
314 vars[
"LIBOCTAVE"] =
"-loctave";
316 vars[
"LIBOCTINTERP"] =
"-loctinterp";
318 vars[
"READLINE_LIBS"] = %OCTAVE_CONF_READLINE_LIBS%;
320 vars[
"LAPACK_LIBS"] =
get_variable (
"LAPACK_LIBS", %OCTAVE_CONF_LAPACK_LIBS%);
324 vars[
"FFTW3_LDFLAGS"]
330 vars[
"FFTW3F_LDFLAGS"]
334 vars[
"FFTW3F_LIBS"] =
get_variable (
"FFTW3F_LIBS", %OCTAVE_CONF_FFTW3F_LIBS%);
342 %OCTAVE_CONF_MKOCTFILE_OCTAVE_LINK_DEPS%);
345 %OCTAVE_CONF_OCTAVE_LINK_OPTS%);
348 %OCTAVE_CONF_MKOCTFILE_OCT_LINK_DEPS%);
350 vars[
"OCT_LINK_OPTS"]
357 %OCTAVE_CONF_LD_STATIC_FLAG%);
361 if (
vars[
"LFLAGS"] != DEFAULT_LDFLAGS)
362 std::cerr <<
"mkoctfile: warning: LFLAGS is deprecated and will be removed in a future version of Octave, use LDFLAGS instead" << std::endl;
365 %OCTAVE_CONF_F77_INTEGER_8_FLAG%);
366 vars[
"ALL_FFLAGS"] =
vars[
"FFLAGS"] +
' ' +
vars[
"F77_INTEGER8_FLAG"];
368 vars[
"ALL_FFLAGS"] +=
" -g";
371 =
vars[
"INCFLAGS"] +
' ' +
vars[
"XTRA_CFLAGS"] +
' ' +
vars[
"CFLAGS"];
373 vars[
"ALL_CFLAGS"] +=
" -g";
376 =
vars[
"INCFLAGS"] +
' ' +
vars[
"XTRA_CXXFLAGS"] +
' ' +
vars[
"CXXFLAGS"];
378 vars[
"ALL_CXXFLAGS"] +=
" -g";
381 =
vars[
"LD_STATIC_FLAG"] +
' ' +
vars[
"CPICFLAG"] +
' ' +
vars[
"LDFLAGS"];
384 = (
vars[
"LIBOCTINTERP"] +
' ' +
vars[
"LIBOCTAVE"] +
' '
385 +
vars[
"SPECIAL_MATH_LIB"]);
387 vars[
"FFTW_LIBS"] =
vars[
"FFTW3_LDFLAGS"] +
' ' +
vars[
"FFTW3_LIBS"] +
' '
388 +
vars[
"FFTW3F_LDFLAGS"] +
' ' +
vars[
"FFTW3F_LIBS"];
393 static std::string
usage_msg =
"usage: mkoctfile [options] file ...";
401 " -h, -?, --help Print this message.\n"
403 " -IDIR Add -IDIR to compile commands.\n"
405 " -idirafter DIR Add -idirafter DIR to compile commands.\n"
407 " -DDEF Add -DDEF to compile commands.\n"
409 " -lLIB Add library LIB to link command.\n"
411 " -LDIR Add -LDIR to link command.\n"
413 " -M, --depend Generate dependency files (.d) for C and C++\n"
415 #if ! defined (OCTAVE_USE_WINDOWS_API)
417 " -pthread Add -pthread to link command.\n"
420 " -RDIR Add -RDIR to link command.\n"
422 " -Wl,... Pass flags though the linker like -Wl,-rpath=...\n"
424 " -W... Pass flags though the compiler like -Wa,OPTION.\n"
426 " -c, --compile Compile, but do not link.\n"
428 " -o FILE, --output FILE Output filename. Default extension is .oct\n"
429 " (or .mex if --mex is specified) unless linking\n"
430 " a stand-alone executable.\n"
432 " -g Enable debugging options for compilers.\n"
434 " -p VAR, --print VAR Print configuration variable VAR. There are\n"
435 " three categories of variables:\n"
437 " Octave configuration variables that users may\n"
438 " override with environment variables. These are\n"
439 " used in commands that mkoctfile executes.\n"
441 " ALL_CFLAGS INCLUDEDIR\n"
442 " ALL_CXXFLAGS LAPACK_LIBS\n"
443 " ALL_FFLAGS LDFLAGS\n"
444 " ALL_LDFLAGS LD_STATIC_FLAG\n"
445 " BLAS_LIBS LIBDIR\n"
447 " CFLAGS LIBOCTINTERP\n"
448 " CPICFLAG OCTAVE_LINK_OPTS\n"
449 " CPPFLAGS OCTINCLUDEDIR\n"
451 " CXXFLAGS OCTAVE_LINK_DEPS\n"
453 " CXXPICFLAG OCT_LINK_DEPS\n"
454 " DL_LDFLAGS OCT_LINK_OPTS\n"
455 " F77 RDYNAMIC_FLAG\n"
456 " F77_INTEGER8_FLAG SPECIAL_MATH_LIB\n"
457 " FFLAGS XTRA_CFLAGS\n"
458 " FPICFLAG XTRA_CXXFLAGS\n"
461 " Octave configuration variables as above, but\n"
462 " currently unused by mkoctfile.\n"
465 " DEPEND_EXTRA_SED_PATTERN\n"
477 " Octave configuration variables that are provided\n"
478 " for informational purposes only. Except for\n"
479 " OCTAVE_HOME and OCTAVE_EXEC_HOME, users may not\n"
480 " override these variables.\n"
482 " If OCTAVE_HOME or OCTAVE_EXEC_HOME are set in\n"
483 " the environment, then other variables are adjusted\n"
484 " accordingly with OCTAVE_HOME or OCTAVE_EXEC_HOME\n"
485 " substituted for the original value of the directory\n"
486 " specified by the --prefix or --exec-prefix options\n"
487 " that were used when Octave was configured.\n"
489 " API_VERSION LOCALFCNFILEDIR\n"
490 " ARCHLIBDIR LOCALOCTFILEDIR\n"
491 " BINDIR LOCALSTARTUPFILEDIR\n"
492 " CANONICAL_HOST_TYPE LOCALVERARCHLIBDIR\n"
493 " DATADIR LOCALVERFCNFILEDIR\n"
494 " DATAROOTDIR LOCALVEROCTFILEDIR\n"
495 " DEFAULT_PAGER MAN1DIR\n"
496 " EXEC_PREFIX MAN1EXT\n"
498 " FCNFILEDIR OCTAVE_EXEC_HOME\n"
499 " IMAGEDIR OCTAVE_HOME\n"
500 " INFODIR OCTAVE_VERSION\n"
501 " INFOFILE OCTDATADIR\n"
502 " LIBEXECDIR OCTDOCDIR\n"
503 " LOCALAPIARCHLIBDIR OCTFILEDIR\n"
504 " LOCALAPIFCNFILEDIR OCTFONTSDIR\n"
505 " LOCALAPIOCTFILEDIR STARTUPFILEDIR\n"
508 " --link-stand-alone Link a stand-alone executable file.\n"
510 " --mex Assume we are creating a MEX file. Set the\n"
511 " default output extension to \".mex\".\n"
513 " -s, --strip Strip output file.\n"
515 " -n, --just-print, --dry-run\n"
516 " Print commands, but do not execute them.\n"
518 " -v, --verbose Echo commands as they are executed.\n"
520 " --silent Ignored. Intended to suppress output from\n"
523 " FILE Compile or link FILE. Recognized file types are:\n"
533 " .f Fortran source (fixed form)\n"
534 " .F Fortran source (fixed form)\n"
535 " .f90 Fortran source (free form)\n"
536 " .F90 Fortran source (free form)\n"
539 #if defined (_MSC_VER)
540 " .lib library file\n"
545 basename (
const std::string& s,
bool strip_path =
false)
549 std::size_t pos = s.rfind (
'.');
551 if (pos == std::string::npos)
554 retval = s.substr (0, pos);
558 std::size_t p1 = retval.rfind (
'/'), p2 = retval.rfind (
'\\');
560 pos = (p1 != std::string::npos && p2 != std::string::npos
561 ?
std::max (p1, p2) : (p2 != std::string::npos ? p2 : p1));
563 if (pos != std::string::npos)
564 retval = retval.substr (++pos, std::string::npos);
573 return (s.length () >= prefix.length () && s.find (prefix) == 0);
577 ends_with (
const std::string& s,
const std::string& suffix)
579 return (s.length () >= suffix.length ()
580 && s.rfind (suffix) == s.length () - suffix.length ());
584 run_command (
const std::string& cmd,
bool verbose,
bool printonly =
false)
588 std::cout << cmd << std::endl;
593 std::cout << cmd << std::endl;
596 int result =
system (cmd.c_str ());
607 return (s ==
"yes" || s ==
"true");
617 #if defined (__MINGW32__) || defined (_MSC_VER)
625 #if defined (P_tmpdir)
632 if (tempd.empty () || tempd == R
"(\)")
633 tempd = R"(c:\temp)";
637 #if defined (P_tmpdir)
655 char *ctmpl =
new char [tmpl.length () + 1];
657 ctmpl = strcpy (ctmpl, tmpl.c_str ());
665 std::string retval (ctmpl);
669 FILE *fid = fdopen (fd,
"w");
670 fputs (
"const int __mx_has_interleaved_complex__ = 1;\n", fid);
681 char *ctmpl =
new char [tmpl.length () + 1];
683 ctmpl = strcpy (ctmpl, tmpl.c_str ());
690 std::string retval (ctmpl);
699 for (
const auto& file : tmp_files)
703 #if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE)
706 wmain (
int argc,
wchar_t **sys_argv)
708 std::vector<std::string> argv;
713 std::wstring_convert<std::codecvt_utf8<wchar_t>,
wchar_t> wchar_conv;
714 for (
int i_arg = 0; i_arg < argc; i_arg++)
715 argv.push_back (wchar_conv.to_bytes (sys_argv[i_arg]));
718 main (
int argc,
char **sys_argv)
720 std::vector<std::string> argv;
723 for (
int i_arg = 0; i_arg < argc; i_arg++)
724 argv.push_back (sys_argv[i_arg]);
733 if (argc == 2 && (argv[1] ==
"-v" || argv[1] ==
"-version"
734 || argv[1] ==
"--version"))
740 std::list<std::string> cfiles, ccfiles, f77files, tmp_objfiles;
741 std::string output_ext =
".oct";
742 std::string objfiles, libfiles, octfile, outputfile;
743 std::string incflags, defs, ldflags, pass_on_options;
744 std::string var_to_print;
746 bool verbose =
false;
748 bool no_oct_file_strip_on_this_platform =
is_true (
"%NO_OCT_FILE_STRIP%");
749 bool compile_only =
false;
750 bool link_stand_alone =
false;
752 bool printonly =
false;
753 bool output_file_option =
false;
754 bool creating_mex_file =
false;
755 bool r2017b_option =
false;
756 bool r2018a_option =
false;
758 bool mx_has_interleaved_complex =
false;
760 for (
int i = 1; i < argc; i++)
762 std::string arg = argv[i];
769 cfiles.push_back (file);
777 ccfiles.push_back (file);
783 f77files.push_back (file);
795 else if (arg ==
"-d" || arg ==
"-debug" || arg ==
"--debug"
796 || arg ==
"-v" || arg ==
"-verbose" || arg ==
"--verbose")
800 else if (arg ==
"-silent" || arg ==
"--silent")
804 else if (arg ==
"-h" || arg ==
"-?" || arg ==
"-help" || arg ==
"--help")
814 else if (arg ==
"-idirafter")
819 incflags += (
" -idirafter " + arg);
822 std::cerr <<
"mkoctfile: include directory name missing"
829 else if (arg ==
"-largeArrayDims" || arg ==
"-compatibleArrayDims")
831 std::cerr <<
"mkoctfile: warning: -largeArrayDims and -compatibleArrayDims are accepted for compatibility, but ignored" << std::endl;
833 else if (arg ==
"-R2017b")
837 std::cerr <<
"mkoctfile: only one of -R2017b and -R2018a may be used" << std::endl;
841 r2017b_option =
true;
843 else if (arg ==
"-R2018a")
847 std::cerr <<
"mkoctfile: only one of -R2017b and -R2018a may be used" << std::endl;
851 r2018a_option =
true;
852 mx_has_interleaved_complex =
true;
859 #if ! defined (OCTAVE_USE_WINDOWS_API)
860 else if (arg ==
"-pthread")
862 ldflags += (
' ' + arg);
865 else if (arg ==
"-M" || arg ==
"-depend" || arg ==
"--depend")
869 else if (arg ==
"-o" || arg ==
"-output" || arg ==
"--output")
871 output_file_option =
true;
879 std::cerr <<
"mkoctfile: output filename missing" << std::endl;
881 else if (arg ==
"-n" || arg ==
"--dry-run" || arg ==
"--just-print")
885 else if (arg ==
"-p" || arg ==
"-print" || arg ==
"--print")
892 if (argv[i] ==
"LFLAGS")
893 std::cerr <<
"mkoctfile: warning: LFLAGS is deprecated and will be removed in a future version of Octave, use LDFLAGS instead" << std::endl;
895 if (! var_to_print.empty ())
896 std::cerr <<
"mkoctfile: warning: only one '" << arg
897 <<
"' option will be processed" << std::endl;
899 var_to_print = argv[i];
902 std::cerr <<
"mkoctfile: --print requires argument" << std::endl;
904 else if (arg ==
"-s" || arg ==
"-strip" || arg ==
"--strip")
906 if (no_oct_file_strip_on_this_platform)
907 std::cerr <<
"mkoctfile: stripping disabled on this platform"
912 else if (arg ==
"-c" || arg ==
"-compile" || arg ==
"--compile")
916 else if (arg ==
"-g")
920 else if (arg ==
"-link-stand-alone" || arg ==
"--link-stand-alone")
922 link_stand_alone =
true;
924 else if (arg ==
"-mex" || arg ==
"--mex")
926 creating_mex_file =
true;
929 #if defined (_MSC_VER)
930 ldflags +=
" -Wl,-export:mexFunction";
936 pass_on_options += (
' ' + arg);
940 pass_on_options += (
' ' + arg);
945 pass_on_options += (
' ' + arg);
953 pass_on_options += (
' ' + arg);
960 std::cerr <<
"mkoctfile: unrecognized argument " << arg << std::endl;
964 if (! file.empty () && octfile.empty ())
968 std::map<std::string, std::string>
vars
971 if (! var_to_print.empty ())
973 if (
vars.find (var_to_print) ==
vars.end ())
975 std::cerr <<
"mkoctfile: unknown variable '" << var_to_print <<
"'"
980 std::cout <<
vars[var_to_print] << std::endl;
985 if (creating_mex_file)
987 if (
vars[
"ALL_CFLAGS"].
find (
"-g") != std::string::npos)
988 defs +=
" -DMEX_DEBUG";
990 if (mx_has_interleaved_complex)
992 defs +=
" -DMX_HAS_INTERLEAVED_COMPLEX=1";
1003 cfiles.push_back (tmp_file);
1010 std::cerr <<
"mkoctfile: warning: -R2017b option ignored unless creating mex file"
1014 std::cerr <<
"mkoctfile: warning: -R2018a option ignored unless creating mex file"
1018 if (compile_only && output_file_option
1019 && (cfiles.size () + ccfiles.size () + f77files.size ()) > 1)
1021 std::cerr <<
"mkoctfile: may not use -c and -o with multiple source files"
1026 std::string output_option;
1028 if (link_stand_alone)
1030 if (! outputfile.empty ())
1031 output_option =
"-o " + outputfile;
1035 if (! outputfile.empty ())
1041 octfile = outputfile;
1042 std::size_t
len = octfile.length ();
1043 std::size_t len_ext = output_ext.length ();
1044 if (
len <= len_ext || octfile.substr (
len-len_ext) != output_ext)
1045 octfile += output_ext;
1048 octfile =
basename (octfile,
true) + output_ext;
1053 #if defined (OCTAVE_USE_WINDOWS_API) && ! defined (_UNICODE)
1054 std::wstring_convert<std::codecvt_utf8<wchar_t>,
wchar_t> wchar_conv;
1057 for (
const auto&
f : cfiles)
1059 std::string dfile =
basename (
f,
true) +
".d", line;
1064 = (
vars[
"CC"] +
' ' +
vars[
"DEPEND_FLAGS"] +
' '
1065 +
vars[
"CPPFLAGS"] +
' ' +
vars[
"ALL_CFLAGS"] +
' '
1068 #if defined (OCTAVE_USE_WINDOWS_API)
1072 std::wstring wcmd = wchar_conv.from_bytes (cmd);
1073 fd = ::_wpopen (wcmd.c_str (), L
"r");
1075 catch (
const std::range_error& e)
1077 fd =
::popen (cmd.c_str (),
"r");
1083 std::wstring wfile = wchar_conv.from_bytes (dfile);
1084 fo.open (wfile.c_str ());
1086 catch (
const std::range_error& e)
1088 fo.open (dfile.c_str ());
1091 FILE *fd =
popen (cmd.c_str (),
"r");
1100 if ((pos = line.rfind (
".o:")) != std::string::npos)
1102 std::size_t spos = line.rfind (
'/', pos);
1104 = (spos == std::string::npos
1105 ? line.substr (0, pos+2)
1106 : line.substr (spos+1, pos-spos+1));
1107 fo <<
"pic/" << ofile <<
' ' << ofile <<
' '
1108 << dfile << line.substr (pos) << std::endl;
1111 fo << line << std::endl;
1117 for (
const auto&
f : ccfiles)
1119 std::string dfile =
basename (
f,
true) +
".d", line;
1124 = (
vars[
"CXX"] +
' ' +
vars[
"DEPEND_FLAGS"] +
' '
1125 +
vars[
"CPPFLAGS"] +
' ' +
vars[
"ALL_CXXFLAGS"] +
' '
1128 #if defined (OCTAVE_USE_WINDOWS_API)
1132 std::wstring wcmd = wchar_conv.from_bytes (cmd);
1133 fd = ::_wpopen (wcmd.c_str (), L
"r");
1135 catch (
const std::range_error& e)
1137 fd =
::popen (cmd.c_str (),
"r");
1143 std::wstring wfile = wchar_conv.from_bytes (dfile);
1144 fo.open (wfile.c_str ());
1146 catch (
const std::range_error& e)
1148 fo.open (dfile.c_str ());
1151 FILE *fd =
popen (cmd.c_str (),
"r");
1160 if ((pos = line.rfind (
".o:")) != std::string::npos)
1162 std::size_t spos = line.rfind (
'/', pos);
1164 = (spos == std::string::npos
1165 ? line.substr (0, pos+2)
1166 : line.substr (spos+1, pos-spos+1));
1167 fo <<
"pic/" << ofile <<
' ' << ofile <<
' '
1168 << dfile << line.substr (pos+2) << std::endl;
1171 fo << line << std::endl;
1180 for (
const auto&
f : f77files)
1182 if (!
vars[
"F77"].empty ())
1187 if (! outputfile.empty ())
1196 tmp_objfiles.push_back (o);
1198 objfiles += (
' ' + o);
1202 = (
vars[
"F77"] +
" -c " +
vars[
"FPICFLAG"] +
' '
1203 +
vars[
"ALL_FFLAGS"] +
' ' + incflags +
' ' + defs +
' '
1207 int status =
run_command (cmd, verbose, printonly);
1214 std::cerr <<
"mkoctfile: no way to compile Fortran file " <<
f
1220 for (
const auto&
f : cfiles)
1222 if (!
vars[
"CC"].empty ())
1227 if (! outputfile.empty ())
1236 tmp_objfiles.push_back (o);
1238 objfiles += (
' ' + o);
1242 = (
vars[
"CC"] +
" -c " +
vars[
"CPPFLAGS"] +
' '
1243 +
vars[
"CPICFLAG"] +
' ' +
vars[
"ALL_CFLAGS"] +
' '
1244 + pass_on_options +
' ' + incflags +
' ' + defs +
' '
1247 int status =
run_command (cmd, verbose, printonly);
1254 std::cerr <<
"mkoctfile: no way to compile C file " <<
f
1260 for (
const auto&
f : ccfiles)
1262 if (!
vars[
"CXX"].empty ())
1267 if (! outputfile.empty ())
1276 tmp_objfiles.push_back (o);
1278 objfiles += (
' ' + o);
1282 = (
vars[
"CXX"] +
" -c " +
vars[
"CPPFLAGS"] +
' '
1283 +
vars[
"CXXPICFLAG"] +
' ' +
vars[
"ALL_CXXFLAGS"] +
' '
1284 + pass_on_options +
' ' + incflags +
' ' + defs +
' '
1287 int status =
run_command (cmd, verbose, printonly);
1294 std::cerr <<
"mkoctfile: no way to compile C++ file " <<
f
1305 if (objfiles.empty ())
1307 std::cerr <<
"mkoctfile: no objects to link" << std::endl;
1311 std::string octave_libs;
1313 if (link_stand_alone)
1315 if (!
vars[
"CXXLD"].empty ())
1318 +
' ' +
vars[
"OCTAVE_LIBS"];
1322 = (
vars[
"CXXLD"] +
' ' +
vars[
"CPPFLAGS"] +
' '
1323 +
vars[
"ALL_CXXFLAGS"] +
' ' +
vars[
"RDYNAMIC_FLAG"] +
' '
1324 + pass_on_options +
' ' + output_option +
' ' + objfiles +
' '
1325 + libfiles +
' ' + ldflags +
' ' +
vars[
"ALL_LDFLAGS"] +
' '
1326 +
vars[
"LFLAGS"] +
' ' + octave_libs +
' '
1327 +
vars[
"OCTAVE_LINK_OPTS"] +
' ' +
vars[
"OCTAVE_LINK_DEPS"]);
1329 int status =
run_command (cmd, verbose, printonly);
1339 <<
"mkoctfile: no way to link stand-alone executable file"
1346 #if defined (OCTAVE_USE_WINDOWS_API) || defined(CROSS)
1348 +
' ' +
vars[
"OCTAVE_LIBS"];
1353 = (
vars[
"CXXLD"] +
' ' +
vars[
"ALL_CXXFLAGS"] +
' '
1354 + pass_on_options +
" -o " + octfile +
' ' + objfiles +
' '
1355 + libfiles +
' ' + ldflags +
' ' +
vars[
"DL_LDFLAGS"] +
' '
1356 +
vars[
"LDFLAGS"] +
' ' +
vars[
"LFLAGS"] +
' ' + octave_libs +
' '
1357 +
vars[
"OCT_LINK_OPTS"] +
' ' +
vars[
"OCT_LINK_DEPS"]);
1359 #if defined (OCTAVE_USE_WINDOWS_API) || defined(CROSS)
1360 if (! f77files.empty () && !
vars[
"FLIBS"].empty ())
1361 cmd +=
' ' +
vars[
"FLIBS"];
1364 int status =
run_command (cmd, verbose, printonly);
1374 std::string cmd =
"strip " + octfile;
1376 int status =
run_command (cmd, verbose, printonly);
charNDArray max(char d, const charNDArray &m)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
int unlink(const std::string &name)
F77_RET_T const F77_DBLE const F77_DBLE * f
int system(const std::string &cmd_str)
std::ofstream ofstream(const std::string &filename, const std::ios::openmode mode)
#define OCTAVE_ARCHLIBDIR
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)
bool is_true(const std::string &s)
bool ends_with(const std::string &s, const std::string &suffix)
static int run_command(const std::string &cmd, bool verbose, bool printonly=false)
int main(int argc, char **sys_argv)
static std::string get_temp_directory(void)
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 > make_vars_map(bool link_stand_alone, bool verbose, bool debug)
static std::string create_interleaved_complex_file(void)
int octave_mkostemps_wrapper(char *tmpl, int suffixlen)
static std::map< std::string, std::string > vars
static std::string Voctave_home
static void set_octave_home(void)
static std::string prepend_octave_exec_home(const std::string &s)
static std::string Voctave_exec_home
static std::string octave_getenv(const std::string &name)
static OCTAVE_UNUSED std::string prepend_octave_home(const std::string &s)
FILE * popen(const char *command, const char *mode)
int octave_unlink_wrapper(const char *nm)
int octave_wexitstatus_wrapper(int status)
bool octave_wifexited_wrapper(int status)