Commit 316a06a1 by Tom Tromey Committed by Tom Tromey

jvspec.c (lang_specific_driver): Recognize -MF and -MT.

	* jvspec.c (lang_specific_driver): Recognize -MF and -MT.
	* lang-specs.h: Added %{MA}, %{MF*}, %{MT*}.
	* lang-options.h: Added -MA, -MT, -MF..
	* lang.c (lang_decode_option): Recognize -MA, -MT, -MF.
	(DEPEND_TARGET_SET): New macro.
	(DEPEND_FILE_ALREADY_SET): Likewise.
	(init_parse): Handle new flags.
	* jcf.h (jcf_dependency_print_dummies): Declare.
	* Make-lang.in (s-java): Added mkdeps.o.
	* Makefile.in (BACKEND): Added mkdeps.o.
	(../gcjh$(exeext)): Added mkdeps.o.
	(../jcf-dump$(exeext)): Added mkdeps.o.
	* jcf-depend.c: Include mkdeps.h.
	(struct entry, dependencies, targets, MAX_OUTPUT_COLUMNS,
	add_entry): Removed.
	(jcf_dependency_reset): Rewrote.
	(dependencies): New global.
	(jcf_dependency_set_target): Rewrote.
	(jcf_dependency_add_target): Likewise.
	(jcf_dependency_add_file): Likewise.
	(munge): Removed.
	(print_ents): Removed.
	(jcf_dependency_write): Rewrote.
	(print_dummies): New global.
	(jcf_dependency_print_dummies): New function
	(jcf_dependency_write): Call deps_dummy_targets if required.

From-SVN: r36981
parent 3f568531
2000-10-16 Tom Tromey <tromey@cygnus.com>
* jvspec.c (lang_specific_driver): Recognize -MF and -MT.
* lang-specs.h: Added %{MA}, %{MF*}, %{MT*}.
* lang-options.h: Added -MA, -MT, -MF..
* lang.c (lang_decode_option): Recognize -MA, -MT, -MF.
(DEPEND_TARGET_SET): New macro.
(DEPEND_FILE_ALREADY_SET): Likewise.
(init_parse): Handle new flags.
* jcf.h (jcf_dependency_print_dummies): Declare.
* Make-lang.in (s-java): Added mkdeps.o.
* Makefile.in (BACKEND): Added mkdeps.o.
(../gcjh$(exeext)): Added mkdeps.o.
(../jcf-dump$(exeext)): Added mkdeps.o.
* jcf-depend.c: Include mkdeps.h.
(struct entry, dependencies, targets, MAX_OUTPUT_COLUMNS,
add_entry): Removed.
(jcf_dependency_reset): Rewrote.
(dependencies): New global.
(jcf_dependency_set_target): Rewrote.
(jcf_dependency_add_target): Likewise.
(jcf_dependency_add_file): Likewise.
(munge): Removed.
(print_ents): Removed.
(jcf_dependency_write): Rewrote.
(print_dummies): New global.
(jcf_dependency_print_dummies): New function
(jcf_dependency_write): Call deps_dummy_targets if required.
2000-10-12 Tom Tromey <tromey@cygnus.com>
* lex.c (java_new_lexer): Initialize new fields.
(java_read_char): Swap bytes if required.
* lex.h (java_lexer): New fields read_anything and byte_swap.
Made out_buffer unsigned.
2000-10-18 Alexandre Petit-Bianco <apbianco@cygnus.com> 2000-10-18 Alexandre Petit-Bianco <apbianco@cygnus.com>
* gjavah.c (add_class_decl): Removed unused variables `tname', * gjavah.c (add_class_decl): Removed unused variables `tname',
......
...@@ -141,7 +141,7 @@ JCF_DUMP_SOURCES = $(srcdir)/java/jcf-dump.c $(srcdir)/java/jcf-io.c \ ...@@ -141,7 +141,7 @@ JCF_DUMP_SOURCES = $(srcdir)/java/jcf-dump.c $(srcdir)/java/jcf-io.c \
jc1$(exeext) gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext): s-java jc1$(exeext) gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext): s-java
s-java: $(P) $(JAVA_SRCS) $(LIBDEPS) $(BACKEND) \ s-java: $(P) $(JAVA_SRCS) $(LIBDEPS) $(BACKEND) mkdeps.o \
$(GCJH_SOURCES) $(LIBDEPS) $(TREE_H) \ $(GCJH_SOURCES) $(LIBDEPS) $(TREE_H) \
$(JV_SCAN_SOURCES) $(BACKEND) $(LIBDEPS) \ $(JV_SCAN_SOURCES) $(BACKEND) $(LIBDEPS) \
$(JCF_DUMP_SOURCES) $(JCF_DUMP_SOURCES)
......
...@@ -181,7 +181,7 @@ JAVA_OBJS = parse.o class.o decl.o expr.o constants.o lang.o typeck.o \ ...@@ -181,7 +181,7 @@ JAVA_OBJS = parse.o class.o decl.o expr.o constants.o lang.o typeck.o \
JAVA_OBJS_LITE = parse-scan.o jv-scan.o JAVA_OBJS_LITE = parse-scan.o jv-scan.o
# Language-independent object files. # Language-independent object files.
BACKEND = ../toplev.o ../libbackend.a BACKEND = ../toplev.o ../mkdeps.o ../libbackend.a
compiler: ../jc1$(exeext) ../jv-scan$(exeext) compiler: ../jc1$(exeext) ../jv-scan$(exeext)
../jc1$(exeext): $(P) $(JAVA_OBJS) $(BACKEND) $(LIBDEPS) ../jc1$(exeext): $(P) $(JAVA_OBJS) $(BACKEND) $(LIBDEPS)
...@@ -192,18 +192,20 @@ compiler: ../jc1$(exeext) ../jv-scan$(exeext) ...@@ -192,18 +192,20 @@ compiler: ../jc1$(exeext) ../jv-scan$(exeext)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JAVA_OBJS_LITE) ../version.o $(LIBS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JAVA_OBJS_LITE) ../version.o $(LIBS)
../jcf-dump$(exeext): jcf-dump.o jcf-io.o jcf-depend.o jcf-path.o \ ../jcf-dump$(exeext): jcf-dump.o jcf-io.o jcf-depend.o jcf-path.o \
zextract.o ../version.o $(LIBDEPS) zextract.o ../version.o ../mkdeps.o $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ jcf-dump.o jcf-io.o \ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ jcf-dump.o jcf-io.o \
jcf-depend.o jcf-path.o zextract.o ../errors.o ../version.o $(LIBS) jcf-depend.o jcf-path.o zextract.o ../errors.o ../version.o \
../mkdeps.o $(LIBS)
# Dependencies here must be kept in sync with dependencies in Make-lang.in. # Dependencies here must be kept in sync with dependencies in Make-lang.in.
../jvgenmain$(exeext): jvgenmain.o mangle.o $(LIBDEPS) ../jvgenmain$(exeext): jvgenmain.o mangle.o $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ jvgenmain.o mangle.o $(LIBS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ jvgenmain.o mangle.o $(LIBS)
../gcjh$(exeext): gjavah.o jcf-io.o jcf-depend.o jcf-path.o \ ../gcjh$(exeext): gjavah.o jcf-io.o jcf-depend.o jcf-path.o \
zextract.o ../version.o $(LIBDEPS) zextract.o ../version.o ../mkdeps.o $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ gjavah.o jcf-io.o \ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ gjavah.o jcf-io.o \
jcf-depend.o jcf-path.o zextract.o ../errors.o ../version.o $(LIBS) jcf-depend.o jcf-path.o zextract.o ../errors.o ../version.o \
../mkdeps.o $(LIBS)
Makefile: $(srcdir)/Makefile.in $(srcdir)/../configure Makefile: $(srcdir)/Makefile.in $(srcdir)/../configure
cd ..; $(SHELL) config.status cd ..; $(SHELL) config.status
......
...@@ -25,6 +25,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ ...@@ -25,6 +25,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "config.h" #include "config.h"
#include "system.h" #include "system.h"
#include "mkdeps.h"
#include <assert.h> #include <assert.h>
...@@ -32,27 +33,8 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ ...@@ -32,27 +33,8 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
/* We keep a linked list of all the files we've already read. */ /* The dependency structure used for this invocation. */
struct entry struct deps *dependencies;
{
char *file;
struct entry *next;
};
static void free_entry PARAMS ((struct entry **));
static void add_entry PARAMS ((struct entry **, const char *));
static const char *munge PARAMS ((const char *));
static int print_ents PARAMS ((struct entry *, int));
/* List of files. */
static struct entry *dependencies = NULL;
/* Name of targets. We support multiple targets when writing .class
files. */
static struct entry *targets = NULL;
/* Number of columns in output. */
#define MAX_OUTPUT_COLUMNS 72
/* The output file, or NULL if we aren't doing dependency tracking. */ /* The output file, or NULL if we aren't doing dependency tracking. */
static FILE *dep_out = NULL; static FILE *dep_out = NULL;
...@@ -60,81 +42,47 @@ static FILE *dep_out = NULL; ...@@ -60,81 +42,47 @@ static FILE *dep_out = NULL;
/* Nonzero if system files should be added. */ /* Nonzero if system files should be added. */
static int system_files; static int system_files;
/* Nonzero if we are dumping out dummy dependencies. */
static int print_dummies;
/* Helper to free an entry list. */
static void
free_entry (entp)
struct entry **entp;
{
struct entry *ent, *next;
for (ent = *entp; ent != NULL; ent = next)
{
next = ent->next;
free (ent->file);
free (ent);
}
*entp = NULL;
}
/* Helper to add to the end of the entry list. */
static void
add_entry (entp, name)
struct entry **entp;
const char *name;
{
struct entry *ent, *last;
for (last = ent = *entp; ent != NULL; last = ent, ent = ent->next)
if (! strcmp (ent->file, name))
return;
ent = (struct entry *) xmalloc (sizeof (struct entry));
ent->file = xstrdup (name);
ent->next = NULL;
if (last == NULL)
{
/* This is only true the first time through, when the entry list
is empty. */
*entp = ent;
}
else
last->next = ent;
}
/* Call this to reset the dependency module. This is required if /* Call this to reset the dependency module. This is required if
multiple dependency files are being generated from a single tool multiple dependency files are being generated from a single tool
invocation. */ invocation. FIXME: we should change our API or just completely use
the one in mkdeps.h. */
void void
jcf_dependency_reset () jcf_dependency_reset ()
{ {
free_entry (&dependencies);
free_entry (&targets);
if (dep_out != NULL) if (dep_out != NULL)
{ {
if (dep_out != stdout) if (dep_out != stdout)
fclose (dep_out); fclose (dep_out);
dep_out = NULL; dep_out = NULL;
} }
if (dependencies != NULL)
{
deps_free (dependencies);
dependencies = NULL;
}
} }
void void
jcf_dependency_set_target (name) jcf_dependency_set_target (name)
const char *name; const char *name;
{ {
free_entry (&targets); /* We just handle this the same as an `add_target'. */
if (name != NULL) if (dependencies != NULL && name != NULL)
add_entry (&targets, name); deps_add_target (dependencies, name);
} }
void void
jcf_dependency_add_target (name) jcf_dependency_add_target (name)
const char *name; const char *name;
{ {
add_entry (&targets, name); if (dependencies != NULL)
deps_add_target (dependencies, name);
} }
void void
...@@ -155,122 +103,41 @@ jcf_dependency_add_file (filename, system_p) ...@@ -155,122 +103,41 @@ jcf_dependency_add_file (filename, system_p)
const char *filename; const char *filename;
int system_p; int system_p;
{ {
if (! dependencies)
return;
/* Just omit system files. */ /* Just omit system files. */
if (system_p && ! system_files) if (system_p && ! system_files)
return; return;
add_entry (&dependencies, filename); deps_add_dep (dependencies, filename);
} }
void void
jcf_dependency_init (system_p) jcf_dependency_init (system_p)
int system_p; int system_p;
{ {
assert (! dependencies);
system_files = system_p; system_files = system_p;
dependencies = deps_init ();
} }
/* FIXME: this is taken almost directly from cccp.c. Such duplication void
is bad. */ jcf_dependency_print_dummies ()
static const char *
munge (filename)
const char *filename;
{
static char *buffer = NULL;
static int buflen = 0;
int len = 2 * strlen (filename) + 1;
const char *p;
char *dst;
if (buflen < len)
{
buflen = len;
buffer = xrealloc (buffer, buflen);
}
dst = buffer;
for (p = filename; *p; ++p)
{
switch (*p)
{
case ' ':
case '\t':
{
/* GNU make uses a weird quoting scheme for white space.
A space or tab preceded by 2N+1 backslashes represents
N backslashes followed by space; a space or tab
preceded by 2N backslashes represents N backslashes at
the end of a file name; and backslashes in other
contexts should not be doubled. */
const char *q;
for (q = p - 1; filename < q && q[-1] == '\\'; q--)
*dst++ = '\\';
}
*dst++ = '\\';
goto ordinary_char;
case '$':
*dst++ = '$';
/* Fall through. This can mishandle things like "$(" but
there's no easy fix. */
default:
ordinary_char:
/* This can mishandle characters in the string "\0\n%*?[\\~";
exactly which chars are mishandled depends on the `make' version.
We know of no portable solution for this;
even GNU make 3.76.1 doesn't solve the problem entirely.
(Also, '\0' is mishandled due to our calling conventions.) */
*dst++ = *p;
break;
}
}
*dst++ = '\0';
return buffer;
}
/* Helper to print list of files. */
static int
print_ents (ent, column)
struct entry *ent;
int column;
{ {
int first = 1; print_dummies = 1;
for (; ent != NULL; ent = ent->next)
{
const char *depname = munge (ent->file);
int len = strlen (depname);
if (column + len + 2 > MAX_OUTPUT_COLUMNS)
{
fprintf (dep_out, " \\\n ");
column = 1;
}
if (! first)
fputs (" ", dep_out);
fputs (depname, dep_out);
first = 0;
column += len + 1;
}
return column;
} }
void void
jcf_dependency_write () jcf_dependency_write ()
{ {
int column = 0;
if (! dep_out) if (! dep_out)
return; return;
assert (targets); assert (dependencies);
column = print_ents (targets, 0);
fputs (" : ", dep_out);
print_ents (dependencies, column); deps_write (dependencies, dep_out, 72);
fputs ("\n", dep_out); if (print_dummies)
deps_dummy_targets (dependencies, dep_out);
fflush (dep_out); fflush (dep_out);
} }
...@@ -264,6 +264,7 @@ extern void jcf_dependency_set_dep_file PARAMS ((const char *)); ...@@ -264,6 +264,7 @@ extern void jcf_dependency_set_dep_file PARAMS ((const char *));
extern void jcf_dependency_add_file PARAMS ((const char *, int)); extern void jcf_dependency_add_file PARAMS ((const char *, int));
extern void jcf_dependency_write PARAMS ((void)); extern void jcf_dependency_write PARAMS ((void));
extern void jcf_dependency_init PARAMS ((int)); extern void jcf_dependency_init PARAMS ((int));
extern void jcf_dependency_print_dummies PARAMS ((void));
/* Declarations for path handling code. */ /* Declarations for path handling code. */
extern void jcf_path_init PARAMS ((void)); extern void jcf_path_init PARAMS ((void));
......
...@@ -262,9 +262,11 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) ...@@ -262,9 +262,11 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
saw_g = 1; saw_g = 1;
else if (argv[i][1] == 'O') else if (argv[i][1] == 'O')
saw_O = 1; saw_O = 1;
else if (((argv[i][2] == '\0' else if ((argv[i][2] == '\0'
&& (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL) && (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
|| strcmp (argv[i], "-Tdata") == 0)) || strcmp (argv[i], "-Tdata") == 0
|| strcmp (argv[i], "-MT") == 0
|| strcmp (argv[i], "-MF") == 0)
{ {
if (strcmp (argv[i], "-o") == 0) if (strcmp (argv[i], "-o") == 0)
saw_o = 1; saw_o = 1;
......
...@@ -41,6 +41,9 @@ DEFINE_LANG_NAME ("Java") ...@@ -41,6 +41,9 @@ DEFINE_LANG_NAME ("Java")
{ "-MMD", "Print dependencies to FILE.d" }, { "-MMD", "Print dependencies to FILE.d" },
{ "-M", "Print dependencies to stdout" }, { "-M", "Print dependencies to stdout" },
{ "-MM", "Print dependencies to stdout" }, { "-MM", "Print dependencies to stdout" },
{ "-MA", "Print dummy rules for included files" },
{ "-MF", "Print dependencies to FILE" },
{ "-MT", "Use TARGET as name of target in dependency file" },
#endif /* ! USE_CPPLIB */ #endif /* ! USE_CPPLIB */
{ "--classpath", "Set class path and suppress system path" }, { "--classpath", "Set class path and suppress system path" },
{ "--CLASSPATH", "Set class path" }, { "--CLASSPATH", "Set class path" },
......
...@@ -32,6 +32,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ ...@@ -32,6 +32,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
{"@java", {"@java",
"%{fjni:%{femit-class-files:%e-fjni and -femit-class-files are incompatible}}\ "%{fjni:%{femit-class-files:%e-fjni and -femit-class-files are incompatible}}\
%{fjni:%{femit-class-file:%e-fjni and -femit-class-file are incompatible}}\ %{fjni:%{femit-class-file:%e-fjni and -femit-class-file are incompatible}}\
%{!E:jc1 %i %(jc1) %(cc1_options) %{+e*} %{I*} %{MD} %{MMD} %{M} %{MM}\ %{!E:jc1 %i %(jc1) %(cc1_options) %{+e*} %{I*}\
%{MD} %{MMD} %{M} %{MM} %{MA} %{MT*} %{MF*}\
%{!fsyntax-only:%(invoke_as)}}"}, %{!fsyntax-only:%(invoke_as)}}"},
...@@ -159,6 +159,8 @@ static int dependency_tracking = 0; ...@@ -159,6 +159,8 @@ static int dependency_tracking = 0;
/* Flag values for DEPENDENCY_TRACKING. */ /* Flag values for DEPENDENCY_TRACKING. */
#define DEPEND_SET_FILE 1 #define DEPEND_SET_FILE 1
#define DEPEND_ENABLE 2 #define DEPEND_ENABLE 2
#define DEPEND_TARGET_SET 4
#define DEPEND_FILE_ALREADY_SET 8
/* /*
* process java-specific compiler command-line options * process java-specific compiler command-line options
...@@ -316,6 +318,23 @@ lang_decode_option (argc, argv) ...@@ -316,6 +318,23 @@ lang_decode_option (argc, argv)
dependency_tracking |= DEPEND_ENABLE; dependency_tracking |= DEPEND_ENABLE;
return 1; return 1;
} }
else if (strcmp (p, "-MA") == 0)
{
jcf_dependency_print_dummies ();
return 1;
}
else if (strcmp (p, "-MT") == 0)
{
jcf_dependency_set_target (argv[1]);
dependency_tracking |= DEPEND_TARGET_SET;
return 2;
}
else if (strcmp (p, "-MF") == 0)
{
jcf_dependency_set_dep_file (argv[1]);
dependency_tracking |= DEPEND_FILE_ALREADY_SET;
return 2;
}
return 0; return 0;
} }
...@@ -342,36 +361,48 @@ init_parse (filename) ...@@ -342,36 +361,48 @@ init_parse (filename)
if (dependency_tracking) if (dependency_tracking)
{ {
char *dot; char *dot;
dot = strrchr (filename, '.');
if (dot == NULL) /* If the target is set and the output filename is set, then
error ("couldn't determine target name for dependency tracking"); there's no processing to do here. Otherwise we must
else compute one or the other. */
if (! ((dependency_tracking & DEPEND_TARGET_SET)
&& (dependency_tracking & DEPEND_FILE_ALREADY_SET)))
{ {
char *buf = (char *) xmalloc (dot - filename + dot = strrchr (filename, '.');
3 + sizeof (OBJECT_SUFFIX)); if (dot == NULL)
strncpy (buf, filename, dot - filename); error ("couldn't determine target name for dependency tracking");
/* If emitting class files, we might have multiple
targets. The class generation code takes care of
registering them. Otherwise we compute the target
name here. */
if (flag_emit_class_files)
jcf_dependency_set_target (NULL);
else else
{ {
strcpy (buf + (dot - filename), OBJECT_SUFFIX); char *buf = (char *) xmalloc (dot - filename +
jcf_dependency_set_target (buf); 3 + sizeof (OBJECT_SUFFIX));
} strncpy (buf, filename, dot - filename);
if ((dependency_tracking & DEPEND_SET_FILE)) /* If emitting class files, we might have multiple
{ targets. The class generation code takes care of
strcpy (buf + (dot - filename), ".d"); registering them. Otherwise we compute the
jcf_dependency_set_dep_file (buf); target name here. */
if ((dependency_tracking & DEPEND_TARGET_SET))
; /* Nothing. */
else if (flag_emit_class_files)
jcf_dependency_set_target (NULL);
else
{
strcpy (buf + (dot - filename), OBJECT_SUFFIX);
jcf_dependency_set_target (buf);
}
if ((dependency_tracking & DEPEND_FILE_ALREADY_SET))
; /* Nothing. */
else if ((dependency_tracking & DEPEND_SET_FILE))
{
strcpy (buf + (dot - filename), ".d");
jcf_dependency_set_dep_file (buf);
}
else
jcf_dependency_set_dep_file ("-");
free (buf);
} }
else
jcf_dependency_set_dep_file ("-");
free (buf);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment