help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Including dependency files automagically + some basic pilot error


From: Angus Leeming
Subject: Re: Including dependency files automagically + some basic pilot error
Date: Mon, 25 Jul 2005 20:59:19 +0100
User-agent: KMail/1.7.1

On Monday 25 July 2005 20:31, Ted Stern wrote:
> Try pattern rules instead, they're more flexible.  For example,
>
>     $(objdir)/%.o: $(srcdir)/%.cpp
>          command to build .o file
>
>     $(DEPSDIR)/%.moc: $(srcdir)/%.h
>          moc -o $@ $<

Perfect! Thanks.

On Monday 25 July 2005 20:38, Paul D. Smith wrote:
>   al> 2. I have, in the past seen some magic to include all the
> .deps al>    files in a simple rule, rather than
>
>   al> include  ./$(DEPSDIR)/foo.Plo
>   al> include  ./$(DEPSDIR)/bar.Plo
>   al> include  ./$(DEPSDIR)/baz.Plo
>
>   al> but I can't for the life of me either remember what it is or
> find al> it through google.
>
> There is a description of a "traditional" way to do this in the GNU
> make manual.  There is a description of a more advanced way to do
> it, based on the methods used in automake, on my website (see
> below).

Thanks, Paul. Got it.

OK, gentlemen, the only remaining problem with the attached makefile 
is that it fails if the .deps directory doesn't exist.

if g++ -MT documentPageCache.o -MD -MP -MF 
".deps/documentPageCache.Tpo" -c -o 
documentPageCache.o ../documentPageCache.cpp; \
then mv -f ".deps/documentPageCache.Tpo" 
".deps/documentPageCache.Plo"; else rm-f 
".deps/documentPageCache.Tpo"; exit 1; fi
../documentPageCache.cpp:350: fatal error: opening dependency 
file .deps/documentPageCache.Tpo: No such file or directory

Clearly, I can create a rule

mkdepsdir
        test -d $(depsdir) || mkdir $(depsdir)

$(objdir)/%.o: $(srcdir)/%.cpp $(MOCS) mkdepsdir

Indeed, it works. However, is it the "recognized" way to do this? I 
don't see anything equivalent in an automake generated makefile 
(although it does store dependencies in .deps).

Regards,
Angus



Attachment: Makefile
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]