]> www.ginac.de Git - ginac.git/blob - cint/ginaccint.cpp
- stamp-vti, version.texi: bumped up version to 0.6.2.
[ginac.git] / cint / ginaccint.cpp
1 /* ginaccint.cpp, a launcher that sets variables to start ginaccint.bin.
2  * This is necessary because Cint is not libtoolized and so may need to have 
3  * LD_LIBRARY_PATH and CINTSYSDIR set.  This cannot be done by a shell-script
4  * because the #!-mechanism works only once and we want to enable the user to
5  * write scripts using that mechanism. */
6
7 #include <unistd.h>
8 #include <stdlib.h>
9 #include <string>
10 #include <iostream>
11 #include "launch.h"
12
13 extern char **environ;
14
15 int main(int argc, char * *argv)
16 {
17     // manually "expand" autoconf-style variables
18     if (exec_prefix=="${prefix}")
19         exec_prefix = prefix;
20     if (bindir=="${exec_prefix}/bin")
21         bindir = exec_prefix + "/bin";
22     if (libdir=="${exec_prefix}/lib")
23         libdir = exec_prefix + "/lib";
24     // now we can guess what to start
25     string binprog = bindir + "/ginaccint.bin";
26     
27     // extend LD_LIBRARY_PATH by libdir, so ginaccint.bin really finds libginac
28     const char * LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
29     if (LD_LIBRARY_PATH == NULL)
30         setenv("LD_LIBRARY_PATH", libdir.c_str(), 1);
31     else
32         setenv("LD_LIBRARY_PATH", (string(LD_LIBRARY_PATH)+':'+libdir).c_str(), 1);
33     
34     // hard-wire CINTSYSDIR, inherited from configure, if it is not set
35     setenv("CINTSYSDIR", CINTSYSDIR.c_str(), 0);
36     
37     // execute the real thing
38     int error = execve(binprog.c_str(), argv, environ);
39     
40     // only gets here on error
41     cerr << argv[0] << ": cannot exec " << binprog << endl;
42     return error;
43 }