ipa-cp.c (ipcp_cloning_candidate_p): Use opt_for_fn.
[gcc.git] / gcc / java / jcf-depend.c
1 /* Functions for handling dependency tracking when reading .class files.
2
3 Copyright (C) 1998-2014 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
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.
11
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.
16
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/>.
20
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. */
24
25 /* Written by Tom Tromey <tromey@cygnus.com>, October 1998. */
26
27 #include "config.h"
28 #include "system.h"
29 #include "coretypes.h"
30 #include "mkdeps.h"
31
32 #include "jcf.h"
33
34 \f
35
36 /* The dependency structure used for this invocation. */
37 struct deps *dependencies;
38
39 /* The output file, or NULL if we aren't doing dependency tracking. */
40 static FILE *dep_out = NULL;
41
42 /* Nonzero if system files should be added. */
43 static int system_files;
44
45 /* Nonzero if we are dumping out dummy dependencies. */
46 static int print_dummies;
47
48 \f
49
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)
56 {
57 if (dep_out != NULL)
58 {
59 if (dep_out != stdout)
60 fclose (dep_out);
61 dep_out = NULL;
62 }
63
64 if (dependencies != NULL)
65 {
66 deps_free (dependencies);
67 dependencies = NULL;
68 }
69 }
70
71 void
72 jcf_dependency_set_target (const char *name)
73 {
74 /* We just handle this the same as an `add_target'. */
75 if (dependencies != NULL && name != NULL)
76 deps_add_target (dependencies, name, 1);
77 }
78
79 void
80 jcf_dependency_add_target (const char *name)
81 {
82 if (dependencies != NULL)
83 deps_add_target (dependencies, name, 1);
84 }
85
86 void
87 jcf_dependency_set_dep_file (const char *name)
88 {
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");
96 }
97
98 void
99 jcf_dependency_add_file (const char *filename ATTRIBUTE_UNUSED, int system_p)
100 {
101 if (! dependencies)
102 return;
103
104 /* Just omit system files. */
105 if (system_p && ! system_files)
106 return;
107
108
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); */
112 }
113
114 void
115 jcf_dependency_init (int system_p)
116 {
117 gcc_assert (! dependencies);
118 system_files = system_p;
119 dependencies = deps_init ();
120 }
121
122 void
123 jcf_dependency_print_dummies (void)
124 {
125 print_dummies = 1;
126 }
127
128 void
129 jcf_dependency_write (void)
130 {
131 if (! dep_out)
132 return;
133
134 gcc_assert (dependencies);
135
136 deps_write (dependencies, dep_out, 72);
137 if (print_dummies)
138 deps_phony_targets (dependencies, dep_out);
139 fflush (dep_out);
140 }