[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Make Question about string replace in dependency list
From: |
Paul D. Smith |
Subject: |
Re: GNU Make Question about string replace in dependency list |
Date: |
Tue, 12 Nov 2002 10:14:34 -0500 |
%% "DeMarco, Paul" <address@hidden> writes:
dp> I absolutly could not get separate directory compilation working:
dp> be in the object dir with source in another dir
You cannot have sources and objects in separate directories with suffix
rules.
If you want to do this you need to use pattern rules.
%.o: $(SRC)/%.cpp $(INCL)/%.h
...
dp> So I fell back to old faithful:
dp> node.o: $(SRC)/node.cpp $(INCL)/node.h
dp> $(CC) $(CPPFLAGS) $(SRC)/node.cpp
You should not use a C compiler to build C++ files.
Use $(CXX) and $(CXXFLAGS). $(CC) is a C compiler, and $(CPPFLAGS) are
flags to the C preprocessor (-I, -D, etc.)
dp> node.o: $(SRC)/$(@:.o=.cpp) $(INCL)/$(@:.cpp=.h)
dp> $(CC) $(CPPFLAGS) $(SRC)/$(@:.o=.cpp)
This is not correct. Automatic variables like $@, etc. are defined only
within the context of the command script; they have no value in the
prerequisite list.
Since $@ has no value, your rule above is equivalent to:
node.o: $(SRC)/ $(INCL)/
...
which makes your .o depend on the directories--and explains the strange
rebuild behavior you're seeing.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist