问题
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?
回答1:
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 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.
回答2:
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:
- benefit from not re-generating those files (for an identical result)
- start immediately to configure and compile.
回答3:
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.
来源:https://stackoverflow.com/questions/3290908/which-files-generated-by-autotools-should-i-keep-in-version-control-repository