help-gnu-utils
[Top][All Lists]
Advanced

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

Re: Make: Can implicit rules be forced to make non-existing prerequisite


From: Jan T. Kim
Subject: Re: Make: Can implicit rules be forced to make non-existing prerequisites?
Date: 7 Aug 2006 11:22:00 -0700
User-agent: G2/0.2

James wrote:
> Jan T. Kim wrote:
> > Dear all,
> >
> > I want to set up a Makefile to handle installation and checking etc.
> > of a bunch of R packages, and I'd like to be able to add a new
> > package by just adding the new name to a variable. I use implicit
> > rules to try and pull this off. The problem I run into is that make
> > cannot
> > be bothered to make prerequisites required by an implicit rule, but in
> > my
> > case, that's what I need.
> >
> > Here's my Makefile:
> >
> > RPACKS                  = xpipe jtkstuff
> > RPACKS_INSTALL          = $(RPACKS:%=%-install)
> > RPACKS_UNINSTALL        = $(RPACKS:%=%-uninstall)
> > RPACKS_CHECK            = $(RPACKS:%=%-check)
> >
> > install : $(RPACKS_INSTALL)
> >
> > # explicit rule: target is unconditionally made
> > jtkstuff-install :
> >         echo target: $@ prerequisites: $^
> >         R CMD INSTALL jtkstuff
> >
> > # implicit rule: nothing is made
> > %-install :
> >         echo target: $@ prerequisites: $^
> >         R CMD INSTALL $*
> >
> > .PHONY : install uninstall check clean $(RPRACKS) $(RPACKS_INSTALL)

[snip]

> How about commenting out .PHONY line?

Ok -- that's the solution indeed. The reason is that .PHONY triggers
skipping of the implicit target search as an optimising side effect,
which I overlooked. Thanks for the pointer.

Specifically, it suffices to remove $(RPACKS_INSTALL) from the
.PHONY target. Of course, this opens the hole that if somehow a
xpipe-install file or directory appears, the implicit rule won't fire
anymore. To work around this, I now made a phony "implicit" target
that is a prerequisite of the implicit rules that I want to execute
unconditionally:

%-install : implicit
        echo target: $@ prerequisites: $^
        R CMD INSTALL $*

.PHONY : install uninstall check clean implicit $(RPRACKS)

Best regards, Jan



reply via email to

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