On Fri, Oct 24, 2008 at 5:10 PM, Peng Yu <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 24, 2008 at 4:58 PM, Philip Guenther <[EMAIL PROTECTED]> 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


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to