how to represent a character class of targets?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to represent a character class of targets?

Robert P. J. Day

  i'm sure there's a simple way to do this, but i'm just not seeing
it.  is there a way to establish a list of dependencies of other
(possibly non-existent) targets based on a character class pattern?

  rationale:  i'm looking at the makefile for sqlite and, in the
makefile, "all" has a dependency of "sqlite3.h", whose rule builds
that specific header file, which many of the source files include
explicitly.  so, obviously, that rule has to be invoked to just create
sqlite3.h. i'm assuming that, when there's an sqlite 4, that rule will
change accordingly.

  now, given that the current makefile really sucks, i want to write
my own replacement makefile but make it version-independent.  i'd like
to have some sort of rule like:

sqlite_header_file:  sqlite[345].h

or something at least as general.  i don't want to have to figure out
the current version, i just want to say, "there's a rule in this
makefile *somewhere* of this general form -- go find it and process
it."

  thoughts?

rday


_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: how to represent a character class of targets?

John Graham-Cumming
On Thu, 2005-06-23 at 13:07 -0400, Robert P. J. Day wrote:
> sqlite_header_file:  sqlite[345].h
>
> or something at least as general.  i don't want to have to figure out
> the current version, i just want to say, "there's a rule in this
> makefile *somewhere* of this general form -- go find it and process
> it."

Why don't you just encode the version in a variable and use it.  It
would surely be clearer than globbing, because what if there were both
sqlite3.h and sqlite4.h present?

I would do

    SQLITE_VERSION := 3

    sqlite_header_file: sqlite$(SQLITE_VERSION).h

John.
--
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/




_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: how to represent a character class of targets?

Robert P. J. Day
On Thu, 23 Jun 2005, John Graham-Cumming wrote:

> On Thu, 2005-06-23 at 13:07 -0400, Robert P. J. Day wrote:
> > sqlite_header_file:  sqlite[345].h
> >
> > or something at least as general.  i don't want to have to figure out
> > the current version, i just want to say, "there's a rule in this
> > makefile *somewhere* of this general form -- go find it and process
> > it."
>
> Why don't you just encode the version in a variable and use it.  It
> would surely be clearer than globbing, because what if there were
> both sqlite3.h and sqlite4.h present?
>
> I would do
>
>     SQLITE_VERSION := 3
>
>     sqlite_header_file: sqlite$(SQLITE_VERSION).h

i wsa just trying to be unspeakably lazy and be able to refer to an
arbitrary sqlite source tree and let the makefile figure it out from
there, that's all.

remember, according to the perl folks, laziness is a virtue.  or was
that hubris?  dammit, i always get those two confused.

rday


_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: how to represent a character class of targets?

John Graham-Cumming
On Thu, 2005-06-23 at 16:40 -0400, Robert P. J. Day wrote:
> i wsa just trying to be unspeakably lazy and be able to refer to an
> arbitrary sqlite source tree and let the makefile figure it out from
> there, that's all.

Well, if what you want to do is find just one sqliteX.h then you could
always do:

sqlite_header_file: $(firstword $(wildcard sqlite[3-5].h))

and then I guess you'll want to sort them so something like this will
work:

sqlite_header_file: $(call last,$(sort $(wildcard sqlite[3-5].h)))

John.
--
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/




_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make