|
@@ -27,6 +27,8 @@
|
|
|
#include "nocross.h"
|
|
|
#include "sizes.h"
|
|
|
#include "align.h"
|
|
|
+#include "macro.h"
|
|
|
+#include "assert.h"
|
|
|
|
|
|
extern struct tokenname tkidf[];
|
|
|
extern char *symbol2str();
|
|
@@ -38,6 +40,10 @@ int inc_total = 0;
|
|
|
int inc_max;
|
|
|
char **inctable;
|
|
|
|
|
|
+extern int do_dependencies;
|
|
|
+extern char *dep_file;
|
|
|
+static File *dep_fd = STDOUT;
|
|
|
+
|
|
|
extern char *getwdir();
|
|
|
#endif NOPP
|
|
|
|
|
@@ -119,10 +125,80 @@ main(argc, argv)
|
|
|
if (options['m']) Info();
|
|
|
#endif DEBUG
|
|
|
|
|
|
+#ifndef NOPP
|
|
|
+ if (do_dependencies) {
|
|
|
+ extern char *source;
|
|
|
+
|
|
|
+ list_dependencies(source);
|
|
|
+ }
|
|
|
+#endif
|
|
|
sys_stop(err_occurred ? S_EXIT : S_END);
|
|
|
/*NOTREACHED*/
|
|
|
}
|
|
|
|
|
|
+#ifndef NOPP
|
|
|
+
|
|
|
+struct idf *file_head;
|
|
|
+extern char *strrindex();
|
|
|
+
|
|
|
+list_dependencies(source)
|
|
|
+char *source;
|
|
|
+{
|
|
|
+ register struct idf *p = file_head;
|
|
|
+
|
|
|
+ if (source) {
|
|
|
+ register char *s = strrindex(source, '.');
|
|
|
+
|
|
|
+ if (s && *(s+1)) {
|
|
|
+ s++;
|
|
|
+ *s++ = 'o';
|
|
|
+ *s = '\0';
|
|
|
+ /* the source may be in another directory than the
|
|
|
+ * object generated, so don't include the pathname
|
|
|
+ * leading to it.
|
|
|
+ */
|
|
|
+ if (s = strrindex(source, '/')) {
|
|
|
+ source = s + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else source = 0;
|
|
|
+ }
|
|
|
+ if (dep_file && !sys_open(dep_file, OP_WRITE, &dep_fd)) {
|
|
|
+ fatal("could not open %s", dep_file);
|
|
|
+ }
|
|
|
+ while (p) {
|
|
|
+ ASSERT(p->id_resmac == K_FILE);
|
|
|
+ dependency(p->id_text, source);
|
|
|
+ p = (struct idf *) (p->id_file);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+add_dependency(s)
|
|
|
+char *s;
|
|
|
+{
|
|
|
+ register struct idf *p = str2idf(s, 0);
|
|
|
+
|
|
|
+ if (! p->id_resmac) {
|
|
|
+ p->id_resmac = K_FILE;
|
|
|
+ p->id_file = (char *) file_head;
|
|
|
+ file_head = p;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+dependency(s, source)
|
|
|
+char *s, *source;
|
|
|
+{
|
|
|
+ if (options['i'] && !strncmp(s, "/usr/include/", 13)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (options['m'] && source) {
|
|
|
+ fprint(dep_fd, "%s: %s\n", source, s);
|
|
|
+ }
|
|
|
+ else fprint(dep_fd, "%s\n", s);
|
|
|
+}
|
|
|
+
|
|
|
+#endif NOPP
|
|
|
+
|
|
|
char *source = 0;
|
|
|
|
|
|
#ifdef GEN_NM_LIST
|