[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: autodependencies
From: |
Luke Shumaker |
Subject: |
Re: autodependencies |
Date: |
Wed, 09 Mar 2011 20:35:58 -0500 |
I've always used the example from the GNU Make manual:
%.d: %.c
@set -e; rm -f $@; \
$(CC) -M $(CPPFLAGS) $< > address@hidden; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < address@hidden > $@; \
rm -f address@hidden
sources = foo.c bar.c
include $(sources:.c=.d)
--
~ LukeShu
http://lukeshu.ath.cx
On Wed, 2011-03-09 at 16:12 -0800, Dan Kujovich wrote:
> I am trying to get my dependencies working for obvious reasons. But when I
> try what has been offered, it lacks the primary goal of recompiling objects
> when any of the dependencies (header files) change.
>
> I like the gcc -MD command as it provides the proper dependencies, but I am
> having trouble having my make file actually be able to use it. Here is an
> example of what I am grabbing from paulandlesley.org/autodep.html
>
>
> a.o : a.cpp
> @gcc -MD -c a.cpp; \
> cp $*.d $*.P; \
> sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
> -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
> rm -f $*.d
> gcc -c a.cpp -o a.o
>
>
> here the command works the first time fine. Then I change the
> header a.h and run make again and it says nothing needs to be done.
>
> Dan
>
>
>
>
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make