Lines 54-59
Link Here
|
54 |
#include "gb_str.h" |
54 |
#include "gb_str.h" |
55 |
#include "gambas.h" |
55 |
#include "gambas.h" |
56 |
|
56 |
|
|
|
57 |
/* needed to install in a different location than /usr */ |
58 |
char *which(const char *app) |
59 |
{ |
60 |
char *path = NULL; |
61 |
char *p = NULL; |
62 |
char *rValue = NULL; |
63 |
|
64 |
path = getenv("PATH"); |
65 |
if (!path) { |
66 |
path = "/usr/bin/"; |
67 |
} |
68 |
p = strtok(strdup(path), ":"); |
69 |
while (p) { |
70 |
rValue = (char *)calloc(sizeof(char), strlen(p)+strlen(app)+2); |
71 |
strcat(rValue, p); |
72 |
rValue[strlen(p)] = '/'; |
73 |
strcat(rValue, app); |
74 |
rValue[strlen(p)+1+strlen(app)] = '\0'; |
75 |
if (access(rValue, X_OK) == 0) { |
76 |
return rValue; |
77 |
} |
78 |
p = strtok(NULL, ":"); |
79 |
free(rValue); |
80 |
rValue = NULL; |
81 |
} |
82 |
return NULL; |
83 |
} |
57 |
|
84 |
|
58 |
PRIVATE char _lib_path[MAX_PATH + 1]; |
85 |
PRIVATE char _lib_path[MAX_PATH + 1]; |
59 |
PRIVATE FILE *out; |
86 |
PRIVATE FILE *out; |
Lines 426-432
Link Here
|
426 |
if (strcmp(name, "gb") == 0) |
453 |
if (strcmp(name, "gb") == 0) |
427 |
{ |
454 |
{ |
428 |
sprintf(path, LIB_PATTERN, _lib_path, name); |
455 |
sprintf(path, LIB_PATTERN, _lib_path, name); |
429 |
dlib = dlopen("/usr/bin/gbx", RTLD_NOW); |
456 |
dlib = dlopen(which("gbx"), RTLD_NOW); |
430 |
if (!dlib) |
457 |
if (!dlib) |
431 |
error2("Cannot open component:", dlerror()); |
458 |
error2("Cannot open component:", dlerror()); |
432 |
|
459 |
|
Lines 476-482
Link Here
|
476 |
sprintf(buf, "LD_PRELOAD=%s", lib); |
503 |
sprintf(buf, "LD_PRELOAD=%s", lib); |
477 |
putenv(buf); |
504 |
putenv(buf); |
478 |
putenv("GAMBAS_PRELOAD=1"); |
505 |
putenv("GAMBAS_PRELOAD=1"); |
479 |
execv("/usr/bin/gbi", argv); |
506 |
execvp("gbi", argv); |
480 |
#endif |
507 |
#endif |
481 |
} |
508 |
} |
482 |
|
509 |
|