help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to automatically update a automatically generated dependence file?


From: Peng Yu
Subject: How to automatically update a automatically generated dependence file?
Date: Thu, 23 Oct 2008 18:49:17 -0500

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]