]> www.ginac.de Git - ginac.git/blob - cint/run_exams.cpp
documentation update
[ginac.git] / cint / run_exams.cpp
1 /* run_exams.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         // what to start
18         std::string binprog = "./ginaccint.bin";
19         
20         // extend LD_LIBRARY_PATH by ../ginac/.libs, so ginaccint.bin really finds libginac
21         const char * LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
22         if (LD_LIBRARY_PATH == NULL)
23                 setenv("LD_LIBRARY_PATH", "../ginac/.libs", 1);
24         else
25                 setenv("LD_LIBRARY_PATH", (std::string(LD_LIBRARY_PATH)+':'+"../ginac/.libs").c_str(), 1);
26         
27         // hard-wire CINTSYSDIR, inherited from configure, but only if it has
28         // been set therein (to allow for system-wide installations of cint).
29         if (CINTSYSDIR != "@CINTSYSDIR@")
30                 setenv("CINTSYSDIR", CINTSYSDIR.c_str(), 1);
31         
32         // execute the real thing
33         int error = execve(binprog.c_str(), argv, environ);
34         
35         // only gets here on error
36         std::cerr << argv[0] << ": cannot exec " << binprog << std::endl;
37         return error;
38 }