The traditional makefile target
for cleaning up various files, particularly object file
s from the build. Normally you want to keep them around; the whole point
is that it only rebuild
s the object files that need
to be rebuilt. But sometimes you want to get rid of all the by-products, so you add a clean target
to your makefile. A simple clean
target could look something like this:
/bin/rm -f $(OBJS)
# The previous line MUST start with a TAB!
Here it's assumed
holds the names of all the object files in the project
Two common uses for make clean:
- A build is just "
make clean; make all".
- Since make only looks at modification times of files, if you want to change the compilation flags you have to force all targets to be rebuilt; "
make clean; make CFLAGS=-g" is a good way to do this.