change flag -xs to -i, -xm to -m, dependencies
This commit is contained in:
@@ -6,15 +6,22 @@
|
||||
/* MAIN PROGRAM */
|
||||
|
||||
#include <alloc.h>
|
||||
#include <assert.h>
|
||||
#include <system.h>
|
||||
#include "arith.h"
|
||||
#include "file_info.h"
|
||||
#include "idfsize.h"
|
||||
#include "idf.h"
|
||||
#include "macro.h"
|
||||
|
||||
extern char *symbol2str();
|
||||
extern char *getwdir();
|
||||
extern int err_occurred;
|
||||
extern int do_dependencies;
|
||||
extern char *dep_file;
|
||||
int idfsize = IDFSIZE;
|
||||
extern char options[];
|
||||
static File *dep_fd = STDOUT;
|
||||
|
||||
arith ifval;
|
||||
|
||||
@@ -81,6 +88,66 @@ compile(argc, argv)
|
||||
source ? source : "stdin");
|
||||
if (source) WorkingDir = getwdir(dummy);
|
||||
preprocess(source);
|
||||
if (do_dependencies) list_dependencies(source);
|
||||
}
|
||||
|
||||
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 = 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 = 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);
|
||||
}
|
||||
|
||||
No_Mem() /* called by alloc package */
|
||||
|
||||
Reference in New Issue
Block a user