I've always used the example from the GNU Make manual:
%.d: %.c
@set -e; rm -f $@; \
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
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
> [email protected]
> http://lists.gnu.org/mailman/listinfo/help-make
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make