23

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?

3 Answers 3

33

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

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

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

1

In that particular instruction (make clean && make mrproper) yes, it's pointless (it's like saying remove all squares, then remove all squares and all triangles)...but make clean is normally much more useful than make mrproper (because the last thing you want, with the vast majority of kernel builds, is to trash your .config)... so perhaps someone wrote the instruction that way purely as a helpful reminder of the difference (i.e. to remind you that the second part was going to trash your .config, so back it up now, if you're used to running make clean and then being able to build as usual).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .