help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Q: How to delete all out of date targets


From: thutt
Subject: Q: How to delete all out of date targets
Date: Tue, 9 Mar 2021 08:45:50 -0800

Cook, Malcolm writes:
 > Hi,
 >
 > Is it possible using Gnu Make to delete all out of date targets?
 >
 > I had previously posted this as a Feature Request (as below), but
 > realize I may be ignorant of a known method for doing what I
 > desire, and positing it as a question might get a reply from
 > someone in the know.
 >

 With standard Make, no.  But, you could probably work out a mechanism
 via Gnu Make functions that collect targets and their prerequisites
 (including order-only prerequisites).  Once the entire Makefile has
 been parsed, you could use $(foreach) to iterate over the collection
 of targets / prerequisites, using $(eval) to generate internal rules
 to remove the file.   At that point, be able to generate a top-level
 target to remove all the targets & prerequisites that is dependent on
 the just-generated targets.

 However(!), it's not so easy to do in practice because there are a
 number of hurdles:

   1. Many normal prerequisites are not created by the build process.

      Consider in regular software development:

          The prerequisite of an object file is going to be the source
          file.

       Thus, there is a definite risk that naively deleting
       prerequisites will remove original source files.

   2. Order-only prerequisites are frequently directories.

      Care must be taken not to blindly delete directories created in
      the build tree, or you may end up doing more work that you
      desire.

   3. Collecting prerequisites isn't straightforward.

      Prerequisites are only fully determined (AFAIK) during
      build-time evaluation of the recipe.

      So, you cannot update target recipes to collect target &
      prerequisite info; you've got to devise a mechanism to collect
      this information.


--
What special thing does        unsigned char fn(void)
this function do?              {
                                   static unsigned char i = 27;
                                   i += !++i;
Is there something wrong with      return i;
the code?                      }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]