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: idf.h
|
||||||
options.o: idfsize.h
|
options.o: idfsize.h
|
||||||
options.o: macro.h
|
options.o: macro.h
|
||||||
|
options.o: mkdep.h
|
||||||
preprocess.o: LLlex.h
|
preprocess.o: LLlex.h
|
||||||
preprocess.o: bits.h
|
preprocess.o: bits.h
|
||||||
preprocess.o: charoffset.h
|
preprocess.o: charoffset.h
|
||||||
|
|
|
@ -278,12 +278,12 @@ do_include()
|
||||||
error("cannot find include file \"%s\"", filenm);
|
error("cannot find include file \"%s\"", filenm);
|
||||||
#else
|
#else
|
||||||
warning("cannot find include file \"%s\"", filenm);
|
warning("cannot find include file \"%s\"", filenm);
|
||||||
add_file(filenm);
|
add_dependency(filenm);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef MKDEP
|
#ifdef MKDEP
|
||||||
add_file(result);
|
add_dependency(result);
|
||||||
#endif
|
#endif
|
||||||
WorkingDir = getwdir(result);
|
WorkingDir = getwdir(result);
|
||||||
svnestlevel[++nestcount] = nestlevel;
|
svnestlevel[++nestcount] = nestlevel;
|
||||||
|
|
|
@ -39,7 +39,7 @@ main(argc, argv)
|
||||||
|
|
||||||
inctable = (char **) Malloc(10 * sizeof(char *));
|
inctable = (char **) Malloc(10 * sizeof(char *));
|
||||||
inc_max = 10;
|
inc_max = 10;
|
||||||
inc_total = 2;
|
inc_total = 3;
|
||||||
inctable[0] = "";
|
inctable[0] = "";
|
||||||
inctable[1] = "/usr/include";
|
inctable[1] = "/usr/include";
|
||||||
init_pp(); /* initialise the preprocessor macros */
|
init_pp(); /* initialise the preprocessor macros */
|
||||||
|
@ -90,25 +90,37 @@ compile(argc, argv)
|
||||||
if (source) WorkingDir = getwdir(dummy);
|
if (source) WorkingDir = getwdir(dummy);
|
||||||
preprocess(source);
|
preprocess(source);
|
||||||
#ifdef MKDEP
|
#ifdef MKDEP
|
||||||
list_files();
|
list_dependencies(source);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MKDEP
|
#ifdef MKDEP
|
||||||
struct idf *file_head;
|
struct idf *file_head;
|
||||||
|
extern char *strrindex();
|
||||||
|
|
||||||
list_files()
|
list_dependencies(source)
|
||||||
|
char *source;
|
||||||
{
|
{
|
||||||
register struct idf *p = file_head;
|
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) {
|
while (p) {
|
||||||
assert(p->id_resmac == K_FILE);
|
assert(p->id_resmac == K_FILE);
|
||||||
print("%s\n", p->id_text);
|
dependency(p->id_text, source);
|
||||||
p = p->id_file;
|
p = p->id_file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_file(s)
|
add_dependency(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
register struct idf *p = str2idf(s, 0);
|
register struct idf *p = str2idf(s, 0);
|
||||||
|
@ -119,4 +131,14 @@ add_file(s)
|
||||||
file_head = p;
|
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
|
#endif
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "class.h"
|
#include "class.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "idf.h"
|
#include "idf.h"
|
||||||
|
#include "mkdep.h"
|
||||||
|
|
||||||
char options[128]; /* one for every char */
|
char options[128]; /* one for every char */
|
||||||
int inc_pos = 1; /* place where next -I goes */
|
int inc_pos = 1; /* place where next -I goes */
|
||||||
|
@ -25,13 +26,19 @@ do_option(text)
|
||||||
{
|
{
|
||||||
switch(*text++) {
|
switch(*text++) {
|
||||||
case '-':
|
case '-':
|
||||||
|
#ifdef MKDEP
|
||||||
|
case 'x':
|
||||||
|
#endif
|
||||||
options[*text] = 1;
|
options[*text] = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
#ifndef MKDEP
|
||||||
error("illegal option: %c", text[-1]);
|
error("illegal option: %c", text[-1]);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'C' : /* comment output */
|
case 'C' : /* comment output */
|
||||||
options['C'] = 1;
|
case 'P' : /* run preprocessor stand-alone, without #'s */
|
||||||
|
options[*(text-1)] = 1;
|
||||||
break;
|
break;
|
||||||
case 'D' : /* -Dname : predefine name */
|
case 'D' : /* -Dname : predefine name */
|
||||||
{
|
{
|
||||||
|
@ -98,9 +105,6 @@ do_option(text)
|
||||||
idfsize = 8;
|
idfsize = 8;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'P' : /* run preprocessor stand-alone, without #'s */
|
|
||||||
options['P'] = 1;
|
|
||||||
break;
|
|
||||||
case 'U' : /* -Uname : undefine predefined */
|
case 'U' : /* -Uname : undefine predefined */
|
||||||
if (*text) {
|
if (*text) {
|
||||||
register struct idf *idef = findidf(text);
|
register struct idf *idef = findidf(text);
|
||||||
|
|
Loading…
Add table
Reference in a new issue