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

"Jan T. Kim" <[email protected]>
Newsgroups gmane.comp.gnu.utils
Organization http://groups.google.com
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.