[lug] OT: Makefile oddity

Tom Tromey tromey at redhat.com
Wed Apr 24 17:54:31 MDT 2002


>>>>> ">" == D Stimits <stimits at idcomm.com> writes:

>> 	g++ ${CXXFLAGS} \
>> 		${INC} \
>> 		-MM -MG ${SRC_UTILS} >> Makefile.dep

>> What this above does is 100% correct, with one exception.

Hmm.

>> It assumes my dependency is for the current directory, e.g., if I
>> have Abc.cxx, the output is Abc.o (this particular build directory
>> has no linking, it is all intermediate object code output), but the
>> actual build lines are using a relative directory, e.g., "../obj/".

Unfortunately you are forced to use sed (or other post-processing),
since you're running g++ once for your whole tree.

If you build dependencies as a side effect of compilation you can use
-MT to solve this particular problem.  This overall approach has the
benefit of being more efficient, parallelizable, and also always
up-to-date.

Tom



More information about the LUG mailing list