options.o: idf.h
options.o: idfsize.h
options.o: macro.h
+options.o: mkdep.h
preprocess.o: LLlex.h
preprocess.o: bits.h
preprocess.o: charoffset.h
error("cannot find include file \"%s\"", filenm);
#else
warning("cannot find include file \"%s\"", filenm);
- add_file(filenm);
+ add_dependency(filenm);
#endif
}
else {
#ifdef MKDEP
- add_file(result);
+ add_dependency(result);
#endif
WorkingDir = getwdir(result);
svnestlevel[++nestcount] = nestlevel;
inctable = (char **) Malloc(10 * sizeof(char *));
inc_max = 10;
- inc_total = 2;
+ inc_total = 3;
inctable[0] = "";
inctable[1] = "/usr/include";
init_pp(); /* initialise the preprocessor macros */
if (source) WorkingDir = getwdir(dummy);
preprocess(source);
#ifdef MKDEP
- list_files();
+ list_dependencies(source);
#endif
}
#ifdef MKDEP
struct idf *file_head;
+extern char *strrindex();
-list_files()
+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';
+ }
+ else source = 0;
+ }
while (p) {
assert(p->id_resmac == K_FILE);
- print("%s\n", p->id_text);
+ dependency(p->id_text, source);
p = p->id_file;
}
}
-add_file(s)
+add_dependency(s)
char *s;
{
register struct idf *p = str2idf(s, 0);
file_head = p;
}
}
+
+dependency(s, source)
+ char *s;
+{
+ if (options['s'] && !strncmp(s, "/usr/include/", 13)) {
+ return;
+ }
+ if (options['m'] && source) print("%s: ", source);
+ print("%s\n", s);
+}
#endif
#include "class.h"
#include "macro.h"
#include "idf.h"
+#include "mkdep.h"
char options[128]; /* one for every char */
int inc_pos = 1; /* place where next -I goes */
{
switch(*text++) {
case '-':
+#ifdef MKDEP
+ case 'x':
+#endif
options[*text] = 1;
break;
default:
+#ifndef MKDEP
error("illegal option: %c", text[-1]);
+#endif
break;
case 'C' : /* comment output */
- options['C'] = 1;
+ case 'P' : /* run preprocessor stand-alone, without #'s */
+ options[*(text-1)] = 1;
break;
case 'D' : /* -Dname : predefine name */
{
idfsize = 8;
}
break;
- case 'P' : /* run preprocessor stand-alone, without #'s */
- options['P'] = 1;
- break;
case 'U' : /* -Uname : undefine predefined */
if (*text) {
register struct idf *idef = findidf(text);