%% Philip Guenther <[EMAIL PROTECTED]> writes: pg> %.o: $(SRC)/%.cpp $(INCL)/%.h pg> $(CC) $(CPPFLAGS) -o $@ $(SRC)/$(@:.o=.cpp)
You should simply use "$<" here, instead of "$(SRC)/$(@:.o=.cpp)". If you really don't like that, I'd at least use "$(SRC)/$*.cpp". Basing it on $@ is much less flexible: what happens when you change the target pattern to "$(OBJ)/%.o"? Now you have to use $(@F) or something. pg> If different sets of files need different 'mappings' from source pg> path to object, then a static pattern rule will do the trick: pg> CPP_OBJ = node.o foo.o pg> $(CPP_OBJ): %.o: $(SRC)/%.cpp $(INCL)/%.h pg> $(CC) $(CPPFLAGS) -o $@ $(SRC)/$(@:.o=.cpp) pg> C_OBJ = low_level.o pg> $(C_OBJ): %.o: $(SRC)/%.c $(INCL)/%.h pg> $(CC) $(CPPFLAGS) -o $@ $(SRC)/$(@:.o=.c) Static pattern rules are often useful, but they aren't actually necessary in the example you provide here (again, just to be pedantic). If make can't match one pattern rule it'll simply keep looking for another one. So, you can make both of the above normal pattern rules instead of static pattern rules, and it will Just Work: when make wants to build node.o it will find a $(SRC)/node.cpp and use that rule; when it wants to build low_level.o it won't find a $(SRC)/low_level.cpp so it rejects the first pattern rule, then it finds a $(SRC)/low_level.c and so chooses that one instead. -- ------------------------------------------------------------------------------- Paul D. Smith <[EMAIL PROTECTED]> 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 _______________________________________________ Help-make mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/help-make