summaryrefslogtreecommitdiff
path: root/gcc/gcc.c
diff options
context:
space:
mode:
authorthorpej <thorpej@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-26 00:31:31 +0000
committerthorpej <thorpej@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-26 00:31:31 +0000
commit68d74c02e713f767c110e40e67a5a912a1a49c8a (patch)
treefb57bd2526716f6ab368a2f04bc887feb665ac9b /gcc/gcc.c
parent5eeaefacd3d5e8fc69575b6c8ef06cb0171607d7 (diff)
downloadgcc-68d74c02e713f767c110e40e67a5a912a1a49c8a.tar.gz
* gcc.c (static_spec_functions): Add if-exists-else spec
function. (if_exists_else_spec_function): New function. * doc/invoke.texi: Document the if-exists-else spec function. * config/netbsd-elf.h (NETBSD_STARTFILE_SPEC): For -static, use "%:if-exists-else(crtbeginT%O%s crtbegin%O%s)". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59480 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r--gcc/gcc.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index a193437c569..d7ec1260f80 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -328,6 +328,7 @@ static const char *convert_filename PARAMS ((const char *, int, int));
#endif
static const char *if_exists_spec_function PARAMS ((int, const char **));
+static const char *if_exists_else_spec_function PARAMS ((int, const char **));
/* The Specs Language
@@ -1451,6 +1452,7 @@ static struct spec_list *specs = (struct spec_list *) 0;
static const struct spec_function static_spec_functions[] =
{
{ "if-exists", if_exists_spec_function },
+ { "if-exists-else", if_exists_else_spec_function },
{ 0, 0 }
};
@@ -7264,3 +7266,23 @@ if_exists_spec_function (argc, argv)
return NULL;
}
+
+/* if-exists-else built-in spec function.
+
+ This is like if-exists, but takes an additional argument which
+ is returned if the first argument does not exist. */
+
+static const char *
+if_exists_else_spec_function (argc, argv)
+ int argc;
+ const char **argv;
+{
+ /* Must have exactly two arguments. */
+ if (argc != 2)
+ return NULL;
+
+ if (IS_ABSOLUTE_PATHNAME (argv[0]) && ! access (argv[0], R_OK))
+ return argv[0];
+
+ return argv[1];
+}