Hi,

I have the following files in a directory.
main.cpp  Makefile  print.hpp

The content of each file is listed below this message.

After I run make, I will get main.cpp compiled and the file '.dep'
will be generated. The content of .dep will be

main.o: main.cpp print.hpp

Now, I change .dep manually (say with vim) to the following.

main.o: main.cpp print.hpp additional.hpp

Then I run make again. I will get the following error message.
make: *** No rule to make target `additional.hpp', needed by `main.o'.  Stop.

I'm wondering how to automatically update .dep if make gets such error.

Thanks,
Peng

#############Begin Makefile
.PHONY: all

all: main.exe

main.exe : main.o
        $(CC) $< $(LOADLIBES) $(LDLIBS) -o $@

-include .dep

.dep:
        @$(CXX) -MM main.cpp > $@
#############End Makefile


///////////////////////////Begin main.cpp
#include "print.hpp"

int main() {
  print();
}
//////////////////////////End main.cpp

/////////////////////////Begin print.hpp
#include <iostream>

void print() {
  std::cout << "Hello World" << std::endl;
}
//////////////////////////End print.hpp


_______________________________________________
Help-make mailing list
Help-make@gnu.org
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to