summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Goncharov <dgoncharov@users.sf.net>2022-11-27 15:40:28 -0500
committerPaul Smith <psmith@gnu.org>2022-11-28 10:50:55 -0500
commit6164608900ad5cc882d4d4bf1b7341d45d743bdf (patch)
tree2cbea5c531d42a9e30817d92f335894c18d3d586
parenta99183ed2b8bfc474be16e42dad38d09b06cd69b (diff)
downloadmake-git-6164608900ad5cc882d4d4bf1b7341d45d743bdf.tar.gz
[SV 63417] Ensure global .NOTINTERMEDIATE disables all intermediates
Fix .NOTINTERMEDIATE without prerequisites to disable intermediate status for all targets. * src/makeint.h: Declare extern no_intermediates. * src/main.c: Add global definition of no_intermediates. * src/file.c: Remove static no_intermediates to use global variable. (remove_intermediates): Check no_intermediates. * src/implicit.c (pattern_search): For a file found by implicit search set file->notintermediate if no_intermediates is set. * src/remake.c (update_file_1): Don't set file->secondary for a pre-existing file if no_intermediates is set. The check for no_intermediates here is redundant, but won't hurt: keep it in case things change so that it matters. * tests/scripts/targets/NOTINTERMEDIATE: Fix a test.
-rw-r--r--src/file.c7
-rw-r--r--src/implicit.c6
-rw-r--r--src/main.c3
-rw-r--r--src/makeint.h2
-rw-r--r--src/remake.c3
-rw-r--r--tests/scripts/targets/NOTINTERMEDIATE3
6 files changed, 12 insertions, 12 deletions
diff --git a/src/file.c b/src/file.c
index 226af61f..f2ca3c0e 100644
--- a/src/file.c
+++ b/src/file.c
@@ -63,9 +63,6 @@ static struct hash_table files;
/* Whether or not .SECONDARY with no prerequisites was given. */
static int all_secondary = 0;
-/* Whether or not .NOTINTERMEDIATE with no prerequisites was given. */
-static int no_intermediates = 0;
-
/* Access the hash table of all file records.
lookup_file given a name, return the struct file * for that name,
or nil if there is none.
@@ -368,7 +365,7 @@ remove_intermediates (int sig)
int doneany = 0;
/* If there's no way we will ever remove anything anyway, punt early. */
- if (question_flag || touch_flag || all_secondary)
+ if (question_flag || touch_flag || all_secondary || no_intermediates)
return;
if (sig && just_print_flag)
@@ -731,7 +728,7 @@ snap_file (const void *item, void *arg)
/* If .NOTINTERMEDIATE is set with no deps, mark all targets as
notintermediate, unless the target is a prereq of .INTERMEDIATE. */
if (no_intermediates && !f->intermediate && !f->secondary)
- f->notintermediate = 1;
+ f->notintermediate = 1;
/* If .EXTRA_PREREQS is set, add them as ignored by automatic variables. */
if (f->variables)
diff --git a/src/implicit.c b/src/implicit.c
index a3bd318c..0d7197db 100644
--- a/src/implicit.c
+++ b/src/implicit.c
@@ -1008,7 +1008,7 @@ pattern_search (struct file *file, int archive,
f->also_make = imf->also_make;
f->is_target = 1;
f->is_explicit |= imf->is_explicit || pat->is_explicit;
- f->notintermediate |= imf->notintermediate;
+ f->notintermediate |= imf->notintermediate || no_intermediates;
f->intermediate |= !f->is_explicit && !f->notintermediate;
f->tried_implicit = 1;
@@ -1090,7 +1090,7 @@ pattern_search (struct file *file, int archive,
{
if (f->precious)
file->precious = 1;
- if (f->notintermediate)
+ if (f->notintermediate || no_intermediates)
file->notintermediate = 1;
}
}
@@ -1123,7 +1123,7 @@ pattern_search (struct file *file, int archive,
{
if (f->precious)
new->file->precious = 1;
- if (f->notintermediate)
+ if (f->notintermediate || no_intermediates)
new->file->notintermediate = 1;
}
diff --git a/src/main.c b/src/main.c
index d8a73725..181fdc9e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -298,6 +298,9 @@ struct variable shell_var;
char cmd_prefix = '\t';
+/* Whether or not .NOTINTERMEDIATE with no prerequisites was given. */
+unsigned int no_intermediates;
+
/* Count the number of commands we've invoked, that might change something in
the filesystem. Start with 1 so calloc'd memory never matches. */
diff --git a/src/makeint.h b/src/makeint.h
index d6ac21b8..fa56d3d2 100644
--- a/src/makeint.h
+++ b/src/makeint.h
@@ -759,6 +759,8 @@ extern int batch_mode_shell;
#define RECIPEPREFIX_DEFAULT '\t'
extern char cmd_prefix;
+extern unsigned int no_intermediates;
+
#define JOBSERVER_AUTH_OPT "jobserver-auth"
extern char *jobserver_auth;
diff --git a/src/remake.c b/src/remake.c
index 4ce3d2a3..7ba606cb 100644
--- a/src/remake.c
+++ b/src/remake.c
@@ -871,7 +871,8 @@ update_file_1 (struct file *file, unsigned int depth)
/* Since make has not created this file, make should not remove it,
even if the file is intermediate. */
- file->secondary = 1;
+ if (!file->notintermediate && no_intermediates == 0)
+ file->secondary = 1;
notice_finished_file (file);
diff --git a/tests/scripts/targets/NOTINTERMEDIATE b/tests/scripts/targets/NOTINTERMEDIATE
index e4690b12..a24c4f7d 100644
--- a/tests/scripts/targets/NOTINTERMEDIATE
+++ b/tests/scripts/targets/NOTINTERMEDIATE
@@ -36,7 +36,6 @@ hello.z:
# Test 4. .NOTINTERMEDIATE without prerequisites makes everything
# notintermediate.
-unlink('hello.z');
run_make_test(q!
hello.z:
%.z: %.x; touch $@
@@ -112,8 +111,6 @@ hello.z:
.SECONDARY:
!, '', "touch hello.z\n");
-
-
unlink('hello.z');
# This tells the test driver that the perl test script executed properly.
1;