23 #if defined (HAVE_CONFIG_H)
33 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
38 static std::map<std::string,std::string>
vars;
40 static std::string
usage_msg =
"usage: octave-config [options]";
45 " -h, -?, --help Print this message.\n"
47 " --m-site-dir Print the name of the directory where Octave\n"
48 " expects to find locally installed .m files.\n"
50 " --oct-site-dir Print the name of the directory where Octave\n"
51 " expects to find locally installed .oct files.\n"
53 " -p VAR, --print VAR Print the value of the given configuration\n"
54 " variable VAR. Recognized variables are:\n"
56 " API_VERSION LOCALAPIARCHLIBDIR\n"
57 " CANONICAL_HOST_TYPE LOCALAPIFCNFILEDIR\n"
58 " DEFAULT_PAGER LOCALAPIOCTFILEDIR\n"
59 " ARCHLIBDIR LOCALARCHLIBDIR\n"
60 " BINDIR LOCALFCNFILEDIR\n"
61 " DATADIR LOCALOCTFILEDIR\n"
62 " DATAROOTDIR LOCALSTARTUPFILEDIR\n"
63 " EXEC_PREFIX LOCALVERARCHLIBDIR\n"
64 " FCNFILEDIR LOCALVERFCNFILEDIR\n"
65 " LOCALVEROCTFILEDIR MAN1DIR\n"
67 " MAN1EXT OCTFILEDIR\n"
68 " INCLUDEDIR OCTINCLUDEDIR\n"
69 " INFODIR OCTLIBDIR\n"
71 " LIBDIR STARTUPFILEDIR\n"
72 " LIBEXECDIR VERSION\n"
74 " -v, --version Print the Octave version number.\n"
79 const std::string new_prefix)
81 std::string retval = s;
83 if (!prefix.empty () && new_prefix != prefix)
85 int len = prefix.length ();
86 if (retval.find (prefix) == 0)
87 retval.replace (0, len, new_prefix);
90 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
91 std::replace (retval.begin (), retval.end (),
'/',
'\\');
105 const char *homestr = getenv (
"OCTAVE_HOME");
109 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
112 std::string bin_dir (n,
'\0');
116 int status = GetModuleFileName (0, &bin_dir[0], n);
120 bin_dir.resize (status);
130 if (! bin_dir.empty ())
132 size_t pos = bin_dir.rfind (
"\\bin\\");
134 if (pos != std::string::npos)
206 for (
int i = 1; i < argc; i++)
208 std::string
arg (argv[i]);
210 if (arg ==
"-h" || arg ==
"-?" || arg ==
"--help")
216 else if (arg ==
"--m-site-dir")
217 std::cout << vars[
"LOCALVERFCNFILEDIR"] << std::endl;
218 else if (arg ==
"--oct-site-dir")
219 std::cout << vars[
"LOCALVEROCTFILEDIR"] << std::endl;
220 else if (arg ==
"-v" || arg ==
"--version")
221 std::cout << vars[
"VERSION"] << std::endl;
222 else if (arg ==
"-p" || arg ==
"--print")
227 std::cout << vars[
arg] << std::endl;
231 std::cerr <<
"octave-config: " << arg
232 <<
" options requires argument" << std::endl;
238 std::cerr <<
"octave-config: unrecognized argument " << arg