34

I installed ffmpeg from sources with help this page. https://trac.ffmpeg.org/wiki/CentosCompilationGuide

I noticed that most of this tutorial calls make distclean after make install. But only libvpx calls make clean after installing.

According this document, http://www.gnu.org/software/automake/manual/automake.html#Clean 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.

1
  • 2
    Make clean is called after installation to clean up. There is no need to keep compiled versions around in the directory where you compiled if you still have both the source (and thus can recreate those) and the installed program.
    – Hennes
    Aug 28, 2013 at 19:02

3 Answers 3

34

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.

1
  • Main reason people use binary packages? What about to save time?
    – x-yuri
    Apr 30, 2019 at 21:28
8

To 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 git repo, 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 clean reduces this to 53 636 kB
  • and finally after make distclean we are nearly at the level right after the cloning: 53 188 kB
4

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.

1
  • Worth noting that the guide now uses make distclean for libvpx. Mar 20, 2019 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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