"make clean" doesn't clean up dependencies on Automake?

I have a C ++ project that uses Autoconf and Automake. I decided that there were too many source files in my src directory, and moved some files to a subdirectory. Then I changed Makefile.am and changed these files from source.cpp to subdir/source.cpp . I knew this approach should work, as I did it before for some new files (but then I didn’t rename anything). Now I have done the following, as usual:

 autoreconf ./configure make clean make 

I got an error message:

 No rule to make target "source.cpp" needed for "source.o" 

I did not understand what went wrong. I checked my Makefile, but it seemed to be correct. So I cloned the git repository to a new location and tried to do there, and it worked. No problem, I thought, and did git clean -xf in my source directory. After that, compilation still didn't work. Now I made diff for the two directory structures (after another git clean -xf and found that the .deps directory .deps . After deleting this file, it compiled.

The moral of this story is this:

  • make clean does not remove dependencies.
  • git clean -xf does not remove dependencies (probably due to a hidden directory).

Is there a way to make clean (or maybe git clean ) automatically delete this directory? Of course, I can do it manually, but it’s very annoying that there are dependency files after cleaning.

+4
source share
3 answers

make clean just makes any clean target in your makefile. If you want to remove the .deps directory, add

 clean:: rm -rf .deps 

in the makefile.

If you want git clean do this for you, just add the -d flag: git clean -fxd will also clear unsigned subdirectories.

0
source

Is it possible to make make clean (or maybe git clean) automatically delete this directory?

Use make distclean instead of make clean , which will remove .deps .

+11
source

If you want to run git clean -xf , you must run git clean -xfd .

From git help clean :

-d Remove untracted directories in addition to untracted files.

0
source

All Articles