Autotools: how to cleanup files created by “./conf

2019-04-18 03:39发布

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 with autotools in details.

Any hints?

2条回答
相关推荐>>
2楼-- · 2019-04-18 04:08

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.

查看更多
可以哭但决不认输i
3楼-- · 2019-04-18 04:10

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!

查看更多
登录 后发表回答