aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/lang.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>1998-10-14 12:54:59 +0000
committerTom Tromey <tromey@gcc.gnu.org>1998-10-14 12:54:59 +0000
commitfc45c7efec9457a616b27caab813322c93481b9d (patch)
tree6c0b69ec67e30f1aa5ef34301b4a5eba2beec889 /gcc/java/lang.c
parentbf94d1ecc773351392f54859e697f557ba097ed8 (diff)
downloadgcc-fc45c7efec9457a616b27caab813322c93481b9d.zip
gcc-fc45c7efec9457a616b27caab813322c93481b9d.tar.gz
gcc-fc45c7efec9457a616b27caab813322c93481b9d.tar.bz2
jcf-write.c (write_classfile): Add output class file as target.
* jcf-write.c (write_classfile): Add output class file as target. * lang-options.h: Added -MD, -MMD, -M, and -MM. * jcf.h: Added declarations for dependency-tracking functions. * lang-specs.h: Handle -M, -MM, MD, and -MMD. * lang.c (lang_decode_option): Recognize -MD and -MMD. (finish_parse): Call jcf_dependency_write. (dependency_tracking): New global. (DEPEND_SET_FILE): New define. (DEPEND_ENABLE): New define. (init_parse): Enable dependency tracking if required. Include "flags.h". * Makefile.in (JAVA_OBJS): Added jcf-depend.o. (../jcf-dump$(exeext)): Depend on and link with jcf-depend.o. (../gcjh$(exeext)): Likewise. (jcf-depend.o): New target. * Make-lang.in (JAVA_SRCS): Added jcf-depend.c. (GCJH_SOURCES): Likewise. * jcf-io.c (open_class): Call jcf_dependency_add_file. Added dep_name argument. (find_classfile): Added dep_name argument. (find_class): Compute name of dependency. (open_in_zip): Call jcf_dependency_add_file. * gjavah.c (output_file): No longer global. (usage): Don't mention "gjavah". (help): Likewise. (java_no_argument): Likewise. (version): Likewise. (main): Recognize and handle -M family of options. (print_mangled_classname): Return is void. (process_file): Handle case where output is suppressed. (HANDLE_END_FIELD): Likewise. (HANDLE_METHOD): Likewise. * jcf-depend.c: New file. From-SVN: r23085
Diffstat (limited to 'gcc/java/lang.c')
-rw-r--r--gcc/java/lang.c78
1 files changed, 77 insertions, 1 deletions
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index 21c30c1..3b1593c 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -31,6 +31,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "java-tree.h"
#include "jcf.h"
#include "toplev.h"
+#include "flags.h"
/* Table indexed by tree code giving a string containing a character
classifying the tree code. Possibilities are
@@ -104,6 +105,14 @@ static struct { char *string; int *variable; int on_value;} lang_f_options[] =
JCF main_jcf[1];
JCF *current_jcf;
+/* Variable controlling how dependency tracking is enabled in
+ init_parse. */
+static int dependency_tracking = 0;
+
+/* Flag values for DEPENDENCY_TRACKING. */
+#define DEPEND_SET_FILE 1
+#define DEPEND_ENABLE 2
+
/*
* process java-specific compiler command-line options
*/
@@ -140,9 +149,35 @@ lang_decode_option (argc, argv)
found = 1;
}
}
+
return found;
}
+ if (strcmp (p, "-MD") == 0)
+ {
+ jcf_dependency_init (1);
+ dependency_tracking |= DEPEND_SET_FILE | DEPEND_ENABLE;
+ return 1;
+ }
+ else if (strcmp (p, "-MMD") == 0)
+ {
+ jcf_dependency_init (0);
+ dependency_tracking |= DEPEND_SET_FILE | DEPEND_ENABLE;
+ return 1;
+ }
+ else if (strcmp (p, "-M") == 0)
+ {
+ jcf_dependency_init (1);
+ dependency_tracking |= DEPEND_ENABLE;
+ return 1;
+ }
+ else if (strcmp (p, "-MM") == 0)
+ {
+ jcf_dependency_init (0);
+ dependency_tracking |= DEPEND_ENABLE;
+ return 1;
+ }
+
return 0;
}
@@ -157,9 +192,49 @@ init_parse (filename)
{
finput = stdin;
filename = "stdin";
+
+ if (dependency_tracking)
+ error ("can't do dependency tracking with input from stdin");
}
else
- finput = fopen (filename, "r");
+ {
+ if (dependency_tracking)
+ {
+ char *dot;
+ dot = strrchr (filename, '.');
+ if (dot == NULL)
+ error ("couldn't determine target name for dependency tracking");
+ else
+ {
+ char *buf = (char *) xmalloc (dot - filename + 3);
+ strncpy (buf, filename, dot - filename);
+
+ /* 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
+ {
+ strcpy (buf + (dot - filename), ".o");
+ jcf_dependency_set_target (buf);
+ }
+
+ 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);
+ }
+ }
+
+ finput = fopen (filename, "r");
+ }
if (finput == 0)
pfatal_with_name (filename);
@@ -175,6 +250,7 @@ void
finish_parse ()
{
fclose (finput);
+ jcf_dependency_write ();
}
/* Buffer used by lang_printable_name. */