summaryrefslogtreecommitdiff
path: root/src/host/slbt_host_params.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/host/slbt_host_params.c')
-rw-r--r--src/host/slbt_host_params.c65
1 files changed, 59 insertions, 6 deletions
diff --git a/src/host/slbt_host_params.c b/src/host/slbt_host_params.c
index cd9ad87..6191ea5 100644
--- a/src/host/slbt_host_params.c
+++ b/src/host/slbt_host_params.c
@@ -4,6 +4,7 @@
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
/*******************************************************************/
+#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
@@ -24,6 +25,8 @@
/* annotation strings */
static const char cfgexplicit[] = "command-line argument";
static const char cfghost[] = "derived from <host>";
+static const char cfgar[] = "derived from <ar>";
+static const char cfgranlib[] = "derived from <ranlib>";
static const char cfgtarget[] = "derived from <target>";
static const char cfgcompiler[] = "derived from <compiler>";
static const char cfgnmachine[] = "native (cached in ccenv/host.mk)";
@@ -97,6 +100,7 @@ slbt_hidden int slbt_init_host_params(
int arprobe;
int arfd;
int ecode;
+ int cint;
size_t toollen;
char * dash;
char * base;
@@ -106,6 +110,7 @@ slbt_hidden int slbt_init_host_params(
bool fhost = false;
bool fcompiler = false;
bool fnative = false;
+ bool fnativear = false;
bool fdumpmachine = false;
char buf [256];
char hostbuf [256];
@@ -251,6 +256,7 @@ slbt_hidden int slbt_init_host_params(
/* toollen */
toollen = fnative ? 0 : strlen(host->host);
toollen += strlen("-utility-name");
+ toollen += host->ranlib ? strlen(host->ranlib) : 0;
/* ar */
if (host->ar)
@@ -314,6 +320,7 @@ slbt_hidden int slbt_init_host_params(
if (ecode && !strcmp(host->host,SLBT_MACHINE)) {
strcpy(drvhost->ar,"ar");
cfgmeta->ar = cfgnative;
+ fnative = true;
}
/* fdcwd */
@@ -329,6 +336,13 @@ slbt_hidden int slbt_init_host_params(
host->ar = drvhost->ar;
}
+ if (!fnative && !strncmp(host->ar,"ar",2)) {
+ if (!host->ar[2] || isspace((cint = host->ar[2]))) {
+ fnative = true;
+ fnativear = true;
+ }
+ }
+
/* as */
if (host->as)
cfgmeta->as = cfgmeta_as ? cfgmeta_as : cfgexplicit;
@@ -338,12 +352,25 @@ slbt_hidden int slbt_init_host_params(
if (fnative) {
strcpy(drvhost->as,"as");
- cfgmeta->as = cfgnative;
+ cfgmeta->as = fnativear ? cfgar : cfgnative;
} else {
sprintf(drvhost->as,"%s-as",host->host);
cfgmeta->as = cfghost;
}
+ if (host->ranlib && (mark = strrchr(host->ranlib,'/'))) {
+ if (strcmp(++mark,"ranlib"))
+ if ((mark = strrchr(mark,'-')))
+ if (strcmp(++mark,"ranlib"))
+ mark = 0;
+
+ if (mark) {
+ strcpy(drvhost->as,host->ranlib);
+ strcpy(&drvhost->as[mark-host->ranlib],"as");
+ cfgmeta->as = cfgranlib;
+ }
+ }
+
host->as = drvhost->as;
}
@@ -356,7 +383,7 @@ slbt_hidden int slbt_init_host_params(
if (fnative) {
strcpy(drvhost->nm,"nm");
- cfgmeta->nm = cfgnative;
+ cfgmeta->nm = fnativear ? cfgar : cfgnative;
} else {
sprintf(drvhost->nm,"%s-nm",host->host);
cfgmeta->nm = cfghost;
@@ -374,7 +401,7 @@ slbt_hidden int slbt_init_host_params(
if (fnative) {
strcpy(drvhost->ranlib,"ranlib");
- cfgmeta->ranlib = cfgnative;
+ cfgmeta->ranlib = fnativear ? cfgar : cfgnative;
} else {
sprintf(drvhost->ranlib,"%s-ranlib",host->host);
cfgmeta->ranlib = cfghost;
@@ -400,12 +427,25 @@ slbt_hidden int slbt_init_host_params(
if (fnative) {
strcpy(drvhost->windres,"windres");
- cfgmeta->windres = cfgnative;
+ cfgmeta->windres = fnativear ? cfgar : cfgnative;
} else {
sprintf(drvhost->windres,"%s-windres",host->host);
cfgmeta->windres = cfghost;
}
+ if ((mark = strrchr(host->ranlib,'/'))) {
+ if (strcmp(++mark,"ranlib"))
+ if ((mark = strrchr(mark,'-')))
+ if (strcmp(++mark,"ranlib"))
+ mark = 0;
+
+ if (mark) {
+ strcpy(drvhost->windres,host->ranlib);
+ strcpy(&drvhost->windres[mark-host->ranlib],"windres");
+ cfgmeta->windres = cfgranlib;
+ }
+ }
+
host->windres = drvhost->windres;
}
@@ -426,12 +466,25 @@ slbt_hidden int slbt_init_host_params(
if (fnative) {
strcpy(drvhost->dlltool,"dlltool");
- cfgmeta->dlltool = cfgnative;
+ cfgmeta->dlltool = fnativear ? cfgar : cfgnative;
} else {
sprintf(drvhost->dlltool,"%s-dlltool",host->host);
cfgmeta->dlltool = cfghost;
}
+ if ((mark = strrchr(host->ranlib,'/'))) {
+ if (strcmp(++mark,"ranlib"))
+ if ((mark = strrchr(mark,'-')))
+ if (strcmp(++mark,"ranlib"))
+ mark = 0;
+
+ if (mark) {
+ strcpy(drvhost->dlltool,host->ranlib);
+ strcpy(&drvhost->dlltool[mark-host->ranlib],"dlltool");
+ cfgmeta->dlltool = cfgranlib;
+ }
+ }
+
host->dlltool = drvhost->dlltool;
}
@@ -452,7 +505,7 @@ slbt_hidden int slbt_init_host_params(
if (fnative) {
strcpy(drvhost->mdso,"mdso");
- cfgmeta->mdso = cfgnative;
+ cfgmeta->mdso = fnativear ? cfgar : cfgnative;
} else {
sprintf(drvhost->mdso,"%s-mdso",host->host);
cfgmeta->mdso = cfghost;