views:

42

answers:

2

I (mostly) use git to download and compile various projects from their source code, keeping my source in /usr/local/src and installing the binaries in /usr/local/bin.

Following the building procedure, usually with ./configure && make && make install, I'm left with a lot of cruft that ends up as 'new' files in my local git repository.

To my understanding, make clean, make distclean and possibly also (?) ./configure clean are thinkable procedures in order to trash most leftover files. But in specific scenarios (see example below) I'm left clueless what thing to do in order to "stay clean", such as I was prior to the installation...

A recent example – installing jscoverage (via git svn) from http://svn.siliconforks.com/jscoverage/trunk jscoverage:

The building instructions for this project prompted me to use ./bootstrap.sh && make && make install. In this case, after compiling and installing was finished, I tried all of the aforementioned cleanup commands (by random), but didn't manage to get rid of everything.

To wrap my question up: Is there any all-mighty, superior cleaning strategy that I haven't grasped? How do you approach this cleanup issue when using a VCS such as git, in a typical workflow where you 1.) download – 2.) build – 3.) pull updates from upstream repository – 4.) build once again – and so forth?

+3  A: 

For an autotooled project (i.e., most of the ones that use ./configure && make && make install), make distclean will get you to the state of a pristine distribution tarball. They won't remove everything autogenerated because that would introduce dependencies on additional tools for the end user.

Many packages will provide a make maintainer-clean that removes as much as possible, but will still keep around enough to build the project (if you have the correct developer tools). This still won't remove files like Makefile.in, which is needed to make Makefile. The idea here is that ./configure && make should still be enough to build everything (provided all of the dependencies are installed).

That said, I think you're potentially asking the wrong question here. If I'm not going to keep the source around for anything, I'd just delete the source directory after installing. If I'm planning on pulling updates and rebuilding, I'd not even bother with a make clean: the whole point of tools like make is that they rebuild only the changed parts of a project and obsessive cleaning defeats that.

When I develop my own projects, I mark any autogenerated file as ignored by the VCS, so it doesn't show up all the time. SVN has the svn:ignore property, mercurial has the .hgignore file and git has the .gitignore file, for example.

Jack Kelly
+1 Thorough examination of the options available
Matt Joiner
Jack: Thanks for a very informative and thorough explanation. I feel a bit more enlightened – especially after reading your notion of not having to clean stuff if you intend to simply just keep a repository for updates and re-building projects.
hced
I would have given you an "accepted answer" vote if I was able to give more than one of those, but since that's impossible, @dgnorton gets it, since his answer lead to the exact result that I was (initially) looking for; i.e. an untouched, clean-slate git clone. (Again, I'm still pondering your suggestion that it's not necessary to clean up for the purpose of only keeping a repo for the aforementioned purposes (of just updating and re-building projects).
hced
+4  A: 

There is also git clean ("Remove untracked files from the working tree"). It's a simple command with relatively few command line options. See the git-clean man page.

dgnorton