418 |
static void |
static void |
419 |
expand_deps (struct file *f) |
expand_deps (struct file *f) |
420 |
{ |
{ |
421 |
register struct dep *d, *d1; |
struct dep *d, *d1; |
422 |
struct dep *new = 0; |
struct dep *new = 0; |
423 |
struct dep *old = f->deps; |
struct dep *old = f->deps; |
424 |
unsigned int last_dep_has_cmds = f->updating; |
unsigned int last_dep_has_cmds = f->updating; |
425 |
|
int initialized = 0; |
426 |
|
|
427 |
f->updating = 0; |
f->updating = 0; |
428 |
f->deps = 0; |
f->deps = 0; |
429 |
|
|
|
/* We are going to do second expansion so initialize file |
|
|
variables for the file. */ |
|
|
initialize_file_variables (f, 0); |
|
|
|
|
430 |
for (d = old; d != 0; d = d->next) |
for (d = old; d != 0; d = d->next) |
431 |
{ |
{ |
432 |
if (d->name != 0) |
if (d->name != 0) |
433 |
{ |
{ |
434 |
char *p; |
char *p; |
|
struct dep **d_ptr; |
|
435 |
|
|
436 |
set_file_variables (f); |
/* If we need a second expansion on these, set up the file |
437 |
|
variables, etc. It takes a lot of extra memory and processing |
438 |
|
to do this, so only do it if it's needed. */ |
439 |
|
if (! d->need_2nd_expansion) |
440 |
|
p = d->name; |
441 |
|
else |
442 |
|
{ |
443 |
|
/* We are going to do second expansion so initialize file |
444 |
|
variables for the file. */ |
445 |
|
if (!initialized) |
446 |
|
{ |
447 |
|
initialize_file_variables (f, 0); |
448 |
|
initialized = 1; |
449 |
|
} |
450 |
|
|
451 |
p = variable_expand_for_file (d->name, f); |
set_file_variables (f); |
452 |
|
|
453 |
|
p = variable_expand_for_file (d->name, f); |
454 |
|
} |
455 |
|
|
456 |
/* Parse the dependencies. */ |
/* Parse the dependencies. */ |
457 |
new = (struct dep *) |
new = (struct dep *) |
464 |
/* Files that follow '|' are special prerequisites that |
/* Files that follow '|' are special prerequisites that |
465 |
need only exist in order to satisfy the dependency. |
need only exist in order to satisfy the dependency. |
466 |
Their modification times are irrelevant. */ |
Their modification times are irrelevant. */ |
467 |
|
struct dep **d_ptr; |
468 |
|
|
|
struct dep *d; |
|
469 |
for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next) |
for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next) |
470 |
; |
; |
471 |
++p; |
++p; |
475 |
parse_file_seq (&p, '\0', sizeof (struct dep), 1), |
parse_file_seq (&p, '\0', sizeof (struct dep), 1), |
476 |
sizeof (struct dep)); |
sizeof (struct dep)); |
477 |
|
|
478 |
for (d = *d_ptr; d != 0; d = d->next) |
for (d1 = *d_ptr; d1 != 0; d1 = d1->next) |
479 |
d->ignore_mtime = 1; |
d1->ignore_mtime = 1; |
480 |
} |
} |
481 |
|
|
482 |
/* Enter them as files. */ |
/* Enter them as files. */ |
488 |
else |
else |
489 |
free (d1->name); |
free (d1->name); |
490 |
d1->name = 0; |
d1->name = 0; |
491 |
|
d1->need_2nd_expansion = 0; |
492 |
} |
} |
493 |
|
|
494 |
/* Add newly parsed deps to f->deps. If this is the last |
/* Add newly parsed deps to f->deps. If this is the last |
505 |
{ |
{ |
506 |
if (d->next == 0 && last_dep_has_cmds) |
if (d->next == 0 && last_dep_has_cmds) |
507 |
{ |
{ |
508 |
|
struct dep **d_ptr; |
509 |
for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next) |
for (d_ptr = &new; *d_ptr; d_ptr = &(*d_ptr)->next) |
510 |
; |
; |
511 |
|
|
512 |
*d_ptr = f->deps; |
*d_ptr = f->deps; |
513 |
f->deps = new; |
f->deps = new; |
514 |
} |
} |
515 |
else |
else |
516 |
{ |
{ |
517 |
for (d_ptr = &(f->deps); *d_ptr; d_ptr = &(*d_ptr)->next) |
struct dep **d_ptr; |
518 |
|
for (d_ptr = &f->deps; *d_ptr; d_ptr = &(*d_ptr)->next) |
519 |
; |
; |
520 |
|
|
521 |
*d_ptr = new; |
*d_ptr = new; |
524 |
} |
} |
525 |
} |
} |
526 |
|
|
527 |
free_ns_chain ((struct nameseq*)old); |
free_ns_chain ((struct nameseq *) old); |
528 |
} |
} |
529 |
|
|
530 |
/* For each dependency of each file, make the `struct dep' point |
/* For each dependency of each file, make the `struct dep' point |
536 |
void |
void |
537 |
snap_deps (void) |
snap_deps (void) |
538 |
{ |
{ |
539 |
register struct file *f; |
struct file *f; |
540 |
register struct file *f2; |
struct file *f2; |
541 |
register struct dep *d; |
struct dep *d; |
542 |
register struct file **file_slot_0; |
struct file **file_slot_0; |
543 |
register struct file **file_slot; |
struct file **file_slot; |
544 |
register struct file **file_end; |
struct file **file_end; |
545 |
|
|
546 |
/* Perform second expansion and enter each dependency |
/* Perform second expansion and enter each dependency |
547 |
name as a file. */ |
name as a file. */ |