On Fri, Oct 24, 2008 at 4:58 PM, Philip Guenther <[EMAIL PROTECTED]> wrote: > On Fri, Oct 24, 2008 at 1:45 PM, Peng Yu <[EMAIL PROTECTED]> wrote: > ... >> I guess. I figure out how to use it. See below for the source code and >> the Makefile. After running make, I can change nothing3.hpp to >> nothing2.hpp. The make still runs after the modification. > ... >> The first one 's/#.*//' seems removes the comment, right? But would >> g++ -MM generate comments? > > If you have a new enough version of gcc, then instead of that complex > 'sed' statement, you could just pass g++ the -MP option. That alters > the -MM option so that it generates the desired stub targets. 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. Instead of defining your own rule for %.o:%.cpp, > just use the builtin one and update the COMPILE.cpp variable to > include the -MM and -MP options: > > COMPILE.cpp += -MM -MP > > That'll generate .d files, so change the include to > > -include $(SRC:.cpp=.d) > > That's it. > > > BTW, your makefile seems confused about whether you're doing C or C++, > as it does some stuff with $(CC) and $(COMPILE.c), and other stuff > with g++. If you're doing C++, then use $(CXX) and $(COMPILE.cpp). > That includes when linking, so that you can be sure the linker will be > told about the C++ library bits.
I'm doing C++. I couldn't reproduce what you told me. Would you please send me the Makefile that incorporates what you said? Thanks, Peng _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
