Cyberithub

How to Remove All Files Created by Make Command

Advertisements

In this article, we will see how to remove all files created by make command. If you have been using make utility to compile all your source files based on Makefile rules then sometimes you might have noticed that you end up using incorrect argument that results in failure of compilation. In that case, you might want to clean up all the files created by make command so that you can recompile the files with correct arguments. Here we will see how you can do that by using a simple example. So that you can apply the same in your case as well.

 

How to Remove All Files Created by Make Command

How to Remove All Files Created by Make Command

Also Read: How to Install GNOME EncFS Manager on Ubuntu 20.04 LTS (Focal Fossa)

To demonstrate the removal of all files created by make command, here we are going to use catdoc source files. In the below example, we already ran make command to compile all the files and now we would like to cleanup all the files created by make utility. This can be done by running make clean command as shown below.

cyberithub@ubuntu:~/catdoc-0.95$ make clean
for i in src doc charsets; do\
    (cd $i; make clean);\
done
make[1]: Entering directory '/home/cyberithub/catdoc-0.95/src'
rm -f *.o catdoc wordview xls2csv catppt
make[1]: Leaving directory '/home/cyberithub/catdoc-0.95/src'
make[1]: Entering directory '/home/cyberithub/catdoc-0.95/doc'
rm -f catppt.txt catppt.ps \
            catdoc.txt catdoc.ps \
            xls2csv.txt xls2csv.ps \
            wordview.txt wordview.ps build
make[1]: Leaving directory '/home/cyberithub/catdoc-0.95/doc'
make[1]: Entering directory '/home/cyberithub/catdoc-0.95/charsets'
make[1]: Nothing to be done for 'clean'.
make[1]: Leaving directory '/home/cyberithub/catdoc-0.95/charsets'

Once you clean up all the files, you can now use make command with correct arguments to recompile all the files. Sometimes, it is also possible that even before compilation stage, you would like to remove all the files created by running ./configure script. In that case, you need to use make distclean command to cleanup all the files as shown below.

cyberithub@ubuntu:~/catdoc-0.95$ make distclean
for i in src doc charsets; do\
    (cd $i; make distclean);\
done
make[1]: Entering directory '/home/cyberithub/catdoc-0.95/src'
rm -f *.o catdoc wordview xls2csv catppt
rm Makefile
make[1]: Leaving directory '/home/cyberithub/catdoc-0.95/src'
make[1]: Entering directory '/home/cyberithub/catdoc-0.95/doc'
rm -f catppt.txt catppt.ps \
            catdoc.txt catdoc.ps \
            xls2csv.txt xls2csv.ps \
            wordview.txt wordview.ps build
rm -f Makefile catdoc.1 xls2csv.1 catppt.1 wordview.1
make[1]: Leaving directory '/home/cyberithub/catdoc-0.95/doc'
make[1]: Entering directory '/home/cyberithub/catdoc-0.95/charsets'
rm Makefile
make[1]: Leaving directory '/home/cyberithub/catdoc-0.95/charsets'
rm -f Makefile config.*

Leave a Comment