diff options
author | Ron Yorston <rmy@pobox.com> | 2024-04-22 15:32:25 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-04-22 15:32:25 +0100 |
commit | 79226860ee5627ffee9b3d4722f6bc91b64ce91c (patch) | |
tree | e28991d9c779d8c05ff716fe271f6addfc45c1cb /miscutils/make.c | |
parent | b5131ae1c0bb7984b35c909d04e2f4a61a7b6d8f (diff) | |
download | busybox-w32-79226860ee5627ffee9b3d4722f6bc91b64ce91c.tar.gz busybox-w32-79226860ee5627ffee9b3d4722f6bc91b64ce91c.tar.bz2 busybox-w32-79226860ee5627ffee9b3d4722f6bc91b64ce91c.zip |
make: better determine that a file is up-to-date
POSIX says:
A target shall be considered up-to-date... if it has already
been made up-to-date by the current invocation of make
(regardless of the target's existence or age).
If the target does not exist after the target has been
successfully made up-to-date, the target shall be treated as
being newer than any target for which it is a prerequisite.
Previously 'make' assumed that if a rule had succeeded the
modification time of the target would be the current time. This
isn't necessarily the case. Instead:
- If the file exists use the modification time of the file as the
the time of the target.
- If it doesn't exist use the current time, which should be more
recent than the time of any file for which it's a prerequisite.
Adds 16 bytes.
(GitHub issue #410)
Diffstat (limited to '')
-rw-r--r-- | miscutils/make.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 97ee8d879..c2e12f2ed 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -2509,9 +2509,11 @@ make(struct name *np, int level) | |||
2509 | free(oodate); | 2509 | free(oodate); |
2510 | } | 2510 | } |
2511 | 2511 | ||
2512 | if (estat & MAKE_DIDSOMETHING) | 2512 | if (estat & MAKE_DIDSOMETHING) { |
2513 | clock_gettime(CLOCK_REALTIME, &np->n_tim); | 2513 | modtime(np); |
2514 | else if (!quest && level == 0 && !timespec_le(&np->n_tim, &dtim)) | 2514 | if (np->n_tim.tv_sec == 0 && np->n_tim.tv_nsec == 0) |
2515 | clock_gettime(CLOCK_REALTIME, &np->n_tim); | ||
2516 | } else if (!quest && level == 0 && !timespec_le(&np->n_tim, &dtim)) | ||
2515 | printf("%s: '%s' is up to date\n", applet_name, np->n_name); | 2517 | printf("%s: '%s' is up to date\n", applet_name, np->n_name); |
2516 | 2518 | ||
2517 | free(allsrc); | 2519 | free(allsrc); |