summaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2007-02-22 23:49:15 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2007-02-22 23:49:15 +0000
commit30d8946bae4f0241144a3bff2cab024b24bb3520 (patch)
treedcb598c670d33f19a370e00849a60a24d74c701c /gcc/gcc.c
parentb69862d1ef8332ab49654ae0b83656a87964729b (diff)
downloadgcc-30d8946bae4f0241144a3bff2cab024b24bb3520.tar.gz
gcc.c (getenv_spec_function): New function.
* gcc.c (getenv_spec_function): New function. (static_spec_functions): Add it. * config/vxworks.h (VXWORKS_TARGET_DIR): Remove. (VXWORKS_ADDITIONAL_CPP_SPEC): Use getenv to find the VxWorks header files. From-SVN: r122240
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 14e4ceea71f..d2f479b2257 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -350,6 +350,7 @@ static void init_gcc_specs (struct obstack *, const char *, const char *,
static const char *convert_filename (const char *, int, int);
#endif
+static const char *getenv_spec_function (int, const char **);
static const char *if_exists_spec_function (int, const char **);
static const char *if_exists_else_spec_function (int, const char **);
static const char *replace_outfile_spec_function (int, const char **);
@@ -1601,6 +1602,7 @@ static struct spec_list *specs = (struct spec_list *) 0;
static const struct spec_function static_spec_functions[] =
{
+ { "getenv", getenv_spec_function },
{ "if-exists", if_exists_spec_function },
{ "if-exists-else", if_exists_else_spec_function },
{ "replace-outfile", replace_outfile_spec_function },
@@ -7645,6 +7647,27 @@ print_multilib_info (void)
}
}
+/* getenv built-in spec function.
+
+ Returns the value of the environment variable given by its first
+ argument, concatenated with the second argument. If the
+ environment variable is not defined, a fatal error is issued. */
+
+static const char *
+getenv_spec_function (int argc, const char **argv)
+{
+ char *value;
+
+ if (argc != 2)
+ return NULL;
+
+ value = getenv (argv[0]);
+ if (!value)
+ fatal ("environment variable \"%s\" not defined", argv[0]);
+
+ return concat (value, argv[1], NULL);
+}
+
/* if-exists built-in spec function.
Checks to see if the file specified by the absolute pathname in