summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2021-05-05 16:20:44 +0000
committermidipix <writeonce@midipix.org>2021-05-05 16:23:20 +0000
commit17e18afed34675d6f9e3aef91ddea8d84c1d1617 (patch)
tree03de97a3076750d14396d33bde3c16f7211cb9e8
parentd55a465814bb3d7ec429f85b36c26d5862ba7e48 (diff)
downloadslibtool-17e18afed34675d6f9e3aef91ddea8d84c1d1617.tar.bz2
slibtool-17e18afed34675d6f9e3aef91ddea8d84c1d1617.tar.xz
driver: added explicit --sysroot support.
-rw-r--r--include/slibtool/slibtool.h1
-rw-r--r--src/driver/slbt_driver_ctx.c46
-rw-r--r--src/internal/slibtool_driver_impl.h1
-rw-r--r--src/skin/slbt_skin_default.c4
4 files changed, 50 insertions, 2 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index b10698a..6b64cd3 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -252,6 +252,7 @@ struct slbt_common_ctx {
const char * output;
const char * shrext;
const char * rpath;
+ const char * sysroot;
const char * release;
const char * symfile;
const char * regex;
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index 37d5660..02b0617 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -277,6 +277,7 @@ static int slbt_split_argv(
int argc;
const char * program;
char * compiler;
+ char * csysroot;
char ** dargv;
char ** targv;
char ** cargv;
@@ -377,6 +378,8 @@ static int slbt_split_argv(
else if (!(sargv->dargs = calloc(1,size+1)))
return -1;
+ csysroot = 0;
+
for (i=0,flast=false,dargv=sargv->dargv,dst=sargv->dargs; i<argc; i++) {
if ((fcopy = flast)) {
(void)0;
@@ -441,6 +444,22 @@ static int slbt_split_argv(
*dst++ = 'L';
strcpy(dst,&argv[i][15]);
dst += strlen(dst)+1;
+
+ } else if (!strcmp(argv[i],"--sysroot") && (i<ctx.unitidx)) {
+ *dargv++ = dst;
+ csysroot = dst;
+ strcpy(dst,argv[i]);
+ dst[9] = '=';
+ strcpy(&dst[10],argv[++i]);
+ dst += strlen(dst)+1;
+ ctx.unitidx--;
+
+ } else if (!strncmp(argv[i],"--sysroot=",10) && (i<ctx.unitidx)) {
+ *dargv++ = dst;
+ csysroot = dst;
+ strcpy(dst,argv[i]);
+ dst += strlen(dst)+1;
+
} else {
fcopy = true;
}
@@ -456,8 +475,8 @@ static int slbt_split_argv(
argc = dargv - sargv->dargv;
argv = sargv->dargv;
- /* allocate split vectors */
- if ((sargv->targv = calloc(2*(argc+2),sizeof(char *))))
+ /* allocate split vectors, account for cargv's added sysroot */
+ if ((sargv->targv = calloc(2*(argc+3),sizeof(char *))))
sargv->cargv = sargv->targv + argc + 2;
else
return -1;
@@ -502,6 +521,14 @@ static int slbt_split_argv(
for (optout=optv; optout[0]->tag != TAG_OUTPUT; optout++)
(void)0;
+ /* compiler */
+ *cargv++ = argv[i++];
+
+ /* sysroot */
+ if (csysroot)
+ *cargv++ = csysroot;
+
+ /* remaining vector */
for (; i<argc; i++) {
if (argv[i][0] != '-') {
if (argv[i+1] && (argv[i+1][0] == '+')
@@ -545,6 +572,17 @@ static int slbt_split_argv(
*cargv++ = argv[i];
*targv++ = argv[i];
+ } else if (!(strncmp("-sysroot=",&argv[i][1],9))) {
+ *cargv++ = argv[i];
+ *targv++ = argv[i];
+
+ } else if (!(strcmp("-sysroot",&argv[i][1]))) {
+ *cargv++ = argv[i];
+ *targv++ = argv[i++];
+
+ *cargv++ = argv[i];
+ *targv++ = argv[i];
+
} else if (!(strcmp("bindir",&argv[i][1]))) {
*targv++ = argv[i++];
*targv++ = argv[i];
@@ -1543,6 +1581,10 @@ int slbt_get_driver_ctx(
cctx.rpath = entry->arg;
break;
+ case TAG_SYSROOT:
+ cctx.sysroot = entry->arg;
+ break;
+
case TAG_RELEASE:
cctx.release = entry->arg;
break;
diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h
index 120c2e3..c70c334 100644
--- a/src/internal/slibtool_driver_impl.h
+++ b/src/internal/slibtool_driver_impl.h
@@ -51,6 +51,7 @@ enum app_tags {
TAG_LDRPATH,
TAG_SHREXT,
TAG_RPATH,
+ TAG_SYSROOT,
TAG_RELEASE,
TAG_DLOPEN,
TAG_DLPREOPEN,
diff --git a/src/skin/slbt_skin_default.c b/src/skin/slbt_skin_default.c
index 5533b04..b499101 100644
--- a/src/skin/slbt_skin_default.c
+++ b/src/skin/slbt_skin_default.c
@@ -161,6 +161,10 @@ const struct argv_option slbt_default_options[] = {
"where a library should eventually be "
"installed, relative to $(DESTDIR)$(PREFIX)"},
+ {"sysroot", 0,TAG_SYSROOT,ARGV_OPTARG_REQUIRED,0,0,"<sysroot>",
+ "an absolute sysroot path to pass to the compiler "
+ "or linker driver"},
+
{"release", 0,TAG_RELEASE,ARGV_OPTARG_REQUIRED,
ARGV_OPTION_HYBRID_ONLY|ARGV_OPTION_HYBRID_SPACE,0,0,
"specify release information; this will result "