Which files generated by Autotools should I keep in version control repository?

GitVersion ControlAutotools

Git Problem Overview


I am new to autotools and I am working on a C project. I want to add my project to a git repository. Which files generated by the autotools I need to track in my version control system and which should be ignored?

Git Solutions


Solution 1 - Git

You should not keep any files under version control that are not hand-edited. That means any generated file should be ignored by the version control system. I basically put only the following under version control:

  • configure.ac
  • Makefile.am
  • the documentation files such as AUTHORS, NEWS etc.
  • Makefile.am in subdirectories

To address the point of having a "ready-to-install" version brought up by Scharron, some people include a script in the project's root directory, called bootstrap or autogen.sh, that you run once when you check a fresh copy out. You can see an example in one of my projects here. For a simpler project, your autogen.sh really only needs to consist of one line:

autoreconf --install || exit 1

although some people prefer to run ./configure automatically at the end of autogen.sh.

Why not track all the generated files in version control? Because their contents depend on the machine you are building on, the version of autotools you generated them with, and the phase of the moon. Any time any of these changes, the generated autotools files will change, and you will get a lot of junk in your commits.

Also, anyone who checks your code out of version control in order to build it should be expected to have proper development tools installed, so you really don't need to worry about people running into trouble because of missing autotools.

What VonC says about C projects coming with a configure file to generate the Makefiles is true for source code distributions (the .tar.gz file that you get when you type make dist) but not necessarily for freshly checked out copies from version control.

Solution 2 - Git

Note: I agree with ptomato'ss answer, and leave this answer as Community Wiki.
It makes sense for source code distributions, but your project may not be one.
For development purpose, ptomato's answer makes more sense.


All the C projects generally comes with a configure file able to generate the actual Makefile used for the compilation.

So when you consider the autotool chain, I would recommend versioning all files generated up to the configure file, as they are normally a one-time generation operation.

http://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Autoconf.svg/309px-Autoconf.svg.png

That means anyone with a checked out copy of your version project can immediately start:

./configure
make
make install

So, while it is generally true you shouldn't version any generated files, you could stored those ones especially if the other reader from that project can:

  • benefit from not re-generating those files (for an identical result)

  • start immediately to configure and compile.

Solution 3 - Git

Generally, you should not keep any generated files on a repository (else you would see changes and have to commit them / revert them). However, if you want to have "ready-to-install" version added (= tagged) to your repository, I would recommand to keep configure and Makefile files. They are the one needed for an install, that should work without autotools.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAbhinav UpadhyayView Question on Stackoverflow
Solution 1 - GitptomatoView Answer on Stackoverflow
Solution 2 - GitVonCView Answer on Stackoverflow
Solution 3 - GitScharronView Answer on Stackoverflow