Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 250
Abhinav Upadhyay Avatar asked Jul 20 '10 14:07

Abhinav Upadhyay


2 Answers

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.

like image 196
ptomato Avatar answered Oct 22 '22 13:10

ptomato


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.
like image 30
5 revs, 2 users 93% Avatar answered Oct 22 '22 13:10

5 revs, 2 users 93%