Autotools: how to cleanup files created by "./configure" in lighttpd project?
Solution 1
I personally would really use the features of a source control software (you should use one) for this. This would cleanup make independent of your build process. See e.g. svn-cleanup
or git clean
.
Nevertheless, automake allows some tweaking when to remove which files. This has (intentionally?) built-in limitations on what files generated by autotools can be remove this way though. Have a look at the definitions for MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, and MAINTAINERCLEANFILES and adjust your Makefile.am
's. With them you can remove a lot of stuff with
make mostlyclean
make clean
make distclean
make maintainer-clean
You won't be able to remove e.g. Makefile
or .deps/
this way.
As for the reliability of make clean
it should "work 100%" if you stick to cleanly specifying your files and stay away from manual intervention. Otherwise extend the cleanup rules.
Solution 2
In addition to Benjamin Bannier's answer, the generated files names may be listed in .gitignore
file so that they are ignored, not tracked with git and don't irritate and bother when run git status
. You can't remove these files with git clean
. In this case I personally use rm -rf * ; git checkout .
command.
But don't use that if you have other ignored files which you don't want to be removed!
Comments
-
Andi almost 2 years
I'm trying out
lighttpd
for an embedded Linux project. I got the latest source package and started writing a master Makefile encapsulating all configure, compile, install (for testing) etc stuff.And vice-versa, I want to cleanup every step. After the cleanup there should be no generated files anymore. This is important for repetitive testing.
I wonder if there is a way to do a complete cleanup of what
./configure
generated? I'm not familiar withautotools
in details.Any hints?
-
Andi almost 14 yearsThanks Honk, I will have a look to the suggested parts of the documentation. If make clean works 99% and a few well-known files can be removed manually, this will be ok. Another question arises: is it possible to redirect all generated output to a specified build-directory (like CMake)? This would be helpful for cleanup, and for building for different platforms I guess?
-
Andi almost 14 yearsOk, it looks like that a command like "make mostlyclean clean distclean maintainer-clean" will do the job! One funny effect is that in the lighttpd package 2 source files are modified by the build processs: src/configparser.c and src/mod_ssi_exprparser.c. But only the relatve include pathes. Maybe this files are re-generated by the build process. Thank you, Honk!
-
Benjamin Bannier almost 14 years@Andi: using a build directory is very similar to cmake:
mkdir build && cd build && $CONF_PATH/.configure && make
-
Andi almost 14 years@Honk: will try this. In the meantime I had a similar idea: create builddir, copy the whole source tree into it and do everything as usual. This doesn't change the modified source files in the original tree. And parallel builds for different platforms doesn't affect each other.
-
Benjamin Bannier almost 14 years@Andi: Maybe I don't understand your point. In that example I gave
build/
doesn't have to be in the source directory. Also, files in the source directory won't be modified by this. WhateverMakefile
is created from you./configure
call has all the information on platform, compiler, ... and will be saved inbuild/
. -
Andi almost 14 years@Honk: you are right, using build/ works file! I wasn't sure about the changed source files mentioned above, but this files are created inside the build/ directory. Great! with this solution I can realize the clean all by removing the build/ directory.
-
Jules Lamur over 7 yearsYou can use
git clean
to remove ignored files:git clean -X
. -
Josh Peak over 5 years
git clean -dnx
to dry-run preview what untracked files would be removed. Thengit clean -dfX
to force the removal