--- src/comp/Makefile.am.org 2004-07-01 20:43:29.670993248 +0200 +++ src/comp/Makefile.am 2004-07-01 20:43:45.909524616 +0200 @@ -18,7 +18,8 @@ gbc_output.c gbc_pcode.c \ gb_file.h gb_file.c \ gbc_form.h gbc_form.c \ - gb_str.h gb_str.c + gb_str.h gb_str.c \ + which.c gba_SOURCES = \ gb_error.h gb_error.c \ @@ -34,7 +35,8 @@ gb_alloc.c gb_array.c \ gb_str.h gb_str.c \ gb_file.h gb_file.c \ - gbi.c + gbi.c \ + which.c %.h: ; --- src/comp/which.c.org 2003-10-27 21:51:41.000000000 +0100 +++ src/comp/which.c 2003-11-17 23:41:29.000000000 +0100 @@ -0,0 +1,33 @@ +/* needed to install in a different location than /usr */ + +#include +#include +#include + +char *which(const char *app) +{ + char *path = NULL; + char *p = NULL; + char *rValue = NULL; + + path = getenv("PATH"); + if (!path) { + path = "/usr/bin/"; + } + p = strtok(strdup(path), ":"); + while (p) { + rValue = (char *)calloc(sizeof(char), strlen(p)+strlen(app)+2); + strcat(rValue, p); + rValue[strlen(p)] = '/'; + strcat(rValue, app); + rValue[strlen(p)+1+strlen(app)] = '\0'; + if (access(rValue, X_OK) == 0) { + return rValue; + } + p = strtok(NULL, ":"); + free(rValue); + rValue = NULL; + } + return NULL; +} + --- src/comp/gbi.c.org 2003-10-27 21:51:41.000000000 +0100 +++ src/comp/gbi.c 2003-11-17 23:41:29.000000000 +0100 @@ -54,6 +54,7 @@ #include "gb_str.h" #include "gambas.h" +char *which(const char *app); PRIVATE char _lib_path[MAX_PATH + 1]; PRIVATE char _info_path[MAX_PATH + 1]; @@ -102,7 +129,7 @@ /* chemin d'installation de Gambas */ - path = FILE_readlink(GAMBAS_LINK_PATH); + path = which("gbx"); if (!path) { path = GAMBAS_LINK_PATH; @@ -422,7 +450,7 @@ if (strcmp(name, "gb") == 0) { sprintf(path, LIB_PATTERN, _lib_path, name); - dlib = dlopen("/usr/bin/gbx", RTLD_NOW); + dlib = dlopen(which("gbx"), RTLD_NOW); if (!dlib) error2("Cannot open component:", dlerror()); @@ -472,7 +500,7 @@ sprintf(buf, "LD_PRELOAD=%s", lib); putenv(buf); putenv("GAMBAS_PRELOAD=1"); - execv("/usr/bin/gbi", argv); + execvp("gbi", argv); #endif } --- src/comp/gbc_compile.c.org 2004-06-25 00:54:43.765214275 +0200 +++ src/comp/gbc_compile.c 2004-06-25 00:56:02.693198071 +0200 @@ -59,6 +59,8 @@ PUBLIC COMPILE COMP_current; +char *which(const char *app); + PRIVATE bool read_line(FILE *f, char *dir, int max) { char *p; @@ -126,7 +155,7 @@ /* chemin d'installation de Gambas */ - path = FILE_readlink(GAMBAS_LINK_PATH); + path = which("gbx"); if (!path) { path = GAMBAS_LINK_PATH;