+#include "file-path.hh"
+#include "file-results.hh"
+#include "my-lily-parser.hh"
+#include "source.hh"
+#include "lily-version.hh"
+#include "scm-hash.hh"
+
+Sources* source_global_l = 0;
+Array<String> inclusion_global_array;
+Array<String> target_str_global_array;
+Link_array<Score> score_global_array;
+Scheme_hash_table * global_header_p;
+
+
+void write_dependency_file (String fn, Array<String> targets,
+ Array<String> deps)
+{
+ const int WRAPWIDTH = 65;
+
+ progress_indication (_f ("dependencies output to `%s'...", fn.ch_C ()));
+ progress_indication ("\n");
+ ofstream f (fn.ch_C ());
+ if (!f)
+ warning (_f ("can't open file: `%s'", fn));
+
+ f << "# Generated automatically by: " << gnu_lilypond_version_str () << '\n';
+ String out;
+ for (int i=0; i < targets.size (); i ++)
+ out += dependency_prefix_global + targets[i] + " ";
+ out += ": ";
+#if 0
+ struct stat stat_buf;
+#endif
+ for (int i=0; i < deps.size (); i ++)
+ {
+ if (out.length_i () > WRAPWIDTH)
+ {
+ f << out << "\\\n";
+ out = " ";
+ }
+ String dep = deps[i];
+ if (!dependency_prefix_global.empty_b ())
+ {
+#if 0//thinko?
+ if (stat (dep.ch_C (), &stat_buf) == -1 && errno == ENOENT)
+ ; //make emacs happy
+#else
+ if (dep.index_i ('/') < 0)
+#endif
+ dep = dependency_prefix_global + dep;
+ }
+ out += " " + dep;
+ }
+ f << out << endl;
+}
+
+void
+do_deps ()
+{
+ if (dependency_global_b)
+ {
+ Path p = split_path (output_name_global);
+ p.ext = "dep";
+ write_dependency_file (p.str (),
+ target_str_global_array,
+ inclusion_global_array);
+ }
+}