It is written in the linux kernel Makefile that

clean - Remove most generated files but keep the config and
        enough build support to build external modules
mrproper - Remove all generated files + config + various backup files

And it is stated on the arch docs that

To finalise the preparation, ensure that the kernel tree is absolutely clean;

$ make clean && make mrproper

So if make mrproper does a more thorough remove, why is the make clean used?


Cleaning is done on three levels, as described in a comment in the Linux kernel Makefile:

# Cleaning is done on three levels.
# make clean     Delete most generated files
#                Leave enough to build external modules
# make mrproper  Delete the current configuration, and all generated files
# make distclean Remove editor backup files, patch leftover files and the like

According to the Makefile, the mrproper target depends on the clean target (see line 1421). Additionally, the distclean target depends on mrproper.

Executing make mrproper will therefore be enough as it would also remove the same things as what the clean target would do (and more).

The mrproper target was added in 1993 (Linux 0.97.7) and has always depended on the clean target. This means that it was never necessary to use both targets as in make clean && make mrproper.

Historic reference: https://archive.org/details/git-history-of-linux

| improve this answer | |
  • @derobert wow, great. So make clean is redundant, right? – sitilge Aug 22 '17 at 13:46
  • 2
    @sitilge yes, it's redundant, as make will run it anyway when you run make mrproper. – derobert Aug 22 '17 at 13:47

clean is a prerequisite for mrproper target in Makefile, so executing make clean separately is redundant.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.