followup to previous question

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

followup to previous question

Robert P. J. Day

  an alternative to my question about character classes is that i can
do this the *proper* way, and extract the major version number of
sqlite from the top of its source tree.

  there's a top-level VERSION file, whose contents will be something
like "3.2.2".  so, for now, i can use:

SRCDIR = [top of source tree]
FULL_VERSION := $(shell cat ${SRCDIR}/VERSION)
$(warning Full version is ${FULL_VERSION}.)

MAJOR_VERSION := $(shell expr ${FULL_VERSION} : "\([0-9]*\)")
$(warning version is ${MAJOR_VERSION}.)


  even though the above works, i'm just betting there's a more natural
way to do either of:

1) get the contents of a one-line text file
2) extract the leading fully-numeric substring of a string

  am i right?  or is the above pretty much it?

rday


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

Re: followup to previous question

Paul Smith-20
%% Regarding followup to previous question; you wrote:

  rpjd> there's a top-level VERSION file, whose contents will be something
  rpjd> like "3.2.2".  so, for now, i can use:

  rpjd> SRCDIR = [top of source tree]
  rpjd> FULL_VERSION := $(shell cat ${SRCDIR}/VERSION)
  rpjd> $(warning Full version is ${FULL_VERSION}.)

  rpjd> MAJOR_VERSION := $(shell expr ${FULL_VERSION} : "\([0-9]*\)")
  rpjd> $(warning version is ${MAJOR_VERSION}.)

  rpjd> even though the above works, i'm just betting there's a more natural
  rpjd> way to do either of:

  rpjd> 1) get the contents of a one-line text file
  rpjd> 2) extract the leading fully-numeric substring of a string

  rpjd> am i right?  or is the above pretty much it?

That's about it as far as getting the contents.  You can get the major
version much more easily, though:

    MAJOR_VERSION := $(firstword $(subst ., ,$(FULL_VERSION)))

If the VERSION file had a make-like syntax, like:

    FULL_VERSION = 3.2.2

then you could, of course, just include it.

--
-------------------------------------------------------------------------------
 Paul D. Smith <[hidden email]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


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

Re: followup to previous question

Robert P. J. Day
On Thu, 23 Jun 2005, Paul D. Smith wrote:

> %% Regarding followup to previous question; you wrote:
>
>   rpjd> there's a top-level VERSION file, whose contents will be something
>   rpjd> like "3.2.2".  so, for now, i can use:
>
>   rpjd> SRCDIR = [top of source tree]
>   rpjd> FULL_VERSION := $(shell cat ${SRCDIR}/VERSION)
>   rpjd> $(warning Full version is ${FULL_VERSION}.)
>
>   rpjd> MAJOR_VERSION := $(shell expr ${FULL_VERSION} : "\([0-9]*\)")
>   rpjd> $(warning version is ${MAJOR_VERSION}.)
>
>   rpjd> even though the above works, i'm just betting there's a more natural
>   rpjd> way to do either of:
>
>   rpjd> 1) get the contents of a one-line text file
>   rpjd> 2) extract the leading fully-numeric substring of a string
>
>   rpjd> am i right?  or is the above pretty much it?
>
> That's about it as far as getting the contents.  You can get the
> major version much more easily, though:
>
>     MAJOR_VERSION := $(firstword $(subst ., ,$(FULL_VERSION)))
>
> If the VERSION file had a make-like syntax, like:
>
>     FULL_VERSION = 3.2.2
>
> then you could, of course, just include it.

nope, it really is just the version string, but i can at least do the
firstword/subst trick on that.  thanks.

rday


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

Re: followup to previous question

John Graham-Cumming
In reply to this post by Robert P. J. Day
On Thu, 2005-06-23 at 13:33 -0400, Robert P. J. Day wrote:

>   there's a top-level VERSION file, whose contents will be something
> like "3.2.2".  so, for now, i can use:
>
> SRCDIR = [top of source tree]
> FULL_VERSION := $(shell cat ${SRCDIR}/VERSION)
> $(warning Full version is ${FULL_VERSION}.)
>
> MAJOR_VERSION := $(shell expr ${FULL_VERSION} : "\([0-9]*\)")
> $(warning version is ${MAJOR_VERSION}.)
>
>   even though the above works, i'm just betting there's a more natural
> way to do either of:
>
> 1) get the contents of a one-line text file
> 2) extract the leading fully-numeric substring of a string

That seems reasonable, but you could avoid the call out to 'expr':

    FULL_VERSION := $(shell cat $(SRCDIR)/VERSION)
    VERSION_LIST := $(call split,.,$(FULL_VERSION))
    MAJOR_VERSION := $(word 1,$(VERSION_LIST))

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