GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
octave-config.cc
Go to the documentation of this file.
1 // DO NOT EDIT! Generated automatically from octave-config.in.cc by Make.
2 /*
3 
4 Copyright (C) 2008-2015 Michael Goffioul
5 
6 This file is part of Octave.
7 
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 #include <config.h>
26 #endif
27 
28 #include <string>
29 #include <map>
30 #include <iostream>
31 #include <algorithm>
32 #include <cstdlib>
33 
34 #ifndef OCTAVE_PREFIX
35 #define OCTAVE_PREFIX "/usr/local"
36 #endif
37 
38 #include "shared-fcns.h"
39 
40 static std::map<std::string,std::string> vars;
41 
42 static std::string usage_msg = "usage: octave-config [options]";
43 
44 static std::string help_msg =
45 "\n"
46 "Options:\n"
47 "\n"
48 " -h, -?, --help Print this message.\n"
49 "\n"
50 " --m-site-dir Print the name of the directory where Octave\n"
51 " expects to find locally installed .m files.\n"
52 "\n"
53 " --oct-site-dir Print the name of the directory where Octave\n"
54 " expects to find locally installed .oct files.\n"
55 "\n"
56 " -p VAR, --print VAR Print the value of the given configuration\n"
57 " variable VAR. Recognized variables are:\n"
58 "\n"
59 " API_VERSION LOCALARCHLIBDIR\n"
60 " ARCHLIBDIR LOCALFCNFILEDIR\n"
61 " BINDIR LOCALOCTFILEDIR\n"
62 " CANONICAL_HOST_TYPE LOCALSTARTUPFILEDIR\n"
63 " DATADIR LOCALVERARCHLIBDIR\n"
64 " DATAROOTDIR LOCALVERFCNFILEDIR\n"
65 " DEFAULT_PAGER LOCALVEROCTFILEDIR\n"
66 " EXEC_PREFIX MAN1DIR\n"
67 " EXEEXT MAN1EXT\n"
68 " FCNFILEDIR MANDIR\n"
69 " IMAGEDIR OCTDATADIR\n"
70 " INCLUDEDIR OCTFILEDIR\n"
71 " INFODIR OCTINCLUDEDIR\n"
72 " INFOFILE OCTLIBDIR\n"
73 " LIBDIR PREFIX\n"
74 " LIBEXECDIR SHLEXT\n"
75 " LOCALAPIARCHLIBDIR STARTUPFILEDIR\n"
76 " LOCALAPIFCNFILEDIR VERSION\n"
77 " LOCALAPIOCTFILEDIR\n"
78 "\n"
79 " -v, --version Print the Octave version number.\n"
80 "\n";
81 
82 static void
83 initialize (void)
84 {
85  vars["OCTAVE_HOME"] = get_octave_home ();
86  vars["PREFIX"] = OCTAVE_PREFIX;
87 
88  vars["API_VERSION"] = "api-v50+";
89  vars["CANONICAL_HOST_TYPE"] = "x86_64-unknown-linux-gnu";
90  vars["DEFAULT_PAGER"] = "less";
91  vars["MAN1EXT"] = ".1";
92  vars["VERSION"] = "4.0.0";
93 
94  vars["ARCHLIBDIR"] = subst_octave_home ("/usr/local/libexec/octave/4.0.0/exec/x86_64-unknown-linux-gnu");
95  vars["BINDIR"] = subst_octave_home ("/usr/local/bin");
96  vars["DATADIR"] = subst_octave_home ("/usr/local/share");
97  vars["DATAROOTDIR"] = subst_octave_home ("/usr/local/share");
98  vars["EXEC_PREFIX"] = subst_octave_home ("/usr/local");
99  vars["EXEEXT"] = subst_octave_home ("");
100  vars["FCNFILEDIR"] = subst_octave_home ("/usr/local/share/octave/4.0.0/m");
101  vars["IMAGEDIR"] = subst_octave_home ("/usr/local/share/octave/4.0.0/imagelib");
102  vars["INCLUDEDIR"] = subst_octave_home ("/usr/local/include");
103  vars["INFODIR"] = subst_octave_home ("/usr/local/share/info");
104  vars["INFOFILE"] = subst_octave_home ("/usr/local/share/info/octave.info");
105  vars["LIBDIR"] = subst_octave_home ("/usr/local/lib");
106  vars["LIBEXECDIR"] = subst_octave_home ("/usr/local/libexec");
107  vars["LOCALAPIARCHLIBDIR"] = subst_octave_home ("/usr/local/libexec/octave/api-v50+/site/exec/x86_64-unknown-linux-gnu");
108  vars["LOCALAPIFCNFILEDIR"] = subst_octave_home ("/usr/local/share/octave/site/api-v50+/m");
109  vars["LOCALAPIOCTFILEDIR"] = subst_octave_home ("/usr/local/lib/octave/site/oct/api-v50+/x86_64-unknown-linux-gnu");
110  vars["LOCALARCHLIBDIR"] = subst_octave_home ("/usr/local/libexec/octave/site/exec/x86_64-unknown-linux-gnu");
111  vars["LOCALFCNFILEDIR"] = subst_octave_home ("/usr/local/share/octave/site/m");
112  vars["LOCALOCTFILEDIR"] = subst_octave_home ("/usr/local/lib/octave/site/oct/x86_64-unknown-linux-gnu");
113  vars["LOCALSTARTUPFILEDIR"] = subst_octave_home ("/usr/local/share/octave/site/m/startup");
114  vars["LOCALVERARCHLIBDIR"] = subst_octave_home ("/usr/local/libexec/octave/4.0.0/site/exec/x86_64-unknown-linux-gnu");
115  vars["LOCALVERFCNFILEDIR"] = subst_octave_home ("/usr/local/share/octave/4.0.0/site/m");
116  vars["LOCALVEROCTFILEDIR"] = subst_octave_home ("/usr/local/lib/octave/4.0.0/site/oct/x86_64-unknown-linux-gnu");
117  vars["MAN1DIR"] = subst_octave_home ("/usr/local/share/man/man1");
118  vars["MANDIR"] = subst_octave_home ("/usr/local/share/man");
119  vars["OCTDATADIR"] = subst_octave_home ("/usr/local/share/octave/4.0.0/data");
120  vars["OCTFILEDIR"] = subst_octave_home ("/usr/local/lib/octave/4.0.0/oct/x86_64-unknown-linux-gnu");
121  vars["OCTINCLUDEDIR"] = subst_octave_home ("/usr/local/include/octave-4.0.0/octave");
122  vars["OCTLIBDIR"] = subst_octave_home ("/usr/local/lib/octave/4.0.0");
123  vars["SHLEXT"] = subst_octave_home ("so");
124  vars["STARTUPFILEDIR"] = subst_octave_home ("/usr/local/share/octave/4.0.0/m/startup");
125 }
126 
127 int
128 main (int argc, char **argv)
129 {
130  initialize ();
131 
132  if (argc == 1)
133  {
134  std::cout << usage_msg << std::endl;
135  return 1;
136  }
137 
138  for (int i = 1; i < argc; i++)
139  {
140  std::string arg (argv[i]);
141 
142  if (arg == "-h" || arg == "-?" || arg == "--help")
143  {
144  std::cout << usage_msg << std::endl;
145  std::cout << help_msg;
146  return 0;
147  }
148  else if (arg == "--m-site-dir")
149  std::cout << vars["LOCALVERFCNFILEDIR"] << std::endl;
150  else if (arg == "--oct-site-dir")
151  std::cout << vars["LOCALVEROCTFILEDIR"] << std::endl;
152  else if (arg == "-v" || arg == "--version")
153  std::cout << vars["VERSION"] << std::endl;
154  else if (arg == "-p" || arg == "--print")
155  {
156  if (i < argc-1)
157  {
158  arg = argv[++i];
159  std::cout << vars[arg] << std::endl;
160  }
161  else
162  {
163  std::cerr << "octave-config: " << arg
164  << " options requires argument" << std::endl;
165  return 1;
166  }
167  }
168  else
169  {
170  std::cerr << "octave-config: unrecognized argument " << arg
171  << std::endl;
172  return 1;
173  }
174  }
175 
176  return 0;
177 }
static std::string get_octave_home(void)
Definition: shared-fcns.h:107
static std::string subst_octave_home(const std::string &s)
Definition: shared-fcns.h:120
static std::string usage_msg
#define OCTAVE_PREFIX
static void initialize(void)
int main(int argc, char **argv)
static std::string help_msg
double arg(double x)
Definition: lo-mappers.h:37
static std::map< std::string, std::string > vars