]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 63417] Ensure global .NOTINTERMEDIATE disables all intermediates
authorDmitry Goncharov <dgoncharov@users.sf.net>
Sun, 27 Nov 2022 20:40:28 +0000 (15:40 -0500)
committerPaul Smith <psmith@gnu.org>
Mon, 28 Nov 2022 15:50:55 +0000 (10:50 -0500)
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.

src/file.c
src/implicit.c
src/main.c
src/makeint.h
src/remake.c
tests/scripts/targets/NOTINTERMEDIATE

index 226af61f448b7c1a446cce122a4fa3be2fa42871..f2ca3c0ecc50184f822808e2b30355a2372faf50 100644 (file)
@@ -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)
index a3bd318c075f409cf682ad049029810fa82db755..0d7197dbf6b94b4cf50b2c994aa065cec1c14173 100644 (file)
@@ -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;
             }
 
index d8a73725474f3bb53b13e3be9d7e8ceafddc7e64..181fdc9ecdabade0fab57e3c33438a79a1faf70b 100644 (file)
@@ -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.  */
 
index d6ac21b8ff5b82cca72ae684f7045fb73df7530c..fa56d3d2682ad82ee42f55ee24b3e2d77628474e 100644 (file)
@@ -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;
index 4ce3d2a379d7b261e82a8a973d5f4dfb8dd542b8..7ba606cb65ae277ca8636d3825a001280d4d891d 100644 (file)
@@ -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);
 
index e4690b128035021db3b5e30ec57d717b762fad95..a24c4f7d976a6dd93530e065db19647292dae093 100644 (file)
@@ -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;