I installed ffmpeg from sources with help this page.
I noticed that most of this tutorial calls make distclean after make install.
But only libvpx calls make clean after installing.
According this document,make clean deletes all files that make created, and make distclean deltes all files that ./configure created.
make clean
Erase from the build tree the files built by make all.
make distclean
Additionally erase anything ./configure created.
I understand that make distclean is called for for next installation,
but I could not understand why make clean is called after installation.
The installed ffmpeg works without problem. So I asked this question because I only want to improve my knowledge about linux. It would be very helpful that someone give me a explanation for it.
13 Answers
The parameter used after make is just dependent on the developer(s) who wrote the Makefile. The documentation you later reference, Autotools, is just one of many ways to create a Makefile.
The typical standard is make clean will remove all intermediate files, and make distclean makes the tree just the way it was when it was un-tarred (or something pretty close) including removing any configure script output. This is the way the Linux kernel works for instance.
In other words, it's totally dependent on the developers for each of those libraries, and this is why sometimes its clean and other times it's distclean. By the way, you don't need to run clean/distclean - I guess they have you run it just to save disk space. make install usually copies the files to the destination directory (again dependent on the developers) - typically places like /usr/lib or /usr/bin (also determined by the configure script, if it's an Autotools build system)
These nuances are the main reason people use package management systems like RPM or Debian packages.
1To my understanding, it's simply to save disk space. After compiling some programs you will have a lot of files, e.g. object files which are not needed anymore, because they are linked together in the binaries. All can be recreated by spending again some CPU time.
Take this example with the current ffmpeg code:
- after cloning the
gitrepo, the source takes 53 160 kB - after the configure run it's 53 632 kB
- after compilation, we have more than 10 times the initial value: 673 668 kB
make cleanreduces this to 53 636 kB- and finally after
make distcleanwe are nearly at the level right after the cloning: 53 188 kB
Why the libvpx step uses make clean instead of make distclean
At the time of writing the guide libvpx had no rule in its Makefile for the target distclean, so clean was used instead.
Why make (dist)clean is included after make install
make distclean/make clean is included after each make install simply as a precautionary measure to provide a "clean slate" for users who go back, change configure options, and re-compile (which occurred more often than expected).
In a previous version of the compile guide, without the preventative make distclean, one of these users would on occasion encounter unexpected results.
What if make distclean/make clean gives an error?
Like this:
Makefile:198: Makefile: No such file or directory
make: *** No rule to make target '/tests/Makefile'. Stop.or this:
make: *** No rule to make target 'distclean'. Stop.Ignore it. It just means you likely ran make distclean twice which is harmless.