From c67e64bc2f3e482943ef699d1010499fa8ac642b Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 18 Sep 2016 23:59:03 -0400 Subject: driver: accommodate hosts that occasionally use '-portbld-' in their triple. --- src/driver/slbt_driver_ctx.c | 17 ++++++++++++++--- src/helper/slbt_dump_machine.c | 6 ++++++ src/internal/slibtool_driver_impl.h | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c index 9c664d3..1379731 100644 --- a/src/driver/slbt_driver_ctx.c +++ b/src/driver/slbt_driver_ctx.c @@ -374,6 +374,7 @@ static int slbt_init_host_params( size_t toollen; char * dash; char * base; + char * mark; const char * machine; bool ftarget = false; bool fhost = false; @@ -391,6 +392,13 @@ static int slbt_init_host_params( if ((cctx->mode == SLBT_MODE_COMPILE) || (cctx->mode == SLBT_MODE_LINK)) fdumpmachine = true; + /* support the portbld <--> unknown synonym */ + if (!(drvhost->machine = strdup(SLBT_MACHINE))) + return -1; + + if ((mark = strstr(drvhost->machine,"-portbld-"))) + memcpy(mark,"-unknown",8); + /* host */ if (host->host) { cfgmeta->host = cfgexplicit; @@ -416,10 +424,10 @@ static int slbt_init_host_params( host->host = drvhost->host; fcompiler = true; - fnative = (!(strcmp(host->host,SLBT_MACHINE))); + fnative = (!(strcmp(host->host,drvhost->machine))); cfgmeta->host = fnative ? cfgnmachine : cfgxmachine; } else { - host->host = SLBT_MACHINE; + host->host = drvhost->machine; cfgmeta->host = cfgnmachine; fnative = true; } @@ -438,7 +446,7 @@ static int slbt_init_host_params( machine = drvhost->host; cfgmeta->flavor = cfgcompiler; } else { - machine = SLBT_MACHINE; + machine = drvhost->machine; cfgmeta->flavor = cfgnmachine; } @@ -537,6 +545,9 @@ static int slbt_init_host_params( static void slbt_free_host_params(struct slbt_host_strs * host) { + if (host->machine) + free(host->machine); + if (host->host) free(host->host); diff --git a/src/helper/slbt_dump_machine.c b/src/helper/slbt_dump_machine.c index b062fb1..0704386 100644 --- a/src/helper/slbt_dump_machine.c +++ b/src/helper/slbt_dump_machine.c @@ -56,6 +56,7 @@ int slbt_dump_machine( int fd[2]; FILE * fmachine; char * newline; + char * mark; char check[2]; char program[PATH_MAX]; @@ -108,5 +109,10 @@ int slbt_dump_machine( close(fd[1]); } + /* support the portbld <--> unknown synonym */ + if (newline) + if ((mark = strstr(machine,"-portbld-"))) + memcpy(mark,"-unknown",8); + return newline ? 0 : -1; } diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 132e0e5..9a4a750 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -60,6 +60,7 @@ enum app_tags { }; struct slbt_host_strs { + char * machine; char * host; char * flavor; char * ar; -- cgit v1.2.3