Added some mkdep features and fixed a bug
This commit is contained in:
parent
f5b29d9ccc
commit
b48f529177
4 changed files with 38 additions and 11 deletions
|
@ -198,6 +198,7 @@ options.o: class.h
|
|||
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
|
||||
|
|
|
@ -278,12 +278,12 @@ do_include()
|
|||
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;
|
||||
|
|
|
@ -39,7 +39,7 @@ main(argc, argv)
|
|||
|
||||
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 */
|
||||
|
@ -90,25 +90,37 @@ compile(argc, argv)
|
|||
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);
|
||||
|
@ -119,4 +131,14 @@ add_file(s)
|
|||
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
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#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 */
|
||||
|
@ -25,13 +26,19 @@ do_option(text)
|
|||
{
|
||||
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 */
|
||||
{
|
||||
|
@ -98,9 +105,6 @@ do_option(text)
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue