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. */
13 extern char **environ;
15 int main(int argc, char * *argv)
17 // manually "expand" autoconf-style variables
18 if (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 std::string binprog = bindir + "/ginaccint.bin";
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);
32 setenv("LD_LIBRARY_PATH", (std::string(LD_LIBRARY_PATH)+':'+libdir).c_str(), 1);
34 // hard-wire CINTSYSDIR, inherited from configure, if it is not set
35 setenv("CINTSYSDIR", CINTSYSDIR.c_str(), 0);
37 // execute the real thing
38 int error = execve(binprog.c_str(), argv, environ);
40 // only gets here on error
41 std::cerr << argv[0] << ": cannot exec " << binprog << std::endl;