static int check_live_switch PARAMS ((int, int));
static const char *handle_braces PARAMS ((const char *));
static char *save_string PARAMS ((const char *, int));
+static void set_collect_gcc_options PARAMS ((void));
static int do_spec_1 PARAMS ((const char *, int, const char *));
static const char *find_file PARAMS ((const char *));
static int is_directory PARAMS ((const char *, const char *, int));
static int execute PARAMS ((void));
static void clear_args PARAMS ((void));
static void fatal_error PARAMS ((int));
-static void set_input PARAMS ((const char *));
static void init_gcc_specs PARAMS ((struct obstack *,
const char *,
const char *));
switches[n_switches].part1 = 0;
infiles[n_infiles].name = 0;
}
+
+/* Store switches not filtered out but %{<S} in spec in COLLECT_GCC_OPTIONS
+ and place that in the environment. */
+
+static void
+set_collect_gcc_options ()
+{
+ int i;
+ int first_time;
+
+ /* Build COLLECT_GCC_OPTIONS to have all of the options specified to
+ the compiler. */
+ obstack_grow (&collect_obstack, "COLLECT_GCC_OPTIONS=",
+ sizeof ("COLLECT_GCC_OPTIONS=") - 1);
+
+ first_time = TRUE;
+ for (i = 0; (int) i < n_switches; i++)
+ {
+ const char *const *args;
+ const char *p, *q;
+ if (!first_time)
+ obstack_grow (&collect_obstack, " ", 1);
+
+ first_time = FALSE;
+
+ /* Ignore elided switches. */
+ if (switches[i].live_cond == SWITCH_IGNORE)
+ continue;
+
+ obstack_grow (&collect_obstack, "'-", 2);
+ q = switches[i].part1;
+ while ((p = strchr (q, '\'')))
+ {
+ obstack_grow (&collect_obstack, q, p - q);
+ obstack_grow (&collect_obstack, "'\\''", 4);
+ q = ++p;
+ }
+ obstack_grow (&collect_obstack, q, strlen (q));
+ obstack_grow (&collect_obstack, "'", 1);
+
+ for (args = switches[i].args; args && *args; args++)
+ {
+ obstack_grow (&collect_obstack, " '", 2);
+ q = *args;
+ while ((p = strchr (q, '\'')))
+ {
+ obstack_grow (&collect_obstack, q, p - q);
+ obstack_grow (&collect_obstack, "'\\''", 4);
+ q = ++p;
+ }
+ obstack_grow (&collect_obstack, q, strlen (q));
+ obstack_grow (&collect_obstack, "'", 1);
+ }
+ }
+ obstack_grow (&collect_obstack, "\0", 1);
+ putenv (obstack_finish (&collect_obstack));
+}
\f
/* Process a spec string, accumulating and running commands. */
argbuf_index--;
}
+ set_collect_gcc_options ();
+
if (argbuf_index > 0)
{
value = execute ();
/* Set up the various global variables to indicate that we're processing
the input file named FILENAME. */
-static void
+void
set_input (filename)
const char *filename;
{
process_command (argc, argv);
- {
- int first_time;
-
- /* Build COLLECT_GCC_OPTIONS to have all of the options specified to
- the compiler. */
- obstack_grow (&collect_obstack, "COLLECT_GCC_OPTIONS=",
- sizeof ("COLLECT_GCC_OPTIONS=") - 1);
-
- first_time = TRUE;
- for (i = 0; (int) i < n_switches; i++)
- {
- const char *const *args;
- const char *p, *q;
- if (!first_time)
- obstack_grow (&collect_obstack, " ", 1);
-
- first_time = FALSE;
- obstack_grow (&collect_obstack, "'-", 2);
- q = switches[i].part1;
- while ((p = strchr (q, '\'')))
- {
- obstack_grow (&collect_obstack, q, p - q);
- obstack_grow (&collect_obstack, "'\\''", 4);
- q = ++p;
- }
- obstack_grow (&collect_obstack, q, strlen (q));
- obstack_grow (&collect_obstack, "'", 1);
-
- for (args = switches[i].args; args && *args; args++)
- {
- obstack_grow (&collect_obstack, " '", 2);
- q = *args;
- while ((p = strchr (q, '\'')))
- {
- obstack_grow (&collect_obstack, q, p - q);
- obstack_grow (&collect_obstack, "'\\''", 4);
- q = ++p;
- }
- obstack_grow (&collect_obstack, q, strlen (q));
- obstack_grow (&collect_obstack, "'", 1);
- }
- }
- obstack_grow (&collect_obstack, "\0", 1);
- putenv (obstack_finish (&collect_obstack));
- }
-
/* Initialize the vector of specs to just the default.
This means one element containing 0s, as a terminator. */
int shared_libgcc = 1;
const char jvgenmain_spec[] =
- "jvgenmain %{D*} %i %{!pipe:%umain.i} |\n\
- cc1 %{!pipe:%Umain.i} %1 \
+ "jvgenmain %{D*} %b %{!pipe:%u.i} |\n\
+ cc1 %{!pipe:%U.i} %1 \
%{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
%{g*} %{O*} \
%{v:-version} %{pg:-p} %{p}\
%{f*} -fdollars-in-identifiers\
%{aux-info*}\
%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
- %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%Umain.s}} |\n\
- %{!S:as %a %Y -o %d%w%umain%O %{!pipe:%Umain.s} %A\n }";
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%U.s}} |\n\
+ %{!S:as %a %Y -o %d%w%u%O %{!pipe:%U.s} %A\n }";
/* Return full path name of spec file if it is in DIR, or NULL if
not. */
int err;
if (main_class_name == NULL)
return 0;
- input_filename = main_class_name;
- input_filename_length = strlen (main_class_name);
+ /* Append `main' to make the filename unique and allow
+
+ gcj --main=hello -save-temps hello.java
+
+ to work. jvgenmain needs to strip this `main' to arrive at the correct
+ class name. Append dummy `.c' that can be stripped by set_input so %b
+ is correct. */
+ set_input (concat (main_class_name, "main.c", NULL));
err = do_spec (jvgenmain_spec);
if (err == 0)
{