tags:

views:

65

answers:

3

Hi everyone.

I am new to autotools and I am working on a C project. I want to add my project to a git repository but I am not sure, which files generated by the autotools I need to track and which should be ignored.

Please provide some hints with regard to this. Thanks

A: 

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.

Scharron
You absolutely cannot put Makefile's in the repository. There is some debate about whether or not to include Makefile.in's in the repo (they should not be, as 'ready-to-build' versions need only exist as tarballs) but it is absolutely wrong to put Makefiles in the repo. The whole point of the configure script is to construct Makefile's (et al) specific to a particular machine, and the Makefile's are liable to be different depending on the platform. Nothing generated by configure can be in the repo
William Pursell
A: 

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.

alt text

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.
VonC
I think you're confused as to what a source code distribution is -- every project has one, but it's not the same as what is kept in version control. Source code distributions should include the files that _users_ need to build the project; version control should contain the files that _developers_ need to build the project.
ptomato
@ptomato: again, I agree. The thing is, I keep recompiling source code distribution project these days (but I do not develop them). Hence my "skewed" vision of what could be in a VCS.
VonC
+6  A: 

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.

ptomato
I agree. +1 (and put my answer as Community Wiki)
VonC
If you add any custom macros in the m4 directory those must ofcourse be added as well.
ext
Thanks for the answer and the tips :)Although I wanted my project to be in a directly installable format, but I believe making a script like autogen.sh is a better option.
Abhinav Upadhyay