2015-10-03 12:28:23 -04:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
2015-10-03 11:09:47 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#define BUILDDIR "@abs_top_builddir@"
|
|
|
|
#define LIBPATHENV "@LIBPATHENV@"
|
2015-10-05 02:29:54 -04:00
|
|
|
#define PATH_SEP '@PATH_SEPARATOR@'
|
|
|
|
#define RUBY_INSTALL_NAME "@RUBY_BASE_NAME@"
|
2015-10-03 11:09:47 -04:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
static const char builddir[] = BUILDDIR;
|
|
|
|
const char *libpath = getenv(LIBPATHENV);
|
|
|
|
if (libpath) {
|
2015-10-05 02:29:58 -04:00
|
|
|
while (*libpath == PATH_SEP) ++libpath;
|
|
|
|
}
|
|
|
|
if (libpath && *libpath) {
|
2015-10-03 11:09:47 -04:00
|
|
|
size_t n = strlen(libpath);
|
|
|
|
char *e = malloc(sizeof(builddir)+n+1);
|
|
|
|
memcpy(e, builddir, sizeof(builddir)-1);
|
2015-10-05 02:29:54 -04:00
|
|
|
e[sizeof(builddir)-1] = PATH_SEP;
|
2015-10-03 11:09:47 -04:00
|
|
|
memcpy(e+sizeof(builddir), libpath, n+1);
|
|
|
|
libpath = e;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
libpath = builddir;
|
|
|
|
}
|
|
|
|
setenv(LIBPATHENV, libpath, 1);
|
2015-10-05 02:29:54 -04:00
|
|
|
execv(BUILDDIR"/"RUBY_INSTALL_NAME, argv);
|
2015-10-03 11:09:47 -04:00
|
|
|
return -1;
|
|
|
|
}
|