diff options
author | Jason Thorpe <thorpej@gcc.gnu.org> | 2002-11-26 00:31:31 +0000 |
---|---|---|
committer | Jason Thorpe <thorpej@gcc.gnu.org> | 2002-11-26 00:31:31 +0000 |
commit | 152a5a9c947ff82ced5cb47beb197f53330ea12c (patch) | |
tree | fb57bd2526716f6ab368a2f04bc887feb665ac9b /gcc/gcc.c | |
parent | a4967b8db12d7f2d9b0d80830507f806c4c36e5b (diff) | |
download | gcc-152a5a9c947ff82ced5cb47beb197f53330ea12c.zip gcc-152a5a9c947ff82ced5cb47beb197f53330ea12c.tar.gz gcc-152a5a9c947ff82ced5cb47beb197f53330ea12c.tar.bz2 |
gcc.c (static_spec_functions): Add if-exists-else spec function.
* 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)".
From-SVN: r59480
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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]; +} |