Mercurial > hg > aboriginal
changeset 748:897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
It doesn't fix gcc 4.2.1's horrible ./configure, which probes this stuff and
then goes off into la-la land trying to use the result, but oh well. (It'd
work if I copied these tools into the current directory where gcc was running
./configure though. Yes, it calls test -x for them, which doesn't search $PATH.
I don't know what the gcc developers are smoking either.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 15 Jun 2009 01:11:26 -0500 |
parents | c8eb04cdc4d8 |
children | 34f9a88336a8 |
files | sources/toys/ccwrap.c |
diffstat | 1 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/sources/toys/ccwrap.c Mon Jun 15 01:09:30 2009 -0500 +++ b/sources/toys/ccwrap.c Mon Jun 15 01:11:26 2009 -0500 @@ -105,13 +105,13 @@ int i, argcnt, liblen, lplen; char **gcc_argv, **libraries, **libpath; char *dlstr, *incstr, *devprefix, *libstr; - char *cc; + char *cc, *toolprefix; char *debug_wrapper=getenv("WRAPPER_DEBUG"); // For C++ char *cpp = NULL; - int len, ctor_dtor = 1, use_nostdinc_plus = 0; + int prefixlen, ctor_dtor = 1, use_nostdinc_plus = 0; // For profiling int profile = 0; @@ -152,14 +152,21 @@ if (!cc) cc = GCC_UNWRAPPED_NAME; // Check end of name, since there could be a cross-prefix on the thing - len = strlen(argv[0]); - if (!strcmp(argv[0]+len-2, "ld")) { + toolprefix = strrchr(argv[0], '/'); + if (!toolprefix) toolprefix = argv[0]; + else toolprefix++; + + prefixlen = strlen(toolprefix); + if (!strcmp(toolprefix+prefixlen-3, "gcc")) prefixlen -= 3; + else if (!strcmp(toolprefix+prefixlen-2, "cc")) prefixlen -= 2; + else if (!strcmp(toolprefix+prefixlen-2, "ld")) { + prefixlen -= 2; // TODO: put support for wrapping the linker here. // Wrapping the c++ compiler? - } else if (!strcmp(argv[0]+len-2, "++")) { - len = strlen(cc); + } else if (!strcmp(toolprefix+prefixlen-2, "++")) { + int len = strlen(cc); cpp = alloca(len+1); strcpy(cpp, cc); cpp[len-1]='+'; @@ -270,7 +277,10 @@ int itemp, showall = 0; temp = argv[i]+7; - if (!strcmp(temp, "search-dirs")) { + if (!strncmp(temp, "prog-name=", 10)) { + printf("%.*s%s\n", prefixlen, toolprefix, temp+10); + exit(0); + } else if (!strcmp(temp, "search-dirs")) { printf("install: %s/\n",devprefix); printf("programs: %s\n",getenv("PATH")); printf("libraries: ");