Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autotools: how to cleanup files created by "./configure" in lighttpd project?

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?

like image 527
Andi Avatar asked May 29 '10 18:05

Andi


People also ask

How do you clean automake?

If make built it, and it is commonly something that one would want to rebuild (for instance, a .o file), then mostlyclean should delete it. Otherwise, if make built it, then clean should delete it. If configure built it, then distclean should delete it.

What is configure AC?

configure.ac (sometimes also named: configure.in) is an input file for autoconf. It contains tests that check for conditions that are likely to differ on different platforms. The tests are made by actually invoke autoconf macros.

What is Distclean make?

make distclean is the first step up from the basic make clean on many GNU Make systems. It seems to be pseudonymous or at least very similar to with make realclean and make clobber in many, but not all cases. It will delete everything that make clean does and remove the configuration.

How do I create an Autotools project?

The "sh" command is required to invoke the configure script. There a number of ways to create an Autotools project. The first method is through the CDT C and C++ Project wizards which can be activated from the File -> New -> C Project and File -> New -> C++ Project menu items, respectively, which are available while in the C/C++ Perspective.

What is the CDT/Autotools plug-in for Eclipse?

For details on the new CDT Autotools, see the CDT/Autotools/User_Guide The Autotools plug-in for Eclipse extends the CDT (C/C++ Development Tools) to add support for maintaining and building C/C++ projects that use GNU Autotools. The GNU Autotools are a set of tools used to make a project portable to multiple systems or build environments.

Is there a way to remove files generated by Autotools?

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.

How do I configure an Autotools project in CLion?

If GNU Autoconf is installed on your system ( autoreconf should be in the system PATH ), CLion will call it first. Pre-configuration is performed on every project reload. By default, CLion uses the following commands to configure an Autotools project: which autoreconf && autoreconf --install --force --verbose; /bin/sh configure


2 Answers

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.

like image 119
Benjamin Bannier Avatar answered Oct 23 '22 04:10

Benjamin Bannier


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!

like image 25
konstunn Avatar answered Oct 23 '22 02:10

konstunn