From: Robert L. <rl...@gd...> - 2002-04-29 13:18:26
|
Hi. Below is a copy of a simple makefile which takes advantage of an implicit rule. file1.cpp is dependent on file2.h which lies in the "C:/anotherdir" directory. Makefile ------------------------------------------- OBJS = file1.o file2.o INCDIR = C:/anotherdir/ program: $(OBJS) g++ $(OBJS) -o program file1.o: file2.o: g++ -c file2.cpp -I$(INCDIR) --------------------------------------------- When I compile my program the first time everything works fine. If I make a change to file1.cpp save and retype make, the compiler knows that file1.cpp is out of date so it recompiles it, then relinks the program with the unchanged file2.o. GREAT! If I make a change to file2.cpp and retype make, file2.cpp does NOT get recompiled and the only thing that happens is a new version of program gets linked, with the old file2.o. :( What am I doing wrong ? Can I take advantage of an implicit rule, even if I have a header file in another directory. Does the VPATH variable, or vpath directive exist in the mingw32 make executable. I've tried this but it doesn't seem to work. Does anyone have a working makefile that creates programs that include headers from other directories, AND does not force you to clobber your object files every time you want to recompile? Thanks is advance. Bobby |