help-make
[Top][All Lists]
Advanced

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

Re: How to automatically update a automatically generated dependence fil


From: Philip Guenther
Subject: Re: How to automatically update a automatically generated dependence file?
Date: Fri, 24 Oct 2008 22:34:49 -0700

On Fri, Oct 24, 2008 at 5:10 PM, Peng Yu <address@hidden> wrote:
> On Fri, Oct 24, 2008 at 4:58 PM, Philip Guenther <address@hidden> wrote:
...
>> Indeed, you don't even need the separate MAKEDEPEND line: you can mix
>>  -MM and -c and gcc/g++ will generate the dependency output *and*
>> compile the file in one pass.

Argh, there's egg on my face: the above is false.  -MM can't be
combined (usefully) with -c; it's the -MMD option which can.


> I'm doing C++. I couldn't reproduce what you told me. Would you please
> send me the Makefile that incorporates what you said?

Here's a correct, *tested* makefile:
--------
.PHONY: all clean

SRC = main.cpp
COMPILE.cpp += -MMD -MP

all: main.exe

main.exe : main.o
        $(LINK.cpp) $< $(LOADLIBES) $(LDLIBS) -o $@

-include $(SRC:.cpp=.d)

clean:
        @$(RM) *.o *.exe *.d
--------

Note the use of LINK.cpp to guarantee linking happens with the correct
compilation driver and options.


Philip Guenther




reply via email to

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