* doc/invoke.texi (i386 Options): Document x86-64 options.
[official-gcc.git] / gcc / java / jcf-depend.c
blobc9995609517ed09c8c9d528c77b7af1ba20ea48f
1 /* Functions for handling dependency tracking when reading .class files.
3 Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU CC; see the file COPYING. If not, write to
17 the Free Software Foundation, 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
20 Java and all Java-based marks are trademarks or registered trademarks
21 of Sun Microsystems, Inc. in the United States and other countries.
22 The Free Software Foundation is independent of Sun Microsystems, Inc. */
24 /* Written by Tom Tromey <tromey@cygnus.com>, October 1998. */
26 #include "config.h"
27 #include "system.h"
28 #include "mkdeps.h"
30 #include <assert.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 ()
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 (name)
73 const char *name;
75 /* We just handle this the same as an `add_target'. */
76 if (dependencies != NULL && name != NULL)
77 deps_add_target (dependencies, name, 1);
80 void
81 jcf_dependency_add_target (name)
82 const char *name;
84 if (dependencies != NULL)
85 deps_add_target (dependencies, name, 1);
88 void
89 jcf_dependency_set_dep_file (name)
90 const char *name;
92 assert (dep_out != stdout);
93 if (dep_out)
94 fclose (dep_out);
95 if (! strcmp (name, "-"))
96 dep_out = stdout;
97 else
98 dep_out = fopen (name, "w");
101 void
102 jcf_dependency_add_file (filename, system_p)
103 const char *filename;
104 int system_p;
106 if (! dependencies)
107 return;
109 /* Just omit system files. */
110 if (system_p && ! system_files)
111 return;
113 deps_add_dep (dependencies, filename);
116 void
117 jcf_dependency_init (system_p)
118 int system_p;
120 assert (! dependencies);
121 system_files = system_p;
122 dependencies = deps_init ();
125 void
126 jcf_dependency_print_dummies ()
128 print_dummies = 1;
131 void
132 jcf_dependency_write ()
134 if (! dep_out)
135 return;
137 assert (dependencies);
139 deps_write (dependencies, dep_out, 72);
140 if (print_dummies)
141 deps_phony_targets (dependencies, dep_out);
142 fflush (dep_out);