From a1478cac726f83c5457bffb44189be35aacbc442 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Mon, 27 Jul 2009 10:53:36 +0200 Subject: [PATCH] objformat: don't hardcode compiler versions In the previous commit a fallback to the "custom" compiler driver was introduced for unknown compilers. The previous approach hard-coded known compiler versions, making it more complicated to add new compilers to base. This commit changes slightly the behavior for the "custom" compiler fallback: The compiler is searched for like before the "custom" change, and in addition, in case no compiler could be found, the search is retried for the "custom" compiler driver. This way we don't have to hard-code known compiler versions, while a truely non-existing CCVER will still be handled by the "custom" compiler driver. --- usr.bin/objformat/objformat.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/usr.bin/objformat/objformat.c b/usr.bin/objformat/objformat.c index b853230f3a..b8f1db44f1 100644 --- a/usr.bin/objformat/objformat.c +++ b/usr.bin/objformat/objformat.c @@ -164,6 +164,7 @@ main(int argc, char **argv) if (objformat_path == NULL) objformat_path = OBJFORMAT_PATH_DEFAULT; +again: path = strdup(objformat_path); if (setenv("OBJFORMAT", objformat, 1) == -1) @@ -181,14 +182,8 @@ main(int argc, char **argv) asprintf(&newcmd, "%s%s/%s/%s/%s", chunk, base_path, env_value, objformat, cmd); } else { - if (strncmp(env_value, "gcc34", 5) != 0 && - strncmp(env_value, "gcc41", 5) != 0) { - asprintf(&newcmd, "%s%s/custom/%s", - chunk, base_path, cmd); - } else { - asprintf(&newcmd, "%s%s/%s/%s", - chunk, base_path, env_value, cmd); - } + asprintf(&newcmd, "%s%s/%s/%s", + chunk, base_path, env_value, cmd); } if (newcmd == NULL) err(1, "cannot allocate memory"); @@ -196,6 +191,17 @@ main(int argc, char **argv) argv[0] = newcmd; execv(newcmd, argv); } + + /* + * Fallback: if we're searching for a compiler, but didn't + * find any, try again using the custom compiler driver. + */ + if (cmds && cmds->type == COMPILER && + strcmp(env_value, "custom") != 0) { + env_value = "custom"; + goto again; + } + if (use_objformat) { err(1, "in path [%s]%s/%s/%s/%s", objformat_path, base_path, env_value, objformat, cmd); -- 2.41.0