Fix bootstrap failure.
[official-gcc.git] / gcc / java / jcf-depend.c
blob89411c37750de9f723cc862695ae4e665ffc4059
1 /* Functions for handling dependency tracking when reading .class files.
3 Copyright (C) 1998-2014 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>.
21 Java and all Java-based marks are trademarks or registered trademarks
22 of Sun Microsystems, Inc. in the United States and other countries.
23 The Free Software Foundation is independent of Sun Microsystems, Inc. */
25 /* Written by Tom Tromey <tromey@cygnus.com>, October 1998. */
27 #include "config.h"
28 #include "system.h"
29 #include "coretypes.h"
30 #include "mkdeps.h"
32 #include "jcf.h"
36 /* The dependency structure used for this invocation. */
37 struct deps *dependencies;
39 /* The output file, or NULL if we aren't doing dependency tracking. */
40 static FILE *dep_out = NULL;
42 /* Nonzero if system files should be added. */
43 static int system_files;
45 /* Nonzero if we are dumping out dummy dependencies. */
46 static int print_dummies;
50 /* Call this to reset the dependency module. This is required if
51 multiple dependency files are being generated from a single tool
52 invocation. FIXME: we should change our API or just completely use
53 the one in mkdeps.h. */
54 void
55 jcf_dependency_reset (void)
57 if (dep_out != NULL)
59 if (dep_out != stdout)
60 fclose (dep_out);
61 dep_out = NULL;
64 if (dependencies != NULL)
66 deps_free (dependencies);
67 dependencies = NULL;
71 void
72 jcf_dependency_set_target (const char *name)
74 /* We just handle this the same as an `add_target'. */
75 if (dependencies != NULL && name != NULL)
76 deps_add_target (dependencies, name, 1);
79 void
80 jcf_dependency_add_target (const char *name)
82 if (dependencies != NULL)
83 deps_add_target (dependencies, name, 1);
86 void
87 jcf_dependency_set_dep_file (const char *name)
89 gcc_assert (dep_out != stdout);
90 if (dep_out)
91 fclose (dep_out);
92 if (! strcmp (name, "-"))
93 dep_out = stdout;
94 else
95 dep_out = fopen (name, "w");
98 void
99 jcf_dependency_add_file (const char *filename ATTRIBUTE_UNUSED, int system_p)
101 if (! dependencies)
102 return;
104 /* Just omit system files. */
105 if (system_p && ! system_files)
106 return;
109 /* FIXME: Don't emit any dependencies. In many cases we'll just see
110 temporary files emitted by ecj... */
111 /* deps_add_dep (dependencies, filename); */
114 void
115 jcf_dependency_init (int system_p)
117 gcc_assert (! dependencies);
118 system_files = system_p;
119 dependencies = deps_init ();
122 void
123 jcf_dependency_print_dummies (void)
125 print_dummies = 1;
128 void
129 jcf_dependency_write (void)
131 if (! dep_out)
132 return;
134 gcc_assert (dependencies);
136 deps_write (dependencies, dep_out, 72);
137 if (print_dummies)
138 deps_phony_targets (dependencies, dep_out);
139 fflush (dep_out);