===================================================================
@@ -9613,6 +9613,15 @@
%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
@end smallexample
+@item @code{remove-outfile}
+The @code{remove-outfile} spec function takes one argument. It looks for the
+first argument in the outfiles array and removes it. Here is a small example
+its usage:
+
+@smallexample
+%:remove-outfile(-lm)
+@end smallexample
+
@item @code{print-asm-header}
The @code{print-asm-header} function takes no arguments and simply
prints a banner like:
===================================================================
@@ -379,6 +379,7 @@
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 **);
+static const char *remove_outfile_spec_function (int, const char **);
static const char *version_compare_spec_function (int, const char **);
static const char *include_spec_function (int, const char **);
static const char *find_file_spec_function (int, const char **);
@@ -1677,6 +1678,7 @@
{ "if-exists", if_exists_spec_function },
{ "if-exists-else", if_exists_else_spec_function },
{ "replace-outfile", replace_outfile_spec_function },
+ { "remove-outfile", remove_outfile_spec_function },
{ "version-compare", version_compare_spec_function },
{ "include", include_spec_function },
{ "find-file", find_file_spec_function },
@@ -8357,6 +8359,27 @@
return NULL;
}
+/* remove-outfile built-in spec function.
+ *
+ * This looks for the first argument in the outfiles array's name and
+ * removes it. */
+
+static const char *
+remove_outfile_spec_function (int argc, const char **argv)
+{
+ int i;
+ /* Must have exactly one argument. */
+ if (argc != 1)
+ abort ();
+
+ for (i = 0; i < n_infiles; i++)
+ {
+ if (outfiles[i] && !strcmp (outfiles[i], argv[0]))
+ outfiles[i] = NULL;
+ }
+ return NULL;
+}
+
/* Given two version numbers, compares the two numbers.
A version number must match the regular expression
([1-9][0-9]*|0)(\.([1-9][0-9]*|0))*
===================================================================
@@ -303,6 +303,9 @@
so put a * after their names so all of them get passed. */
#define LINK_SPEC \
"%{static}%{!static:-dynamic} \
+ %:remove-outfile(-ldl) \
+ %:remove-outfile(-lm) \
+ %:remove-outfile(-lpthread) \
%{fgnu-runtime: %{static|static-libgcc: \
%:replace-outfile(-lobjc libobjc-gnu.a%s); \
:%:replace-outfile(-lobjc -lobjc-gnu ) } }\