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?
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
AUTHORS
, NEWS
etc.Makefile.am
in subdirectoriesTo 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 Makefile
s 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.
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With