[Top][All Lists]
[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 14:58:03 -0700 |
On Fri, Oct 24, 2008 at 1:45 PM, Peng Yu <address@hidden> 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.
Philip Guenther
- How to automatically update a automatically generated dependence file?, Peng Yu, 2008/10/23
- Re: How to automatically update a automatically generated dependence file?, Greg Chicares, 2008/10/23
- Re: How to automatically update a automatically generated dependence file?, Peng Yu, 2008/10/24
- Re: How to automatically update a automatically generated dependence file?,
Philip Guenther <=
- Re: How to automatically update a automatically generated dependence file?, Peng Yu, 2008/10/25
- Re: How to automatically update a automatically generated dependence file?, Philip Guenther, 2008/10/25
- Re: How to automatically update a automatically generated dependence file?, Peng Yu, 2008/10/25
- Re: How to automatically update a automatically generated dependence file?, Philip Guenther, 2008/10/25