version 1.36, 2000/10/13 08:30:49 |
version 1.37, 2000/11/24 14:36:33 |
|
|
arch = ArchFindMember(archive, member, &sarh, "r"); |
arch = ArchFindMember(archive, member, &sarh, "r"); |
|
|
if (arch == NULL) |
if (arch == NULL) |
return NULL; |
return result; |
else { |
else { |
fclose(arch); |
fclose(arch); |
grab_date( (time_t)strtol(sarh.ar_date, NULL, 10), result); |
grab_date( (time_t)strtol(sarh.ar_date, NULL, 10), result); |
|
|
*/ |
*/ |
arch = fopen(archive, "r"); |
arch = fopen(archive, "r"); |
if (arch == NULL) |
if (arch == NULL) |
return (NULL); |
return result; |
|
|
/* |
/* |
* We use the ARMAG string to make sure this is an archive we |
* We use the ARMAG string to make sure this is an archive we |
|
|
if ((fread(magic, SARMAG, 1, arch) != 1) || |
if ((fread(magic, SARMAG, 1, arch) != 1) || |
(strncmp(magic, ARMAG, SARMAG) != 0)) { |
(strncmp(magic, ARMAG, SARMAG) != 0)) { |
fclose(arch); |
fclose(arch); |
return NULL; |
return result; |
} |
} |
|
|
ar = (Arch *)emalloc(sizeof (Arch)); |
ar = (Arch *)emalloc(sizeof (Arch)); |
|
|
arch = ArchFindMember(Varq_Value(ARCHIVE_INDEX, gn), |
arch = ArchFindMember(Varq_Value(ARCHIVE_INDEX, gn), |
Varq_Value(MEMBER_INDEX, gn), |
Varq_Value(MEMBER_INDEX, gn), |
&arh, "r+"); |
&arh, "r+"); |
sprintf(arh.ar_date, "%-12ld", (long) now); |
sprintf(arh.ar_date, "%-12ld", (long) timestamp2time_t(now)); |
|
|
if (arch != NULL) { |
if (arch != NULL) { |
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch); |
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch); |
|
|
#ifdef RANLIBMAG |
#ifdef RANLIBMAG |
FILE * arch; /* Stream open to archive */ |
FILE * arch; /* Stream open to archive */ |
struct ar_hdr arh; /* Header describing table of contents */ |
struct ar_hdr arh; /* Header describing table of contents */ |
struct utimbuf times; /* Times for utime() call */ |
|
|
|
arch = ArchFindMember (gn->path, RANLIBMAG, &arh, "r+"); |
arch = ArchFindMember (gn->path, RANLIBMAG, &arh, "r+"); |
sprintf(arh.ar_date, "%-12ld", (long) now); |
sprintf(arh.ar_date, "%-12ld", (long) timestamp2time_t(now)); |
|
|
if (arch != NULL) { |
if (arch != NULL) { |
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch); |
(void)fwrite ((char *)&arh, sizeof (struct ar_hdr), 1, arch); |
fclose (arch); |
fclose (arch); |
|
|
times.actime = times.modtime = now; |
set_times(gn->path); |
utime(gn->path, ×); |
|
} |
} |
#endif |
#endif |
} |
} |
|
|
GNode *gn; |
GNode *gn; |
{ |
{ |
LstNode ln; |
LstNode ln; |
GNode *pgn; |
|
char *nameStart, |
|
*nameEnd; |
|
|
|
Lst_Open(&gn->parents); |
for (ln = Lst_First(&gn->parents); ln != NULL; ln = Lst_Adv(ln)) { |
while ((ln = Lst_Next(&gn->parents)) != NULL) { |
GNode *pgn; |
|
char *nameStart, |
|
*nameEnd; |
|
|
pgn = (GNode *)Lst_Datum(ln); |
pgn = (GNode *)Lst_Datum(ln); |
|
|
if (pgn->type & OP_ARCHV) { |
if (pgn->type & OP_ARCHV) { |
/* |
/* If the parent is an archive specification and is being made |
* If the parent is an archive specification and is being made |
|
* and its member's name matches the name of the node we were |
* and its member's name matches the name of the node we were |
* given, record the modification time of the parent in the |
* given, record the modification time of the parent in the |
* child. We keep searching its parents in case some other |
* child. We keep searching its parents in case some other |
* parent requires this child to exist... |
* parent requires this child to exist... */ |
*/ |
if ((nameStart = strchr(pgn->name, '(') ) != NULL) { |
/* OpenBSD: less ugly check for nameStart == NULL */ |
|
if ((nameStart = strchr (pgn->name, '(') ) != NULL) { |
|
nameStart++; |
nameStart++; |
nameEnd = strchr (nameStart, ')'); |
nameEnd = strchr(nameStart, ')'); |
} else |
} else |
nameEnd = NULL; |
nameEnd = NULL; |
|
|
if (pgn->make && nameEnd != NULL && |
if (pgn->make && nameEnd != NULL && |
strncmp(nameStart, gn->name, nameEnd - nameStart) == 0) { |
strncmp(nameStart, gn->name, nameEnd - nameStart) == 0 && |
if (Arch_MTime(pgn)) |
gn->name[nameEnd-nameStart] == '\0') |
gn->mtime = pgn->mtime; |
gn->mtime = Arch_MTime(pgn); |
else |
|
gn->mtime = OUT_OF_DATE; |
|
} |
|
} else if (pgn->make) { |
} else if (pgn->make) { |
/* |
/* Something which isn't a library depends on the existence of |
* Something which isn't a library depends on the existence of |
* this target, so it needs to exist. */ |
* this target, so it needs to exist. |
set_out_of_date(gn->mtime); |
*/ |
|
gn->mtime = OUT_OF_DATE; |
|
break; |
break; |
} |
} |
} |
} |
|
|
Lst_Close(&gn->parents); |
|
|
|
return gn->mtime; |
return gn->mtime; |
} |
} |
|
|
|
|
Arch_LibOODate (gn) |
Arch_LibOODate (gn) |
GNode *gn; /* The library's graph node */ |
GNode *gn; /* The library's graph node */ |
{ |
{ |
Boolean oodate; |
TIMESTAMP modTimeTOC; /* mod time of __.SYMDEF */ |
|
|
if (OP_NOP(gn->type) && Lst_IsEmpty(&gn->children)) { |
if (OP_NOP(gn->type) && Lst_IsEmpty(&gn->children)) |
oodate = FALSE; |
return FALSE; |
} else if (gn->mtime > now || gn->mtime < gn->cmtime || |
if (is_before(now, gn->mtime) || is_before(gn->mtime, gn->cmtime) || |
gn->mtime == OUT_OF_DATE) { |
is_out_of_date(gn->mtime)) |
oodate = TRUE; |
return TRUE; |
} else { |
|
#ifdef RANLIBMAG |
#ifdef RANLIBMAG |
time_t modTimeTOC; /* The table-of-contents's mod time */ |
/* non existent libraries are always out-of-date. */ |
|
if (gn->path == NULL) |
|
return TRUE; |
|
|
modTimeTOC = ArchMTimeMember(gn->path, RANLIBMAG, FALSE); |
modTimeTOC = ArchMTimeMember(gn->path, RANLIBMAG, FALSE); |
|
|
if (!is_out_of_date(modTimeTOC)) { |
if (!is_out_of_date(modTimeTOC)) { |
if (DEBUG(ARCH) || DEBUG(MAKE)) |
if (DEBUG(ARCH) || DEBUG(MAKE)) |
printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC)); |
printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC)); |
oodate = is_before(modTimeTOC, gn->cmtime); |
return is_before(modTimeTOC, gn->cmtime); |
} else { |
} |
/* |
/* A library w/o a table of contents is out-of-date */ |
* A library w/o a table of contents is out-of-date |
if (DEBUG(ARCH) || DEBUG(MAKE)) |
*/ |
printf("No t.o.c...."); |
if (DEBUG(ARCH) || DEBUG(MAKE)) |
return TRUE; |
printf("No t.o.c...."); |
|
oodate = TRUE; |
|
} |
|
#else |
#else |
oodate = FALSE; |
return FALSE; |
#endif |
#endif |
} |
|
return (oodate); |
|
} |
} |
|
|
/*- |
/*- |