Search code examples
recursionbuildmakefiletemporary-files

Hiding the removal of intermediate files using Make


I use intermediate files in my Makefile, however make prints out the rm command that it uses to delete them all afterwards. How do I hide this print statement?


Solution

  • The make manual says that targets marked .SECONDARY will behave as .INTERMEDIATE but won't be automatically deleted. You could mark all the intermediate targets as secondary, and then remove the files yourself, something like

    OBJECTS=foo.o bar.o
    all:foo bar
        @rm -f $(OBJECTS)
    .SECONDARY: $(OBJECTS)
    

    should do.