Search code examples
makefilermbuilding

make - remove intermediate files silently


When building a chain rule make automatically invokes rm to remove any intermediate files at the end of the build process. Since I have about 400 intermediate files to delete that way, that floods console output badly.

Is there a way to silently rm those intermediate files, so that eighter nothing will be echoed after the build is finished oder a message like "Removing intermediate files" is echoed?


Solution

  • You could run make -s or build your very own version of make with this patch applied:

    diff --git file.c file.c
    index ae1c285..de3c426 100644
    --- file.c
    +++ file.c
    @@ -410,18 +410,6 @@ remove_intermediates (int sig)
                       {
                         if (! doneany)
                           DB (DB_BASIC, (_("Removing intermediate files...\n")));
    -                    if (!silent_flag)
    -                      {
    -                        if (! doneany)
    -                          {
    -                            fputs ("rm ", stdout);
    -                            doneany = 1;
    -                          }
    -                        else
    -                          putchar (' ');
    -                        fputs (f->name, stdout);
    -                        fflush (stdout);
    -                      }
                       }
                     if (status < 0)
                       perror_with_name ("unlink: ", f->name);