Why both `make clean` and `make mrproper` are used?
It is written in the linux kernel
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
make mrproper does a more thorough remove, why is the
make clean used?
clean is a prerequisite for
mrproper target in Makefile, so executing
make clean separately is redundant.
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
make mrproper will therefore be enough as it would also remove the same things as what the
clean target would do (and more).
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
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).